adb pull and
adb push can be used to transfer files from and to the device via the ADB connection.
However, even on a rooted device, these commands seem to operate with user permissions. I can access anything on
/sdcard, but when I try to push to, say,
/data, the operation fails due to lack of permissions.
Of course, I can push the file to a different location, then
adb shell into the device, run
su to become root, and then copy the file to its final destination – but that is a kludgy workaround, not a real solution.
Also, I can install an SSH server on the device which runs as root and use SSH to copy the files over, but I am wondering if ADB offers something similar natively.
Is there any way I can get
adb pull to operate with root privileges on the device?
adbdis by default compiled in "secure mode" which means it is started with root permissions but after start-up it drops it's root permissions. So the only way to change this is to replace or modify the
adbdbinary included in the installed ROM.
adbdruns as a non-privileged user, as does any process it spawns. That includes shell sessions – however, if enabled on the device, I can then run
sufrom that shell session to obtain root privileges. So you’re saying that
adbddoes not have any built-in functionality for doing that and/or the ADB wire protocol lacks the means to specify whether an operation is to be carried out in privileged mode?
adbdruns as non-privileged user, but it is started with root permissions (which is then dropped after start-up). ssh is running always with root permissions and if a user connects the shell process is executed as the user which has logged-in. adbd can not do somethin similar because it has dropped root permissions after start-up and also adbd is not designed to run a shell or a file-transfer session as a different user, so adb always has the permissions adbd runs with.
adb rootworks on your device, it'll make
adbdrun with UID 0.
-cflag, similar to this. or push files to /data/local/tmp and then move them