use the new flag by default
[packages/xinetd.git] / debian / patches / 0007-xinetd-should-be-able-to-listen-on-IPv6-even-in-ine.patch
1 From f44b218ccc779ab3f4aed072390ccf129d94b58d Mon Sep 17 00:00:00 2001
2 From: David Madore <david@pleiades.stars>
3 Date: Mon, 24 Mar 2008 12:45:36 +0100
4 Subject: [PATCH] xinetd should be able to listen on IPv6 even in -inetd_compat mode
5
6 xinetd does not bind to IPv6 addresses (and does not seem to have an
7 option to do so) when used in -inetd_compat mode.  As current inetd's
8 are IPv6-aware, this is a problem: this means xinetd cannot be used as
9 a drop-in inetd replacement.
10
11 The attached patch is a suggestion: it adds a -inetd_ipv6 global
12 option that, if used, causes inetd-compatibility lines to have an
13 implicit "IPv6" option.  Perhaps this is not the best solution, but
14 there should definitely be a way to get inetd.conf to be read in
15 IPv6-aware mode.
16 ---
17  xinetd/confparse.c |    1 +
18  xinetd/inet.c      |   17 +++++++++++++++++
19  xinetd/options.c   |    3 +++
20  xinetd/xinetd.man  |    6 ++++++
21  4 files changed, 27 insertions(+), 0 deletions(-)
22
23 diff --git a/xinetd/confparse.c b/xinetd/confparse.c
24 index db9f431..d7b0bcc 100644
25 --- a/xinetd/confparse.c
26 +++ b/xinetd/confparse.c
27 @@ -40,6 +40,7 @@
28  #include "inet.h"
29  #include "main.h"
30  
31 +extern int inetd_ipv6;
32  extern int inetd_compat;
33  
34  /*
35 diff --git a/xinetd/inet.c b/xinetd/inet.c
36 index 8caab45..2e617ae 100644
37 --- a/xinetd/inet.c
38 +++ b/xinetd/inet.c
39 @@ -25,6 +25,8 @@
40  
41  static psi_h iter ;
42  
43 +extern int inetd_ipv6;
44 +
45  static int get_next_inet_entry( int fd, pset_h sconfs, 
46                            struct service_config *defaults);
47  
48 @@ -360,6 +362,21 @@ static int get_next_inet_entry( int fd, pset_h sconfs,
49           }
50           SC_SERVER_ARGV(scp)[u] = p;
51        }
52 +
53 +      /* Set the IPv6 flag if we were passed the -inetd_ipv6 option */
54 +      if ( inetd_ipv6 )
55 +      {
56 +         nvp = nv_find_value( service_flags, "IPv6" );
57 +         if ( nvp == NULL )
58 +         {
59 +            parsemsg( LOG_WARNING, func, "inetd.conf - Bad foo %s", name ) ;
60 +            pset_destroy(args);
61 +            sc_free(scp);
62 +            return -1;
63 +         }
64 +         M_SET(SC_XFLAGS(scp), nvp->value);
65 +      }
66 +
67        /* Set the reuse flag, as this is the default for inetd */
68        nvp = nv_find_value( service_flags, "REUSE" );
69        if ( nvp == NULL )
70 diff --git a/xinetd/options.c b/xinetd/options.c
71 index b058b6a..dc2f3a0 100644
72 --- a/xinetd/options.c
73 +++ b/xinetd/options.c
74 @@ -30,6 +30,7 @@ int logprocs_option ;
75  unsigned logprocs_option_arg ;
76  int stayalive_option=0;
77  char *program_name ;
78 +int inetd_ipv6 = 0 ;
79  int inetd_compat = 0 ;
80  int dont_fork = 0;
81  
82 @@ -128,6 +129,8 @@ int opt_recognize( int argc, char *argv[] )
83              fprintf(stderr, "\n");
84              exit(0);
85           }
86 +         else if ( strcmp ( &argv[ arg ][ 1 ], "inetd_ipv6" ) == 0 )
87 +            inetd_ipv6 = 1;
88           else if ( strcmp ( &argv[ arg ][ 1 ], "inetd_compat" ) == 0 )
89              inetd_compat = 1;
90        }
91 diff --git a/xinetd/xinetd.man b/xinetd/xinetd.man
92 index c76c3c6..c9dd803 100644
93 --- a/xinetd/xinetd.man
94 +++ b/xinetd/xinetd.man
95 @@ -106,6 +106,12 @@ This option causes xinetd to read /etc/inetd.conf in addition to the
96  standard xinetd config files.  /etc/inetd.conf is read after the
97  standard xinetd config files.
98  .TP
99 +.BI \-inetd_ipv6
100 +This option causes xinetd to bind to IPv6 (AF_INET6) addresses for
101 +inetd compatibility lines (see previous option).  This only affects
102 +how /etc/inetd.conf is interpreted and thus only has any effect if
103 +the \-inetd_compat option is also used.
104 +.TP
105  .BI \-cc " interval"
106  This option instructs
107  .B xinetd
108 -- 
109 1.5.5.rc0.127.gb4337
110