X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=xinetd%2Fchild.c;h=48e9615eab7851f82c0f0899d83e76cea0ba4925;hb=d588b6530e1382a624898b3f4307f636c72c80a9;hp=89ee54c947bc8f65789cae7c8b8d4e784594792c;hpb=7d80dea6e340c708819fa904651114351bdd8318;p=packages%2Fxinetd.git diff --git a/xinetd/child.c b/xinetd/child.c index 89ee54c..48e9615 100644 --- a/xinetd/child.c +++ b/xinetd/child.c @@ -284,6 +284,7 @@ void child_process( struct server *serp ) connection_s *cp = SERVER_CONNECTION( serp ) ; struct service_config *scp = SVC_CONF( sp ) ; const char *func = "child_process" ; + int fd, null_fd; signal_default_state(); @@ -296,9 +297,22 @@ void child_process( struct server *serp ) signals_pending[0] = -1; signals_pending[1] = -1; - Sclose(0); - Sclose(1); - Sclose(2); + if ( ( null_fd = open( "/dev/null", O_RDONLY ) ) == -1 ) + { + msg( LOG_ERR, func, "open('/dev/null') failed: %m") ; + _exit( 1 ) ; + } + + for ( fd = 0 ; fd <= MAX_PASS_FD ; fd++ ) + { + if ( fd != null_fd && dup2( null_fd, fd ) == -1 ) + { + msg( LOG_ERR, func, "dup2(%d, %d) failed: %m") ; + _exit( 1 ) ; + } + } + if ( null_fd > MAX_PASS_FD ) + (void) Sclose( null_fd ) ; #ifdef DEBUG_SERVER