title: Can't push files to device
body: <p>I am using <code>adb</code> to push and pull files to and from an android device.
  Those files are configs and data for our app, that is installed and used on a restricted user account.</p>
  
  <p>There is a special exchange folder in the device-users home directory.
  A typical folder layout (for android 6+) is as follows:</p>
  
  <pre><code>/storage/emulated/0             // home dir of main device user
  
  /storage/emulated/10            // home dir of restricted user
  /storage/emulated/10/exchange   // our file exchange dir
  </code></pre>
  
  <p>Recently we discovered that file exchange is not working on a <code>Samsung Galaxy Tab S</code> running Android 6.0.1.</p>
  
  <pre><code>// Pushing to main user works just fine
  $ ./adb push barfoo.txt /storage/emulated/0
  [   ?] /storage/emulated/0/barfoo.txt: 0/?
  
  // Pushing to restricted user does not work
  $ ./adb push barfoo.txt /storage/emulated/10
  adb: error: failed to copy 'barfoo.txt' to '/storage/emulated/10/barfoo.txt': Permission denied
  </code></pre>
  
  <p>In the logcat output I found the following clues:</p>
  
  <pre><code>audit   : type=1400 msg=audit(1496849979.822:280): avc:  denied  { write } for  pid=15762 comm="adbd" name="10" dev="sdcardfs" ino=130656 scontext=u:r:adbd:s0 tcontext=u:object_r:container_app_data_backend:s0:c522,c768 tclass=dir
  audit   :  SEPF_SECMOBILE_6.0.1_0021
  audit   : type=1300 msg=audit(1496849979.822:280): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=b6bc0fc8 a2=a00c1 a3=1b6 items=1 ppid=1 ppcomm=init pid=15762 auid=4294967295 uid=2000 gid=2000 euid=2000 suid=2000 fsuid=2000 egid=2000 sgid=2000 fsgid=2000 tty=(none) ses=4294967295 comm="adbd" exe="/sbin/adbd" subj=u:r:adbd:s0 key=(null)
  audit   : type=1307 msg=audit(1496849979.822:280):  cwd="/"
  audit   : type=1302 msg=audit(1496849979.822:280): item=0 name="/storage/emulated/10/barfoo.txt" inode=130656 dev=00:17 mode=040771 ouid=0 ogid=1015 rdev=00:00 obj=u:object_r:container_app_data_backend:s0:c522,c768
  audit   : type=1327 msg=audit(1496849979.822:280): proctitle=2F7362696E2F61646264002D2D726F6F745F7365636C6162656C3D753A723A73753A7330
  audit   : type=1320 msg=audit(1496849979.822:280): 
  </code></pre>
  
  <p>As far as I understand there are some SELinux policies enforced that prevent me from pushing files.</p>
  
  <p>Is anyone able to reproduce this? Is there a way to loosen the SELinux policies? What would you do to exchange the files?</p>