This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch master updated. glibc-2.29.9000-55-g0c6d82e
- From: fw at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 12 Feb 2019 13:44:41 -0000
- Subject: GNU C Library master sources branch master updated. glibc-2.29.9000-55-g0c6d82e
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 0c6d82e979d562147c9cfe0e6f65b42a904288bc (commit)
from b3fbfe81961a1d14d7b54d1c9757e1f487073bcb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=0c6d82e979d562147c9cfe0e6f65b42a904288bc
commit 0c6d82e979d562147c9cfe0e6f65b42a904288bc
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue Feb 12 14:26:20 2019 +0100
nss: getent: Print IPv6 scope ID for ahosts/ahostsv6 if available
This information is sometimes useful and actually required for
link-local addresses.
diff --git a/ChangeLog b/ChangeLog
index 46c2198..77b4587 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-02-12 Florian Weimer <fweimer@redhat.com>
+
+ * nss/getent.c (ahosts_keys_int): Include IPv6 scope ID in output.
+
2019-02-12 Adhemerval Zanella <adhemerval.zanella@linaro.org>
[BZ #24122]
diff --git a/nss/getent.c b/nss/getent.c
index f25de8f..07a7d09 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -40,6 +40,7 @@
#include <netinet/in.h>
#include <sys/socket.h>
#include <scratch_buffer.h>
+#include <inttypes.h>
/* Get libc version number. */
#include <version.h>
@@ -393,15 +394,34 @@ ahosts_keys_int (int af, int xflags, int number, char *key[])
sockstr = sockbuf;
}
+ /* Three digits per byte, plus '%' and null terminator. */
+ char scope[3 * sizeof (uint32_t) + 2];
+ struct sockaddr_in6 *addr6
+ = (struct sockaddr_in6 *) runp->ai_addr;
+ if (runp->ai_family != AF_INET6 || addr6->sin6_scope_id == 0)
+ /* No scope ID present. */
+ scope[0] = '\0';
+ else
+ snprintf (scope, sizeof (scope), "%%%" PRIu32,
+ addr6->sin6_scope_id);
+
char buf[INET6_ADDRSTRLEN];
- printf ("%-15s %-6s %s\n",
- inet_ntop (runp->ai_family,
- runp->ai_family == AF_INET
- ? (void *) &((struct sockaddr_in *) runp->ai_addr)->sin_addr
- : (void *) &((struct sockaddr_in6 *) runp->ai_addr)->sin6_addr,
- buf, sizeof (buf)),
- sockstr,
- runp->ai_canonname ?: "");
+ if (inet_ntop (runp->ai_family,
+ runp->ai_family == AF_INET
+ ? (void *) &((struct sockaddr_in *) runp->ai_addr)->sin_addr
+ : &addr6->sin6_addr,
+ buf, sizeof (buf)) == NULL)
+ {
+ strcpy (buf, "<invalid>");
+ scope[0] = '\0';
+ }
+
+ int pad = 15 - strlen (buf) - strlen (scope);
+ if (pad < 0)
+ pad = 0;
+
+ printf ("%s%-*s %-6s %s\n",
+ buf, pad, scope, sockstr, runp->ai_canonname ?: "");
runp = runp->ai_next;
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 4 ++++
nss/getent.c | 36 ++++++++++++++++++++++++++++--------
2 files changed, 32 insertions(+), 8 deletions(-)
hooks/post-receive
--
GNU C Library master sources