Blob Blame History Raw
autofs-5.1.0-beta1 - allow empty value in macro selectors

From: Ian Kent <raven@themaw.net>

Some map selectors (this case is olny considering macro selectors) may
be given the comparison value left blank, possibly with the intent the
selector will not match so a mount will not be attempted, such as when
the delay option is also given.

autofs doesn't implement the delay option but it shouldn't fail to parse
these locations so that a valid locations in the list can be tried.
---
 CHANGELOG           |    1 +
 modules/amd_parse.y |   14 ++++++++++++++
 modules/parse_amd.c |    9 +++++++--
 3 files changed, 22 insertions(+), 2 deletions(-)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -125,6 +125,7 @@
 - fix multi entry ldap option handling.
 - cleanup options in amd_parse.c
 - allow empty value for some map options.
+- allow empty value in macro selectors.
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/modules/amd_parse.y
+++ autofs-5.0.7/modules/amd_parse.y
@@ -200,12 +200,26 @@ selection: SELECTOR IS_EQUAL SELECTOR_VA
 			YYABORT;
 		}
 	}
+	| SELECTOR IS_EQUAL
+	{
+		if (!make_selector($1, "", NULL, SEL_COMP_EQUAL)) {
+			amd_notify($1);
+			YYABORT;
+		}
+	}
 	| SELECTOR NOT_EQUAL SELECTOR_VALUE
 	{
 		if (!make_selector($1, $3, NULL, SEL_COMP_NOTEQUAL)) {
 			amd_notify($1);
 			YYABORT;
 		}
+	}
+	| SELECTOR NOT_EQUAL
+	{
+		if (!make_selector($1, "", NULL, SEL_COMP_EQUAL)) {
+			amd_notify($1);
+			YYABORT;
+		}
 	}
 	| SELECTOR LBRACKET SEL_ARG_VALUE RBRACKET
 	{
--- autofs-5.0.7.orig/modules/parse_amd.c
+++ autofs-5.0.7/modules/parse_amd.c
@@ -350,8 +350,13 @@ static int eval_selector(unsigned int lo
 			break;
 
 		case SEL_FLAG_NUM:
-			res = atoi(v->val);
-			val = atoi(s->comp.value);
+			if (!*s->comp.value) {
+				res = 1;
+				val = 0;
+			} else {
+				res = atoi(v->val);
+				val = atoi(s->comp.value);
+			}
 			if (s->compare & SEL_COMP_EQUAL && res == val) {
 				debug(logopt, MODPREFIX
 				      "matched selector %s(%s) equal to %s",