Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Upstream-Status: Pending [from other distro Debian] |
| 2 | |
| 3 | From a3410b0bc81ab03a889d9ffc14e351badf8372f1 Mon Sep 17 00:00:00 2001 |
| 4 | From: Pierre Habouzit <madcoder@debian.org> |
| 5 | Date: Mon, 26 Nov 2007 16:02:04 +0100 |
| 6 | Subject: [PATCH] Various fixes from the previous maintainer. |
| 7 | |
| 8 | --- |
| 9 | xinetd/child.c | 20 +++++++++++++++++--- |
| 10 | xinetd/service.c | 8 ++++---- |
| 11 | 2 files changed, 21 insertions(+), 7 deletions(-) |
| 12 | |
| 13 | diff --git a/xinetd/child.c b/xinetd/child.c |
| 14 | index 89ee54c..48e9615 100644 |
| 15 | --- a/xinetd/child.c |
| 16 | +++ b/xinetd/child.c |
| 17 | @@ -284,6 +284,7 @@ void child_process( struct server *serp ) |
| 18 | connection_s *cp = SERVER_CONNECTION( serp ) ; |
| 19 | struct service_config *scp = SVC_CONF( sp ) ; |
| 20 | const char *func = "child_process" ; |
| 21 | + int fd, null_fd; |
| 22 | |
| 23 | signal_default_state(); |
| 24 | |
| 25 | @@ -296,9 +297,22 @@ void child_process( struct server *serp ) |
| 26 | signals_pending[0] = -1; |
| 27 | signals_pending[1] = -1; |
| 28 | |
| 29 | - Sclose(0); |
| 30 | - Sclose(1); |
| 31 | - Sclose(2); |
| 32 | + if ( ( null_fd = open( "/dev/null", O_RDONLY ) ) == -1 ) |
| 33 | + { |
| 34 | + msg( LOG_ERR, func, "open('/dev/null') failed: %m") ; |
| 35 | + _exit( 1 ) ; |
| 36 | + } |
| 37 | + |
| 38 | + for ( fd = 0 ; fd <= MAX_PASS_FD ; fd++ ) |
| 39 | + { |
| 40 | + if ( fd != null_fd && dup2( null_fd, fd ) == -1 ) |
| 41 | + { |
| 42 | + msg( LOG_ERR, func, "dup2(%d, %d) failed: %m") ; |
| 43 | + _exit( 1 ) ; |
| 44 | + } |
| 45 | + } |
| 46 | + if ( null_fd > MAX_PASS_FD ) |
| 47 | + (void) Sclose( null_fd ) ; |
| 48 | |
| 49 | |
| 50 | #ifdef DEBUG_SERVER |
| 51 | diff --git a/xinetd/service.c b/xinetd/service.c |
| 52 | index 3d68d78..0132d6c 100644 |
| 53 | --- a/xinetd/service.c |
| 54 | +++ b/xinetd/service.c |
| 55 | @@ -745,8 +745,8 @@ static status_e failed_service(struct service *sp, |
| 56 | return FAILED; |
| 57 | |
| 58 | if ( last == NULL ) { |
| 59 | - last = SAIN( calloc( 1, sizeof(union xsockaddr) ) ); |
| 60 | - SVC_LAST_DGRAM_ADDR(sp) = (union xsockaddr *)last; |
| 61 | + SVC_LAST_DGRAM_ADDR(sp) = SAIN( calloc( 1, sizeof(union xsockaddr) ) ); |
| 62 | + last = SAIN( SVC_LAST_DGRAM_ADDR(sp) ); |
| 63 | } |
| 64 | |
| 65 | (void) time( ¤t_time ) ; |
| 66 | @@ -772,8 +772,8 @@ static status_e failed_service(struct service *sp, |
| 67 | return FAILED; |
| 68 | |
| 69 | if( last == NULL ) { |
| 70 | - last = SAIN6(calloc( 1, sizeof(union xsockaddr) ) ); |
| 71 | - SVC_LAST_DGRAM_ADDR( sp ) = (union xsockaddr *)last; |
| 72 | + SVC_LAST_DGRAM_ADDR(sp) = SAIN6(calloc( 1, sizeof(union xsockaddr) ) ); |
| 73 | + last = SAIN6(SVC_LAST_DGRAM_ADDR(sp)); |
| 74 | } |
| 75 | |
| 76 | (void) time( ¤t_time ) ; |
| 77 | -- |
| 78 | 1.5.3.6.2040.g15e6 |
| 79 | |