Closed zner0L closed 1 year ago
While trying to fix this, I noticed something weird is going on with pipes:
$ adb shell su -c /bin/sh -c "whoami"
root
$ adb shell su -c /bin/sh -c "echo | whoami"
shell
This breaks the wireguard setup since we need to pipe some base64.
I fixed that by passing the whole command as a string:
adb shell /bin/sh -c 'su -c /bin/sh -c "echo | whoami"'
which doesn‘t work in the shell, but apparently does in execa
:
await runAndroidDevTool('adb', ['shell', '/bin/sh', '-c', `'su root -c /bin/sh -c "echo | whoami"'`], {
stdio: 'inherit',
});
// root
Another weird error:
$ adb shell su -c mv /sdcard/appstraction-tmp/f71c2061-b77c-4c41-ad3a-f8b78784216d /sdcard/Android/obb/com.pixellabs.pixelstrike3d/main.273.com.pixellabs.pixelstrike3d.obb
mv: bad '/sdcard/appstraction-tmp/f71c2061-b77c-4c41-ad3a-f8b78784216d': No such file or directory
But the file exists:
$ adb shell su -c stat /sdcard/appstraction-tmp/f71c2061-b77c-4c41-ad3a-f8b78784216d
File: /sdcard/appstraction-tmp/f71c2061-b77c-4c41-ad3a-f8b78784216d
Size: 834045431 Blocks: 1630608 IO Blocks: 512 regular file
Device: 5fh/95d Inode: 13871 Links: 1 Device type: 0,0
Access: (0660/-rw-rw----) Uid: ( 0/ root) Gid: ( 9997/everybody)
Access: 2023-06-12 14:17:50.000000000 +0200
Modify: 2023-06-12 14:17:50.000000000 +0200
Change: 2023-06-12 14:18:08.207175000 +0200
That a confusing error message but an easy fix. What mv
meant to say was that the destination directory did not exist. I needed to create that.
Random fun fact: When pushin large files, adb push
seems to randomly just give up. Maybe it is related to this: https://forum.xda-developers.com/t/q-adb-hangs-during-push-of-large-files.1184186/
Sending the intent does not fail using adb shell su -c am broadcast -a com.wireguard.android.action.SET_TUNNEL_UP -n'com.wireguard.android/.model.TunnelManager$IntentReceiver' -e tunnel appstraction
, but it does not start the tunnel either. However if I use the shell interactively and log into the root shell using su
, I am able to start the tunnel with the same command. I wonder what the difference is…
Ah, I finally found this was an error with escaping the $
. It needs to be escaped like this: \\$\\
On an Android 11 Google Pixel 3
adb root
fails withadbd cannot run as root in production builds
, though a current Magisk root is installed.The workaround using
adb shell su
does work, however. We should implement that as well, ifadb root
throws.