Magisk: su console output not available from "adb shell su -c cmd" in 20416 or later

Created on 31 Jul 2020  路  7Comments  路  Source: topjohnwu/Magisk

When executing commands from Windows adb (e.g. with adb shell su -c "echo su-test"), the stdout output from su does not show in the console window, starting with canary 20416, tested on Galaxy S10 SM-G977B. This was first observed when trying to root an S2 5G+ SM-G986B with canary 20419 but could be reproduced with the S10, too.

test code (windows)
adb shell "echo nop > /sdcard/test.log ; echo sh-1 ; su -c 'echo su-2 && echo suf-3 > /sdcard/test.log' ; echo sh-4 ; echo shf-5 >> /sdcard/test.log ; cat /sdcard/test.log" & echo xxx & adb shell "echo sh-2nd ; cat /sdcard/test.log"

expected output:
sh-1
su-2
sh-4
suf-3
shf-5
xxx
sh-2nd
suf-3
shf-5

output up to 20415 (SM-G977B)
sh-1
su-2
... sh-4 missing here
... cat missing but /sdcard/test.log exists with suf-3 and shf-5
xxx
sh-2nd
suf-3
shf-5
-> stdout behavior for su OK, commands are executed as expected
-> after su terminates, stdoutput is not shown any longer (not perfect, but this has been the case for a long time)

output starting with 20416 up to 20419 (SM-G977B)
sh-1
... su-2 missing here -> su stdout does not reach windows console
sh-4
suf-3
shf-5
xxx
sh-2nd
suf-3
shf-5
-> su output is no longer available
-> but commands after su can now provide output

Can this be fixed or are workarounds known (except for redirecting everything into log files)? Output from an interactive session with adb shell or puadb is working as expected. I've seen such issues in the past but only with service related commands, e.g. pm disable.

Most helpful comment

Confirmed and better than ever. Now output from commands after su is available, too. Thanks a lot.

Galaxy S20 e4030f6 Sep 5, 2020 Update Canary Channel: Upstream to 11f254e5 297 20424
adb shell "echo nop > /sdcard/test.log ; echo sh-12 ; su -c 'echo su-34 && echo suf-56 > /sdcard/test.log' ; echo sh-78 ; echo shf-9a >> /sdcard/test.log ; cat /sdcard/test.log" & echo xxx & adb shell "echo sh-2nd ; cat /sdcard/test.log"
sh-12
su-34
sh-78
suf-56
shf-9a
xxx
sh-2nd
suf-56
shf-9a

All 7 comments

Is this the same problem as #2960 ?

Not sure, I'll try to run the tests and modifications from 2960 later. But I'd assume su was executed (though not sure if with elevated rights) and not blocked. So maybe it's a different thing.

Thanks for pointing me to 2960. I did a test, su commands are definitely executed correctly on the S10, just console output is missing. setenforce 0 doesn't change the behavior, however the magiskpolicy --live command from 2960 changes the system back to the old behavior, i.e. I get the following response to my test command:
sh-1
su-2
xxx
sh-2nd
suf-3
shf-5

So maybe it's the same problem or just similar. Can I persistently add the permissions from 2960 to a magisk patched device?

Not sure. I think we'll keep both open for now and @topjohnwu will need to work out what needs to be added since he will likely know when/why the regression occured once he has time to review.

OK, I'll try if 20415 or a previous version works for the S20. Thank you for your very fast response.

Should be fixed in 4dacffd7a195ef0ae0ec23999185407237e7805f

Confirmed and better than ever. Now output from commands after su is available, too. Thanks a lot.

Galaxy S20 e4030f6 Sep 5, 2020 Update Canary Channel: Upstream to 11f254e5 297 20424
adb shell "echo nop > /sdcard/test.log ; echo sh-12 ; su -c 'echo su-34 && echo suf-56 > /sdcard/test.log' ; echo sh-78 ; echo shf-9a >> /sdcard/test.log ; cat /sdcard/test.log" & echo xxx & adb shell "echo sh-2nd ; cat /sdcard/test.log"
sh-12
su-34
sh-78
suf-56
shf-9a
xxx
sh-2nd
suf-56
shf-9a

Was this page helpful?
0 / 5 - 0 ratings