diff options
author | nectar <nectar@FreeBSD.org> | 2000-09-06 18:16:48 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2000-09-06 18:16:48 +0000 |
commit | 748554442d0ac4467fdac2ce9d42006588fd4481 (patch) | |
tree | aed2ddbcac97f46f60ee9c2063a3345553f6a1ee /lib/libc/net/getnetbydns.c | |
parent | 59ffb36b778f8e629622726f6bd32dfa4fda7e35 (diff) | |
download | FreeBSD-src-748554442d0ac4467fdac2ce9d42006588fd4481.zip FreeBSD-src-748554442d0ac4467fdac2ce9d42006588fd4481.tar.gz |
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be
looked up using flat files, NIS, or Hesiod.
= Hesiod has been added to libc (see hesiod(3)).
= A library routine for parsing nsswitch.conf and invoking callback
functions as specified has been added to libc (see nsdispatch(3)).
= The following C library functions have been modified to use nsdispatch:
. getgrent, getgrnam, getgrgid
. getpwent, getpwnam, getpwuid
. getusershell
. getaddrinfo
. gethostbyname, gethostbyname2, gethostbyaddr
. getnetbyname, getnetbyaddr
. getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr
= host.conf has been removed from src/etc. rc.network has been modified
to warn that host.conf is no longer used at boot time. In addition, if
there is a host.conf but no nsswitch.conf, the latter is created at boot
time from the former.
Obtained from: NetBSD
Diffstat (limited to 'lib/libc/net/getnetbydns.c')
-rw-r--r-- | lib/libc/net/getnetbydns.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c index 65d9d2d..5827103 100644 --- a/lib/libc/net/getnetbydns.c +++ b/lib/libc/net/getnetbydns.c @@ -77,6 +77,8 @@ static char rcsid[] = "$FreeBSD$"; #include <string.h> #include <unistd.h> #include <syslog.h> +#include <stdarg.h> +#include <nsswitch.h> #include "res_config.h" @@ -218,11 +220,11 @@ static char *net_aliases[MAXALIASES], netbuf[PACKETSZ]; return (NULL); } -struct netent * -_getnetbydnsaddr(net, net_type) - register unsigned long net; - register int net_type; +int +_dns_getnetbyaddr(void *rval, void *cb_data, va_list ap) { + unsigned long net; + int net_type; unsigned int netbr[4]; int nn, anslen; querybuf buf; @@ -230,8 +232,13 @@ _getnetbydnsaddr(net, net_type) unsigned long net2; struct netent *net_entry; + net = va_arg(ap, unsigned long); + net_type = va_arg(ap, int); + + *(struct netent **)rval = NULL; + if (net_type != AF_INET) - return (NULL); + return NS_UNAVAIL; for (nn = 4, net2 = net; net2; net2 >>= 8) netbr[--nn] = net2 & 0xff; @@ -257,7 +264,7 @@ _getnetbydnsaddr(net, net_type) if (_res.options & RES_DEBUG) printf("res_query failed\n"); #endif - return (NULL); + return NS_UNAVAIL; } net_entry = getnetanswer(&buf, anslen, BYADDR); if (net_entry) { @@ -267,22 +274,27 @@ _getnetbydnsaddr(net, net_type) while ((u_net & 0xff) == 0 && u_net != 0) u_net >>= 8; net_entry->n_net = u_net; - return (net_entry); + *(struct netent **)rval = net_entry; + return NS_SUCCESS; } - return (NULL); + return NS_NOTFOUND; } -struct netent * -_getnetbydnsname(net) - register const char *net; +int +_dns_getnetbyname(void *rval, void *cb_data, va_list ap) { + const char *net; int anslen; querybuf buf; char qbuf[MAXDNAME]; + net = va_arg(ap, const char *); + + *(struct netent**)rval = NULL; + if ((_res.options & RES_INIT) == 0 && res_init() == -1) { h_errno = NETDB_INTERNAL; - return (NULL); + return NS_UNAVAIL; } strncpy(qbuf, net, sizeof(qbuf) - 1); qbuf[sizeof(qbuf) - 1] = '\0'; @@ -292,9 +304,10 @@ _getnetbydnsname(net) if (_res.options & RES_DEBUG) printf("res_query failed\n"); #endif - return (NULL); + return NS_UNAVAIL; } - return getnetanswer(&buf, anslen, BYNAME); + *(struct netent**)rval = getnetanswer(&buf, anslen, BYNAME); + return (*(struct netent**)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND; } void |