summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-04-15 16:17:04 +0000
committerwpaul <wpaul@FreeBSD.org>1996-04-15 16:17:04 +0000
commit78748acfc60b88987b419de1eada1d6b9828a33b (patch)
tree8721ecdc062aa7417830ecb8608737052d3c3976
parent64edb8a1f64fad69d52cb6ebb82c141c0b87fd0f (diff)
downloadFreeBSD-src-78748acfc60b88987b419de1eada1d6b9828a33b.zip
FreeBSD-src-78748acfc60b88987b419de1eada1d6b9828a33b.tar.gz
Fix a few NIS-related bogons:
- Clear the _yp_innetgr flag immediately after calling setnetgrent() from innetgr(). We only need the flag set to temporarily alter setnetgrent()'s behavior. Previously, it was being cleared too late. - When in NIS-only mode, innetgr() was wasting time doing unecessary extra processing after it had already found a match. - Remember to free memory allocated by the NIS functions during innetgr() searches.
-rw-r--r--lib/libc/gen/getnetgrent.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 2997f63..a15252d 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -166,7 +166,7 @@ setnetgrent(group)
/* Presumed guilty until proven innocent. */
_use_only_yp = 0;
/*
- * IF /etc/netgroup doesn't exist or is empty,
+ * If /etc/netgroup doesn't exist or is empty,
* use NIS exclusively.
*/
if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) &&
@@ -280,11 +280,12 @@ int len;
{
char *ptr = list;
- while (ptr != (char *)(list + len)) {
- if (!strncmp(group, ptr, strlen(group)))
- return(1);
- ptr++;
- }
+ if ((ptr = strstr(list, group)) == NULL)
+ return(0);
+
+ if (*(ptr + strlen(group)) == ',' || *(ptr + strlen(group)) == '\n')
+ return(1);
+
return(0);
}
@@ -320,6 +321,7 @@ innetgr(group, host, user, dom)
#ifdef YP
char *result;
int resultlen;
+ int rv;
#endif
/* Sanity check */
@@ -331,6 +333,7 @@ innetgr(group, host, user, dom)
#endif
setnetgrent(group);
#ifdef YP
+ _yp_innetgr = 0;
/*
* If we're in NIS-only mode, do the search using
* NIS 'reverse netgroup' lookups.
@@ -347,20 +350,20 @@ innetgr(group, host, user, dom)
&resultlen))
free(result);
else {
- if (_listmatch(result, group, resultlen)) {
- free(result);
+ rv = _listmatch(result, group, resultlen);
+ free(result);
+ if (rv)
return(1);
- }
+ else
+ return(0);
}
}
- free(result);
#ifdef CHARITABLE
}
/*
* Couldn't match using NIS-exclusive mode -- try
* standard mode.
*/
- _yp_innetgr = 0;
setnetgrent(group);
#else
return(0);
OpenPOWER on IntegriCloud