diff options
author | Tom Marshall <tdm.code@gmail.com> | 2019-01-10 16:18:59 -0800 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-01-13 03:26:42 +0200 |
commit | fee4dc888bd235123fceff06aed02e0b1db73d7f (patch) | |
tree | 124c61b5478f80e766c185b749699003fa8b4214 | |
parent | 912b958fc2f73ae601a53f5300cd7ccbdbd77747 (diff) | |
download | android_bionic-lineage-15.1.tar.gz android_bionic-lineage-15.1.tar.bz2 android_bionic-lineage-15.1.zip |
bionic: Prefer /sbin/sh if it existslineage-15.1
Prefer /sbin/sh because in recovery (or generally, not booted to the
main Android system), the system shell and its associated rc file
should not be used. One reason is that TMPDIR is set to a path that
will likely not be mounted (/data/local/tmp).
Change-Id: I3ec22aa2537a7795baae6e782134d3b05f4b3ace
-rw-r--r-- | libc/bionic/__bionic_get_shell_path.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libc/bionic/__bionic_get_shell_path.cpp b/libc/bionic/__bionic_get_shell_path.cpp index 41162e93e..20bd7605f 100644 --- a/libc/bionic/__bionic_get_shell_path.cpp +++ b/libc/bionic/__bionic_get_shell_path.cpp @@ -29,11 +29,18 @@ #include <errno.h> #include <string.h> #include <sys/cdefs.h> +#include <sys/stat.h> #include <unistd.h> #define VENDOR_PREFIX "/vendor/" static const char* init_sh_path() { + /* Prefer /sbin/sh */ + struct stat st; + if (stat("/sbin/sh", &st) == 0) { + return "/sbin/sh"; + } + /* If the device is not treble enabled, return the path to the system shell. * Vendor code, on non-treble enabled devices could use system() / popen() * with relative paths for executables on /system. Since /system will not be |