[Midnightbsd-cvs] mports [15667] trunk/dns: add nsswitch modules for avahi and mDNSResponder.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Dec 14 18:03:56 EST 2013


Revision: 15667
          http://svnweb.midnightbsd.org/mports/?rev=15667
Author:   laffer1
Date:     2013-12-14 18:03:55 -0500 (Sat, 14 Dec 2013)
Log Message:
-----------
add nsswitch modules for avahi and mDNSResponder. We do have one in base that is very similar for the latter but might as well have a up to date port version for older releases

Modified Paths:
--------------
    trunk/dns/Makefile

Added Paths:
-----------
    trunk/dns/mDNSResponder_nss/
    trunk/dns/mDNSResponder_nss/Makefile
    trunk/dns/mDNSResponder_nss/distinfo
    trunk/dns/mDNSResponder_nss/files/
    trunk/dns/mDNSResponder_nss/files/nss_mdns_freebsd.c
    trunk/dns/mDNSResponder_nss/files/patch-mDNSPosix__nss_mdns.c
    trunk/dns/mDNSResponder_nss/pkg-descr
    trunk/dns/mDNSResponder_nss/pkg-plist
    trunk/dns/nss_mdns/
    trunk/dns/nss_mdns/Makefile
    trunk/dns/nss_mdns/distinfo
    trunk/dns/nss_mdns/files/
    trunk/dns/nss_mdns/files/patch-aclocal.m4
    trunk/dns/nss_mdns/files/patch-src__Makefile.am
    trunk/dns/nss_mdns/files/patch-src__bsdnss.c
    trunk/dns/nss_mdns/files/patch-src__nss.c
    trunk/dns/nss_mdns/files/patch-src__nss_gethostname_select.h
    trunk/dns/nss_mdns/pkg-descr

Modified: trunk/dns/Makefile
===================================================================
--- trunk/dns/Makefile	2013-12-09 15:38:09 UTC (rev 15666)
+++ trunk/dns/Makefile	2013-12-14 23:03:55 UTC (rev 15667)
@@ -16,8 +16,10 @@
 SUBDIR += libbind
 SUBDIR += libidn
 SUBDIR += linux-f10-libasyncns
+SUBDIR += mDNSResponder_nss
 SUBDIR += mdnsd
 SUBDIR += nslint
+SUBDIR += nss_mdns
 SUBDIR += p5-Net-DNS
 SUBDIR += p5-Net-DNS-Resolver-Programmable
 SUBDIR += pdnsd

Added: trunk/dns/mDNSResponder_nss/Makefile
===================================================================
--- trunk/dns/mDNSResponder_nss/Makefile	                        (rev 0)
+++ trunk/dns/mDNSResponder_nss/Makefile	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,40 @@
+# $MidnightBSD$
+
+PORTNAME=	mDNSResponder_nss
+PORTVERSION=	541
+CATEGORIES=	dns net
+MASTER_SITES=	http://opensource.apple.com/tarballs/mDNSResponder/
+DISTNAME=	${PORTNAME:S/_nss//}-${PORTVERSION}
+
+MAINTAINER=	mazhe at alkumuna.eu
+COMMENT=	Apple\'s mDNS responder - BSD nsswitch module
+
+LICENSE=    	apache2
+
+LIB_DEPENDS=	dns_sd:${PORTSDIR}/net/mDNSResponder
+
+CONFLICTS_INSTALL= dns/nss_mdns
+
+WRKSRC=		${WRKDIR}/${PORTNAME:S/_nss//}-${PORTVERSION}
+
+post-extract:
+	@${CP} ${FILESDIR}/nss_mdns_freebsd.c ${WRKSRC}/mDNSPosix
+
+do-build:
+	(cd ${WRKSRC}/mDNSPosix && ${CC} ${CFLAGS} -c -std=c99 -Wall -fPIC \
+		-I. -I${PREFIX}/include -DPREFIX=\"${PREFIX}\" \
+		nss_mdns.c nss_mdns_freebsd.c)
+	(cd ${WRKSRC}/mDNSPosix && ${LD} -shared nss_mdns.o nss_mdns_freebsd.o \
+		-o nss_mdns.so.1 -L${PREFIX}/lib -R${PREFIX}/lib -ldns_sd)
+
+do-install:
+	${INSTALL_LIB} ${WRKSRC}/mDNSPosix/nss_mdns.so.1 ${STAGEDIR}${PREFIX}/lib
+	${LN} -sf ${PREFIX}/lib/nss_mdns.so.1 ${STAGEDIR}${PREFIX}/lib/nss_mdns.so
+	${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
+	${INSTALL_DATA} ${WRKSRC}/mDNSPosix/nss_mdns.conf ${STAGEDIR}${EXAMPLESDIR}
+	${INSTALL_MAN} ${WRKSRC}/mDNSPosix/nss_mdns.conf.5 ${STAGEDIR}${MANPREFIX}/man/man5
+
+post-install:
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/nss_mdns.so.1
+
+.include <bsd.port.mk>

Added: trunk/dns/mDNSResponder_nss/distinfo
===================================================================
--- trunk/dns/mDNSResponder_nss/distinfo	                        (rev 0)
+++ trunk/dns/mDNSResponder_nss/distinfo	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,2 @@
+SHA256 (mDNSResponder-541.tar.gz) = b768999280756325b6bacd78acaff00d2bb06136450b727c6b0eb441c1ff2e30
+SIZE (mDNSResponder-541.tar.gz) = 2153009

Added: trunk/dns/mDNSResponder_nss/files/nss_mdns_freebsd.c
===================================================================
--- trunk/dns/mDNSResponder_nss/files/nss_mdns_freebsd.c	                        (rev 0)
+++ trunk/dns/mDNSResponder_nss/files/nss_mdns_freebsd.c	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,156 @@
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <nsswitch.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+
+extern int _nss_mdns_gethostbyname2_r(const char *, int,
+		struct hostent *, char *, size_t, int *, int *);
+extern int _nss_mdns_gethostbyaddr_r(const void *, socklen_t, int,
+		struct hostent *, char *, size_t, int *, int *);
+
+static NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyname2_r);
+static NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyaddr_r);
+static NSS_METHOD_PROTOTYPE(__nss_compat_getaddrinfo);
+
+static ns_mtab methods[] = {
+	{ NSDB_HOSTS, "gethostbyname_r", __nss_compat_gethostbyname2_r, NULL },
+	{ NSDB_HOSTS, "gethostbyname2_r", __nss_compat_gethostbyname2_r, NULL },
+	{ NSDB_HOSTS, "gethostbyaddr_r", __nss_compat_gethostbyaddr_r, NULL },
+	{ NSDB_HOSTS, "getaddrinfo", __nss_compat_getaddrinfo, NULL },
+};
+
+ns_mtab *
+nss_module_register(const char *source, unsigned int *mtabsize,
+		nss_module_unregister_fn *unreg)
+{
+	*mtabsize = sizeof(methods)/sizeof(methods[0]);
+	*unreg = NULL;
+	return methods;
+}
+
+static int
+__nss_compat_gethostbyname2_r(void *retval, void *mdata, va_list ap)
+{
+	int s;
+
+	const char *name;
+	int af;
+	struct hostent *hptr;
+	char *buffer;
+	size_t buflen;
+	int *errnop;
+	int *h_errnop;
+
+	name = va_arg(ap, const char *);
+	af = va_arg(ap, int);
+	hptr = va_arg(ap, struct hostent *);
+	buffer = va_arg(ap, char *);
+	buflen = va_arg(ap, size_t);
+	errnop = va_arg(ap, int *);
+	h_errnop = va_arg(ap, int *);
+
+	s = _nss_mdns_gethostbyname2_r(
+			name, af, hptr, buffer, buflen, errnop, h_errnop);
+	*(struct hostent **)retval = (s == NS_SUCCESS) ? hptr : NULL;
+
+	return s;
+}
+
+static int
+__nss_compat_gethostbyaddr_r(void *retval, void *mdata, va_list ap)
+{
+	int s;
+	
+	const void *addr;
+	socklen_t addrlen;
+	int af;
+	struct hostent *hptr;
+	char *buffer;
+	size_t buflen;
+	int *errnop;
+	int *h_errnop;
+
+    addr = va_arg(ap, const void *);
+    addrlen = va_arg(ap, socklen_t);
+    af = va_arg(ap, int);
+    hptr = va_arg(ap, struct hostent *);
+    buffer = va_arg(ap, char *);
+    buflen = va_arg(ap, size_t);
+    errnop = va_arg(ap, int *);
+    h_errnop = va_arg(ap, int *);
+
+	s = _nss_mdns_gethostbyaddr_r(
+			addr, addrlen, af, hptr, buffer, buflen, errnop, h_errnop);
+	*(struct hostent **)retval = (s == NS_SUCCESS) ? hptr : NULL;
+
+	return s;
+} 
+
+static void
+aiforaf(const char *name, int af, struct addrinfo *pai, struct addrinfo **aip)
+{
+	int s;
+	struct hostent host;
+	char hostbuf[8*1024];
+	int err, herr;
+	char **addrp;
+	char addrstr[INET6_ADDRSTRLEN];
+	struct addrinfo hints, *res0, *res;
+
+	s = _nss_mdns_gethostbyname2_r(name, af, &host, hostbuf, sizeof(hostbuf),
+			&err, &herr);
+	if (s != NS_SUCCESS)
+		return;
+
+	for (addrp = host.h_addr_list; *addrp; addrp++) {
+		/* XXX this sucks, but get_ai is not public */
+		if (!inet_ntop(host.h_addrtype, *addrp,
+			       addrstr, sizeof(addrstr)))
+			continue;
+		hints = *pai;
+		hints.ai_flags = AI_NUMERICHOST;
+		hints.ai_family = af;
+		if (getaddrinfo(addrstr, NULL, &hints, &res0))
+			continue;
+		for (res = res0; res; res = res->ai_next)
+			res->ai_flags = pai->ai_flags;
+
+		(*aip)->ai_next = res0;
+		while ((*aip)->ai_next)
+			*aip = (*aip)->ai_next;
+	}
+}
+
+static int
+__nss_compat_getaddrinfo(void *retval, void *mdata, va_list ap)
+{
+	struct addrinfo sentinel, *cur;
+	const char *name;
+	struct addrinfo *ai;
+
+	name  = va_arg(ap, char *);
+	ai = va_arg(ap, struct addrinfo *);
+
+	memset(&sentinel, 0, sizeof(sentinel));
+	cur = &sentinel;
+
+	if ((ai->ai_family == AF_UNSPEC) || (ai->ai_family == AF_INET6))
+		aiforaf(name, AF_INET6, ai, &cur);
+	if ((ai->ai_family == AF_UNSPEC) || (ai->ai_family == AF_INET))
+		aiforaf(name, AF_INET, ai, &cur);
+
+	if (!sentinel.ai_next) {
+		h_errno = HOST_NOT_FOUND;
+		return NS_NOTFOUND;
+	}
+	*((struct addrinfo **)retval) = sentinel.ai_next;
+
+	return NS_SUCCESS;
+}
+

Added: trunk/dns/mDNSResponder_nss/files/patch-mDNSPosix__nss_mdns.c
===================================================================
--- trunk/dns/mDNSResponder_nss/files/patch-mDNSPosix__nss_mdns.c	                        (rev 0)
+++ trunk/dns/mDNSResponder_nss/files/patch-mDNSPosix__nss_mdns.c	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,31 @@
+--- ./mDNSPosix/nss_mdns.c.orig	2012-04-15 08:07:19.000000000 +0200
++++ ./mDNSPosix/nss_mdns.c	2013-11-05 11:00:14.000000000 +0100
+@@ -379,7 +379,18 @@
+ #define ENTNAME  hostent
+ #define DATABASE "hosts"
+ 
+-#include <nss.h>
++#if defined __FreeBSD__
++# include <nsswitch.h>
++enum nss_status {
++  NSS_STATUS_SUCCESS = NS_SUCCESS,
++  NSS_STATUS_NOTFOUND = NS_NOTFOUND,
++  NSS_STATUS_UNAVAIL = NS_UNAVAIL,
++  NSS_STATUS_TRYAGAIN = NS_TRYAGAIN,
++  NSS_STATUS_RETURN = NS_RETURN
++};
++#elif defined __Linux__
++# include <nss.h>
++#endif
+ // For nss_status
+ #include <netdb.h>
+ // For hostent
+@@ -1684,7 +1695,7 @@
+ //----------
+ // Types and Constants
+ 
+-const char * k_conf_file = "/etc/nss_mdns.conf";
++const char * k_conf_file = PREFIX"/etc/nss_mdns.conf";
+ #define CONF_LINE_SIZE 1024
+ 
+ const char k_comment_char = '#';

Added: trunk/dns/mDNSResponder_nss/pkg-descr
===================================================================
--- trunk/dns/mDNSResponder_nss/pkg-descr	                        (rev 0)
+++ trunk/dns/mDNSResponder_nss/pkg-descr	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,2 @@
+This is a nsswitch plugin from Apple's mDNSResponder code, adapted for FreeBSD's
+nsswitch and libc.

Added: trunk/dns/mDNSResponder_nss/pkg-plist
===================================================================
--- trunk/dns/mDNSResponder_nss/pkg-plist	                        (rev 0)
+++ trunk/dns/mDNSResponder_nss/pkg-plist	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,5 @@
+lib/nss_mdns.so
+lib/nss_mdns.so.1
+man/man5/nss_mdns.conf.5
+%%EXAMPLESDIR%%/nss_mdns.conf
+ at dirrm %%EXAMPLESDIR%%

Added: trunk/dns/nss_mdns/Makefile
===================================================================
--- trunk/dns/nss_mdns/Makefile	                        (rev 0)
+++ trunk/dns/nss_mdns/Makefile	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,69 @@
+# Created by: Bruce M. Simpson <bms at FreeBSD.org>
+# $MidnightBSD$
+
+PORTNAME=	nss_mdns
+PORTVERSION=	0.10
+CATEGORIES=	dns ipv6
+MASTER_SITES=	http://0pointer.de/lennart/projects/nss-mdns/
+DISTNAME=	nss-mdns-${PORTVERSION}
+
+MAINTAINER=	ports at MidnightBSD.org
+COMMENT=	NSS module implementing multicast DNS name resolution
+
+LICENSE=	lgpl2
+
+USE_AUTOTOOLS=	autoconf automake libtool
+USE_GMAKE=	yes
+USE_LDCONFIG=	yes
+AUTOTOOLSFILES=	aclocal.m4
+
+LIB_DEPENDS+=	avahi-client:${PORTSDIR}/net/avahi-app
+
+OPTIONS_DEFINE=	SEARCH_DOMAINS DOCS
+SEARCH_DOMAINS_DESC=	Honour search domains in resolv.conf
+
+CONFIGURE_ARGS+=		\
+	--sysconfdir=/etc	\
+	--localstatedir=/var	\
+	--disable-static	\
+	--enable-shared		\
+	--enable-avahi		\
+	--disable-legacy	\
+	--disable-lynx
+
+INSTALLED_MODULES=nss_mdns nss_mdns_minimal
+
+.include <bsd.mport.options.mk>
+
+.if ${PORT_OPTIONS:MSEARCH_DOMAINS}
+CONFIGURE_ARGS+=	--enable-search-domains
+.endif
+
+#
+# libtool is used, therefore we must perform a GNU make based install,
+# followed by removal of build rubble; we must create our own .so symlinks;
+# we do this from the do-install target so as to avoid causing any
+# problems if we are later packaged.
+#
+do-install:
+	@( cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${INSTALL_TARGET} )
+.for INSTALLED_MODULE in ${INSTALLED_MODULES}
+	( cd ${PREFIX}/lib ; ${LN} -s ${INSTALLED_MODULE}.so.1 ${INSTALLED_MODULE}.so )
+	${RM} ${PREFIX}/lib/${INSTALLED_MODULE}.a ${PREFIX}/lib/${INSTALLED_MODULE}.la
+.endfor
+.if ${PORT_OPTIONS:MDOCS}
+	${MKDIR} ${DOCSDIR}/
+	${INSTALL_DATA} ${INSTALL_WRKSRC}/doc/README ${DOCSDIR}
+	${INSTALL_DATA} ${INSTALL_WRKSRC}/doc/README.html ${DOCSDIR}
+.endif
+
+# TODO: Print a message about the etc directory used for mdns.allow
+# being relative to ${PREFIX}.
+PLIST_FILES=	${INSTALLED_MODULES:C/^/lib\//:C/$/.so/} ${INSTALLED_MODULES:C/^/lib\//:C/$/.so.1/}
+PORTDOCS=	README README.html
+
+post-configure:
+	@${FIND} ${WRKSRC} -name Makefile -print | \
+		${XARGS} ${REINPLACE_CMD} -e 's|MKDIR_P|mkdir_p|g'
+
+.include <bsd.port.mk>

Added: trunk/dns/nss_mdns/distinfo
===================================================================
--- trunk/dns/nss_mdns/distinfo	                        (rev 0)
+++ trunk/dns/nss_mdns/distinfo	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,2 @@
+SHA256 (nss-mdns-0.10.tar.gz) = 1e683c2e7c3921814706d62fbbd3e9cbf493a75fa00255e0e715508d8134fa6d
+SIZE (nss-mdns-0.10.tar.gz) = 353130

Added: trunk/dns/nss_mdns/files/patch-aclocal.m4
===================================================================
--- trunk/dns/nss_mdns/files/patch-aclocal.m4	                        (rev 0)
+++ trunk/dns/nss_mdns/files/patch-aclocal.m4	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,12 @@
+--- aclocal.m4.orig	2007-05-12 09:55:30.000000000 -0500
++++ aclocal.m4	2010-09-28 10:18:36.000000000 -0500
+@@ -6392,3 +6392,3 @@
+ # generated from the m4 files accompanying Automake X.Y.
+-AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
++AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="%%AUTOMAKE_VERSION%%"])
+ 
+@@ -6399,3 +6399,3 @@
+ AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+-	 [AM_AUTOMAKE_VERSION([1.9.6])])
++	 [AM_AUTOMAKE_VERSION([%%AUTOMAKE_APIVER%%])])
+ 

Added: trunk/dns/nss_mdns/files/patch-src__Makefile.am
===================================================================
--- trunk/dns/nss_mdns/files/patch-src__Makefile.am	                        (rev 0)
+++ trunk/dns/nss_mdns/files/patch-src__Makefile.am	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,24 @@
+--- src/Makefile.am.orig	2007-02-08 16:42:23.000000000 +0000
++++ src/Makefile.am	2008-10-13 23:23:25.000000000 +0100
+@@ -36,11 +36,7 @@
+ if FREEBSD_NSS
+ lib_LTLIBRARIES += \
+ 	nss_mdns.la \
+-	nss_mdns4.la \
+-	nss_mdns6.la \
+-	nss_mdns_minimal.la \
+-	nss_mdns4_minimal.la \
+-	nss_mdns6_minimal.la
++	nss_mdns_minimal.la
+ else
+ lib_LTLIBRARIES += \
+ 	libnss_mdns.la \
+@@ -90,7 +86,7 @@
+ libnss_mdns6_minimal_la_LDFLAGS=$(libnss_mdns_la_LDFLAGS)
+ 
+ # FreeBSD
+-nss_mdns_la_SOURCES=$(sources) bsdnss.c
++nss_mdns_la_SOURCES=$(sources) bsdnss.c nss.c
+ nss_mdns_la_CFLAGS=$(AM_CFLAGS)
+ nss_mdns_la_LDFLAGS=$(AM_LDFLAGS) -shrext .so.1
+ 

Added: trunk/dns/nss_mdns/files/patch-src__bsdnss.c
===================================================================
--- trunk/dns/nss_mdns/files/patch-src__bsdnss.c	                        (rev 0)
+++ trunk/dns/nss_mdns/files/patch-src__bsdnss.c	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,73 @@
+--- src/bsdnss.c.orig	2007-02-08 16:42:23.000000000 +0000
++++ src/bsdnss.c	2008-10-07 23:38:41.000000000 +0100
+@@ -45,6 +45,7 @@
+ #include <netinet/in.h>
+ #include <netdb.h>
+ 
++#include "nss_gethostname_select.h"
+ #include "config.h"
+ 
+ #ifdef MDNS_MINIMAL
+@@ -80,37 +81,6 @@
+ ns_mtab *nss_module_register(const char *source, unsigned int *mtabsize,
+ 			     nss_module_unregister_fn *unreg);
+ 
+-extern enum nss_status _nss_mdns_gethostbyname_r (const char *name, struct hostent * result,
+-			   char *buffer, size_t buflen, int *errnop,
+-			   int *h_errnop);
+-
+-extern enum nss_status _nss_mdns_gethostbyname2_r (const char *name, int af, struct hostent * result,
+-			    char *buffer, size_t buflen, int *errnop,
+-			    int *h_errnop);
+-extern enum nss_status _nss_mdns_gethostbyaddr_r (struct in_addr * addr, int len, int type,
+-			   struct hostent * result, char *buffer,
+-			   size_t buflen, int *errnop, int *h_errnop);
+-extern enum nss_status _nss_mdns4_gethostbyname_r (const char *name, struct hostent * result,
+-			   char *buffer, size_t buflen, int *errnop,
+-			   int *h_errnop);
+-
+-extern enum nss_status _nss_mdns4_gethostbyname2_r (const char *name, int af, struct hostent * result,
+-			    char *buffer, size_t buflen, int *errnop,
+-			    int *h_errnop);
+-extern enum nss_status _nss_mdns4_gethostbyaddr_r (struct in_addr * addr, int len, int type,
+-			   struct hostent * result, char *buffer,
+-			   size_t buflen, int *errnop, int *h_errnop);
+-extern enum nss_status _nss_mdns6_gethostbyname_r (const char *name, struct hostent * result,
+-			   char *buffer, size_t buflen, int *errnop,
+-			   int *h_errnop);
+-
+-extern enum nss_status _nss_mdns6_gethostbyname2_r (const char *name, int af, struct hostent * result,
+-			    char *buffer, size_t buflen, int *errnop,
+-			    int *h_errnop);
+-extern enum nss_status _nss_mdns6_gethostbyaddr_r (struct in_addr * addr, int len, int type,
+-			   struct hostent * result, char *buffer,
+-			   size_t buflen, int *errnop, int *h_errnop);
+-
+ typedef enum nss_status 	(*_bsd_nsstub_fn_t)(const char *, struct hostent *, char *, size_t, int *, int *);
+ 
+ /* XXX: FreeBSD 5.x is not supported. */
+@@ -219,22 +189,8 @@
+ 	 * 2. Map hostent to addrinfo.
+ 	 * 3. Hand-off buffer to libc.
+ 	 */
+-	switch (pai->ai_family) {
+-	case AF_UNSPEC:
+-		status = _nss_mdns_gethostbyname_r(name, hp, buffer, mbuflen,
+-						   &_errno, &_h_errno);
+-		break;
+-	case AF_INET:
+-		status = _nss_mdns4_gethostbyname_r(name, hp, buffer, mbuflen,
+-						    &_errno, &_h_errno);
+-		break;
+-	case AF_INET6:
+-		status = _nss_mdns6_gethostbyname_r(name, hp, buffer, mbuflen,
+-						    &_errno, &_h_errno);
+-		break;
+-	default:
+-		break;
+-	}
++	status = _nss_mdns_gethostbyname2_r(name, pai->ai_family, hp, buffer,
++					   mbuflen, &_errno, &_h_errno);
+ 	status = __nss_compat_result(status, _errno);
+ 
+ 	if (status == NS_SUCCESS) {

Added: trunk/dns/nss_mdns/files/patch-src__nss.c
===================================================================
--- trunk/dns/nss_mdns/files/patch-src__nss.c	                        (rev 0)
+++ trunk/dns/nss_mdns/files/patch-src__nss.c	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,39 @@
+--- src/nss.c.orig	2008-10-06 23:16:19.000000000 +0100
++++ src/nss.c	2008-10-07 22:15:07.000000000 +0100
+@@ -23,6 +23,7 @@
+ #include <config.h>
+ #endif
+ 
++#include <netinet/in.h>
+ #include <unistd.h>
+ #include <errno.h>
+ #include <string.h>
+@@ -39,27 +40,7 @@
+ #include "avahi.h"
+ #endif
+ 
+-#if defined(NSS_IPV4_ONLY) && ! defined(MDNS_MINIMAL)
+-#define _nss_mdns_gethostbyname2_r _nss_mdns4_gethostbyname2_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_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_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_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_gethostbyname_r  _nss_mdns_minimal_gethostbyname_r
+-#define _nss_mdns_gethostbyaddr_r  _nss_mdns_minimal_gethostbyaddr_r
+-#endif
++#include "nss_gethostname_select.h"
+ 
+ /* Maximum number of entries to return */
+ #define MAX_ENTRIES 16

Added: trunk/dns/nss_mdns/files/patch-src__nss_gethostname_select.h
===================================================================
--- trunk/dns/nss_mdns/files/patch-src__nss_gethostname_select.h	                        (rev 0)
+++ trunk/dns/nss_mdns/files/patch-src__nss_gethostname_select.h	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,55 @@
+--- src/nss_gethostname_select.h.orig	2008-10-07 22:27:59.000000000 +0100
++++ src/nss_gethostname_select.h	2008-10-07 22:22:10.000000000 +0100
+@@ -0,0 +1,52 @@
++/* $Id$ */
++
++/***
++	This file is part of nss-mdns.
++
++	nss-mdns is free software; you can redistribute it and/or modify
++	it under the terms of the GNU Lesser General Public License as published
++	by the Free Software Foundation; either version 2 of the License,
++	or (at your option) any later version.
++
++	nss-mdns is distributed in the hope that it will be useful, but1
++	WITHOUT ANY WARRANTY; without even the implied warranty of
++	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++	General Public License for more details.
++
++	You should have received a copy of the GNU Lesser General Public License
++	along with nss-mdns; if not, write to the Free Software
++	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
++	USA.
++***/
++
++#ifndef NSS_GETHOSTNAME_SELECT_H
++#define NSS_GETHOSTNAME_SELECT_H
++
++#if defined(NSS_IPV4_ONLY) && ! defined(MDNS_MINIMAL)
++#define _nss_mdns_gethostbyname2_r _nss_mdns4_gethostbyname2_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_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_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_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_gethostbyname_r  _nss_mdns_minimal_gethostbyname_r
++#define _nss_mdns_gethostbyaddr_r  _nss_mdns_minimal_gethostbyaddr_r
++#endif
++
++/* prototypes of things in nss.c */
++enum nss_status _nss_mdns_gethostbyaddr_r(const void* addr, int len, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
++enum nss_status _nss_mdns_gethostbyname_r(const char *name, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
++enum nss_status _nss_mdns_gethostbyname2_r(const char *name, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
++
++#endif

Added: trunk/dns/nss_mdns/pkg-descr
===================================================================
--- trunk/dns/nss_mdns/pkg-descr	                        (rev 0)
+++ trunk/dns/nss_mdns/pkg-descr	2013-12-14 23:03:55 UTC (rev 15667)
@@ -0,0 +1,3 @@
+nss_mdns is a plugin for libc which provides host name resolution via
+Multicast DNS, building on Avahi.
+Only name resolution is provided; nss_mdns does not advertise services.



More information about the Midnightbsd-cvs mailing list