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

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