cswl / tsu

Gain root shell on Termux.
ISC License
646 stars 155 forks source link

Preserve PATH and LD_* env vars when invoking sudo -E #64

Closed pschmitt closed 4 years ago

pschmitt commented 4 years ago

Right now LD_PRELOAD and LD_LIBRARY_PATH get unset when invoking sudo -E which should not be the case IMHO. If as a user I want to preserve the env by explicitly specifying -E I expect it to preserve it ;)

Unsetting them results in not being able to run scripts whose shebang rely on LD_PRELOAD being correctly set.

Also there seems to be an issue with --preserve-environment: PATH does not currently get preserved.

Example:

whoami.sh

#!/usr/bin/env bash
whoami
  1. Current behavior
# Running it normally works
$ ./whoami.sh
u0_a147

# sudoing does not
$ sudo ./whoami.sh
env: can't execute 'whoami.sh': No such file or directory
  1. What this PR achieves:
# Running it normally works
$ ./whoami.sh
u0_a147

# sudoing as well \o/
$ sudo ./whoami.sh
root
cswl commented 4 years ago

Which android version are you on?

This will not work for some Android versions #57

I will merge this now.. and work out the problem later..

pschmitt commented 4 years ago

Which android version are you on?

10

This will not work for some Android versions #57

Hm, I don't see how this issue relates. But I get your point, How about adding a check for the current android version?