Blame SOURCES/autofs-5.0.9-amd-lookup-add-handling-of-unhandled-options.patch

304803
autofs-5.0.9 - amd lookup add handling of unhandled options
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
There are a number of map options that are either not yet implemented
304803
or aren't planned on being supported.
304803
304803
Add log message feedback for these.
304803
---
304803
 modules/amd_parse.y |   84 +++++++++++++++++++++++++++++++++++++++++++++++++--
304803
 modules/amd_tok.l   |   12 +++++--
304803
 2 files changed, 90 insertions(+), 6 deletions(-)
304803
304803
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
304803
index cd69c49..77adbe5 100644
304803
--- a/modules/amd_parse.y
304803
+++ b/modules/amd_parse.y
304803
@@ -28,6 +28,7 @@
304803
 
304803
 #include "automount.h"
304803
 #include "parse_amd.h"
304803
+#include "log.h"
304803
 
304803
 #define MAX_OPTS_LEN	1024
304803
 #define MAX_ERR_LEN	512
304803
@@ -45,6 +46,7 @@ static void local_free_vars(void);
304803
 
304803
 static int amd_error(const char *s);
304803
 static int amd_notify(const char *s);
304803
+static int amd_info(const char *s);
304803
 static int amd_msg(const char *s);
304803
 
304803
 static int add_location(void);
304803
@@ -59,6 +61,7 @@ static struct autofs_point *pap;
304803
 struct substvar *psv;
304803
 static char opts[MAX_OPTS_LEN];
304803
 static void prepend_opt(char *, char *);
304803
+static char msg_buf[MAX_ERR_LEN];
304803
 
304803
 #define YYDEBUG 0
304803
 
304803
@@ -99,6 +102,7 @@ static int amd_fprintf(FILE *, char *, ...);
304803
 
304803
 %token <strtype> MAP_OPTION
304803
 %token <strtype> MAP_TYPE
304803
+%token <strtype> CACHE_OPTION
304803
 %token <strtype> FS_TYPE
304803
 %token <strtype> FS_OPTION
304803
 %token <strtype> FS_OPT_VALUE
304803
@@ -259,6 +263,20 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
304803
 			   !strcmp($3, "ext4")) {
304803
 			entry.flags |= AMD_MOUNT_TYPE_EXT;
304803
 			entry.type = amd_strdup($3);
304803
+		} else if (!strcmp($3, "jfs") ||
304803
+			   !strcmp($3, "linkx") ||
304803
+			   !strcmp($3, "nfsx") ||
304803
+			   !strcmp($3, "nfsl") ||
304803
+			   !strcmp($3, "program") ||
304803
+			   !strcmp($3, "lustre") ||
304803
+			   !strcmp($3, "direct")) {
304803
+			sprintf(msg_buf, "file system type %s is "
304803
+					 "not yet implemented", $3);
304803
+			amd_msg(msg_buf);
304803
+			YYABORT;
304803
+		} else if (!strcmp($3, "cachefs")) {
304803
+			sprintf(msg_buf, "file syatem %s is not "
304803
+					 "supported by autofs, ignored", $3);
304803
 		} else {
304803
 			amd_notify($1);
304803
 			YYABORT;
304803
@@ -275,7 +293,18 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
304803
 		else if (!strcmp($3, "exec"))
304803
 			/* autofs uses "program" for "exec" map type */
304803
 			entry.map_type = amd_strdup("program");
304803
-		else {
304803
+		else if (!strcmp($3, "passwd")) {
304803
+			sprintf(msg_buf, "map type %s is "
304803
+					 "not yet implemented", $3);
304803
+			amd_msg(msg_buf);
304803
+			YYABORT;
304803
+		} else if (!strcmp($3, "ndbm") ||
304803
+			   !strcmp($3, "union")) {
304803
+			sprintf(msg_buf, "map type %s is not "
304803
+					 "supported by autofs", $3);
304803
+			amd_msg(msg_buf);
304803
+			YYABORT;
304803
+		} else {
304803
 			amd_notify($1);
304803
 			YYABORT;
304803
 		}
304803
@@ -304,7 +333,17 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
304803
 			entry.rfs = amd_strdup($3);
304803
 		else if (!strcmp($1, "dev"))
304803
 			entry.dev = amd_strdup($3);
304803
-		else {
304803
+		else if (!strcmp($1, "mount") ||
304803
+			 !strcmp($1, "unmount") ||
304803
+			 !strcmp($1, "umount")) {
304803
+			amd_info("file system type program is not "
304803
+				 "yet implemented, option ignored");
304803
+			YYABORT;
304803
+		} else if (!strcmp($1, "delay") ||
304803
+			   !strcmp($1, "cachedir")) {
304803
+			sprintf(msg_buf, "option %s is not used by autofs", $1);
304803
+			amd_info(msg_buf);
304803
+		} else {
304803
 			amd_notify($1);
304803
 			YYABORT;
304803
 		}
304803
@@ -326,11 +365,44 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
304803
 			YYABORT;
304803
 		}
304803
 	}
304803
+	| MAP_OPTION OPTION_ASSIGN CACHE_OPTION
304803
+	{
304803
+		sprintf(msg_buf, "option %s is not used, autofs "
304803
+				 "default caching is always used", $1);
304803
+		amd_info(msg_buf);
304803
+	}
304803
 	;
304803
 
304803
 options: OPTION
304803
 	{
304803
-		prepend_opt(opts, $1);
304803
+		if (!strcmp($1, "browsable") ||
304803
+		    !strcmp($1, "fullybrowsable") ||
304803
+		    !strcmp($1, "nounmount") ||
304803
+		    !strcmp($1, "unmount")) {
304803
+			sprintf(msg_buf, "option %s is not currently "
304803
+					 "implemented, ignored", $1);
304803
+			amd_info(msg_buf);
304803
+		} else if (!strncmp($1, "ping=", 5) ||
304803
+			   !strncmp($1, "retry=", 6) ||
304803
+			   !strcmp($1, "public") ||
304803
+			   !strcmp($1, "softlookup") ||
304803
+			   !strcmp($1, "xlatecookie")) {
304803
+			sprintf(msg_buf, "option %s is not used by "
304803
+					 "autofs, ignored", $1);
304803
+			amd_info(msg_buf);
304803
+		} else if (!strncmp($1, "utimeout=", 9)) {
304803
+			if (entry.flags & AMD_MOUNT_TYPE_AUTO) {
304803
+				char *opt = $1;
304803
+				prepend_opt(opts, ++opt);
304803
+			} else {
304803
+				sprintf(msg_buf, "umount timeout can't be "
304803
+						 "used for other than type "
304803
+						 "\"auto\" with autofs, "
304803
+						 "ignored");
304803
+				amd_info(msg_buf);
304803
+			}
304803
+		} else
304803
+			prepend_opt(opts, $1);
304803
 	}
304803
 	| OPTION COMMA options
304803
 	{
304803
@@ -387,6 +459,12 @@ static int amd_notify(const char *s)
304803
 	return(0);
304803
 }
304803
 
304803
+static int amd_info(const char *s)
304803
+{
304803
+	info(pap->logopt, "%s\n", s);
304803
+	return 0;
304803
+}
304803
+
304803
 static int amd_msg(const char *s)
304803
 {
304803
 	logmsg("%s\n", s);
304803
diff --git a/modules/amd_tok.l b/modules/amd_tok.l
304803
index fdc8899..8a6d40c 100644
304803
--- a/modules/amd_tok.l
304803
+++ b/modules/amd_tok.l
304803
@@ -94,13 +94,14 @@ OPTS		({OSTR}(=({VSTR}|{QSTR}|{MACRO})+)?)
304803
 SOPT		(({SSTR}|{QSTR}|{MACRO})+)
304803
 NOPT		({SSTR}|(({IP4ADDR}(\/{V4MASK})?)|({IP6ADDR}(\/{V6MASK})?)))
304803
 
304803
-MAPOPT		(fs|type|maptype|pref|sublink|delay)
304803
+MAPOPT		(fs|type|maptype|pref|sublink|cache)
304803
 MNTOPT		(opts|addopts|remopts)
304803
-FSOPTS		(rhost|rfs|dev|cachedir)
304803
+FSOPTS		(rhost|rfs|dev|cachedir|mount|unmount|umount|delay)
304803
+CHEOPT		(mapdefault|none|inc|re|regexp|all)
304803
 MAPTYPE		(file|nis|nisplus|ldap|hesiod|exec|ndbm|passwd|union)
304803
 FSTYPE_LOCAL	(link|linkx|lofs|ext2|ext3|ext4|xfs|jfs|cachefs)
304803
 FSTYPE_NET	(nfs|nfsx|nfsl|host)
304803
-FSTYPE		(auto|program|direct|{FSTYPE_LOCAL}|{FSTYPE_NET})
304803
+FSTYPE		(auto|program|direct|lustre|{FSTYPE_LOCAL}|{FSTYPE_NET})
304803
 
304803
 OSSEL		(arch|karch|os|osver|full_os|vendor)
304803
 HSTSEL		(host|hostd|domain|byte|cluster)
304803
@@ -204,6 +205,11 @@ CUTSEP		(\|\||\/)
304803
 		return MAP_TYPE;
304803
 	}
304803
 
304803
+	{CHEOPT} {
304803
+		strcpy(amd_lval.strtype, amd_text);
304803
+		return CACHE_OPTION;
304803
+	}
304803
+
304803
 	{FOPT} {
304803
 		strcpy(amd_lval.strtype, amd_text);
304803
 		return FS_OPT_VALUE;