Fix internal uses of _PATH_BSHELL.
We regressed on this recently: code under the upstream-* directories has
_PATH_BSHELL defined as a call to __bionic_get_shell_path(). In our own
code, we may as well just call it directly.
Bug: https://issuetracker.google.com/129030706
Test: ran tests
Change-Id: Ic2423f521272be95e67f94771772fe8072636ef0
diff --git a/libc/bionic/__bionic_get_shell_path.cpp b/libc/bionic/__bionic_get_shell_path.cpp
index 1352815..7aeed18 100644
--- a/libc/bionic/__bionic_get_shell_path.cpp
+++ b/libc/bionic/__bionic_get_shell_path.cpp
@@ -26,6 +26,8 @@
* SUCH DAMAGE.
*/
+#include "private/__bionic_get_shell_path.h"
+
#include <errno.h>
#include <string.h>
#include <sys/cdefs.h>
@@ -51,7 +53,7 @@
return "/system/bin/sh";
}
-__LIBC_HIDDEN__ extern "C" const char* __bionic_get_shell_path() {
+const char* __bionic_get_shell_path() {
static const char* sh_path = init_sh_path();
return sh_path;
}
diff --git a/libc/bionic/exec.cpp b/libc/bionic/exec.cpp
index 1cf3a58..3309585 100644
--- a/libc/bionic/exec.cpp
+++ b/libc/bionic/exec.cpp
@@ -39,6 +39,7 @@
#include <string.h>
#include <unistd.h>
+#include "private/__bionic_get_shell_path.h"
#include "private/FdPath.h"
extern "C" char** environ;
@@ -111,7 +112,7 @@
script_argv[0] = "sh";
script_argv[1] = buf;
memcpy(script_argv + 2, argv + 1, arg_count * sizeof(char*));
- return execve(_PATH_BSHELL, const_cast<char**>(script_argv), envp);
+ return execve(__bionic_get_shell_path(), const_cast<char**>(script_argv), envp);
}
int execvpe(const char* name, char* const* argv, char* const* envp) {
diff --git a/libc/bionic/system.cpp b/libc/bionic/system.cpp
index 7411ae5..950f05c 100644
--- a/libc/bionic/system.cpp
+++ b/libc/bionic/system.cpp
@@ -27,12 +27,12 @@
*/
#include <errno.h>
-#include <paths.h>
#include <stdlib.h>
#include <spawn.h>
#include <sys/wait.h>
#include <unistd.h>
+#include "private/__bionic_get_shell_path.h"
#include "private/ScopedSignalBlocker.h"
#include "private/ScopedSignalHandler.h"
@@ -58,7 +58,7 @@
const char* argv[] = { "sh", "-c", command, nullptr };
pid_t child;
- if ((errno = posix_spawn(&child, _PATH_BSHELL, nullptr, &attributes,
+ if ((errno = posix_spawn(&child, __bionic_get_shell_path(), nullptr, &attributes,
const_cast<char**>(argv), environ)) != 0) {
return -1;
}