diff options
Diffstat (limited to 'login-utils/simpleinit.c')
-rw-r--r-- | login-utils/simpleinit.c | 15 |
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*/ |