Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 224

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

diff --git a/daemon/lookup.c b/daemon/lookup.c
index fd99cf2..0be10d3 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -222,6 +222,28 @@ int lookup_nss_read_master(struct master *master, time_t age)
 		      "reading master %s %s", this->source, master->name);
 
 		result = read_master_map(master, this->source, age);
+
+		/*
+		 * If the name of the master map hasn't been explicitly
+		 * configured and we're not reading an included master map
+		 * then we're using auto.master as the default. Many setups
+		 * also use auto_master as the default master map so we
+		 * check for this map when auto.master isn't found.
+		 */
+		if (result != NSS_STATUS_SUCCESS &&
+		    !master->depth && !defaults_master_set()) {
+			char *tmp = strchr(master->name, '.');
+			if (tmp) {
+				debug(logopt,
+				      "%s not found, replacing '.' with '_'",
+				       master->name);
+				*tmp = '_';
+				result = read_master_map(master, this->source, age);
+				if (result != NSS_STATUS_SUCCESS)
+					*tmp = '.';
+			}
+		}
+
 		if (result == NSS_STATUS_UNKNOWN) {
 			debug(logopt, "no map - continuing to next source");
 			continue;
diff --git a/include/defaults.h b/include/defaults.h
index 0e0e2a5..e296478 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -43,6 +43,7 @@ struct ldap_searchdn;
 
 unsigned int defaults_read_config(unsigned int);
 const char *defaults_get_master_map(void);
+int defaults_master_set(void);
 unsigned int defaults_get_timeout(void);
 unsigned int defaults_get_browse_mode(void);
 unsigned int defaults_get_logging(void);
diff --git a/lib/defaults.c b/lib/defaults.c
index 94885e8..f494103 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -350,6 +350,15 @@ const char *defaults_get_master_map(void)
 	return (const char *) master;
 }
 
+int defaults_master_set(void)
+{
+	char *val = getenv(ENV_NAME_MASTER_MAP);
+	if (!val)
+		return 0;
+
+	return 1;
+}
+
 unsigned int defaults_get_timeout(void)
 {
 	long timeout;