summaryrefslogtreecommitdiffstats
path: root/login-utils/simpleinit.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:26:08 +0100
committerKarel Zak2006-12-07 00:26:08 +0100
commita5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d (patch)
tree830565491cb6af2b456960d28c093054fa287e0b /login-utils/simpleinit.c
parentImported from util-linux-2.11x tarball. (diff)
downloadkernel-qcow2-util-linux-a5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d.tar.gz
kernel-qcow2-util-linux-a5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d.tar.xz
kernel-qcow2-util-linux-a5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d.zip
Imported from util-linux-2.11y tarball.
Diffstat (limited to 'login-utils/simpleinit.c')
-rw-r--r--login-utils/simpleinit.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c
index cf33fe146..093c00303 100644
--- a/login-utils/simpleinit.c
+++ b/login-utils/simpleinit.c
@@ -13,6 +13,8 @@
* - block signals in handlers, so that longjmp() doesn't kill context
* 2001-02-25 Richard Gooch <rgooch@atnf.csiro.au>
* - make default INIT_PATH the boot_prog (if it is a directory) - YECCH
+ * 2002-11-20 patch from SuSE
+ * - refuse initctl_fd if setting FD_CLOEXEC fails
*/
#include <sys/types.h>
@@ -204,6 +206,19 @@ int main(int argc, char *argv[])
err ( _("error opening fifo\n") );
}
+ if (initctl_fd >= 0 && fcntl(initctl_fd, F_SETFD, FD_CLOEXEC) != 0) {
+ err ( _("error setting close-on-exec on /dev/initctl") );
+
+ /* Can the fcntl ever fail? If it does, and we leave
+ the descriptor open in child processes, then any
+ process on the system will be able to write to
+ /dev/initctl and have us execute arbitrary commands
+ as root. So let's refuse to use the fifo in this case. */
+
+ close(initctl_fd);
+ initctl_fd = -1;
+ }
+
if ( want_single || (access (_PATH_SINGLE, R_OK) == 0) ) do_single ();
/*If we get a SIGTSTP before multi-user mode, do nothing*/