# How to write data to a file outside sandbox

**URL:** <https://forum.legato.io/t/how-to-write-data-to-a-file-outside-sandbox/246>\
**Category:** Legato Application Framework\
**Created:** [August 30, 2016, 9:51am UTC](https://forum.legato.io/t/how-to-write-data-to-a-file-outside-sandbox/246 "2016-08-30T09:51:47Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Alegato](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Alegato](https://forum.legato.io/u/Alegato)\
**Post date:** [October 5, 2018, 11:58pm UTC](https://forum.legato.io/t/how-to-write-data-to-a-file-outside-sandbox/246/13 "2018-10-05T23:58:57Z")

</div>

From [Application Definition .adef - Legato Docs](https://docs.legato.io/latest/defFilesAdef.html#defFilesAdef_requiresFile:)

> Note  
> Even though the file system object appears in the app’s sandbox it still needs permissions settings on the file. File permissions (both DAC and MAC) and ownership (group and user) on the original file in the target system remain in effect inside the sandbox.

Each sandboxed application runs as a separate user. You’ll have to set the permission so that your sand boxed application can write to the file. In my case, the app names is “HelloWorld”. You can get the app name from “app list”

> root@swi-mdm9x28-wp:~# echo 2 \> hello.txt  
> root@swi-mdm9x28-wp:~# chmod o+w hello.txt  
> root@swi-mdm9x28-wp:~# xattr set ‘security.SMACK64’ ‘app.HelloWorldrwx’ hello.txt  
> root@swi-mdm9x28-wp:~# xattr get hello.txt  
> name=security.SMACK64; value=app.HelloWorldrwx  
> root@swi-mdm9x28-wp:~#

Run your sand boxed application

> root@swi-mdm9x28-wp:~# cat hello.txt  
> HELLO

---

_[View the full topic](https://forum.legato.io/t/how-to-write-data-to-a-file-outside-sandbox/246)._
