summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@hadrons.org>2010-11-18 05:52:10 +0100
committerGuillem Jover <guillem@hadrons.org>2010-11-18 05:53:44 +0100
commitf923df53fa4af38ceded4d8b1600a1a3cf803689 (patch)
treeecc8dd303f0051b1c989b3cda58694cb70552c98
parent83f785971876acdcba41f062e633b23e87c070da (diff)
downloadinetutils-f923df53fa4af38ceded4d8b1600a1a3cf803689.tar.gz
Fix IPv6 support in inetd and telnetd on GNU/kFreeBSD
By passing the correct struct sockaddr length to socket functions depending on the address family, instead of always passing the size of struct sockaddr_storage. Thanks-to: Mats Erik Andersson <gnu@gisladisker.se> Thanks-to: Simon Josefsson <simon@josefsson.org>
-rw-r--r--debian/changelog4
-rw-r--r--debian/patches/63_inetd_ipv6_sockaddrlen.patch49
-rw-r--r--debian/patches/64_telnetd_ipv6_sockaddrlen.patch30
-rw-r--r--debian/patches/series2
4 files changed, 85 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 369a2c1..ad3569a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,10 @@ inetutils (2:1.8-3) UNRELEASED; urgency=low
* Revert wrong hunk from the tcpmux services fix.
Thanks to Mats Erik Andersson.
+ * Fix IPv6 support in inetd and telnetd on GNU/kFreeBSD by passing
+ the correct struct sockaddr length to socket functions depending on
+ the address family, instead of always passing the size of struct
+ sockaddr_storage. Thanks to Mats Erik Andersson and Simon Josefsson.
-- Guillem Jover <guillem@debian.org> Thu, 18 Nov 2010 04:01:33 +0100
diff --git a/debian/patches/63_inetd_ipv6_sockaddrlen.patch b/debian/patches/63_inetd_ipv6_sockaddrlen.patch
new file mode 100644
index 0000000..5dff7fb
--- /dev/null
+++ b/debian/patches/63_inetd_ipv6_sockaddrlen.patch
@@ -0,0 +1,49 @@
+From 71a5c6478ea29872b95db9c3c8d1595b0920ff27 Mon Sep 17 00:00:00 2001
+From: Mats Erik Andersson <gnu@gisladisker.se>
+Date: Sun, 31 Oct 2010 04:29:21 +0100
+Subject: [PATCH 2/2] src/inetd.c: Use exact length of address structure.
+
+Bind socket using knowledge of exact sockaddr length.
+
+* src/inetd.c: New element `se_addrlen' in `struct servtab'.
+(expand_enter): Record in SE_ADDRLEN the actual length of each
+established control address.
+(setup): Use the exact address length in call to bind(3).
+---
+ src/inetd.c | 5 ++++-
+ 2 files changed, 13 insertions(+), 1 deletions(-)
+
+diff --git a/src/inetd.c b/src/inetd.c
+index 272e874..2a30acf 100644
+--- a/src/inetd.c
++++ b/src/inetd.c
+@@ -254,6 +254,7 @@ struct servtab
+ sa_family_t se_family; /* address family of the socket */
+ char se_v4mapped; /* 1 = accept v4mapped connection, 0 = don't */
+ struct sockaddr_storage se_ctrladdr; /* bound address */
++ socklen_t se_addrlen; /* exact address length in use */
+ unsigned se_refcnt;
+ int se_count; /* number started since se_time */
+ struct timeval se_time; /* start of se_count */
+@@ -585,7 +586,7 @@ setup (struct servtab *sep)
+ syslog (LOG_ERR, "setsockopt (SO_REUSEADDR): %m");
+
+ err = bind (sep->se_fd, (struct sockaddr *) &sep->se_ctrladdr,
+- sizeof (sep->se_ctrladdr));
++ sep->se_addrlen);
+ if (err < 0)
+ {
+ /* If we can't bind with AF_INET6 try again with AF_INET. */
+@@ -800,7 +801,9 @@ expand_enter (struct servtab *sep)
+
+ for (rp = result; rp != NULL; rp = rp->ai_next)
+ {
++ memset (&sep->se_ctrladdr, 0, sizeof (sep->se_ctrladdr));
+ memcpy (&sep->se_ctrladdr, rp->ai_addr, rp->ai_addrlen);
++ sep->se_addrlen = rp->ai_addrlen;
+ cp = enter (sep);
+ servent_setup (cp);
+ }
+--
+1.7.1
+
diff --git a/debian/patches/64_telnetd_ipv6_sockaddrlen.patch b/debian/patches/64_telnetd_ipv6_sockaddrlen.patch
new file mode 100644
index 0000000..aa17701
--- /dev/null
+++ b/debian/patches/64_telnetd_ipv6_sockaddrlen.patch
@@ -0,0 +1,30 @@
+commit c4956d533efbc0972bf97ed66e1b867e92b4d56f
+Author: Mats Erik Andersson <gnu@gisladisker.se>
+Date: Tue Oct 26 22:48:15 2010 +0200
+
+ telnetd/telnetd.c: Reuse address length. Needed for OpenBSD.
+
+ Signed-off-by: Simon Josefsson <simon@josefsson.org>
+
+diff --git a/telnetd/telnetd.c b/telnetd/telnetd.c
+index b72cd73..b155087 100644
+--- a/telnetd/telnetd.c
++++ b/telnetd/telnetd.c
+@@ -300,7 +300,7 @@ telnetd_setup (int fd)
+ }
+
+ #ifdef IPV6
+- err = getnameinfo ((struct sockaddr *) &saddr, sizeof (saddr), buf,
++ err = getnameinfo ((struct sockaddr *) &saddr, len, buf,
+ sizeof (buf), NULL, 0, NI_NUMERICHOST);
+ if (err)
+ {
+@@ -317,7 +317,7 @@ telnetd_setup (int fd)
+
+ /* We use a second buffer so we don't have to call getnameinfo again
+ if we need the numeric host below. */
+- err = getnameinfo ((struct sockaddr *) &saddr, sizeof (saddr), buf2,
++ err = getnameinfo ((struct sockaddr *) &saddr, len, buf2,
+ sizeof (buf2), NULL, 0, NI_NAMEREQD);
+
+ if (reverse_lookup)
diff --git a/debian/patches/series b/debian/patches/series
index 1e66f36..13d1e05 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,4 +10,6 @@
60_inetd_support_argless_services.patch
61_inetd_listen_on_tcpmux_ports.patch
62_inetd_change_ipv6_protocol_semantics.patch
+63_inetd_ipv6_sockaddrlen.patch
+64_telnetd_ipv6_sockaddrlen.patch
70_ftbfs_non-linux.patch