From e3035e2a92f1293766ae543265cbc06bed5bc0ad Mon Sep 17 00:00:00 2001 From: wpaul Date: Fri, 18 Jul 2003 23:51:15 +0000 Subject: Revert to using yp_order() to probe for master.paswd.by* maps and don't probe the server at all for passwd.by* maps. This fixes interoperability with the Services For UNIX NIS server (which is really a front end to Captive^WActiveDirectory). This server incorrectly returns success for all YPPROC_MASTER requests, even for maps that don't exist, which makes it impossible to (ab)use it to probe for the existence of the master.passwd.by* maps. This is a little kludgey, but basically restores the original behavior of getpwent.c as it is in -stable, and works around both the lack of YPPROC_ORDER on NIS+ servers as well as the broken YPPROC_MASTER on Services For UNIX servers. --- lib/libc/gen/getpwent.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index d846db0..3f73640 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -934,31 +934,38 @@ nis_endstate(void *p) free(p); } +/* + * Test for the presence of special FreeBSD-specific master.passwd.by* + * maps. We do this using yp_order(). If it fails, then either the server + * doesn't have the map, or the YPPROC_ORDER procedure isn't supported by + * the server (Sun NIS+ servers in YP compat mode behave this way). If + * the master.passwd.by* maps don't exist, then let the lookup routine try + * the regular passwd.by* maps instead. If the lookup routine fails, it + * can return an error as needed. + */ static int nis_map(char *domain, enum nss_lookup_type how, char *buffer, size_t bufsize, int *master) { - int rv; - char *outname; + int rv, order; *master = 0; if (geteuid() == 0) { if (snprintf(buffer, bufsize, "master.passwd.by%s", (how == nss_lt_id) ? "uid" : "name") >= bufsize) return (NS_UNAVAIL); - rv = yp_master(domain, buffer, &outname); + rv = yp_order(domain, buffer, &order); if (rv == 0) { *master = 1; return (NS_SUCCESS); } } + if (snprintf(buffer, bufsize, "passwd.by%s", (how == nss_lt_id) ? "uid" : "name") >= bufsize) return (NS_UNAVAIL); - rv = yp_master(domain, buffer, &outname); - if (rv == 0) - return (NS_SUCCESS); - return (NS_UNAVAIL); + + return (NS_SUCCESS); } -- cgit v1.1