summaryrefslogtreecommitdiff
path: root/sys-auth/nss-mdns
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-auth/nss-mdns
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-auth/nss-mdns')
-rw-r--r--sys-auth/nss-mdns/Manifest9
-rw-r--r--sys-auth/nss-mdns/files/mdns.allow3
-rw-r--r--sys-auth/nss-mdns/files/nss-mdns-0.10-avahi-socket.patch14
-rw-r--r--sys-auth/nss-mdns/files/nss-mdns-0.10-ipv6.patch528
-rw-r--r--sys-auth/nss-mdns/metadata.xml24
-rw-r--r--sys-auth/nss-mdns/nss-mdns-0.10-r3.ebuild62
-rw-r--r--sys-auth/nss-mdns/nss-mdns-9999.ebuild58
7 files changed, 698 insertions, 0 deletions
diff --git a/sys-auth/nss-mdns/Manifest b/sys-auth/nss-mdns/Manifest
new file mode 100644
index 000000000000..4a0c0bc98f66
--- /dev/null
+++ b/sys-auth/nss-mdns/Manifest
@@ -0,0 +1,9 @@
+AUX mdns.allow 29 SHA256 9fde506c70de0983039fc17b705fd40a2e43fbb8d426a74f662a09136458bc40 SHA512 a89d2f8288acd653192ac463f784cdd8a8e8e014094e997d99c4ad5c6522cd3cf1f161714d15b28d9db2cfba60b55302f20a0e810bcf5c9ba633a5ee42dc3f50 WHIRLPOOL 2ab9ded2d87fd20bb3fca341331ab0c0bc6546748924242c4ff3e9d2d8224a47b0130f5888048fe83eab178a22e44b966293d50b4353d4404e544abfc6f518a9
+AUX nss-mdns-0.10-avahi-socket.patch 394 SHA256 2fa66e3e110dcbf2b99ae08416850c086325b69a45e985d3d472bcd72ba892d6 SHA512 79bfccaab009a3affc44ea5d02b572adbe3637aca27064e6cc5d347a74d36c0244b31f7d95b68f9771af02dc1baa788d041ecbaf5d3632dd3507b52f1559f661 WHIRLPOOL cae18aa8c05bab993c424ebb2ac39b251f6ddef4a6ff2535e082623d04edfe7511f47a3b0e683cad11226b80957f3841ddc229188664ed8f98668ffaf3265000
+AUX nss-mdns-0.10-ipv6.patch 15651 SHA256 d3a7745cf7cf2d357d2f41a93165296b09be94805899258be679b555594c6b92 SHA512 8021b5dbb7e484fc29041e54d88a01346ee1dac7840b1bc13caacb4460e7b6baa99d079f34e0b28e9d665e821ccddccc83580f315454c63bf7ba1b2f6ab4c230 WHIRLPOOL ea64de447f2986c59032aeaa8dfb8156a296bfddfc17bdc0140d76beed634d4b6b4d3eebc79d9ba36aeb10cd0b26cc898f1eb55d81c68afaf574d386e37e0fdc
+DIST nss-mdns-0.10.tar.gz 353130 SHA256 1e683c2e7c3921814706d62fbbd3e9cbf493a75fa00255e0e715508d8134fa6d SHA512 7c9f4150648dfab34bc6f8551e5b58b0b7065e4c1472efb8ce1b00b2bd75627e5928b2c199d9dae742abe839968a8774e39c7646f8ce855d342b4d90252efc0e WHIRLPOOL 27298dd51e307d0c3798096b1e8ccfc7b0f454ebca15e1abea1502326f17e8850af789cb8fa926be4d4918cc81819487603e3f8eb3ad76605325da97be23db66
+EBUILD nss-mdns-0.10-r3.ebuild 1840 SHA256 349483a567e6fb3b413f8b132f5c1ae16317eaf3d3fb166d167ac62dcef9740e SHA512 50265452786edd3ac7b554904a57fdf38b9a121641363bc14587633efada2017d7b36c7f131740ce69e2a5389fc4be2d4a6b5c52bb6193dd0320891748f3ce5a WHIRLPOOL 58af0569d4c45e2fa1fabbc112d0710d759caa0aa0b7cd190ce3fced2a268d02d5301e63793363257c39379395fc659086b3fcae3564ab4c7570ed317f169ede
+EBUILD nss-mdns-9999.ebuild 1596 SHA256 07c9a5f71a179ea5dae7e39edc8474aa2448b07f5bf7f228009650ada7689f97 SHA512 bdb772d5fcb650405dff7baa52049d1cc1943489b65ba0f786c8fb6ab22ea3ab14425a259e04515879b354db918efbc14cb32dbd22d9d628d18eb2fa7a7a1c21 WHIRLPOOL 8e67abd65301c8637371d1032e40c9e13e7bd065cd7131089c097eb8cecabe848643e2f677f86217c498472bd2aa4ed91af78cc8c2ba9412551d5df6e14b2d9e
+MISC ChangeLog 3349 SHA256 8cdd36fa8e0b20657bb96ebc97b934bb6f5d112c8b7d65a3ec9b92ca6fcea67c SHA512 36ec5420116e2046c52894aa2b44e4a1cb897cc548535bbe75d9947ff1ffe40ebf303435825987f46b668205cde640165e6700316267dfa8c8dc20bdc2af8b4f WHIRLPOOL d2ce84b9fa5d160c23ee19906cec1b0f9d10a5c697e42575430d91a300b0f5ac55dd31749046a960204cbc93f611a20e635b59ea5eb46e0f254ad4dbebdb59a2
+MISC ChangeLog-2015 5873 SHA256 2d3335e0a5495f28c0e09c375de68f403b33d3b2b61d1b290be6ac6d27d2f753 SHA512 e9768343daf3139f0e177c26698065051ab43b6143f0e9b750bfc0301fc089dfb25e93a3d7abe62e5df521b91c62dd169f81b050838f077c08c200cb4ffaf274 WHIRLPOOL 8c6a6df56c079ef52792bbcf91f36b319d3b17737cd85753efa5db79263bc52523142afea8d0c607995b3c2f0f5171c9bc809cacf813f37e622003464bda6172
+MISC metadata.xml 795 SHA256 87db4ce4778525f76fbd326e52c5f1a7f6b4542dfb40463b839e17247e8ba73a SHA512 912e8a154a0672a58bd89ee1f52efd8d43cfbeff1f1c40def47d6bd7600fb9b74e1b11dd633ea1ad6f75ef9ae9979ac5b741cfd5df97ea6b0055b060df33c977 WHIRLPOOL 686871660b786586ef5aaea8661cc8a08e909121ef4f39dd825c7436acd71659a3c73a6154307ddbe9561ea56eff5782b8ef3203b905add361a7418fd5536d24
diff --git a/sys-auth/nss-mdns/files/mdns.allow b/sys-auth/nss-mdns/files/mdns.allow
new file mode 100644
index 000000000000..80b49b097b03
--- /dev/null
+++ b/sys-auth/nss-mdns/files/mdns.allow
@@ -0,0 +1,3 @@
+# mdns.allow:
+.local.
+.local
diff --git a/sys-auth/nss-mdns/files/nss-mdns-0.10-avahi-socket.patch b/sys-auth/nss-mdns/files/nss-mdns-0.10-avahi-socket.patch
new file mode 100644
index 000000000000..9ada93d2b8fb
--- /dev/null
+++ b/sys-auth/nss-mdns/files/nss-mdns-0.10-avahi-socket.patch
@@ -0,0 +1,14 @@
+https://bugs.gentoo.org/159341
+
+fix the full path to the socket run dir
+
+--- src/Makefile.am
++++ src/Makefile.am
+@@ -20,7 +20,7 @@
+ AM_CFLAGS = \
+ -DMDNS_ALLOW_FILE=\"$(sysconfdir)/mdns.allow\" \
+ -DRESOLV_CONF_FILE=\"$(sysconfdir)/resolv.conf\" \
+- -DAVAHI_SOCKET=\"$(localstatedir)/run/avahi-daemon/socket\"
++ -DAVAHI_SOCKET=\"/var/run/avahi-daemon/socket\"
+
+ #AM_CFLAGS += -DNDEBUG=1 -Os
diff --git a/sys-auth/nss-mdns/files/nss-mdns-0.10-ipv6.patch b/sys-auth/nss-mdns/files/nss-mdns-0.10-ipv6.patch
new file mode 100644
index 000000000000..6d6dbc9eab58
--- /dev/null
+++ b/sys-auth/nss-mdns/files/nss-mdns-0.10-ipv6.patch
@@ -0,0 +1,528 @@
+diff -u src/avahi.c src/avahi.c
+--- src/avahi.c 2006-04-29 05:14:09.000000000 +0800
++++ src/avahi.c 2013-01-04 10:00:05.025558790 +0800
+@@ -26,6 +26,7 @@
+ #include <sys/socket.h>
+ #include <string.h>
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <sys/types.h>
+ #include <arpa/inet.h>
+ #include <sys/un.h>
+@@ -34,6 +35,7 @@
+
+ #include "avahi.h"
+ #include "util.h"
++#include "query.h"
+
+ #define WHITESPACE " \t"
+
+@@ -93,7 +95,8 @@
+ p = ln+1;
+ p += strspn(p, WHITESPACE);
+
+- /* Skip interface */
++ /* Parse interface */
++ if (af == AF_INET6) ((ipv6_address_t*)data)->if_idx = strtoul(p, 0, 10);
+ p += strcspn(p, WHITESPACE);
+ p += strspn(p, WHITESPACE);
+
+diff -u src/avahi-test.c src/avahi-test.c
+--- src/avahi-test.c 2007-02-09 00:42:23.000000000 +0800
++++ src/avahi-test.c 2013-01-04 09:59:06.174017729 +0800
+@@ -24,6 +24,7 @@
+ #include <stdio.h>
+
+ #include "avahi.h"
++#include "query.h"
+
+ int main(int argc, char *argv[]) {
+ uint8_t data[64];
+@@ -35,15 +36,20 @@
+ else
+ printf("AF_INET: failed (%i).\n", r);
+
+-/* if ((r = avahi_resolve_name(AF_INET6, argc >= 2 ? argv[1] : "cocaine.local", data)) == 0) */
+-/* printf("AF_INET6: %s\n", inet_ntop(AF_INET6, data, t, sizeof(t))); */
+-/* else */
+-/* printf("AF_INET6: failed (%i).\n", r); */
+-
+ if ((r = avahi_resolve_address(AF_INET, data, t, sizeof(t))) == 0)
+ printf("REVERSE: %s\n", t);
+ else
+ printf("REVERSE: failed (%i).\n", r);
++
++ if ((r = avahi_resolve_name(AF_INET6, argc >= 2 ? argv[1] : "cocaine.local", data)) == 0)
++ printf("AF_INET6: %s, %u\n", inet_ntop(AF_INET6, data, t, sizeof(t)), ((ipv6_address_t*)data)->if_idx);
++ else
++ printf("AF_INET6: failed (%i).\n", r);
++
++ if ((r = avahi_resolve_address(AF_INET6, data, t, sizeof(t))) == 0)
++ printf("REVERSE: %s\n", t);
++ else
++ printf("REVERSE: failed (%i).\n", r);
+
+ return 0;
+ }
+diff -u src/bsdnss.c src/bsdnss.c
+--- src/bsdnss.c 2007-02-09 00:42:23.000000000 +0800
++++ src/bsdnss.c 2013-01-04 09:49:45.566389491 +0800
+@@ -258,6 +258,8 @@
+ ai->ai_addrlen = sizeof(struct sockaddr_in6);
+ memcpy(&((struct sockaddr_in6 *)psa)->sin6_addr, hap,
+ ai->ai_addrlen);
++ if (((struct sockaddr_in6 *)psa)->sin6_addr[0] == 0xfe && ((struct sockaddr_in6 *)psa)->sin6_addr[0] == 0x80)
++ ((struct sockaddr_in6 *)psa)->sin6_scope_id = ((struct ipv6_address_t*) hap)->if_idx;
+ break;
+ default:
+ ai->ai_addrlen = sizeof(struct sockaddr_storage);
+diff -u src/map-file src/map-file
+--- src/map-file 2007-01-02 02:36:21.000000000 +0800
++++ src/map-file 2013-01-07 08:56:56.406478774 +0800
+@@ -18,6 +18,12 @@
+ _nss_mdns_minimal_gethostbyname2_r;
+ _nss_mdns4_minimal_gethostbyname2_r;
+ _nss_mdns6_minimal_gethostbyname2_r;
++_nss_mdns_gethostbyname4_r;
++_nss_mdns4_gethostbyname4_r;
++_nss_mdns6_gethostbyname4_r;
++_nss_mdns_minimal_gethostbyname4_r;
++_nss_mdns4_minimal_gethostbyname4_r;
++_nss_mdns6_minimal_gethostbyname4_r;
+ local:
+ *;
+ };
+diff -u src/nss.c src/nss.c
+--- src/nss.c 2013-01-07 15:14:23.000000000 +0800
++++ src/nss.c 2013-01-07 16:52:38.399842517 +0800
+@@ -41,22 +41,27 @@
+
+ #if defined(NSS_IPV4_ONLY) && ! defined(MDNS_MINIMAL)
+ #define _nss_mdns_gethostbyname2_r _nss_mdns4_gethostbyname2_r
++#define _nss_mdns_gethostbyname4_r _nss_mdns4_gethostbyname4_r
+ #define _nss_mdns_gethostbyname_r _nss_mdns4_gethostbyname_r
+ #define _nss_mdns_gethostbyaddr_r _nss_mdns4_gethostbyaddr_r
+ #elif defined(NSS_IPV4_ONLY) && defined(MDNS_MINIMAL)
+ #define _nss_mdns_gethostbyname2_r _nss_mdns4_minimal_gethostbyname2_r
++#define _nss_mdns_gethostbyname4_r _nss_mdns4_minimal_gethostbyname4_r
+ #define _nss_mdns_gethostbyname_r _nss_mdns4_minimal_gethostbyname_r
+ #define _nss_mdns_gethostbyaddr_r _nss_mdns4_minimal_gethostbyaddr_r
+ #elif defined(NSS_IPV6_ONLY) && ! defined(MDNS_MINIMAL)
+ #define _nss_mdns_gethostbyname2_r _nss_mdns6_gethostbyname2_r
++#define _nss_mdns_gethostbyname4_r _nss_mdns6_gethostbyname4_r
+ #define _nss_mdns_gethostbyname_r _nss_mdns6_gethostbyname_r
+ #define _nss_mdns_gethostbyaddr_r _nss_mdns6_gethostbyaddr_r
+ #elif defined(NSS_IPV6_ONLY) && defined(MDNS_MINIMAL)
+ #define _nss_mdns_gethostbyname2_r _nss_mdns6_minimal_gethostbyname2_r
++#define _nss_mdns_gethostbyname4_r _nss_mdns6_minimal_gethostbyname4_r
+ #define _nss_mdns_gethostbyname_r _nss_mdns6_minimal_gethostbyname_r
+ #define _nss_mdns_gethostbyaddr_r _nss_mdns6_minimal_gethostbyaddr_r
+ #elif defined(MDNS_MINIMAL)
+ #define _nss_mdns_gethostbyname2_r _nss_mdns_minimal_gethostbyname2_r
++#define _nss_mdns_gethostbyname4_r _nss_mdns_minimal_gethostbyname4_r
+ #define _nss_mdns_gethostbyname_r _nss_mdns_minimal_gethostbyname_r
+ #define _nss_mdns_gethostbyaddr_r _nss_mdns_minimal_gethostbyaddr_r
+ #endif
+@@ -81,6 +86,12 @@
+ char *name[MAX_ENTRIES];
+ } data;
+ };
++struct user_gai_buf {
++ struct gaih_addrtuple *list_base;
++ int list_size;
++ int list_idx;
++ int wrote_name;
++};
+
+ #ifndef NSS_IPV6_ONLY
+ static void ipv4_callback(const ipv4_address_t *ipv4, void *userdata) {
+@@ -93,6 +104,21 @@
+ u->data.ipv4[u->count++] = *ipv4;
+ u->data_len += sizeof(ipv4_address_t);
+ }
++static void ipv4_gai_callback(const ipv4_address_t *ipv4, void *userdata) {
++ struct user_gai_buf *u = userdata;
++ assert(ipv4 && userdata);
++
++ if (u->list_idx+1 >= u->list_size)
++ return;
++
++ u->list_base[u->list_idx].name = 0;
++ u->list_base[u->list_idx].family = AF_INET;
++ u->list_base[u->list_idx].addr[0] = ipv4->address;
++ u->list_base[u->list_idx].scopeid = 0;
++ if (u->list_idx > 0) u->list_base[u->list_idx-1].next = &u->list_base[u->list_idx];
++ u->list_base[u->list_idx].next = 0;
++ u->list_idx += 1;
++}
+ #endif
+
+ #ifndef NSS_IPV4_ONLY
+@@ -106,6 +132,21 @@
+ u->data.ipv6[u->count++] = *ipv6;
+ u->data_len += sizeof(ipv6_address_t);
+ }
++static void ipv6_gai_callback(const ipv6_address_t *ipv6, void *userdata) {
++ struct user_gai_buf *u = userdata;
++ assert(ipv6 && userdata);
++
++ if (u->list_idx+1 >= u->list_size)
++ return;
++
++ u->list_base[u->list_idx].name = 0;
++ u->list_base[u->list_idx].family = AF_INET6;
++ memcpy(u->list_base[u->list_idx].addr, ipv6->address, sizeof(u->list_base[u->list_idx].addr));
++ u->list_base[u->list_idx].scopeid = ipv6->if_idx;
++ if (u->list_idx > 0) u->list_base[u->list_idx-1].next = &u->list_base[u->list_idx];
++ u->list_base[u->list_idx].next = 0;
++ u->list_idx += 1;
++}
+ #endif
+
+ static void name_callback(const char*name, void *userdata) {
+@@ -538,6 +579,265 @@
+
+ status = NSS_STATUS_SUCCESS;
+
++finish:
++#ifdef ENABLE_LEGACY
++ if (fd >= 0)
++ close(fd);
++#endif
++
++ return status;
++}
++
++enum nss_status _nss_mdns_gethostbyname4_r(
++ const char *name,
++ struct gaih_addrtuple **pat,
++ char *buffer,
++ size_t buflen,
++ int *errnop,
++ int *h_errnop,
++ int32_t *ttlp) {
++
++ struct user_gai_buf u;
++ enum nss_status status = NSS_STATUS_UNAVAIL;
++ int i;
++ size_t l, idx;
++ void (*ipv4_func)(const ipv4_address_t *ipv4, void *userdata);
++ void (*ipv6_func)(const ipv6_address_t *ipv6, void *userdata);
++ int name_allowed;
++ int af = AF_UNSPEC;
++
++#ifdef ENABLE_AVAHI
++ int avahi_works = 1;
++ void * data[32];
++#endif
++
++#ifdef ENABLE_LEGACY
++ int fd = -1;
++#endif
++
++ if (pat) {
++ af = (*pat)->family;
++ }
++
++/* DEBUG_TRAP; */
++
++#ifdef NSS_IPV6_ONLY
++ if (af == AF_UNSPEC)
++ af = AF_INET6;
++#endif
++
++#ifdef NSS_IPV4_ONLY
++ if (af == AF_UNSPEC)
++ af = AF_INET;
++#endif
++
++#ifdef NSS_IPV4_ONLY
++ if (af != AF_INET)
++#elif NSS_IPV6_ONLY
++ if (af != AF_INET6)
++#else
++ if (af != AF_INET && af != AF_INET6 && af != AF_UNSPEC)
++#endif
++ {
++ *errnop = EINVAL;
++ *h_errnop = NO_RECOVERY;
++
++ goto finish;
++ }
++
++ if (buflen <
++ sizeof(struct gaih_addrtuple)) {
++
++ *errnop = ERANGE;
++ *h_errnop = NO_RECOVERY;
++ status = NSS_STATUS_TRYAGAIN;
++
++ goto finish;
++ }
++
++ u.list_base = (struct user_gai_buf*) buffer;
++ u.list_size = buflen / sizeof( struct user_gai_buf );
++ u.list_idx = 0;
++ u.wrote_name = 0;
++
++#ifdef NSS_IPV6_ONLY
++ ipv4_func = NULL;
++#else
++ ipv4_func = (af == AF_INET || af == AF_UNSPEC) ? ipv4_gai_callback : NULL;
++#endif
++
++#ifdef NSS_IPV4_ONLY
++ ipv6_func = NULL;
++#else
++ ipv6_func = (af == AF_INET6 || af == AF_UNSPEC) ? ipv6_gai_callback : NULL;
++#endif
++
++ name_allowed = verify_name_allowed(name);
++
++#ifdef ENABLE_AVAHI
++
++ if (avahi_works && name_allowed) {
++ int r;
++
++ if (af == AF_INET || af == AF_UNSPEC) {
++ if ((r = avahi_resolve_name(AF_INET, name, data)) < 0)
++ avahi_works = 0;
++ else if (r == 0) {
++ if (ipv4_func) {
++ ipv4_func((ipv4_address_t*) data, &u);
++ }
++ }
++ else
++ status = NSS_STATUS_NOTFOUND;
++ }
++ if (af == AF_INET6 || af == AF_UNSPEC) {
++ if ((r = avahi_resolve_name(AF_INET6, name, data)) < 0)
++ avahi_works = 0;
++ else if (r == 0) {
++ if (ipv6_func)
++ ipv6_func((ipv6_address_t*)data, &u);
++ }
++ else
++ status = NSS_STATUS_NOTFOUND;
++ }
++ }
++
++#ifdef HONOUR_SEARCH_DOMAINS
++ if (u.list_idx == 0 && avahi_works && !ends_with(name, ".")) {
++ char **domains;
++
++ if ((domains = get_search_domains())) {
++ char **p;
++
++ /* Try to concatenate host names */
++ for (p = domains; *p; p++) {
++ int fullnamesize;
++ char *fullname;
++
++ fullnamesize = strlen(name) + strlen(*p) + 2;
++
++ if (!(fullname = malloc(fullnamesize)))
++ break;
++
++ snprintf(fullname, fullnamesize, "%s.%s", name, *p);
++
++ if (verify_name_allowed(fullname)) {
++ int r;
++
++ if (af == AF_INET || af == AF_UNSPEC) {
++ r = avahi_resolve_name(AF_INET, fullname, data);
++
++ if (r < 0) {
++ /* Lookup failed */
++ avahi_works = 0;
++ free(fullname);
++ break;
++ } else if (r == 0) {
++ /* Lookup succeeded */
++ if (ipv4_func)
++ ipv4_func((ipv4_address_t*) data, &u);
++ }
++ }
++ if (af == AF_INET6 || af == AF_UNSPEC) {
++ r = avahi_resolve_name(AF_INET6, fullname, data);
++
++ if (r < 0) {
++ /* Lookup failed */
++ avahi_works = 0;
++ free(fullname);
++ break;
++ } else if (r == 0) {
++ /* Lookup succeeded */
++ if (ipv6_func)
++ ipv6_func((ipv6_address_t*)data, &u);
++ }
++ }
++ free(fullname);
++ if (u.list_idx > 0) break;
++
++ } else
++ free(fullname);
++ }
++
++ free_domains(domains);
++ }
++ }
++#endif /* HONOUR_SEARCH_DOMAINS */
++#endif /* ENABLE_AVAHI */
++
++#if defined(ENABLE_LEGACY) && defined(ENABLE_AVAHI)
++ if (u.list_idx == 0 && !avahi_works)
++#endif
++
++#if defined(ENABLE_LEGACY)
++ {
++ if ((fd = mdns_open_socket()) < 0) {
++ *errnop = errno;
++ *h_errnop = NO_RECOVERY;
++ goto finish;
++ }
++
++ if (name_allowed) {
++ /* Ignore return value */
++ mdns_query_name(fd, name, ipv4_func, ipv6_func, &u);
++
++ if (!u.list_idx)
++ status = NSS_STATUS_NOTFOUND;
++ }
++
++#ifdef HONOUR_SEARCH_DOMAINS
++ if (u.list_idx == 0 && !ends_with(name, ".")) {
++ char **domains;
++
++ /* Try the search domains if the user did not use a traling '.' */
++
++ if ((domains = get_search_domains())) {
++ char **p;
++
++ for (p = domains; *p; p++) {
++ int fullnamesize = 0;
++ char *fullname = NULL;
++
++ fullnamesize = strlen(name) + strlen(*p) + 2;
++ if (!(fullname = malloc(fullnamesize)))
++ break;
++
++ snprintf(fullname, fullnamesize, "%s.%s", name, *p);
++
++ if (verify_name_allowed(fullname)) {
++
++ /* Ignore return value */
++ mdns_query_name(fd, fullname, ipv4_func, ipv6_func, &u);
++
++ if (u.list_idx > 0) {
++ /* We found something, so let's quit */
++ free(fullname);
++ break;
++ } else
++ status = NSS_STATUS_NOTFOUND;
++
++ }
++
++ free(fullname);
++ }
++
++ free_domains(domains);
++ }
++ }
++#endif /* HONOUR_SEARCH_DOMAINS */
++ }
++#endif /* ENABLE_LEGACY */
++
++ if (u.list_idx == 0) {
++ *errnop = ETIMEDOUT;
++ *h_errnop = HOST_NOT_FOUND;
++ goto finish;
++ }
++
++ *pat = (struct gaih_addrtuple*) buffer;
++
++ status = NSS_STATUS_SUCCESS;
++
+ finish:
+ #ifdef ENABLE_LEGACY
+ if (fd >= 0)
+diff -u src/query.c src/query.c
+--- src/query.c 2007-02-09 00:42:23.000000000 +0800
++++ src/query.c 2013-01-04 09:57:03.778972196 +0800
+@@ -263,7 +263,7 @@
+ return n_sent;
+ }
+
+-static int recv_dns_packet(int fd, struct dns_packet **ret_packet, uint8_t *ret_ttl, struct timeval *end) {
++static int recv_dns_packet(int fd, struct dns_packet **ret_packet, uint8_t *ret_ttl, uint32_t *if_idx, struct timeval *end) {
+ struct dns_packet *p= NULL;
+ struct msghdr msg;
+ struct iovec io;
+@@ -286,6 +286,10 @@
+ msg.msg_controllen = sizeof(aux);
+ msg.msg_flags = 0;
+
++#ifndef IP_PKTINFO
++ *if_idx = 0;
++#endif
++
+ for (;;) {
+ ssize_t l;
+ int r;
+@@ -304,6 +308,14 @@
+ *ret_ttl = (uint8_t) (*(uint32_t*) CMSG_DATA(cmsg));
+ break;
+ }
++#ifdef IP_PKTINFO
++ if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO)
++ {
++ *if_idx = ((struct in_pktinfo*) CMSG_DATA(cmsg))->ipi_ifindex;
++ break;
++ }
++#endif
++
+ }
+
+ if (!cmsg)
+@@ -427,9 +439,10 @@
+
+ while (!done) {
+ uint8_t ttl;
++ uint32_t if_idx;
+ int r;
+
+- if ((r = recv_dns_packet(fd, &p, &ttl, &end)) < 0)
++ if ((r = recv_dns_packet(fd, &p, &ttl, &if_idx, &end)) < 0)
+ return -1;
+ else if (r > 0) /* timeout */
+ return 1;
+@@ -488,6 +501,7 @@
+ rdlength == sizeof(ipv6_address_t)) {
+
+ ipv6_address_t ipv6;
++ ipv6.if_idx = if_idx;
+
+ if (dns_packet_consume_bytes(p, &ipv6, sizeof(ipv6_address_t)) < 0)
+ break;
+@@ -584,9 +598,10 @@
+
+ while (!done) {
+ uint8_t ttl;
++ uint32_t if_idx;
+ int r;
+
+- if ((r = recv_dns_packet(fd, &p, &ttl, &end)) < 0)
++ if ((r = recv_dns_packet(fd, &p, &ttl, &if_idx, &end)) < 0)
+ return -1;
+ else if (r > 0) /* timeout */
+ return 1;
+diff -u src/query.h src/query.h
+--- src/query.h 2005-06-21 22:43:23.000000000 +0800
++++ src/query.h 2013-01-03 14:09:22.138018327 +0800
+@@ -30,6 +30,7 @@
+
+ typedef struct {
+ uint8_t address[16];
++ uint32_t if_idx;
+ } ipv6_address_t;
+
diff --git a/sys-auth/nss-mdns/metadata.xml b/sys-auth/nss-mdns/metadata.xml
new file mode 100644
index 000000000000..a409ede683e9
--- /dev/null
+++ b/sys-auth/nss-mdns/metadata.xml
@@ -0,0 +1,24 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>amynka@gentoo.org</email>
+ </maintainer>
+ <maintainer type="person">
+ <email>mgorny@gentoo.org</email>
+ <name>Michał Górny</name>
+ </maintainer>
+ <use>
+ <flag name="search-domains">Honour search domains from
+ /etc/resolv.conf (see bug #201948 for possible side effects)</flag>
+ </use>
+ <longdescription lang="en">
+ Name service switch module for multicast dns.
+ </longdescription>
+ <longdescription lang="ja">
+ マルチキャスト DNS 向けネーム・サービス・スイッチのモジュールです。
+ </longdescription>
+ <upstream>
+ <remote-id type="github">lathiat/nss-mdns</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/sys-auth/nss-mdns/nss-mdns-0.10-r3.ebuild b/sys-auth/nss-mdns/nss-mdns-0.10-r3.ebuild
new file mode 100644
index 000000000000..8183106781f9
--- /dev/null
+++ b/sys-auth/nss-mdns/nss-mdns-0.10-r3.ebuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+inherit autotools eutils multilib-minimal
+
+DESCRIPTION="Name Service Switch module for Multicast DNS"
+HOMEPAGE="http://0pointer.de/lennart/projects/nss-mdns/"
+SRC_URI="http://0pointer.de/lennart/projects/nss-mdns/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 ~arm ~hppa ~mips ppc x86"
+IUSE="search-domains"
+
+RDEPEND=">=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}]"
+DEPEND="${RDEPEND}"
+RDEPEND="${RDEPEND}
+ abi_x86_32? (
+ !<=app-emulation/emul-linux-x86-baselibs-20140508-r7
+ !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
+ )"
+
+src_prepare() {
+ epatch "${FILESDIR}"/${PN}-0.10-avahi-socket.patch \
+ "${FILESDIR}"/${PN}-0.10-ipv6.patch
+ epatch_user
+ eautoreconf
+}
+
+multilib_src_configure() {
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable search-domains) \
+ --enable-avahi
+}
+
+multilib_src_install_all() {
+ dodoc README
+
+ insinto /etc
+ doins "${FILESDIR}"/mdns.allow
+}
+
+pkg_postinst() {
+ ewarn
+ ewarn "You must modify your name service switch look up file to enable"
+ ewarn "multicast DNS lookups. If you wish to resolve only IPv6 addresses"
+ ewarn "use mdns6. For IPv4 addresses only, use mdns4. To resolve both"
+ ewarn "use mdns. Keep in mind that mdns will be slower if there are no"
+ ewarn "IPv6 addresses published via mDNS on the network. There are also"
+ ewarn "minimal (mdns?_minimal) libraries which only lookup .local hosts"
+ ewarn "and 169.254.x.x addresses."
+ ewarn
+ ewarn "Add the appropriate mdns into the hosts line in /etc/nsswitch.conf"
+ ewarn "An example line looks like:"
+ ewarn "hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4"
+ ewarn
+ ewarn "If you want to perform mDNS lookups for domains other than the ones"
+ ewarn "ending in .local, add them to /etc/mdns.allow"
+ ewarn
+}
diff --git a/sys-auth/nss-mdns/nss-mdns-9999.ebuild b/sys-auth/nss-mdns/nss-mdns-9999.ebuild
new file mode 100644
index 000000000000..22527697c7c8
--- /dev/null
+++ b/sys-auth/nss-mdns/nss-mdns-9999.ebuild
@@ -0,0 +1,58 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+EGIT_REPO_URI="https://github.com/lathiat/nss-mdns"
+inherit autotools git-r3 multilib-minimal
+
+DESCRIPTION="Name Service Switch module for Multicast DNS"
+HOMEPAGE="https://github.com/lathiat/nss-mdns"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS=""
+IUSE=""
+
+RDEPEND=">=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}]"
+DEPEND="${RDEPEND}"
+
+src_prepare() {
+ default
+ eautoreconf
+}
+
+multilib_src_configure() {
+ local myconf=(
+ # $(localstatedir)/run/... is used to locate avahi-daemon socket
+ --localstatedir=/var
+ )
+
+ ECONF_SOURCE=${S} \
+ econf "${myconf[@]}"
+}
+
+multilib_src_install_all() {
+ dodoc *.md
+
+ insinto /etc
+ doins "${FILESDIR}"/mdns.allow
+}
+
+pkg_postinst() {
+ ewarn "You have to modify your name service switch look up file to enable"
+ ewarn "multicast DNS lookups. If you wish to resolve only IPv6 addresses"
+ ewarn "use mdns6. For IPv4 addresses only, use mdns4. To resolve both"
+ ewarn "use mdns. Keep in mind that mdns will be slower if there are no"
+ ewarn "IPv6 addresses published via mDNS on the network. There are also"
+ ewarn "minimal (mdns?_minimal) libraries which only lookup .local hosts"
+ ewarn "and 169.254.x.x addresses."
+ ewarn
+ ewarn "Add the appropriate mdns into the hosts line in /etc/nsswitch.conf."
+ ewarn "An example line looks like:"
+ ewarn "hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4"
+ ewarn
+ ewarn "If you want to perform mDNS lookups for domains other than the ones"
+ ewarn "ending in .local, add them to /etc/mdns.allow."
+}