aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libc/bionic/__bionic_get_shell_path.cpp7
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