# Legato writtable directory

**URL:** https://forum.legato.io/t/legato-writtable-directory/3753
**Category:** Uncategorized
**Created:** [October 11, 2018, 8:55am UTC](https://forum.legato.io/t/legato-writtable-directory/3753 "2018-10-11T08:55:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![lazzox](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lazzox](https://forum.legato.io/u/lazzox)
#### Post date: [October 11, 2018, 8:55am UTC](https://forum.legato.io/t/legato-writtable-directory/3753/1 "2018-10-11T08:55:52Z")

</div>

Is there a way for a sandbox application to have a **writtable** directory _ **outside its sandbox** _, that **wont delete** after a restart?

---

<div class="post-metadata">

### Author: ![flu](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/flu/32/813_2.png) [@flu](https://forum.legato.io/u/flu)
#### Post date: [October 11, 2018, 12:12pm UTC](https://forum.legato.io/t/legato-writtable-directory/3753/2 "2018-10-11T12:12:22Z")

</div>

Hello lazzox,

You must add this to your \*.adef file:

```
requires: {
	dir: {
		"/etc/myDirExternal"	"/myDirExternal"
	}
}

```

/etc/myDirExternal must already exist when the Legato Application is started.

Default access rule is rx (SMACK label “_”):  
# /legato/systems/current/bin/xattr get /etc/myDirExternal  
name=security.SMACK64; value=_  
# /legato/systems/current/bin/xattr get /etc/myDirExternal/file.txt  
name=security.SMACK64; value=\_

Access to the directory content can be changed to rwx (SMACK label: “_”):  
# /legato/systems/current/bin/xattr set security.SMACK64 "_" “/etc/myDirExternal/file.txt”  
# /legato/systems/current/bin/xattr get /etc/myDirExternal/file.txt  
name=security.SMACK64; value=\*

KR.

---

<div class="post-metadata">

### Author: ![lazzox](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lazzox](https://forum.legato.io/u/lazzox)
#### Post date: [October 11, 2018, 1:52pm UTC](https://forum.legato.io/t/legato-writtable-directory/3753/3 "2018-10-11T13:52:58Z")

</div>

Thank you for your reply, output is a bit different.  
I am using Legato 18.03 and WP76xx.

_root@swi-mdm9x28:/etc/myDir# xattr get /etc/myDir/file.txt_  
_name=security.SMACK64; value=_\_  
_root@swi-mdm9x28:/etc/myDir# xattr get /etc/myDir/_  
_name=security.SMACK64; value=_\_

And I get this:

_root@swi-mdm9x28:/etc/myDir# xattr set security.SMACK64 “” “/etc/myDir/file.txt”_  
_Could not set extended attribute. Invalid argument_

So I use instead the “\*”

_root@swi-mdm9x28:/etc/myDir# xattr set security.SMACK64 “\*” file.txt_  
_root@swi-mdm9x28:/etc/myDir# xattr get /etc/myDir/file.txt_  
_name=security.SMACK64; value=\*_

But all of that leaves my directory still only readable. Sandbox application can’t make files in that directory.

_root@swi-mdm9x28:/etc/myDir# xattr get /etc/myDir_  
_name=security.SMACK64; value=_\_

I tried giving my directory \* as SMACK label, but that didn’t still enable the sandbox app to write to the directory.

---

<div class="post-metadata">

### Author: ![lazzox](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lazzox](https://forum.legato.io/u/lazzox)
#### Post date: [October 12, 2018, 7:13am UTC](https://forum.legato.io/t/legato-writtable-directory/3753/4 "2018-10-12T07:13:27Z")

</div>

Looks like in addition to this setting _chmod 777_ on the file solved the problem I was having.  
I am sure that not all of that from 777 is necessary .
