Skip to contentSkip to conversation

fall back to yp_master if yp_order fails

PATCH New Jeff Moyer 1 participant 1 message Nov 9, 2006

Subsystems (2)
lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 fall back to yp_master if yp_order fails

Hi, Ian, list,

Some nisplus servers, when running in nis compatibility mode, will not support yp_order. So, we check for the existence of the map with the yp_master call, instead.

I don't have a nisplus server with which to test this patch, so it's only compile tested (and verified by the one person who ran into this, but that was on the RHEL code base).

-Jeff

lib/nsswitch.c +15 -3
index 6ff097f..c884cc7 100644
@@ -16,6 +16,7 @@ #include <ldap.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <rpcsvc/ypclnt.h>
+#include <rpc/types.h>
 #include "automount.h"
 
 #define MODPREFIX "nsswitch: "
@@ -208,16 +209,27 @@ int isypmap(const char *loc)
 {
 	int err;
 	char *domainname;
+	char *hostname;
 	unsigned int order;
 
 	if ((err = yp_get_default_domain(&domainname)) != YPERR_SUCCESS) {
 		error(MODPREFIX "unable to get default yp domain");
 		return 0;
 	}
+
 	if ((err = yp_order(domainname, loc, &order)) != YPERR_SUCCESS) {
-		debug(MODPREFIX "unable to find map, %s in domain, %s",
-		      loc, domainname);
-		return 0;
+		/*
+		 * Some nisplus servers, when running in nis compatibility
+		 * mode, will not support yp_order.  So, we check for the
+		 * existence of the map with the yp_master call.
+		 */
+		err = yp_master(domainname, loc, &hostname);
+		if (err != YPERR_SUCCESS) {
+			debug(MODPREFIX "unable to find map, %s in domain, %s",
+			      loc, domainname);
+			return 0;
+		}
+		free(hostname);
 	}
 
 	return 1;