Blame SOURCES/autofs-5.1.1-move-check_nss_result-to-nsswitch_c.patch

306fa1
autofs-5.1.1 - move check_nss_result() to nsswitchr.c
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
The check_nss_result() function will be needed by the multi-map lookup
306fa1
module so move it to the nss library module.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 daemon/lookup.c    |   45 ---------------------------------------------
306fa1
 include/nsswitch.h |    1 +
306fa1
 lib/nsswitch.c     |   45 +++++++++++++++++++++++++++++++++++++++++++++
306fa1
 3 files changed, 46 insertions(+), 45 deletions(-)
306fa1
306fa1
diff --git a/daemon/lookup.c b/daemon/lookup.c
306fa1
index 62071df..53455a1 100644
306fa1
--- a/daemon/lookup.c
306fa1
+++ b/daemon/lookup.c
306fa1
@@ -25,51 +25,6 @@
306fa1
 #include "automount.h"
306fa1
 #include "nsswitch.h"
306fa1
 
306fa1
-static int check_nss_result(struct nss_source *this, enum nsswitch_status result)
306fa1
-{
306fa1
-	enum nsswitch_status status;
306fa1
-	struct nss_action a;
306fa1
-
306fa1
-	/* Check if we have negated actions */
306fa1
-	for (status = 0; status < NSS_STATUS_MAX; status++) {
306fa1
-		a = this->action[status];
306fa1
-		if (a.action == NSS_ACTION_UNKNOWN)
306fa1
-			continue;
306fa1
-
306fa1
-		if (a.negated && result != status) {
306fa1
-			if (a.action == NSS_ACTION_RETURN) {
306fa1
-				if (result == NSS_STATUS_SUCCESS)
306fa1
-					return 1;
306fa1
-				else
306fa1
-					return 0;
306fa1
-			}
306fa1
-		}
306fa1
-	}
306fa1
-
306fa1
-	a = this->action[result];
306fa1
-
306fa1
-	/* Check if we have other actions for this status */
306fa1
-	switch (result) {
306fa1
-	case NSS_STATUS_SUCCESS:
306fa1
-		if (a.action == NSS_ACTION_CONTINUE)
306fa1
-			break;
306fa1
-		return 1;
306fa1
-
306fa1
-	case NSS_STATUS_NOTFOUND:
306fa1
-	case NSS_STATUS_UNAVAIL:
306fa1
-	case NSS_STATUS_TRYAGAIN:
306fa1
-		if (a.action == NSS_ACTION_RETURN) {
306fa1
-			return 0;
306fa1
-		}
306fa1
-		break;
306fa1
-
306fa1
-	default:
306fa1
-		break;
306fa1
-	}
306fa1
-
306fa1
-	return -1;
306fa1
-}
306fa1
-
306fa1
 static void nsslist_cleanup(void *arg)
306fa1
 {
306fa1
 	struct list_head *nsslist = (struct list_head *) arg;
306fa1
diff --git a/include/nsswitch.h b/include/nsswitch.h
306fa1
index 2b445a9..d3e4027 100644
306fa1
--- a/include/nsswitch.h
306fa1
+++ b/include/nsswitch.h
306fa1
@@ -56,6 +56,7 @@ struct nss_source {
306fa1
 }; 
306fa1
 
306fa1
 int set_action(struct nss_action *a, char *status, char *action, int negated);
306fa1
+int check_nss_result(struct nss_source *this, enum nsswitch_status result);
306fa1
 struct nss_source *add_source(struct list_head *head, char *source);
306fa1
 int free_sources(struct list_head *list);
306fa1
 
306fa1
diff --git a/lib/nsswitch.c b/lib/nsswitch.c
306fa1
index c6163a7..74c7525 100644
306fa1
--- a/lib/nsswitch.c
306fa1
+++ b/lib/nsswitch.c
306fa1
@@ -55,6 +55,51 @@ int set_action(struct nss_action *act, char *status, char *action, int negated)
306fa1
 	return 1;
306fa1
 }
306fa1
 
306fa1
+int check_nss_result(struct nss_source *this, enum nsswitch_status result)
306fa1
+{
306fa1
+	enum nsswitch_status status;
306fa1
+	struct nss_action a;
306fa1
+
306fa1
+	/* Check if we have negated actions */
306fa1
+	for (status = 0; status < NSS_STATUS_MAX; status++) {
306fa1
+		a = this->action[status];
306fa1
+		if (a.action == NSS_ACTION_UNKNOWN)
306fa1
+			continue;
306fa1
+
306fa1
+		if (a.negated && result != status) {
306fa1
+			if (a.action == NSS_ACTION_RETURN) {
306fa1
+				if (result == NSS_STATUS_SUCCESS)
306fa1
+					return 1;
306fa1
+				else
306fa1
+					return 0;
306fa1
+			}
306fa1
+		}
306fa1
+	}
306fa1
+
306fa1
+	a = this->action[result];
306fa1
+
306fa1
+	/* Check if we have other actions for this status */
306fa1
+	switch (result) {
306fa1
+	case NSS_STATUS_SUCCESS:
306fa1
+		if (a.action == NSS_ACTION_CONTINUE)
306fa1
+			break;
306fa1
+		return 1;
306fa1
+
306fa1
+	case NSS_STATUS_NOTFOUND:
306fa1
+	case NSS_STATUS_UNAVAIL:
306fa1
+	case NSS_STATUS_TRYAGAIN:
306fa1
+		if (a.action == NSS_ACTION_RETURN) {
306fa1
+			return 0;
306fa1
+		}
306fa1
+		break;
306fa1
+
306fa1
+	default:
306fa1
+		break;
306fa1
+	}
306fa1
+
306fa1
+	return -1;
306fa1
+}
306fa1
+
306fa1
 struct nss_source *add_source(struct list_head *head, char *source)
306fa1
 {
306fa1
 	struct nss_source *s;