1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-20 20:09:11 +00:00

- Build and install the nss_mdns_minimal module. This module only performs

lookups for the .local domain and self assigned IP addresses, rejecting
  others. This can be used to speed up the resolution of non mdns registered
  host names.

PR:		ports/128107
Submitted by:	Andrew <andrew@ugh.net.au>
Approved by:	Ashish Shukla <wahjava@gmail.com> (maintainer)
This commit is contained in:
Pav Lucistnik 2008-11-14 10:23:34 +00:00
parent 94e76155a3
commit a9d2704f22
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=222829
5 changed files with 159 additions and 25 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= nss_mdns
PORTVERSION= 0.10
PORTREVISION= 1
CATEGORIES= dns ipv6
MASTER_SITES= http://0pointer.de/lennart/projects/nss-mdns/
DISTNAME= nss-mdns-${PORTVERSION}
@ -32,6 +33,8 @@ CONFIGURE_ARGS+= \
--disable-legacy \
--disable-lynx
INSTALLED_MODULES=nss_mdns nss_mdns_minimal
#
# 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;
@ -40,8 +43,10 @@ CONFIGURE_ARGS+= \
#
do-install:
@( cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${INSTALL_TARGET} )
( cd ${PREFIX}/lib ; ${LN} -s nss_mdns.so.1 nss_mdns.so )
${RM} ${PREFIX}/lib/nss_mdns.a ${PREFIX}/lib/nss_mdns.la
.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 !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}/
${INSTALL_DATA} ${INSTALL_WRKSRC}/doc/README ${DOCSDIR}
@ -50,7 +55,7 @@ do-install:
# TODO: Print a message about the etc directory used for mdns.allow
# being relative to ${PREFIX}.
PLIST_FILES= lib/nss_mdns.so lib/nss_mdns.so.1
PLIST_FILES= ${INSTALLED_MODULES:C/^/lib\//:C/$/.so/} ${INSTALLED_MODULES:C/^/lib\//:C/$/.so.1/}
PORTDOCS= README README.html
.include <bsd.port.pre.mk>

View File

@ -1,21 +1,19 @@
--- src/Makefile.am.orig 2007-02-08 22:12:23.000000000 +0530
+++ src/Makefile.am 2008-04-30 02:52:50.000000000 +0530
@@ -34,13 +34,7 @@
lib_LTLIBRARIES =
--- 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 \
lib_LTLIBRARIES += \
nss_mdns.la \
- nss_mdns4.la \
- nss_mdns6.la \
- nss_mdns_minimal.la \
- nss_mdns4_minimal.la \
- nss_mdns6_minimal.la
+lib_LTLIBRARIES += nss_mdns.la
+ nss_mdns_minimal.la
else
lib_LTLIBRARIES += \
libnss_mdns.la \
@@ -90,7 +84,7 @@
@@ -90,7 +86,7 @@
libnss_mdns6_minimal_la_LDFLAGS=$(libnss_mdns_la_LDFLAGS)
# FreeBSD

View File

@ -1,15 +1,52 @@
--- src/bsdnss.c.orig 2008-04-30 02:40:37.000000000 +0530
+++ src/bsdnss.c 2008-04-30 02:43:11.000000000 +0530
@@ -56,7 +56,7 @@
#if defined(NSS_IPV4_ONLY) || defined(NSS_IPV6_ONLY)
/*
* FreeBSD's libc is always built with IPv4 support.
- * There is no way of telling at compile time with a define if libc
+ * Therxe is no way of telling at compile time with a define if libc
* was built with -DINET6 or not; a configure test would be required.
* Therefore, distinguishing between the two makes no sense.
*/
@@ -219,22 +219,8 @@
--- 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.
*/
@ -30,7 +67,7 @@
- break;
- }
+ status = _nss_mdns_gethostbyname2_r(name, pai->ai_family, hp, buffer,
+ mbuflen, &_errno, &_h_errno);
+ mbuflen, &_errno, &_h_errno);
status = __nss_compat_result(status, _errno);
if (status == NS_SUCCESS) {

View File

@ -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

View File

@ -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