1 From d588b6530e1382a624898b3f4307f636c72c80a9 Mon Sep 17 00:00:00 2001
2 From: Pierre Habouzit <madcoder@debian.org>
3 Date: Wed, 28 Nov 2007 10:13:08 +0100
4 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
10 Signed-off-by: Pierre Habouzit <madcoder@debian.org>
12 xinetd/inet.c | 22 +++++++++++++++++++---
13 1 files changed, 19 insertions(+), 3 deletions(-)
15 diff --git a/xinetd/inet.c b/xinetd/inet.c
16 index 1cb2ba2..8caab45 100644
25 static int get_next_inet_entry( int fd, pset_h sconfs,
26 struct service_config *defaults);
28 @@ -32,12 +34,15 @@ void parse_inet_conf_file( int fd, struct configuration *confp )
29 struct service_config *default_config = CNF_DEFAULTS( confp );
32 + iter = psi_create (sconfs);
36 if (get_next_inet_entry(fd, sconfs, default_config) == -2)
43 static int get_next_inet_entry( int fd, pset_h sconfs,
44 @@ -46,7 +51,7 @@ static int get_next_inet_entry( int fd, pset_h sconfs,
47 char *line = next_line(fd);
48 - struct service_config *scp;
49 + struct service_config *scp, *tmp;
51 const char *func = "get_next_inet_entry";
52 char *name = NULL, *rpcvers = NULL, *rpcproto = NULL;
53 @@ -405,7 +410,16 @@ static int get_next_inet_entry( int fd, pset_h sconfs,
54 SC_SPECIFY( scp, A_SOCKET_TYPE );
55 SC_SPECIFY( scp, A_WAIT );
57 - if( ! pset_add(sconfs, scp) )
58 + for ( tmp = SCP( psi_start( iter ) ) ; tmp ; tmp = SCP( psi_next(iter)) ){
59 + if (EQ(SC_ID(scp), SC_ID(tmp))) {
60 + parsemsg(LOG_DEBUG, func, "removing duplicate service %s", SC_NAME(scp));
67 + if( scp && ! pset_add(sconfs, scp) )
69 out_of_memory( func );
71 @@ -414,7 +428,9 @@ static int get_next_inet_entry( int fd, pset_h sconfs,
75 - parsemsg( LOG_DEBUG, func, "added service %s", SC_NAME(scp));
77 + parsemsg( LOG_DEBUG, func, "added service %s", SC_NAME(scp));