summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getnetbynis.c
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2000-09-06 18:16:48 +0000
committernectar <nectar@FreeBSD.org>2000-09-06 18:16:48 +0000
commit748554442d0ac4467fdac2ce9d42006588fd4481 (patch)
treeaed2ddbcac97f46f60ee9c2063a3345553f6a1ee /lib/libc/net/getnetbynis.c
parent59ffb36b778f8e629622726f6bd32dfa4fda7e35 (diff)
downloadFreeBSD-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/getnetbynis.c')
-rw-r--r--lib/libc/net/getnetbynis.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/lib/libc/net/getnetbynis.c b/lib/libc/net/getnetbynis.c
index 0ab7073..d226b01 100644
--- a/lib/libc/net/getnetbynis.c
+++ b/lib/libc/net/getnetbynis.c
@@ -38,6 +38,8 @@ static char rcsid[] = "$FreeBSD$";
#include <ctype.h>
#include <errno.h>
#include <string.h>
+#include <stdarg.h>
+#include <nsswitch.h>
#include <arpa/nameser.h>
#ifdef YP
#include <rpc/rpc.h>
@@ -50,15 +52,10 @@ static char rcsid[] = "$FreeBSD$";
#ifdef YP
static char *host_aliases[MAXALIASES];
-#endif /* YP */
static struct netent *
-_getnetbynis(name, map, af)
- const char *name;
- char *map;
- int af;
+_getnetbynis(const char *name, char *map, int af)
{
-#ifdef YP
register char *cp, **q;
static char *result;
int resultlen;
@@ -117,32 +114,45 @@ _getnetbynis(name, map, af)
}
*q = NULL;
return (&h);
-#else
- return (NULL);
-#endif
}
+#endif /* YP */
-struct netent *
-_getnetbynisname(name)
- const char *name;
+int
+_nis_getnetbyname(void *rval, void *cb_data, va_list ap)
{
- return _getnetbynis(name, "networks.byname", AF_INET);
+#ifdef YP
+ const char *name;
+
+ name = va_arg(ap, const char *);
+
+ *(struct netent **)rval = _getnetbynis(name, "networks.byname", AF_INET);
+ return (*(struct netent **)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND;
+#else
+ return NS_UNAVAIL;
+#endif
+
}
-struct netent *
-_getnetbynisaddr(addr, af)
+int
+_nis_getnetbyaddr(void *rval, void *cb_data, va_list ap)
+{
+#ifdef YP
unsigned long addr;
int af;
-{
char *str, *cp;
unsigned long net2;
int nn;
unsigned int netbr[4];
char buf[MAXDNAME];
+ addr = va_arg(ap, unsigned long);
+ af = va_arg(ap, int);
+
+ *(struct netent **)rval = NULL;
+
if (af != AF_INET) {
errno = EAFNOSUPPORT;
- return (NULL);
+ return NS_UNAVAIL;
}
for (nn = 4, net2 = addr; net2; net2 >>= 8) {
@@ -173,5 +183,9 @@ _getnetbynisaddr(addr, af)
cp = str + (strlen(str) - 2);
}
- return _getnetbynis(str, "networks.byaddr", af);
+ *(struct netent **)rval = _getnetbynis(str, "networks.byaddr", af);
+ return (*(struct netent**)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND;
+#else
+ return NS_UNAVAIL;
+#endif /* YP */
}
OpenPOWER on IntegriCloud