aboutsummaryrefslogtreecommitdiff
path: root/posix/wordexp.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-09-26 07:56:19 +0000
committerUlrich Drepper <drepper@redhat.com>2000-09-26 07:56:19 +0000
commit316ca440b070114ba877455c3dbbcdc1b20e4f33 (patch)
tree4224faacba4731e0b405a79552dde36c31e3eeea /posix/wordexp.c
parente5448d7ad2c39a6784894e8e840514b0d88333bc (diff)
downloadglibc-316ca440b070114ba877455c3dbbcdc1b20e4f33.tar
glibc-316ca440b070114ba877455c3dbbcdc1b20e4f33.tar.gz
glibc-316ca440b070114ba877455c3dbbcdc1b20e4f33.tar.bz2
glibc-316ca440b070114ba877455c3dbbcdc1b20e4f33.zip
Update.
* misc/daemon.c (daemon): Fail if !noclose and we cannot open the real /dev/null device. * sysdeps/generic/check_fds.c: Include device-nrs.h. * sysdeps/generic/device-nrs.h: New file. * sysdeps/unix/sysv/linux/device-nrs.h: New file. * misc/Makefile (distribute): Add device-nrs.h. * posix/wordexp.c (exec_comm_child): Likewise. * locale/nl_langinfo.c: Allow use of file for __nl_langinfo_l definition.
Diffstat (limited to 'posix/wordexp.c')
-rw-r--r--posix/wordexp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/posix/wordexp.c b/posix/wordexp.c
index 739df218fb..4bd84ddb7a 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -44,6 +44,9 @@
/* #define NDEBUG 1 */
#include <assert.h>
+/* Get some device information. */
+#include <device-nrs.h>
+
/*
* This is a recursive-descent-style word expansion routine.
*/
@@ -840,6 +843,7 @@ exec_comm_child (char *comm, int *fildes, int showerr, int noexec)
/* Redirect stderr to /dev/null if we have to. */
if (showerr == 0)
{
+ struct stat64 st;
int fd;
__close (2);
fd = __open (_PATH_DEVNULL, O_WRONLY);
@@ -848,6 +852,18 @@ exec_comm_child (char *comm, int *fildes, int showerr, int noexec)
__dup2 (fd, 2);
__close (fd);
}
+ /* Be paranoid. Check that we actually opened the /dev/null
+ device. */
+ if (__builtin_expect (__fxstat64 (_STAT_VER, 2, &st), 0) != 0
+ || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0
+#if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR
+ || st.st_rdev != makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR)
+#endif
+ )
+ /* It's not the /dev/null device. Stop right here. The
+ problem is: how do we stop? We use _exit() with an
+ hopefully unusual exit code. */
+ _exit (90);
}
/* Make sure the subshell doesn't field-split on our behalf. */