| 1 | We want to allow builds in chroots that lack /bin/sh. Thus, system(3)
|
| 2 | and popen(3) need to be tweaked to use the right shell. For the bootstrap
|
| 3 | glibc, we just use whatever `sh' can be found in $PATH. The final glibc
|
| 4 | instead uses the hard-coded absolute file name of `bash'.
|
| 5 |
|
| 6 | In addition, status should be initialized to 0 and not -1.
|
| 7 |
|
| 8 | Adapted to glibc-2.41.
|
| 9 |
|
| 10 | diff --git a/libio/iopopen.c b/libio/iopopen.c
|
| 11 | index ebc381ed7c..e0d3ed1bc3 100644
|
| 12 | |
| 13 | |
| 14 | @@ -106,8 +106,8 @@ spawn_process (posix_spawn_file_actions_t *fa, FILE *fp, const char *command,
|
| 15 | }
|
| 16 | }
|
| 17 |
|
| 18 | - err = __posix_spawn (&((_IO_proc_file *) fp)->pid, _PATH_BSHELL, fa, NULL,
|
| 19 | + err = __posix_spawnp (&((_IO_proc_file *) fp)->pid, "sh", fa, NULL,
|
| 20 | (char *const[]){ (char*) "sh", (char*) "-c", (char*) "--",
|
| 21 | (char *) command, NULL }, __environ);
|
| 22 | if (err != 0)
|
| 23 | return err;
|
| 24 | diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c
|
| 25 | index a03f478fc7..94da6facf3 100644
|
| 26 | |
| 27 | |
| 28 | @@ -101,7 +101,7 @@ cancel_handler (void *arg)
|
| 29 | static int
|
| 30 | do_system (const char *line)
|
| 31 | {
|
| 32 | - int status = -1;
|
| 33 | + int status = 0;
|
| 34 | int ret;
|
| 35 | pid_t pid;
|
| 36 | struct sigaction sa;
|
| 37 | @@ -145,7 +145,7 @@ do_system (const char *line)
|
| 38 | __posix_spawnattr_setflags (&spawn_attr,
|
| 39 | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK);
|
| 40 |
|
| 41 | - ret = __posix_spawn (&pid, SHELL_PATH, NULL, &spawn_attr,
|
| 42 | + ret = __posix_spawnp (&pid, SHELL_NAME, NULL, &spawn_attr,
|
| 43 | (char *const[]){ (char *) SHELL_NAME,
|
| 44 | (char *) "-c",
|
| 45 | (char *) line, NULL },
|
| 46 |
|
| 47 | |
| 48 | |
| 49 | @@ -5,6 +5,9 @@
|
| 50 | __typeof (posix_spawn) __posix_spawn;
|
| 51 | libc_hidden_proto (__posix_spawn)
|
| 52 |
|
| 53 | +__typeof (posix_spawnp) __posix_spawnp;
|
| 54 | +libc_hidden_proto (__posix_spawnp)
|
| 55 | +
|
| 56 | __typeof (posix_spawn_file_actions_addclose)
|
| 57 | __posix_spawn_file_actions_addclose attribute_hidden;
|
| 58 |
|
| 59 | |
| 60 | |
| 61 | @@ -31,6 +31,7 @@ __posix_spawnp (pid_t *pid, const char *file,
|
| 62 | SPAWN_XFLAGS_USE_PATH);
|
| 63 | }
|
| 64 | versioned_symbol (libc, __posix_spawnp, posix_spawnp, GLIBC_2_15);
|
| 65 | +libc_hidden_def (__posix_spawnp)
|
| 66 |
|
| 67 |
|
| 68 | #if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15)
|
| 69 |
|