summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Paul <wpaul@FreeBSD.org>1997-10-13 17:09:15 +0000
committerBill Paul <wpaul@FreeBSD.org>1997-10-13 17:09:15 +0000
commite882d43eca044dd302623f4497a941954dbdb3d8 (patch)
tree3c5ac1b3b01213b6c47e5d3ad687e9c5485a2238
parent9d8c91b749e7a6474aa2a4c54ea85316de126a6a (diff)
Notes
-rw-r--r--lib/libc/gen/getnetgrent.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index ba4c1470f8bf..605dd500e422 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -82,12 +82,6 @@ static char sccsid[] = "@(#)getnetgrent.c 8.2 (Berkeley) 4/27/95";
* netgroup entries, we use just those local entries and ignore
* NIS (this is the original, pre-NIS behavior).
*/
-/*
- * NIS+ servers in YP emulation mode suport only the netgroup map
- * (they have no netgroup.byhost and netgroup.byuser 'reverse' maps)
- * so we need this for compatibility.
- */
-#define CHARITABLE
#include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h>
@@ -349,14 +343,23 @@ innetgr(group, host, user, dom)
*/
if (_use_only_yp) {
char _key[MAXHOSTNAMELEN];
- int rot = 0;
+ int rot = 0, y = 0;
if(yp_get_default_domain(&_netgr_yp_domain))
return(0);
while(_buildkey(_key, user ? user : host, dom, &rot)) {
- if (!yp_match(_netgr_yp_domain, user? "netgroup.byuser":
+ y = yp_match(_netgr_yp_domain, user? "netgroup.byuser":
"netgroup.byhost", _key, strlen(_key), &result,
- &resultlen)) {
+ &resultlen);
+ if (y) {
+ /*
+ * If we get an error other than 'no
+ * such key in map' then something is
+ * wrong and we should stop the search.
+ */
+ if (y != YPERR_KEY)
+ break;
+ } else {
rv = _listmatch(result, group, resultlen);
free(result);
if (rv)
@@ -365,18 +368,22 @@ innetgr(group, host, user, dom)
return(0);
}
}
-#ifdef CHARITABLE
+ /*
+ * Couldn't match using NIS-exclusive mode. If the error
+ * was YPERR_MAP, then the failure happened because there
+ * was no netgroup.byhost or netgroup.byuser map. The odds
+ * are we are talking to an Sun NIS+ server in YP emulation
+ * mode; if this is the case, then we have to do the check
+ * the 'old-fashioned' way by grovelling through the netgroup
+ * map and resolving memberships on the fly.
+ */
+ if (y != YPERR_MAP)
+ return(0);
}
- /*
- * Couldn't match using NIS-exclusive mode -- try
- * standard mode.
- */
+
setnetgrent(group);
-#else
- return(0);
- }
-#endif /* CHARITABLE */
#endif /* YP */
+
while (getnetgrent(&hst, &usr, &dm))
if ((host == NULL || hst == NULL || !strcmp(host, hst)) &&
(user == NULL || usr == NULL || !strcmp(user, usr)) &&