1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
From ee6ea58645a4db63f6ccad40566b37b23279797e Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Mon, 6 Sep 2010 10:52:27 +0200
Subject: [PATCH 3/3] inetd: Change protocol semantics in inetd.conf
* src/inetd.c (setup): Update comment.
(getconfigent) [IPV6]: Change default family to IPv4 for "tcp" and
"udp". Change "tcp6" and "udp6" to support IPv4 mapped addresses.
Add "tcp6only" and "udp6only" protocols for IPv6 only addresses.
(fix_tcpmux) [IPV6]: Set se_proto to "tcp6".
[!IPV6]: Set se_proto to "tcp".
---
src/inetd.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/inetd.c b/src/inetd.c
index 1c51a51..0d3ff69 100644
--- a/src/inetd.c
+++ b/src/inetd.c
@@ -563,8 +563,8 @@ setup (struct servtab *sep)
if (sep->se_family == AF_INET6)
{
/* Reverse the value of SEP->se_v4mapped, since otherwise if
- using `tcp' as a protocol type all connections will be mapped
- to IPv6, and with `tcp6' they get mapped IPv4 mapped to
+ using `tcp6' as a protocol type all connections will be mapped
+ to IPv6, and with `tcp6only' they get mapped IPv4 mapped to
IPv6. */
int val = sep->se_v4mapped ? 0 : 1;
if (setsockopt (sep->se_fd, IPPROTO_IPV6, IPV6_V6ONLY,
@@ -1002,10 +1002,9 @@ getconfigent (FILE *fconfig, const char *file, size_t *line)
sep->se_proto = newstr (argv[INETD_PROTOCOL]);
#ifdef IPV6
- /* We default to IPv6, in setup() we'll fall back to IPv4 if
- it doesn't work. */
- sep->se_family = AF_INET6;
- sep->se_v4mapped = 1;
+ /* We default to IPv4. */
+ sep->se_family = AF_INET;
+ sep->se_v4mapped = 0;
if ((strncmp (sep->se_proto, "tcp", 3) == 0)
|| (strncmp (sep->se_proto, "udp", 3) == 0))
@@ -1013,7 +1012,11 @@ getconfigent (FILE *fconfig, const char *file, size_t *line)
if (sep->se_proto[3] == '6')
{
sep->se_family = AF_INET6;
- sep->se_v4mapped = 0;
+ /* Check for tcp6only and udp6only. */
+ if (strcmp (&sep->se_proto[3], "6only") == 0)
+ sep->se_v4mapped = 0;
+ else
+ sep->se_v4mapped = 1;
}
else if (sep->se_proto[3] == '4')
{
@@ -1221,7 +1224,6 @@ fix_tcpmux (void)
serv.se_service = newstr ("tcpmux");
serv.se_socktype = SOCK_STREAM;
- serv.se_proto = newstr ("tcp");
serv.se_checked = 1;
serv.se_user = newstr ("root");
serv.se_bi = bi_lookup (&serv);
@@ -1239,9 +1241,11 @@ fix_tcpmux (void)
serv.se_fd = -1;
serv.se_type = NORM_TYPE;
#ifdef IPV6
+ serv.se_proto = newstr ("tcp6");
serv.se_family = AF_INET6;
serv.se_v4mapped = 1;
#else
+ serv.se_proto = newstr ("tcp");
serv.se_family = AF_INET;
#endif
if (debug)
--
1.7.1
|