Various-fixes-from-the-previous-maintainer.patch 2.5 KB

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