"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xinetd/child.c" between
xinetd-2.3.15.tar.gz and xinetd-2.3.15.4.tar.xz

About: xinetd is a secure replacement for inetd, the internet services daemon (openSUSE fork).

child.c  (xinetd-2.3.15):child.c  (xinetd-2.3.15.4.tar.xz)
skipping to change at line 12 skipping to change at line 12
* (c) Copyright 1992 by Panagiotis Tsirigotis * (c) Copyright 1992 by Panagiotis Tsirigotis
* (c) Sections Copyright 1998-2001 by Rob Braun * (c) Sections Copyright 1998-2001 by Rob Braun
* All rights reserved. The file named COPYRIGHT specifies the terms * All rights reserved. The file named COPYRIGHT specifies the terms
* and conditions for redistribution. * and conditions for redistribution.
*/ */
#include "config.h" #include "config.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h> #include <sys/resource.h>
#endif
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <syslog.h> #include <syslog.h>
#include <errno.h> #include <errno.h>
#include <pwd.h> #include <pwd.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined (HAVE_GRP_H)
#include <grp.h> #include <grp.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h> #include <netdb.h>
#endif
#ifdef LABELED_NET #ifdef LABELED_NET
#include <selinux/selinux.h> #include <selinux/selinux.h>
#include <selinux/flask.h>
#include <selinux/context.h> #include <selinux/context.h>
#endif #endif
#include "str.h" #include "str.h"
#include "child.h" #include "child.h"
#include "sconf.h" #include "sconf.h"
#include "msg.h" #include "msg.h"
#include "main.h" #include "main.h"
#include "xconfig.h" #include "xconfig.h"
#include "ident.h" #include "ident.h"
skipping to change at line 109 skipping to change at line 102
if ( dup2( descriptor, fd ) == -1 ) if ( dup2( descriptor, fd ) == -1 )
{ {
msg_resume(); msg_resume();
msg( LOG_ERR, func, msg( LOG_ERR, func,
"dup2( %d, %d ) failed: %m", descriptor, fd ) ; "dup2( %d, %d ) failed: %m", descriptor, fd ) ;
_exit( 1 ) ; _exit( 1 ) ;
} }
} }
#ifdef RLIMIT_NOFILE #ifdef RLIMIT_NOFILE
rl.rlim_max = ps.ros.orig_max_descriptors ; if ( SC_RLIM_FILES( scp ))
rl.rlim_cur = ps.ros.max_descriptors ; {
ps.ros.max_descriptors = SC_RLIM_FILES( scp );
}
rl.rlim_max = rl.rlim_cur = ps.ros.max_descriptors ;
(void) setrlimit( RLIMIT_NOFILE, &rl ) ; (void) setrlimit( RLIMIT_NOFILE, &rl ) ;
#endif #endif
#ifdef RLIMIT_AS #ifdef RLIMIT_AS
if (SC_RLIM_AS (scp)) if (SC_RLIM_AS (scp))
{ {
rl.rlim_cur = SC_RLIM_AS( scp ); rl.rlim_cur = SC_RLIM_AS( scp );
rl.rlim_max = SC_RLIM_AS( scp ); rl.rlim_max = SC_RLIM_AS( scp );
(void) setrlimit( RLIMIT_AS, &rl ); (void) setrlimit( RLIMIT_AS, &rl );
} }
#endif #endif
skipping to change at line 171 skipping to change at line 167
msg( LOG_ERR, func, msg( LOG_ERR, func,
"Changing process context failed for %s", SC_ID( scp )) ; "Changing process context failed for %s", SC_ID( scp )) ;
_exit( 1 ) ; _exit( 1 ) ;
} }
} }
#endif #endif
(void) Sclose( descriptor ) ; (void) Sclose( descriptor ) ;
#ifndef solaris #ifndef solaris
#if !defined(HAVE_SETSID)
msg_resume();
#endif
no_control_tty() ; no_control_tty() ;
#if !defined(HAVE_SETSID)
msg_suspend();
#endif
#endif #endif
(void) execve( server, SC_SERVER_ARGV( scp ), (void) execve( server, SC_SERVER_ARGV( scp ),
env_getvars( SC_ENV( scp )->env_handle ) ) ; env_getvars( SC_ENV( scp )->env_handle ) ) ;
/* /*
* The exec failed. Log the error and exit. * The exec failed. Log the error and exit.
*/ */
msg_resume() ; msg_resume() ;
msg( LOG_ERR, func, "execv( %s ) failed: %m", server ) ; msg( LOG_ERR, func, "execv( %s ) failed: %m", server ) ;
skipping to change at line 317 skipping to change at line 307
if ((signals_pending[0] >= 0 && Sclose(signals_pending[0])) || if ((signals_pending[0] >= 0 && Sclose(signals_pending[0])) ||
(signals_pending[1] >= 0 && Sclose(signals_pending[1]))) (signals_pending[1] >= 0 && Sclose(signals_pending[1])))
{ {
msg(LOG_ERR, func, "Failed to close the signal pipe: %m"); msg(LOG_ERR, func, "Failed to close the signal pipe: %m");
_exit(1); _exit(1);
} }
signals_pending[0] = -1; signals_pending[0] = -1;
signals_pending[1] = -1; signals_pending[1] = -1;
Sclose(0);
Sclose(1);
Sclose(2);
#ifdef DEBUG_SERVER #ifdef DEBUG_SERVER
if ( debug.on ) if ( debug.on )
{ {
msg( LOG_DEBUG, func, "Process %d is sleeping", getpid() ) ; msg( LOG_DEBUG, func, "Process %d is sleeping", getpid() ) ;
sleep( 10 ) ; sleep( 10 ) ;
} }
#endif #endif
if ( ! SC_IS_INTERCEPTED( scp ) ) if ( ! SC_IS_INTERCEPTED( scp ) )
{ {
skipping to change at line 369 skipping to change at line 355
/* this is where the server gets executed -bbraun */ /* this is where the server gets executed -bbraun */
if ( ! SC_IS_INTERNAL( scp ) ) if ( ! SC_IS_INTERNAL( scp ) )
{ {
if( SC_REDIR_ADDR(scp) != NULL ) if( SC_REDIR_ADDR(scp) != NULL )
{ {
redir_handler( serp ); redir_handler( serp );
} }
else else
{ {
#if defined(HAVE_SETENV)
char buff[1024]; char buff[1024];
strx_sprint(buff, sizeof(buff)-1, "REMOTE_HOST=%s", conn_addrstr(cp)); strx_sprint(buff, sizeof(buff)-1, "REMOTE_HOST=%s", conn_addrstr(cp));
if( env_addstr(SC_ENV(scp)->env_handle, buff) != ENV_OK ) { if( env_addstr(SC_ENV(scp)->env_handle, buff) != ENV_OK ) {
msg( LOG_ERR, func, "Error adding REMOTE_HOST variable for %s: %m", SC_NAME(scp) ); msg( LOG_ERR, func, "Error adding REMOTE_HOST variable for %s: %m", SC_NAME(scp) );
_exit( 1 ) ; _exit( 1 ) ;
} }
#endif
exec_server( serp ) ; exec_server( serp ) ;
} }
} }
else else
{ {
char name[ 180 ] ; char name[ 180 ] ;
/* /*
* We don't bother to disassociate from the controlling terminal * We don't bother to disassociate from the controlling terminal
* (we have a controlling terminal only if debug.on is TRUE) * (we have a controlling terminal only if debug.on is TRUE)
* *
skipping to change at line 441 skipping to change at line 425
void child_exit(void) void child_exit(void)
{ {
const char *func = "child_exit" ; const char *func = "child_exit" ;
for ( ;; ) /* Find all children that exited */ for ( ;; ) /* Find all children that exited */
{ {
int status ; int status ;
pid_t pid ; pid_t pid ;
struct server *serp ; struct server *serp ;
#ifdef HAVE_WAITPID
pid = waitpid( -1, &status, WNOHANG ) ; pid = waitpid( -1, &status, WNOHANG ) ;
#else
#if defined( sun ) && defined( lint )
pid = wait3( (union wait *)&status, WNOHANG, RUSAGE_NULL ) ;
#else
pid = wait3( &status, WNOHANG, RUSAGE_NULL ) ;
#endif
#endif
if ( debug.on ) if ( debug.on )
#ifdef HAVE_WAITPID
msg( LOG_DEBUG, func, "waitpid returned = %d", pid ) ; msg( LOG_DEBUG, func, "waitpid returned = %d", pid ) ;
#else
msg( LOG_DEBUG, func, "wait3 returned = %d", pid ) ;
#endif
if ( pid == -1 ) { if ( pid == -1 ) {
if ( errno == EINTR ) if ( errno == EINTR )
continue ; continue ;
else else
break ; break ;
} }
if ( pid == 0 ) if ( pid == 0 )
break ; break ;
skipping to change at line 541 skipping to change at line 513
if (!context_range_get(pcon)) if (!context_range_get(pcon))
goto fail; goto fail;
if (context_range_set(bcon, context_range_get(pcon))) if (context_range_set(bcon, context_range_get(pcon)))
goto fail; goto fail;
if (!(new_context = context_str(bcon))) if (!(new_context = context_str(bcon)))
goto fail; goto fail;
if (security_compute_create(new_context, exec_context, SECCLASS_PROCESS, if (security_compute_create(new_context, exec_context, string_to_security_cla ss ("process"),
&new_exec_context) < 0) &new_exec_context) < 0)
goto fail; goto fail;
retval = set_context(new_exec_context); retval = set_context(new_exec_context);
freecon(new_exec_context); freecon(new_exec_context);
fail: fail:
context_free(pcon); context_free(pcon);
context_free(bcon); context_free(bcon);
 End of changes. 17 change blocks. 
34 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)