summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1995-08-25 11:52:12 +0000
committerDavid Greenman <dg@FreeBSD.org>1995-08-25 11:52:12 +0000
commit6bd7399d2f96801ed0d48768dd763a976fd06dd2 (patch)
treee97668df6abd70cfa023135aa6769dd5bd7bcff6 /lib
parent87e32b1e917fc403f5801abe91dfb243e8b6f620 (diff)
downloadsrc-test2-6bd7399d2f96801ed0d48768dd763a976fd06dd2.tar.gz
src-test2-6bd7399d2f96801ed0d48768dd763a976fd06dd2.zip
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/rcmd.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index 34ac18bf9f2f..b5ca8700eb2d 100644
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -51,6 +51,11 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#include <stdio.h>
#include <ctype.h>
#include <string.h>
+#ifdef YP
+#include <rpc/rpc.h>
+#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/ypclnt.h>
+#endif
#define max(a, b) ((a > b) ? a : b)
@@ -356,14 +361,23 @@ __ivaliduser(hostf, raddr, luser, ruser)
register char *user, *p;
int ch;
char buf[MAXHOSTNAMELEN + 128]; /* host + login */
+ char hname[MAXHOSTNAMELEN];
struct hostent *hp;
/* Presumed guilty until proven innocent. */
int userok = 0, hostok = 0;
+#ifdef YP
+ char *ypdomain;
+ if (yp_get_default_domain(&ypdomain))
+ ypdomain = NULL;
+#else
+#define ypdomain NULL
+#endif
/* We need to get the damn hostname back for netgroup matching. */
if ((hp = gethostbyaddr((char *)&raddr, sizeof(u_long),
AF_INET)) == NULL)
return (-1);
+ strcpy(hname, hp->h_name);
while (fgets(buf, sizeof(buf), hostf)) {
p = buf;
@@ -376,6 +390,10 @@ __ivaliduser(hostf, raddr, luser, ruser)
/* comment... */
continue;
}
+ if (*p == '\n' || *p == '#') {
+ /* comment... */
+ continue;
+ }
while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') {
*p = isupper(*p) ? tolower(*p) : *p;
p++;
@@ -402,15 +420,15 @@ __ivaliduser(hostf, raddr, luser, ruser)
break;
}
if (buf[1] == '@') /* match a host by netgroup */
- hostok = innetgr((char *)&buf[2], hp->h_name,
- NULL, NULL);
+ hostok = innetgr((char *)&buf[2],
+ (char *)&hname, NULL, ypdomain);
else /* match a host by addr */
hostok = __icheckhost(raddr,(char *)&buf[1]);
break;
case '-': /* reject '-' hosts and all their users */
if (buf[1] == '@') {
if (innetgr((char *)&buf[2],
- hp->h_name, NULL, NULL))
+ (char *)&hname, NULL, ypdomain))
return(-1);
} else {
if (__icheckhost(raddr,(char *)&buf[1]))
@@ -428,7 +446,7 @@ __ivaliduser(hostf, raddr, luser, ruser)
break;
}
if (*(user+1) == '@') /* match a user by netgroup */
- userok = innetgr(user+2, NULL, ruser, NULL);
+ userok = innetgr(user+2, NULL, ruser, ypdomain);
else /* match a user by direct specification */
userok = !(strcmp(ruser, user+1));
break;
@@ -438,7 +456,7 @@ __ivaliduser(hostf, raddr, luser, ruser)
return(-1);
if (*(user+1) == '@') {
if (innetgr(user+2, NULL,
- ruser, NULL))
+ ruser, ypdomain))
return(-1);
} else {
if (!strcmp(ruser, user+1))