1

I'm playing with mount points, directories and files permissions on a rooted MotoG1 using adb (a model without SDCard Slot), and I've come into certain behaviours I can't really understand.

Connected with shell I can see a mounted partition:

$ mount | grep storage              
/data/media /storage/emulated/legacy esdfs rw,relatime,upper=0:1028:660:771,derive=legacy,nosplit 0 0

In that directory there is a file, which belongs to root, without read persmissions for user shell:

shell@falcon_umts:/storage/emulated/legacy $ ls -l contacts2.db
-rw-rw---- root     sdcard_r   315392 2016-12-02 16:24 contacts2.db

Since I need to move that file to the host computer using adb pull command, I get root access to change the owner of that file to shell (surprisingly I find the files are located in /data/media/0, not directly in /data/media):

root@falcon_umts:/data/media/0 # ls -l contacts2.db
-rw------- root     root       315392 2016-12-02 16:24 contacts2.db

root@falcon_umts:/data/media/0 # chmod 755  contacts2.db
root@falcon_umts:/data/media/0 # ls -l contacts2.db
-rwxr-xr-x shell    shell      315392 2016-12-02 16:24 contacts2.db

As root, the changes to the file owner seem to be made, but when I get back to the shell account, the file keeps its previous owner.

root@falcon_umts:/data/media/0 # exit
shell@falcon_umts:/storage/emulated/legacy $ ls -l contacts2.db
-rw-rw---- root     sdcard_r   315392 2016-12-02 16:24 contacts2.db

Do you have any idea of the reason of this behaviour? On the other hand if the shell mount point is /data/media, shouldn't be the files on that directory also with root, instead of /data/media/0?

  • 1
    The data under the /storage/emulated/legacy is accessed through a particular, restrictive method called Emulated SD Card File System, which acts like a mask, and prevents you or any app from editing ownership or permissions of the files accessed from within it, thus adding a layer of security (and you can see it in the mount output /data/media /storage/emulated/legacy esdfs [...]). If you or an app have root permissions, though, you can directly access the unmasked, underlying filesystem and make potentially dangerous changes, as proven by the successful permission editing... – Death Mask Salesman Dec 2 '16 at 16:48
  • ... you yourself did, by issuing chmod 755 contacts2.db. The data under /data/media belongs to root because it's not meant to be accessed that way. – Death Mask Salesman Dec 2 '16 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.