Disable-services-from-inetd.conf-if-a-service-with-t.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. Upstream-Status: Pending [from other distro Debian]
  2. From d588b6530e1382a624898b3f4307f636c72c80a9 Mon Sep 17 00:00:00 2001
  3. From: Pierre Habouzit <madcoder@debian.org>
  4. Date: Wed, 28 Nov 2007 10:13:08 +0100
  5. Subject: [PATCH] Disable services from inetd.conf if a service with the same id exists.
  6. This way, if a service is enabled in /etc/xinetd* _and_ in
  7. /etc/inetd.conf, the one (even if disabled) from /etc/xinetd* takes
  8. precedence.
  9. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
  10. ---
  11. xinetd/inet.c | 22 +++++++++++++++++++---
  12. 1 files changed, 19 insertions(+), 3 deletions(-)
  13. diff --git a/xinetd/inet.c b/xinetd/inet.c
  14. index 1cb2ba2..8caab45 100644
  15. --- a/xinetd/inet.c
  16. +++ b/xinetd/inet.c
  17. @@ -23,6 +23,8 @@
  18. #include "parsesup.h"
  19. #include "nvlists.h"
  20. +static psi_h iter ;
  21. +
  22. static int get_next_inet_entry( int fd, pset_h sconfs,
  23. struct service_config *defaults);
  24. @@ -32,12 +34,15 @@ void parse_inet_conf_file( int fd, struct configuration *confp )
  25. struct service_config *default_config = CNF_DEFAULTS( confp );
  26. line_count = 0;
  27. + iter = psi_create (sconfs);
  28. for( ;; )
  29. {
  30. if (get_next_inet_entry(fd, sconfs, default_config) == -2)
  31. break;
  32. }
  33. +
  34. + psi_destroy(iter);
  35. }
  36. static int get_next_inet_entry( int fd, pset_h sconfs,
  37. @@ -46,7 +51,7 @@ static int get_next_inet_entry( int fd, pset_h sconfs,
  38. char *p;
  39. str_h strp;
  40. char *line = next_line(fd);
  41. - struct service_config *scp;
  42. + struct service_config *scp, *tmp;
  43. unsigned u, i;
  44. const char *func = "get_next_inet_entry";
  45. char *name = NULL, *rpcvers = NULL, *rpcproto = NULL;
  46. @@ -405,7 +410,16 @@ static int get_next_inet_entry( int fd, pset_h sconfs,
  47. SC_SPECIFY( scp, A_SOCKET_TYPE );
  48. SC_SPECIFY( scp, A_WAIT );
  49. - if( ! pset_add(sconfs, scp) )
  50. + for ( tmp = SCP( psi_start( iter ) ) ; tmp ; tmp = SCP( psi_next(iter)) ){
  51. + if (EQ(SC_ID(scp), SC_ID(tmp))) {
  52. + parsemsg(LOG_DEBUG, func, "removing duplicate service %s", SC_NAME(scp));
  53. + sc_free(scp);
  54. + scp = NULL;
  55. + break;
  56. + }
  57. + }
  58. +
  59. + if( scp && ! pset_add(sconfs, scp) )
  60. {
  61. out_of_memory( func );
  62. pset_destroy(args);
  63. @@ -414,7 +428,9 @@ static int get_next_inet_entry( int fd, pset_h sconfs,
  64. }
  65. pset_destroy(args);
  66. - parsemsg( LOG_DEBUG, func, "added service %s", SC_NAME(scp));
  67. + if (scp) {
  68. + parsemsg( LOG_DEBUG, func, "added service %s", SC_NAME(scp));
  69. + }
  70. return 0;
  71. }
  72. --
  73. 1.5.3.6.2040.g15e6