Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Mar 2000 16:17:45 -0600
From:      Jonathan Lemon <jlemon@flugsvamp.com>
To:        bugs@freebsd.org
Cc:        jordan@freebsd.org
Subject:   Re: kern/17290: getaddrinfo() does not seem to honor NIS
Message-ID:  <20000309161745.C14209@prism.flugsvamp.com>

next in thread | raw e-mail | index | archive | help
Here's a quick patch to allow NIS for IPV4 addresses.  I've explicitly
filtered out IPV6 addresses, since it's not likely that the NIS maps
`hosts.byname' and `hosts.byaddr' are in IPV6 format.

This should be in RELEASE, otherwise NIS support will be broken.
--
Jonathan


Index: name6.c
===================================================================
RCS file: /ncvs/src/lib/libc/net/name6.c,v
retrieving revision 1.5
diff -u -r1.5 name6.c
--- name6.c	2000/02/10 02:59:50	1.5
+++ name6.c	2000/03/09 22:08:54
@@ -116,6 +116,8 @@
 static struct	 hostent *_files_ghbyaddr(const void *addr, int addrlen, int af, int *errp);
 static void	 _files_shent(int stayopen);
 static void	 _files_ehent(void);
+static struct	 hostent *_nis_ghbyname(const char *name, int af, int *errp);
+static struct	 hostent *_nis_ghbyaddr(const void *addr, int addrlen, int af, int *errp);
 static struct	 hostent *_dns_ghbyname(const char *name, int af, int *errp);
 static struct	 hostent *_dns_ghbyaddr(const void *addr, int addrlen, int af, int *errp);
 static void	 _dns_shent(int stayopen);
@@ -186,6 +188,11 @@
 				_hostconf[n].byaddr = _dns_ghbyaddr;
 				n++;
 			}
+			else if (strcmp(p, "nis") == 0) {
+				_hostconf[n].byname = _nis_ghbyname;
+				_hostconf[n].byaddr = _nis_ghbyaddr;
+				n++;
+			}
 #ifdef ICMPNL
 			else if (strcmp(p, "icmp") == 0) {
 				_hostconf[n].byname = NULL;
@@ -823,6 +830,27 @@
 	}
 	fclose(fp);
 	return hp;
+}
+
+/*
+ * NIS
+ *
+ * XXX actually a hack, these are INET4 specific.
+ */
+static struct hostent *
+_nis_ghbyname(const char *name, int af, int *errp)
+{
+	if (af == AF_INET6)
+		return (NULL);
+	return (_gethostbynisname(name, af));
+}
+
+static struct hostent *
+_nis_ghbyaddr(const void *addr, int addrlen, int af, int *errp)
+{
+	if (af == AF_INET6)
+		return (NULL);
+	return (_gethostbynisaddr(addr, addrlen, af));
 }
 
 #ifdef DEBUG


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000309161745.C14209>