Re: Why adb changes file permission?

1,784 views
Skip to first unread message

Jean-Baptiste Queru

unread,
May 17, 2013, 11:23:52 AM5/17/13
to android-...@googlegroups.com
I'll take a very wild guess: this is probably done to match the way system.img is created by the build, so that files that get pushed or synced don't end up with different permissions.

As an example, if you sync an apk, it needs to be world-readable on the Android side, even if it's not world-readable on your host machine.

JBQ


On Thu, May 16, 2013 at 3:00 PM, <chengl...@gmail.com> wrote:
Hi,

A piece of code in adb seems to manipulate the file permission intentionally
by copying owner's permission to ``group'' and '``other''.  This causes
kernel module load problems if we make some changes to kernel modules,
and do ``adb sync'' or ``adb push'' to the devices since mode 644 would become
mode 666.

       /* copy user permission bits to "group" and "other" permissions */
       mode |= ((mode >> 3) & 0070);
       mode |= ((mode >> 3) & 0007);

Anyone knows why it is necessary to do this? Any side-affects
if I ``correct'' (to keep original file permission) this?

Thanks

zombie@zombie-linux:~/Temp$ ls -la err
-rwxr--r-- 1 zombie zombie 10036 2011-11-04 13:36 err
zombie@zombie-linux:~/Temp$ adb push ./err /system/bin
162 KB/s (10036 bytes in 0.060s)
zombie@zombie-linux:~/Temp$ adb shell ls /system/bin/err -la
-rwxrwxrwx root     root        10036 2011-11-04 18:36 err

zombie@zombie-linux:~/Temp$ chmod 644 err
zombie@zombie-linux:~/Temp$ adb push ./err /system/bin 
213 KB/s (10036 bytes in 0.045s)
zombie@zombie-linux:~/Temp$ adb shell ls /system/bin/err -la
-rw-rw-rw- root     root        10036 2011-11-04 18:36 err

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jean-Baptiste M. "JBQ" Queru
Technical Lead, Android Open Source Project, Google.

Questions sent directly to me that have no reason for being private will likely get ignored or forwarded to a public forum with no further warning.

Steve Jones

unread,
May 19, 2013, 6:23:17 AM5/19/13
to android-...@googlegroups.com
Hi JBQ,  

I think the problem is that adb goes too far, just a Liang has describe the same also happens with /system/build.prop. It becomes writeable to group and everyone which if left that way will obviously be marked as unsafe at boot time.

Too wildly speculate I suspect it's an oversight from when you guys implemented the safe file sanity checks in the init binary.... @Liang probably worth submitting a patch to the AOSP ProjecT.



Reply all
Reply to author
Forward
0 new messages