openstf / adbkit

A pure Node.js client for the Android Debug Bridge.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pushed file mode is not set successfully

pimterry opened this issue · comments

As far as I can tell, the file mode setting for push doesn't seem to work. For example:

client.push('emulator-5554', './local-file', '/data/local/tmp/my-file', 0o755);

Then, looking manually with adb shell:

> ls -l /data/local/tmp
-rwxrwxrwx 1 shell shell   0 2020-02-07 00:39 my-file

I'm expecting that to be -rwxr-xr-x. I'm assuming that 0o755 is the right format because it matches the default argument here: https://github.com/openstf/adbkit/blob/master/src/adb/sync.coffee#L16.

You can change the permissions with other values, so it's not ignoring the mode argument completely, but it's interpreting it in some unpredictable way like it's expecting the mode in a different format. I can't find any format that will work as I expect though. What am I missing?

Ok, as far as I can tell this is a general ADB bug. https://stackoverflow.com/questions/43395799/adb-push-changes-file-permissions and https://groups.google.com/forum/#!topic/android-platform/YE8NdH9xE3c have a little more info.

I can reproduce it with adb push too - looking at wireshark, it sets the default permissions as 33188 (644), but the resulting file is still given permissions 666.

In general, it seems like if you set any set of permissions then the user permission will always be copied across as the group & others permissions. Not sure if it applies to all devices, but I'm certainly seeing it on my phone and multiple emulators.

I'm going to close this for now, since it's clearly not a adbkit bug. Might be worth documenting here though, since it makes the mode argument to push pretty useless. In my case I'm trying to write a file that only the shell user should be able to read - for now I'll just write it with no permissions and chmod it on the device, that should do as a basic workaround.