Merge "use /system/bin/sh for all" into main am: 79434542bc

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2969412

Change-Id: I229fe068b9a9d2a3c571d1f33c77536af0f6e8ba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jooyung Han 2024-02-22 06:40:57 +00:00 committed by Automerger Merge Worker
commit caeb54a332

View file

@ -28,29 +28,11 @@
#include "private/__bionic_get_shell_path.h"
#include <errno.h>
#include <string.h>
#include <sys/cdefs.h>
#include <unistd.h>
#define VENDOR_PREFIX "/vendor/"
static const char* init_sh_path() {
const char* __bionic_get_shell_path() {
#if !defined(__ANDROID__)
// For the host Bionic, use the standard /bin/sh
return "/bin/sh";
#else
// Look for /system or /vendor prefix.
char exe_path[strlen(VENDOR_PREFIX)];
ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
if (len != -1 && !strncmp(exe_path, VENDOR_PREFIX, strlen(VENDOR_PREFIX))) {
return "/vendor/bin/sh";
}
return "/system/bin/sh";
#endif // if !defined(__ANDROID__)
}
const char* __bionic_get_shell_path() {
static const char* sh_path = init_sh_path();
return sh_path;
}