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