Blame SOURCES/autofs-5.1.1-fix-return-handling-in-sss-lookup-module.patch

306fa1
autofs-5.1.1 - fix return handling in sss lookup module
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
In the sss lookup module some of the calls don't distinguish between
306fa1
no entry found and service unavailable.
306fa1
306fa1
If service unavailable gets returned from a master map read it results
306fa1
in autofs not updating the mounts. A notfound return doesn't because it
306fa1
indicates the map doesn't exist so updating the mounts isn't a problem
306fa1
as it can be when the source is unavailable.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG            |    1 +
306fa1
 modules/lookup_sss.c |   24 +++++++++++++++++-------
306fa1
 2 files changed, 18 insertions(+), 7 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -171,6 +171,7 @@
306fa1
 - fix mount as you go offset selection.
306fa1
 - init qdn before use in get_query_dn().
306fa1
 - fix left mount count return from umount_multi_triggers().
306fa1
+- fix return handling in sss lookup module.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/modules/lookup_sss.c
306fa1
+++ autofs-5.0.7/modules/lookup_sss.c
306fa1
@@ -148,9 +148,8 @@ static int setautomntent(unsigned int lo
306fa1
 		error(logopt, MODPREFIX "setautomntent: %s", estr);
306fa1
 		if (*sss_ctxt)
306fa1
 			free(*sss_ctxt);
306fa1
-		return 0;
306fa1
 	}
306fa1
-	return 1;
306fa1
+	return ret;
306fa1
 }
306fa1
 
306fa1
 static int endautomntent(unsigned int logopt,
306fa1
@@ -161,9 +160,8 @@ static int endautomntent(unsigned int lo
306fa1
 		char buf[MAX_ERR_BUF];
306fa1
 		char *estr = strerror_r(ret, buf, MAX_ERR_BUF);
306fa1
 		error(logopt, MODPREFIX "endautomntent: %s", estr);
306fa1
-		return 0;
306fa1
 	}
306fa1
-	return 1;
306fa1
+	return ret;
306fa1
 }
306fa1
 
306fa1
 int lookup_read_master(struct master *master, time_t age, void *context)
306fa1
@@ -180,8 +178,12 @@ int lookup_read_master(struct master *ma
306fa1
 	char *value = NULL;
306fa1
 	int count, ret;
306fa1
 
306fa1
-	if (!setautomntent(logopt, ctxt, ctxt->mapname, &sss_ctxt))
306fa1
+	ret = setautomntent(logopt, ctxt, ctxt->mapname, &sss_ctxt);
306fa1
+	if (ret) {
306fa1
+		if (ret == ENOENT)
306fa1
+			return NSS_STATUS_NOTFOUND;
306fa1
 		return NSS_STATUS_UNAVAIL;
306fa1
+	}
306fa1
 
306fa1
 	count = 0;
306fa1
 	while (1) {
306fa1
@@ -280,8 +282,12 @@ int lookup_read_map(struct autofs_point
306fa1
 		return NSS_STATUS_SUCCESS;
306fa1
 	}
306fa1
 
306fa1
-	if (!setautomntent(ap->logopt, ctxt, ctxt->mapname, &sss_ctxt))
306fa1
+	ret = setautomntent(ap->logopt, ctxt, ctxt->mapname, &sss_ctxt);
306fa1
+	if (ret) {
306fa1
+		if (ret == ENOENT)
306fa1
+			return NSS_STATUS_NOTFOUND;
306fa1
 		return NSS_STATUS_UNAVAIL;
306fa1
+	}
306fa1
 
306fa1
 	count = 0;
306fa1
 	while (1) {
306fa1
@@ -386,8 +392,12 @@ static int lookup_one(struct autofs_poin
306fa1
 
306fa1
 	mc = source->mc;
306fa1
 
306fa1
-	if (!setautomntent(ap->logopt, ctxt, ctxt->mapname, &sss_ctxt))
306fa1
+	ret = setautomntent(ap->logopt, ctxt, ctxt->mapname, &sss_ctxt);
306fa1
+	if (ret) {
306fa1
+		if (ret == ENOENT)
306fa1
+			return NSS_STATUS_NOTFOUND;
306fa1
 		return NSS_STATUS_UNAVAIL;
306fa1
+	}
306fa1
 
306fa1
 	ret = ctxt->getautomntbyname_r(qKey, &value, sss_ctxt);
306fa1
 	if (ret && ret != ENOENT) {