[git commit] libbb: make xmalloc_sockaddr2dotted use NI_NUMERICSCOPE

Denys Vlasenko vda.linux at googlemail.com
Mon Sep 26 17:53:04 UTC 2016


commit: https://git.busybox.net/busybox/commit/?id=3c18e3051dfdb5591afc18562e9d9da987a5945e
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Gives "mount -t cifs //fe80::6a05:caff:fe3e:dbf5%eth0/test test"
a chance to work: mount must pass "ip=numeric_IPv6%numeric_iface_id"
in the omunt option string. Currently, it does not.

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 libbb/xconnect.c   | 7 +++++--
 util-linux/mount.c | 6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 6e78e63..3a0dc26 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -496,12 +496,15 @@ char* FAST_FUNC xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa)
 {
 	return sockaddr2str(sa, NI_NAMEREQD | IGNORE_PORT);
 }
+#ifndef NI_NUMERICSCOPE
+# define NI_NUMERICSCOPE 0
+#endif
 char* FAST_FUNC xmalloc_sockaddr2dotted(const struct sockaddr *sa)
 {
-	return sockaddr2str(sa, NI_NUMERICHOST);
+	return sockaddr2str(sa, NI_NUMERICHOST | NI_NUMERICSCOPE);
 }
 
 char* FAST_FUNC xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa)
 {
-	return sockaddr2str(sa, NI_NUMERICHOST | IGNORE_PORT);
+	return sockaddr2str(sa, NI_NUMERICHOST | NI_NUMERICSCOPE | IGNORE_PORT);
 }
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 13590ce..c3e91e2 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -1975,6 +1975,12 @@ static int singlemount(struct mntent *mp, int ignore_busy)
 		dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
 		if (ENABLE_FEATURE_CLEAN_UP) free(lsa);
 		ip = xasprintf("ip=%s", dotted);
+// Note: IPv6 scoped addresses ("name%iface", see RFC 4007) should be
+// handled by libc in getnameinfo() (inside xmalloc_sockaddr2dotted_noport()).
+// Currently, glibc does not support that (has no NI_NUMERICSCOPE),
+// musl apparently does. This results in "ip=numericIPv6%iface_name"
+// (instead of _numeric_ iface_id) with glibc.
+// This probalby should be fixed in glibc, not here.
 		if (ENABLE_FEATURE_CLEAN_UP) free(dotted);
 		parse_mount_options(ip, &filteropts);
 		if (ENABLE_FEATURE_CLEAN_UP) free(ip);


More information about the busybox-cvs mailing list