Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Major enhancements to mdnsd nsswitch support:
details: https://anonhg.NetBSD.org/src/rev/de32e4128705
branches: trunk
changeset: 748475:de32e4128705
user: tsarna <tsarna%NetBSD.org@localhost>
date: Sun Oct 25 00:17:06 2009 +0000
description:
Major enhancements to mdnsd nsswitch support:
- nss_mdns renamed to nss_multicast_dns for clarity and less chance of
confusion with nss_mdnsd (see next).
- Support using mdnsd for all unicast too with new nss_mdnsd module
(note: this mode requires an updated mdnsd too, not yet committed)
- Implement resolv.conf "search" directive support. Needed for nss_mdnsd,
potentially useful with nss_multicast_dns (you could now do
"search example.com local" in resolv.conf if you wanted to and it would
act as you might expect)
- Add references in nsswitch.conf man page and sample file
- Implement AI_CANONNAME
- Various bug fixes
diffstat:
distrib/sets/lists/base/shl.mi | 6 +-
etc/nsswitch.conf | 4 +-
external/apache2/mDNSResponder/nss/Makefile | 8 +-
external/apache2/mDNSResponder/nss/nss_mdns.c | 673 ------------------
external/apache2/mDNSResponder/nss/nss_mdnsd.c | 905 +++++++++++++++++++++++++
share/man/man5/nsswitch.conf.5 | 22 +-
6 files changed, 935 insertions(+), 683 deletions(-)
diffs (truncated from 1696 to 300 lines):
diff -r 40209df3c2c2 -r de32e4128705 distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi Sun Oct 25 00:14:31 2009 +0000
+++ b/distrib/sets/lists/base/shl.mi Sun Oct 25 00:17:06 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.501 2009/10/18 20:26:33 pooka Exp $
+# $NetBSD: shl.mi,v 1.502 2009/10/25 00:17:06 tsarna Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -174,7 +174,9 @@
./usr/lib/libzfs.so.0.0 base-zfs-shlib zfs,dynamicroot
./usr/lib/libzpool.so.0.0 base-zfs-shlib zfs,dynamicroot
./usr/lib/libzpool_pic.a base-zfs-shlib zfs,dynamicroot
-./usr/lib/nss_mdns.so.0 base-mdns-shlib mdns
+./usr/lib/nss_mdns.so.0 base-mdns-shlib mdns,obsolete
+./usr/lib/nss_mdnsd.so.0 base-mdns-shlib mdns
+./usr/lib/nss_multicast_dns.so.0 base-mdns-shlib mdns
./usr/lib/security/pam_afslog.so.3 base-sys-shlib kerberos,pam
./usr/lib/security/pam_chroot.so.3 base-sys-shlib pam
./usr/lib/security/pam_deny.so.3 base-sys-shlib pam
diff -r 40209df3c2c2 -r de32e4128705 etc/nsswitch.conf
--- a/etc/nsswitch.conf Sun Oct 25 00:14:31 2009 +0000
+++ b/etc/nsswitch.conf Sun Oct 25 00:17:06 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: nsswitch.conf,v 1.5 1999/10/24 12:36:52 lukem Exp $
+# $NetBSD: nsswitch.conf,v 1.6 2009/10/25 00:17:06 tsarna Exp $
#
# nsswitch.conf(5) -
# name service switch configuration file
@@ -21,7 +21,7 @@
#
# group: compat, dns, files, nis
# group_compat: dns, nis
-# hosts: dns, files, nis
+# hosts: dns, files, nis, mdnsd, multicast_dns
# netgroup: files, nis
# networks: dns, files, nis
# passwd: compat, dns, files, nis
diff -r 40209df3c2c2 -r de32e4128705 external/apache2/mDNSResponder/nss/Makefile
--- a/external/apache2/mDNSResponder/nss/Makefile Sun Oct 25 00:14:31 2009 +0000
+++ b/external/apache2/mDNSResponder/nss/Makefile Sun Oct 25 00:17:06 2009 +0000
@@ -1,7 +1,9 @@
-# $NetBSD: Makefile,v 1.1 2009/10/05 03:54:17 tsarna Exp $
+# $NetBSD: Makefile,v 1.2 2009/10/25 00:17:06 tsarna Exp $
-LIB= nss_mdns
+LIB= nss_mdnsd
SHLIB_MAJOR= 0
+LINKS= ${LIBDIR}/${LIB}.so.${SHLIB_MAJOR} \
+ ${LIBDIR}/nss_multicast_dns.so.${SHLIB_MAJOR}
NOLINT= # don't build a lint library
NOPROFILE= # don't build a profile library
@@ -11,7 +13,7 @@
.include "${.CURDIR}/../Makefile.inc"
-SRCS= nss_mdns.c
+SRCS= nss_mdnsd.c
LDADD+= -ldns_sd
DPADD+= ${LIBDNS_SD}
diff -r 40209df3c2c2 -r de32e4128705 external/apache2/mDNSResponder/nss/nss_mdns.c
--- a/external/apache2/mDNSResponder/nss/nss_mdns.c Sun Oct 25 00:14:31 2009 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,673 +0,0 @@
-/* $NetBSD: nss_mdns.c,v 1.1 2009/10/05 03:54:17 tsarna Exp $ */
-
-/*-
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Tyler C. Sarna
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Multicast DNS ("Bonjour") hosts name service switch
- *
- * Documentation links:
- *
- * http://developer.apple.com/bonjour/
- * http://www.multicastdns.org/
- * http://www.dns-sd.org/
- */
-
-#include <nsswitch.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <sys/param.h>
-#include <netdb.h>
-#include <arpa/nameser.h>
-#include <dns_sd.h>
-#include <poll.h>
-#include <string.h>
-#include <stdio.h>
-
-#ifndef lint
-#define UNUSED(a) (void)&a
-#else
-#define UNUSED(a) a = a
-#endif
-
-#if defined(__NetBSD__) && (__NetBSD_Version__ < 599002000)
-static struct addrinfo *
-allocaddrinfo(socklen_t addrlen)
-{
- struct addrinfo *ai;
-
- ai = calloc(sizeof(struct addrinfo) + addrlen, 1);
- if (ai) {
- ai->ai_addrlen = addrlen;
- ai->ai_addr = (void *)(ai+1);
- }
-
- return ai;
-}
-#endif
-
-#define MAXALIASES 35
-#define MAXADDRS 35
-
-typedef struct callback_ctx {
- int done;
-} callback_ctx;
-
-typedef struct hostent_ctx {
- callback_ctx cb_ctx; /* must come first */
- struct hostent host;
- char *h_addr_ptrs[MAXADDRS + 1];
- char *host_aliases[MAXALIASES];
- char addrs[MAXADDRS * 16];
- char buf[8192], *next;
- int done, naliases, naddrs;
-} hostent_ctx;
-
-typedef struct addrinfo_ctx {
- callback_ctx cb_ctx; /* must come first */
- struct addrinfo start, *last;
-} addrinfo_ctx;
-
-#define HCTX_BUFLEFT(c) (sizeof((c)->buf) - ((c)->next - (c)->buf))
-
-static hostent_ctx h_ctx;
-
-
-static int _mdns_getaddrinfo(void *cbrv, void *cbdata, va_list ap);
-static int _mdns_gethtbyaddr(void *cbrv, void *cbdata, va_list ap);
-static int _mdns_gethtbyname(void *cbrv, void *cbdata, va_list ap);
-
-static void _mdns_addrinfo_init(addrinfo_ctx *ctx, const struct addrinfo *ai);
-static void _mdns_addrinfo_add_ai(addrinfo_ctx *ctx, struct addrinfo *ai);
-static struct addrinfo *_mdns_addrinfo_done(addrinfo_ctx *ctx);
-
-static void _mdns_hostent_init(hostent_ctx *ctx, int af, int addrlen);
-static void _mdns_hostent_add_host(hostent_ctx *ctx, const char *name);
-static void _mdns_hostent_add_addr(hostent_ctx *ctx, const void *addr, uint16_t len);
-static struct hostent *_mdns_hostent_done(hostent_ctx *ctx);
-
-static void _mdns_addrinfo_cb(DNSServiceRef sdRef, DNSServiceFlags flags,
- uint32_t interfaceIndex, DNSServiceErrorType errorCode,
- const char *hostname, const struct sockaddr *address, uint32_t ttl,
- void *context);
-static void _mdns_hostent_cb(DNSServiceRef sdRef, DNSServiceFlags flags,
- uint32_t interfaceIndex, DNSServiceErrorType errorCode,
- const char *fullname, uint16_t rrtype, uint16_t rrclass,
- uint16_t rdlen, const void *rdata, uint32_t ttl, void *context);
-static void _mdns_eventloop(DNSServiceRef sdRef, callback_ctx *ctx);
-
-static char *_mdns_rdata2name(const unsigned char *rdata, uint16_t rdlen,
- char *buf, size_t buflen);
-
-
-static ns_mtab mtab[] = {
- { NSDB_HOSTS, "getaddrinfo", _mdns_getaddrinfo, NULL },
- { NSDB_HOSTS, "gethostbyaddr", _mdns_gethtbyaddr, NULL },
- { NSDB_HOSTS, "gethostbyname", _mdns_gethtbyname, NULL },
-};
-
-
-
-ns_mtab *
-nss_module_register(const char *source, u_int *nelems,
- nss_module_unregister_fn *unreg)
-{
- UNUSED(source);
- UNUSED(unreg);
-
- *nelems = sizeof(mtab) / sizeof(mtab[0]);
- *unreg = NULL;
-
- return mtab;
-}
-
-
-
-static int
-_mdns_getaddrinfo(void *cbrv, void *cbdata, va_list ap)
-{
- const struct addrinfo *pai;
- const char *name;
- addrinfo_ctx ctx;
- DNSServiceProtocol proto;
- DNSServiceErrorType err;
- DNSServiceRef sdRef;
-
- UNUSED(cbdata);
-
- name = va_arg(ap, char *);
- pai = va_arg(ap, struct addrinfo *);
-
- //XXX check valid name space
-
- switch (pai->ai_family) {
- case AF_UNSPEC:
- proto = kDNSServiceProtocol_IPv6 | kDNSServiceProtocol_IPv4;
- break;
-
- case AF_INET6:
- proto = kDNSServiceProtocol_IPv6;
- break;
-
- case AF_INET:
- proto = kDNSServiceProtocol_IPv4;
- break;
-
- default:
- return NS_UNAVAIL;
- }
-
- _mdns_addrinfo_init(&ctx, pai);
-
- err = DNSServiceGetAddrInfo(
- &sdRef,
- kDNSServiceFlagsForceMulticast,
- kDNSServiceInterfaceIndexAny,
- proto,
- name,
- _mdns_addrinfo_cb,
- &ctx
- );
-
- if (err) {
- h_errno = NETDB_INTERNAL;
- return NS_UNAVAIL;
- }
-
- _mdns_eventloop(sdRef, (void *)&h_ctx);
-
- DNSServiceRefDeallocate(sdRef);
-
- if (ctx.start.ai_next) {
- *(struct addrinfo **)cbrv = _mdns_addrinfo_done(&ctx);
-
- return NS_SUCCESS;
- } else {
- return NS_NOTFOUND;
- }
-}
-
-
-
-static int
-_mdns_gethtbyaddr(void *cbrv, void *cbdata, va_list ap)
-{
- const unsigned char *addr;
- int addrlen, af;
- char qbuf[NS_MAXDNAME + 1], *qp, *ep;
- int advance, n;
- DNSServiceErrorType err;
- DNSServiceRef sdRef;
-
- UNUSED(cbdata);
-
- addr = va_arg(ap, unsigned char *);
- addrlen = va_arg(ap, int);
- af = va_arg(ap, int);
-
Home |
Main Index |
Thread Index |
Old Index