Blame SOURCES/autofs-5.1.3-make-open_lookup-error-handling-more-consistent.patch

306fa1
autofs-5.1.3 - make open_lookup() error handling more consistent
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
If the open of a lookup module fails then open_lookup() should return
306fa1
an NSS status that causes the source to be skipped as it is most likely
306fa1
due to the map source not being configured.
306fa1
306fa1
Currently open_lookup() returns NSS_STATUS_UNAVAIL for failures whereas
306fa1
much of the other lookup code returns NSS_STATUS_UNKNOWN for similar
306fa1
errors encountered by open_lookup().
306fa1
306fa1
But NSS_STATUS_UNAVAIL will result in waiting for the lookup module to
306fa1
become avaiable when trying to read the master map at startup even
306fa1
though it isn't likely to become available. So NSS_STATUS_UNKNOWN is
306fa1
more appropriate becuase that will cause the source to be skipped and
306fa1
is used for the same purpose elsewhere.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG       |    1 +
306fa1
 daemon/module.c |   14 +++++++-------
306fa1
 2 files changed, 8 insertions(+), 7 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -259,6 +259,7 @@
306fa1
 - revert fix argc off by one in mount_autofs.c.
306fa1
 - only take master map mutex for master map update.
306fa1
 - fix nisplus lookup init not configured check.
306fa1
+- make open_lookup() error handling more consistent.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/daemon/module.c
306fa1
+++ autofs-5.0.7/daemon/module.c
306fa1
@@ -73,7 +73,7 @@ int open_lookup(const char *name, const
306fa1
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
306fa1
 			logerr("%s%s", err_prefix, estr);
306fa1
 		}
306fa1
-		return NSS_STATUS_UNAVAIL;
306fa1
+		return NSS_STATUS_UNKNOWN;
306fa1
 	}
306fa1
 
306fa1
 	type = strdup(name);
306fa1
@@ -83,7 +83,7 @@ int open_lookup(const char *name, const
306fa1
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
306fa1
 			logerr("%s%s", err_prefix, estr);
306fa1
 		}
306fa1
-		return NSS_STATUS_UNAVAIL;
306fa1
+		return NSS_STATUS_UNKNOWN;
306fa1
 	}
306fa1
 
306fa1
 	size = snprintf(fnbuf, sizeof(fnbuf),
306fa1
@@ -95,7 +95,7 @@ int open_lookup(const char *name, const
306fa1
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
306fa1
 			logerr("%s%s", err_prefix, estr);
306fa1
 		}
306fa1
-		return NSS_STATUS_UNAVAIL;
306fa1
+		return NSS_STATUS_UNKNOWN;
306fa1
 	}
306fa1
 
306fa1
 	if (!(dh = dlopen(fnbuf, RTLD_NOW))) {
306fa1
@@ -104,7 +104,7 @@ int open_lookup(const char *name, const
306fa1
 			       err_prefix, name, dlerror());
306fa1
 		free(mod);
306fa1
 		free(type);
306fa1
-		return NSS_STATUS_UNAVAIL;
306fa1
+		return NSS_STATUS_UNKNOWN;
306fa1
 	}
306fa1
 
306fa1
 	if (!(ver = (int *) dlsym(dh, "lookup_version"))
306fa1
@@ -115,7 +115,7 @@ int open_lookup(const char *name, const
306fa1
 		dlclose(dh);
306fa1
 		free(mod);
306fa1
 		free(type);
306fa1
-		return NSS_STATUS_UNAVAIL;
306fa1
+		return NSS_STATUS_UNKNOWN;
306fa1
 	}
306fa1
 
306fa1
 	if (!(mod->lookup_init = (lookup_init_t) dlsym(dh, "lookup_init")) ||
306fa1
@@ -129,14 +129,14 @@ int open_lookup(const char *name, const
306fa1
 		dlclose(dh);
306fa1
 		free(mod);
306fa1
 		free(type);
306fa1
-		return NSS_STATUS_UNAVAIL;
306fa1
+		return NSS_STATUS_UNKNOWN;
306fa1
 	}
306fa1
 
306fa1
 	if (mod->lookup_init(mapfmt, argc, argv, &mod->context)) {
306fa1
 		dlclose(dh);
306fa1
 		free(mod);
306fa1
 		free(type);
306fa1
-		return NSS_STATUS_NOTFOUND;
306fa1
+		return NSS_STATUS_UNKNOWN;
306fa1
 	}
306fa1
 
306fa1
 	mod->type = type;