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