Browse Source

Replaced any occurence of /bin/sh with _PATH_BSHELL to allow easier portability on system with default shell on a different directory, like for instance on android.

Signed-off-by: Ubaldo Porcheddu <ubaldo@eja.it>
Ubaldo Porcheddu 8 years ago
parent
commit
75d8660d99
3 changed files with 9 additions and 6 deletions
  1. 2 1
      libc/stdio/popen.c
  2. 4 3
      libc/stdlib/system.c
  3. 3 2
      libc/unistd/exec.c

+ 2 - 1
libc/stdio/popen.c

@@ -17,6 +17,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <paths.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/wait.h>
@@ -91,7 +92,7 @@ FILE *popen(const char *command, const char *modes)
 			close(po->f->__filedes);
 		}
 
-		execl("/bin/sh", "sh", "-c", command, (char *)0);
+		execl(_PATH_BSHELL, "sh", "-c", command, (char *)0);
 
 		/* SUSv3 mandates an exit code of 127 for the child if the
 		 * command interpreter can not be invoked. */

+ 4 - 3
libc/stdlib/system.c

@@ -11,6 +11,7 @@
 #include <unistd.h>
 #include <sys/wait.h>
 #include <stdlib.h>
+#include <paths.h>
 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
 #include <sched.h>
 #include <errno.h>
@@ -50,7 +51,7 @@ int __libc_system(const char *command)
 		sigaction(SIGINT, &save_int, NULL);
 		sigprocmask(SIG_SETMASK, &save_mask, NULL);
 
-		execl("/bin/sh", "sh", "-c", command, (char *) 0);
+		execl(_PATH_BSHELL, "sh", "-c", command, (char *) 0);
 		_exit(127);
 	}
 
@@ -169,7 +170,7 @@ do_system (const char *line)
     {
       /* Child side.  */
       const char *new_argv[4];
-      new_argv[0] = "/bin/sh";
+      new_argv[0] = _PATH_BSHELL;
       new_argv[1] = "-c";
       new_argv[2] = line;
       new_argv[3] = NULL;
@@ -181,7 +182,7 @@ do_system (const char *line)
       INIT_LOCK ();
 
       /* Exec the shell.  */
-      (void) execve ("/bin/sh", (char *const *) new_argv, __environ);
+      (void) execve (_PATH_BSHELL, (char *const *) new_argv, __environ);
       _exit (127);
     }
   else if (pid < (pid_t) 0)

+ 3 - 2
libc/unistd/exec.c

@@ -20,6 +20,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <paths.h>
 #include <string.h>
 #include <errno.h>
 #include <stdarg.h>
@@ -273,9 +274,9 @@ int execvpe(const char *path, char *const argv[], char *const envp[])
 			nargv[1] = (char *)path;
 			memcpy(nargv+2, argv+1, n*sizeof(char *));
 #if defined (L_execvp)
-			execve("/bin/sh", nargv, __environ);
+			execve(_PATH_BSHELL, nargv, __environ);
 #elif defined (L_execvpe)
-			execve("/bin/sh", nargv, envp);
+			execve(_PATH_BSHELL, nargv, envp);
 #endif
 			EXEC_FREE(nargv, size2);
 		}