diff options
-rw-r--r-- | initscripts.spec | 5 | ||||
-rw-r--r-- | src/process.c | 12 | ||||
-rw-r--r-- | src/testd.c | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/initscripts.spec b/initscripts.spec index aa003796..019a7415 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -1,6 +1,6 @@ Summary: The inittab file and the /etc/init.d scripts. Name: initscripts -Version: 5.65 +Version: 5.66 Copyright: GPL Group: System Environment/Base Release: 1 @@ -254,6 +254,9 @@ rm -rf $RPM_BUILD_ROOT %ghost %attr(0664,root,utmp) /var/run/utmp %changelog +* Wed Feb 21 Nalin Dahyabhai <nalin@redhat.com> +- close extra file descriptors before exec()ing commands in initlog + * Mon Feb 19 2001 Bill Nottingham <notting@redhat.com> - fix some substitions in init.d/functions (fixes various killproc issues) - make sure ipv6 module alias is available if configured diff --git a/src/process.c b/src/process.c index b320051f..ce0d459d 100644 --- a/src/process.c +++ b/src/process.c @@ -71,6 +71,8 @@ int forkCommand(char **args, int *outfd, int *errfd, int *cmdfd, int quiet) { return pid; } else { /* kid */ + int sc_open_max; + if (outfd) { if ( (dup2(fdout,1)==-1) ) { perror("dup2"); @@ -107,6 +109,16 @@ int forkCommand(char **args, int *outfd, int *errfd, int *cmdfd, int quiet) { close(*errfd); if (cmdfd) close(*cmdfd); + + /* close up extra fds, and hope this doesn't break anything */ + sc_open_max = sysconf(_SC_OPEN_MAX); + if(sc_open_max > 1) { + int fd; + for(fd = 3; fd < sc_open_max; fd++) { + close(fd); + } + } + execvp(args[0],args); perror("execvp"); exit(-1); diff --git a/src/testd.c b/src/testd.c index 7deb00eb..b2a5c7e6 100644 --- a/src/testd.c +++ b/src/testd.c @@ -1,5 +1,6 @@ #include <sys/signal.h> #include <unistd.h> +#include <stdlib.h> int main() { signal(SIGTERM, SIG_IGN); |