Merge "Fix internal uses of _PATH_BSHELL." am: b1ddbfdcdc
am: b4c1555dcd
Change-Id: Ice856f4e0b56eae26b22c26bc1acd77a17a553a7
This commit is contained in:
commit
3914996a7c
5 changed files with 40 additions and 5 deletions
|
@ -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 @@ static const char* init_sh_path() {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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 @@ static int __exec_as_script(const char* buf, char* const* argv, char* const* env
|
|||
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) {
|
||||
|
|
|
@ -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 @@ int system(const char* command) {
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
31
libc/private/__bionic_get_shell_path.h
Normal file
31
libc/private/__bionic_get_shell_path.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
extern "C" const char* __bionic_get_shell_path();
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
#include "local.h"
|
||||
#include "glue.h"
|
||||
#include "private/__bionic_get_shell_path.h"
|
||||
#include "private/bionic_fortify.h"
|
||||
#include "private/ErrnoRestorer.h"
|
||||
#include "private/thread_private.h"
|
||||
|
@ -1218,7 +1219,7 @@ FILE* popen(const char* cmd, const char* mode) {
|
|||
if (dup2(fds[child], desired_child_fd) == -1) _exit(127);
|
||||
close(fds[child]);
|
||||
if (bidirectional) dup2(STDOUT_FILENO, STDIN_FILENO);
|
||||
execl(_PATH_BSHELL, "sh", "-c", cmd, nullptr);
|
||||
execl(__bionic_get_shell_path(), "sh", "-c", cmd, nullptr);
|
||||
_exit(127);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue