mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
posix: Fix return value of system if shell can not be executed [BZ #27053]
POSIX states that system returned code for failure to execute the shell
shall be as if the shell had terminated using _exit(127). This
behaviour was removed with 5fb7fc9635
.
Checked on x86_64-linux-gnu.
This commit is contained in:
@ -26,6 +26,7 @@
|
|||||||
#include <support/check.h>
|
#include <support/check.h>
|
||||||
#include <support/temp_file.h>
|
#include <support/temp_file.h>
|
||||||
#include <support/support.h>
|
#include <support/support.h>
|
||||||
|
#include <support/xunistd.h>
|
||||||
|
|
||||||
static char *tmpdir;
|
static char *tmpdir;
|
||||||
static long int namemax;
|
static long int namemax;
|
||||||
@ -138,6 +139,22 @@ do_test (void)
|
|||||||
support_capture_subprocess_check (&result, "system", 0, sc_allow_none);
|
support_capture_subprocess_check (&result, "system", 0, sc_allow_none);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct stat64 st;
|
||||||
|
xstat (_PATH_BSHELL, &st);
|
||||||
|
mode_t mode = st.st_mode;
|
||||||
|
xchmod (_PATH_BSHELL, mode & ~(S_IXUSR | S_IXGRP | S_IXOTH));
|
||||||
|
|
||||||
|
struct support_capture_subprocess result;
|
||||||
|
result = support_capture_subprocess (call_system,
|
||||||
|
&(struct args) {
|
||||||
|
"exit 1", 127, 0
|
||||||
|
});
|
||||||
|
support_capture_subprocess_check (&result, "system", 0, sc_allow_none);
|
||||||
|
|
||||||
|
xchmod (_PATH_BSHELL, st.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_COMPARE (system (""), 0);
|
TEST_COMPARE (system (""), 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -91,6 +91,7 @@ libsupport-routines = \
|
|||||||
xchroot \
|
xchroot \
|
||||||
xclock_gettime \
|
xclock_gettime \
|
||||||
xclose \
|
xclose \
|
||||||
|
xchmod \
|
||||||
xconnect \
|
xconnect \
|
||||||
xcopy_file_range \
|
xcopy_file_range \
|
||||||
xdlfcn \
|
xdlfcn \
|
||||||
|
@ -175,6 +175,10 @@ do_system (const char *line)
|
|||||||
__libc_cleanup_region_end (0);
|
__libc_cleanup_region_end (0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
/* POSIX states that failure to execute the shell should return
|
||||||
|
as if the shell had terminated using _exit(127). */
|
||||||
|
status = W_EXITCODE (127, 0);
|
||||||
|
|
||||||
DO_LOCK ();
|
DO_LOCK ();
|
||||||
if (SUB_REF () == 0)
|
if (SUB_REF () == 0)
|
||||||
|
Reference in New Issue
Block a user