Blame SOURCES/autofs-5.1.0-beta1-allow-empty-value-for-some-map-options.patch

6bbd11
autofs-5.1.0-beta1 - allow empty value for some map options
6bbd11
6bbd11
From: Ian Kent <raven@themaw.net>
6bbd11
6bbd11
Some map options may be given but left blank, possibly with the intent
6bbd11
the mount location mount attempt will not be done or fail, such as when
6bbd11
the delay option is also given.
6bbd11
6bbd11
autofs doesn't implement the delay option but it shouldn't fail to parse
6bbd11
these locations so that a valid locations in the list can be tried.
6bbd11
---
6bbd11
 CHANGELOG           |    1 
6bbd11
 lib/parse_subs.c    |   12 +++-
6bbd11
 modules/amd_parse.y |   36 ++++++++++++++
6bbd11
 modules/amd_tok.l   |   35 ++++++++++++--
6bbd11
 modules/parse_amd.c |  125 ++++++++++++++++++++++++++++++++--------------------
6bbd11
 5 files changed, 155 insertions(+), 54 deletions(-)
6bbd11
6bbd11
--- autofs-5.0.7.orig/CHANGELOG
6bbd11
+++ autofs-5.0.7/CHANGELOG
6bbd11
@@ -124,6 +124,7 @@
6bbd11
 - add plus to path match pattern.
6bbd11
 - fix multi entry ldap option handling.
6bbd11
 - cleanup options in amd_parse.c
6bbd11
+- allow empty value for some map options.
6bbd11
 
6bbd11
 25/07/2012 autofs-5.0.7
6bbd11
 =======================
6bbd11
--- autofs-5.0.7.orig/lib/parse_subs.c
6bbd11
+++ autofs-5.0.7/lib/parse_subs.c
6bbd11
@@ -889,14 +889,20 @@ char *merge_options(const char *opt1, co
6bbd11
 	char *tok, *ptr = NULL;
6bbd11
 	size_t len;
6bbd11
 
6bbd11
-	if (!opt1 && !opt2)
6bbd11
+	if ((!opt1 || !*opt1) && (!opt2 || !*opt2))
6bbd11
 		return NULL;
6bbd11
 
6bbd11
-	if (!opt2)
6bbd11
+	if (!opt2 || !*opt2) {
6bbd11
+		if (!*opt1)
6bbd11
+			return NULL;
6bbd11
 		return strdup(opt1);
6bbd11
+	}
6bbd11
 
6bbd11
-	if (!opt1)
6bbd11
+	if (!opt1 || !*opt1) {
6bbd11
+		if (!*opt2)
6bbd11
+			return NULL;
6bbd11
 		return strdup(opt2);
6bbd11
+	}
6bbd11
 
6bbd11
 	if (!strcmp(opt1, opt2))
6bbd11
 		return strdup(opt1);
6bbd11
--- autofs-5.0.7.orig/modules/amd_parse.y
6bbd11
+++ autofs-5.0.7/modules/amd_parse.y
6bbd11
@@ -335,6 +335,15 @@ option_assignment: MAP_OPTION OPTION_ASS
6bbd11
 			YYABORT;
6bbd11
 		}
6bbd11
 	}
6bbd11
+	| MAP_OPTION OPTION_ASSIGN
6bbd11
+	{
6bbd11
+		if (!strcmp($1, "fs"))
6bbd11
+			entry.fs = amd_strdup("");
6bbd11
+		else {
6bbd11
+			amd_notify($1);
6bbd11
+			YYABORT;
6bbd11
+		}
6bbd11
+	}
6bbd11
 	| FS_OPTION OPTION_ASSIGN FS_OPT_VALUE
6bbd11
 	{
6bbd11
 		if (!strcmp($1, "rhost"))
6bbd11
@@ -358,6 +367,19 @@ option_assignment: MAP_OPTION OPTION_ASS
6bbd11
 			YYABORT;
6bbd11
 		}
6bbd11
 	}
6bbd11
+	| FS_OPTION OPTION_ASSIGN
6bbd11
+	{
6bbd11
+		if (!strcmp($1, "rhost"))
6bbd11
+			entry.rhost = amd_strdup("");
6bbd11
+		else if (!strcmp($1, "rfs"))
6bbd11
+			entry.rfs = amd_strdup("");
6bbd11
+		else if (!strcmp($1, "dev"))
6bbd11
+			entry.dev = amd_strdup("");
6bbd11
+		else {
6bbd11
+			amd_notify($1);
6bbd11
+			YYABORT;
6bbd11
+		}
6bbd11
+	}
6bbd11
 	| MNT_OPTION OPTION_ASSIGN options
6bbd11
 	{
6bbd11
 		memset(opts, 0, sizeof(opts));
6bbd11
@@ -370,6 +392,20 @@ option_assignment: MAP_OPTION OPTION_ASS
6bbd11
 		else {
6bbd11
 			amd_notify($1);
6bbd11
 			YYABORT;
6bbd11
+		}
6bbd11
+	}
6bbd11
+	| MNT_OPTION OPTION_ASSIGN
6bbd11
+	{
6bbd11
+		memset(opts, 0, sizeof(opts));
6bbd11
+		if (!strcmp($1, "opts"))
6bbd11
+			entry.opts = amd_strdup("");
6bbd11
+		else if (!strcmp($1, "addopts"))
6bbd11
+			entry.addopts = amd_strdup("");
6bbd11
+		else if (!strcmp($1, "remopts"))
6bbd11
+			entry.remopts = amd_strdup("");
6bbd11
+		else {
6bbd11
+			amd_notify($1);
6bbd11
+			YYABORT;
6bbd11
 		}
6bbd11
 	}
6bbd11
 	| MAP_OPTION OPTION_ASSIGN CACHE_OPTION
6bbd11
--- autofs-5.0.7.orig/modules/amd_tok.l
6bbd11
+++ autofs-5.0.7/modules/amd_tok.l
6bbd11
@@ -177,9 +177,14 @@ CUTSEP		(\|\||\/)
6bbd11
 }
6bbd11
 
6bbd11
 <MAPOPTVAL>{
6bbd11
-	{NL} |
6bbd11
+	{NL} {
6bbd11
+		BEGIN(INITIAL);
6bbd11
+		yyless(1);
6bbd11
+	}
6bbd11
+
6bbd11
 	\x00 {
6bbd11
 		BEGIN(INITIAL);
6bbd11
+		return SEPERATOR;
6bbd11
 		yyless(1);
6bbd11
 	}
6bbd11
 
6bbd11
@@ -217,9 +222,14 @@ CUTSEP		(\|\||\/)
6bbd11
 }
6bbd11
 
6bbd11
 <FSOPTVAL>{
6bbd11
-	{NL} |
6bbd11
+	{NL} {
6bbd11
+		BEGIN(INITIAL);
6bbd11
+		yyless(1);
6bbd11
+	}
6bbd11
+
6bbd11
 	\x00 {
6bbd11
 		BEGIN(INITIAL);
6bbd11
+		return SEPERATOR;
6bbd11
 		yyless(1);
6bbd11
 	}
6bbd11
 
6bbd11
@@ -242,9 +252,14 @@ CUTSEP		(\|\||\/)
6bbd11
 }
6bbd11
 
6bbd11
 <MNTOPTVAL>{
6bbd11
-	{NL} |
6bbd11
+	{NL} {
6bbd11
+		BEGIN(INITIAL);
6bbd11
+		yyless(1);
6bbd11
+	}
6bbd11
+
6bbd11
 	\x00 {
6bbd11
 		BEGIN(INITIAL);
6bbd11
+		return SEPERATOR;
6bbd11
 		yyless(1);
6bbd11
 	}
6bbd11
 
6bbd11
@@ -269,9 +284,14 @@ CUTSEP		(\|\||\/)
6bbd11
 }
6bbd11
 
6bbd11
 <SELOPTVAL>{
6bbd11
-	{NL} |
6bbd11
+	{NL} {
6bbd11
+		BEGIN(INITIAL);
6bbd11
+		yyless(1);
6bbd11
+	}
6bbd11
+
6bbd11
 	\x00 {
6bbd11
 		BEGIN(INITIAL);
6bbd11
+		return SEPERATOR;
6bbd11
 		yyless(1);
6bbd11
 	}
6bbd11
 
6bbd11
@@ -296,9 +316,14 @@ CUTSEP		(\|\||\/)
6bbd11
 }
6bbd11
 
6bbd11
 <SELARGVAL>{
6bbd11
-	{NL} |
6bbd11
+	{NL} {
6bbd11
+		BEGIN(INITIAL);
6bbd11
+		yyless(1);
6bbd11
+	}
6bbd11
+
6bbd11
 	\x00 {
6bbd11
 		BEGIN(INITIAL);
6bbd11
+		return SEPERATOR;
6bbd11
 		yyless(1);
6bbd11
 	}
6bbd11
 
6bbd11
--- autofs-5.0.7.orig/modules/parse_amd.c
6bbd11
+++ autofs-5.0.7/modules/parse_amd.c
6bbd11
@@ -683,7 +683,7 @@ static struct substvar *expand_entry(str
6bbd11
 	unsigned int logopt = ap->logopt;
6bbd11
 	char *expand;
6bbd11
 
6bbd11
-	if (entry->rhost) {
6bbd11
+	if (entry->rhost && *entry->rhost) {
6bbd11
 		char *host = strdup(entry->rhost);
6bbd11
 		char *nn;
6bbd11
 		if (!host) {
6bbd11
@@ -720,7 +720,7 @@ next:
6bbd11
 		sv = macro_addvar(sv, "sublink", 7, entry->sublink);
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->rfs) {
6bbd11
+	if (entry->rfs && *entry->rfs) {
6bbd11
 		if (expand_selectors(ap, entry->rfs, &expand, sv)) {
6bbd11
 			debug(logopt, MODPREFIX
6bbd11
 			      "rfs expand(\"%s\") -> %s", entry->rfs, expand);
6bbd11
@@ -730,7 +730,7 @@ next:
6bbd11
 		sv = macro_addvar(sv, "rfs", 3, entry->rfs);
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->fs) {
6bbd11
+	if (entry->fs && *entry->fs) {
6bbd11
 		if (expand_selectors(ap, entry->fs, &expand, sv)) {
6bbd11
 			debug(logopt, MODPREFIX
6bbd11
 			      "fs expand(\"%s\") -> %s", entry->fs, expand);
6bbd11
@@ -740,7 +740,7 @@ next:
6bbd11
 		sv = macro_addvar(sv, "fs", 2, entry->fs);
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->opts) {
6bbd11
+	if (entry->opts && *entry->opts) {
6bbd11
 		if (expand_selectors(ap, entry->opts, &expand, sv)) {
6bbd11
 			debug(logopt, MODPREFIX
6bbd11
 			      "ops expand(\"%s\") -> %s", entry->opts, expand);
6bbd11
@@ -750,7 +750,7 @@ next:
6bbd11
 		sv = macro_addvar(sv, "opts", 4, entry->opts);
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->addopts) {
6bbd11
+	if (entry->addopts && *entry->addopts) {
6bbd11
 		if (expand_selectors(ap, entry->addopts, &expand, sv)) {
6bbd11
 			debug(logopt, MODPREFIX
6bbd11
 			      "addopts expand(\"%s\") -> %s",
6bbd11
@@ -761,7 +761,7 @@ next:
6bbd11
 		sv = macro_addvar(sv, "addopts", 7, entry->addopts);
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->remopts) {
6bbd11
+	if (entry->remopts && *entry->remopts) {
6bbd11
 		if (expand_selectors(ap, entry->remopts, &expand, sv)) {
6bbd11
 			debug(logopt, MODPREFIX
6bbd11
 			      "remopts expand(\"%s\") -> %s",
6bbd11
@@ -781,7 +781,7 @@ static void expand_merge_options(struct
6bbd11
 {
6bbd11
 	char *tmp;
6bbd11
 
6bbd11
-	if (entry->opts) {
6bbd11
+	if (entry->opts && *entry->opts) {
6bbd11
 		if (!expand_selectors(ap, entry->opts, &tmp, sv))
6bbd11
 			error(ap->logopt, MODPREFIX "failed to expand opts");
6bbd11
 		else {
6bbd11
@@ -790,7 +790,7 @@ static void expand_merge_options(struct
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->addopts) {
6bbd11
+	if (entry->addopts && *entry->addopts) {
6bbd11
 		if (!expand_selectors(ap, entry->addopts, &tmp, sv))
6bbd11
 			error(ap->logopt, MODPREFIX "failed to expand addopts");
6bbd11
 		else {
6bbd11
@@ -799,7 +799,7 @@ static void expand_merge_options(struct
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->remopts) {
6bbd11
+	if (entry->remopts && *entry->remopts) {
6bbd11
 		if (!expand_selectors(ap, entry->remopts, &tmp, sv))
6bbd11
 			error(ap->logopt, MODPREFIX "failed to expand remopts");
6bbd11
 		else {
6bbd11
@@ -832,11 +832,13 @@ static struct substvar *merge_entry_opti
6bbd11
 			entry->opts = tmp;
6bbd11
 			sv = macro_addvar(sv, "opts", 4, entry->opts);
6bbd11
 		}
6bbd11
-		tmp = strdup(entry->opts);
6bbd11
-		if (tmp) {
6bbd11
-			free(entry->remopts);
6bbd11
-			entry->remopts = tmp;
6bbd11
-			sv = macro_addvar(sv, "remopts", 7, entry->remopts);
6bbd11
+		if (*entry->opts) {
6bbd11
+			tmp = strdup(entry->opts);
6bbd11
+			if (tmp) {
6bbd11
+				free(entry->remopts);
6bbd11
+				entry->remopts = tmp;
6bbd11
+				sv = macro_addvar(sv, "remopts", 7, entry->remopts);
6bbd11
+			}
6bbd11
 		}
6bbd11
 		return sv;
6bbd11
 	}
6bbd11
@@ -853,7 +855,7 @@ static struct substvar *merge_entry_opti
6bbd11
 			entry->opts = tmp;
6bbd11
 			sv = macro_addvar(sv, "opts", 4, entry->opts);
6bbd11
 		}
6bbd11
-	} else if (entry->addopts) {
6bbd11
+	} else if (entry->addopts && *entry->addopts) {
6bbd11
 		tmp = strdup(entry->addopts);
6bbd11
 		if (tmp) {
6bbd11
 			info(ap->logopt, MODPREFIX
6bbd11
@@ -875,7 +877,7 @@ static struct substvar *merge_entry_opti
6bbd11
 			entry->remopts = tmp;
6bbd11
 			sv = macro_addvar(sv, "remopts", 7, entry->remopts);
6bbd11
 		}
6bbd11
-	} else if (entry->addopts) {
6bbd11
+	} else if (entry->addopts && *entry->addopts) {
6bbd11
 		tmp = strdup(entry->addopts);
6bbd11
 		if (tmp) {
6bbd11
 			info(ap->logopt, MODPREFIX
6bbd11
@@ -910,6 +912,7 @@ static int do_link_mount(struct autofs_p
6bbd11
 			 struct amd_entry *entry, unsigned int flags)
6bbd11
 {
6bbd11
 	char target[PATH_MAX + 1];
6bbd11
+	const char *opts = (entry->opts && *entry->opts) ? entry->opts : NULL;
6bbd11
 	int ret;
6bbd11
 
6bbd11
 	if (entry->sublink)
6bbd11
@@ -922,7 +925,7 @@ static int do_link_mount(struct autofs_p
6bbd11
 
6bbd11
 	/* For a sublink this might cause an external mount */
6bbd11
 	ret = do_mount(ap, ap->path,
6bbd11
-		       name, strlen(name), target, "bind", entry->opts);
6bbd11
+		       name, strlen(name), target, "bind", opts);
6bbd11
 	if (!ret)
6bbd11
 		goto out;
6bbd11
 
6bbd11
@@ -967,12 +970,13 @@ static int do_generic_mount(struct autof
6bbd11
 			    struct amd_entry *entry, const char *target,
6bbd11
 			    unsigned int flags)
6bbd11
 {
6bbd11
+	const char *opts = (entry->opts && *entry->opts) ? entry->opts : NULL;
6bbd11
 	unsigned int umount = 0;
6bbd11
 	int ret = 0;
6bbd11
 
6bbd11
 	if (!entry->fs) {
6bbd11
-		ret = do_mount(ap, ap->path, name, strlen(name),
6bbd11
-			       target, entry->type, entry->opts);
6bbd11
+		ret = do_mount(ap, ap->path, name,
6bbd11
+			       strlen(name), target, entry->type, opts);
6bbd11
 	} else {
6bbd11
 		/*
6bbd11
 		 * Careful, external mounts may get mounted
6bbd11
@@ -981,7 +985,7 @@ static int do_generic_mount(struct autof
6bbd11
 		 */
6bbd11
 		if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) {
6bbd11
 			ret = do_mount(ap, entry->fs, "/", 1,
6bbd11
-				       target, entry->type, entry->opts);
6bbd11
+				       target, entry->type, opts);
6bbd11
 			if (ret)
6bbd11
 				goto out;
6bbd11
 			umount = 1;
6bbd11
@@ -999,7 +1003,7 @@ static int do_nfs_mount(struct autofs_po
6bbd11
 {
6bbd11
 	char target[PATH_MAX + 1];
6bbd11
 	unsigned int proximity;
6bbd11
-	char *opts = entry->opts;
6bbd11
+	char *opts = (entry->opts && *entry->opts) ? entry->opts : NULL;
6bbd11
 	unsigned int umount = 0;
6bbd11
 	int ret = 0;
6bbd11
 
6bbd11
@@ -1008,7 +1012,7 @@ static int do_nfs_mount(struct autofs_po
6bbd11
 	strcat(target, entry->rfs);
6bbd11
 
6bbd11
 	proximity = get_network_proximity(entry->rhost);
6bbd11
-	if (proximity == PROXIMITY_OTHER && entry->remopts)
6bbd11
+	if (proximity == PROXIMITY_OTHER && entry->remopts && *entry->remopts)
6bbd11
 		opts = entry->remopts;
6bbd11
 
6bbd11
 	if (!entry->fs) {
6bbd11
@@ -1120,7 +1124,7 @@ static int do_host_mount(struct autofs_p
6bbd11
 			goto out;
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->opts) {
6bbd11
+	if (entry->opts && *entry->opts) {
6bbd11
 		argv[0] = entry->opts;
6bbd11
 		argv[1] = NULL;
6bbd11
 		pargv = argv;
6bbd11
@@ -1180,9 +1184,13 @@ static unsigned int validate_auto_option
6bbd11
 	/*
6bbd11
 	 * The amd manual implies all the mount type auto options
6bbd11
 	 * are optional but I don't think there's much point if
6bbd11
-	 * no map is given.
6bbd11
+	 * no map is given. If the option has been intentionally
6bbd11
+	 * left blank the mount must be expected to fail so don't
6bbd11
+	 * report the error.
6bbd11
 	 */
6bbd11
-	if (!entry->fs) {
6bbd11
+	if (!*entry->fs)
6bbd11
+		return 0;
6bbd11
+	else if (!entry->fs) {
6bbd11
 		error(logopt, MODPREFIX
6bbd11
 		      "%s: file system not given", entry->type);
6bbd11
 		return 0;
6bbd11
@@ -1201,11 +1209,19 @@ static unsigned int validate_nfs_options
6bbd11
 					 struct amd_entry *entry)
6bbd11
 {
6bbd11
 	/*
6bbd11
-	 * Required option rhost will always have a value.
6bbd11
-	 * It is set from ${host} if it is found to be NULL
6bbd11
-	 * earlier in the parsing process.
6bbd11
+	 * Required option rhost will always have a value unless
6bbd11
+	 * it has been intentionally left blank. It is set from
6bbd11
+	 * ${host} if it is found to be NULL earlier in the parsing
6bbd11
+	 * process. Don't report the error if it has been left blank
6bbd11
+	 * or if the fs option has been left blank since the mount is
6bbd11
+	 * expected to fail.
6bbd11
 	 */
6bbd11
-	if (!entry->rfs) {
6bbd11
+	if (!entry->rfs || !*entry->rfs) {
6bbd11
+		if (!*entry->rfs)
6bbd11
+			return 0;
6bbd11
+		/* Map option fs has been intentionally left blank */
6bbd11
+		if (entry->fs && !*entry->fs)
6bbd11
+			return 0;
6bbd11
 		if (entry->fs)
6bbd11
 			entry->rfs = strdup(entry->fs);
6bbd11
 		if (!entry->rfs) {
6bbd11
@@ -1226,14 +1242,22 @@ static unsigned int validate_generic_opt
6bbd11
 					     unsigned long fstype,
6bbd11
 					     struct amd_entry *entry)
6bbd11
 {
6bbd11
+	/*
6bbd11
+	 * If dev or rfs are empty in the map entry the mount is
6bbd11
+	 * expected to fail so don't report the error.
6bbd11
+	 */
6bbd11
 	if (fstype != AMD_MOUNT_TYPE_LOFS) {
6bbd11
-		if (!entry->dev) {
6bbd11
+		if (!*entry->dev)
6bbd11
+			return 0;
6bbd11
+		else if (!entry->dev) {
6bbd11
 			error(logopt, MODPREFIX
6bbd11
 			      "%s: mount device not given", entry->type);
6bbd11
 			return 0;
6bbd11
 		}
6bbd11
 	} else {
6bbd11
-		if (!entry->rfs) {
6bbd11
+		if (!*entry->rfs)
6bbd11
+			return 0;
6bbd11
+		else if (!entry->rfs) {
6bbd11
 			/*
6bbd11
 			 * Can't use entry->type as the mount type to reprot
6bbd11
 			 * the error since entry->type == "bind" not "lofs".
6bbd11
@@ -1270,11 +1294,14 @@ static unsigned int validate_host_option
6bbd11
 					  struct amd_entry *entry)
6bbd11
 {
6bbd11
 	/*
6bbd11
-	 * Not really that useful since rhost is always non-null
6bbd11
-	 * because it will have the the value of the host name if
6bbd11
-	 * it isn't set in the map entry.
6bbd11
+	 * rhost is always non-null, unless it is intentionally left
6bbd11
+	 * empty, because it will have the the value of the host name
6bbd11
+	 * if it isn't given in the map entry. Don't report an error
6bbd11
+	 * if it has been left empty since it's expected to fail.
6bbd11
 	 */
6bbd11
-	if (!entry->rhost) {
6bbd11
+	if (!*entry->rhost)
6bbd11
+		return 0;
6bbd11
+	else if (!entry->rhost) {
6bbd11
 		error(logopt, MODPREFIX
6bbd11
 		      "%s: remote host name not given", entry->type);
6bbd11
 		return 0;
6bbd11
@@ -1382,7 +1409,7 @@ void dequote_entry(struct autofs_point *
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->fs) {
6bbd11
+	if (entry->fs && *entry->fs) {
6bbd11
 		res = dequote(entry->fs, strlen(entry->fs), ap->logopt);
6bbd11
 		if (res) {
6bbd11
 			debug(ap->logopt,
6bbd11
@@ -1393,7 +1420,7 @@ void dequote_entry(struct autofs_point *
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->rfs) {
6bbd11
+	if (entry->rfs && *entry->rfs) {
6bbd11
 		res = dequote(entry->rfs, strlen(entry->rfs), ap->logopt);
6bbd11
 		if (res) {
6bbd11
 			debug(ap->logopt,
6bbd11
@@ -1404,7 +1431,7 @@ void dequote_entry(struct autofs_point *
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->opts) {
6bbd11
+	if (entry->opts && *entry->opts) {
6bbd11
 		res = dequote(entry->opts, strlen(entry->opts), ap->logopt);
6bbd11
 		if (res) {
6bbd11
 			debug(ap->logopt,
6bbd11
@@ -1415,7 +1442,7 @@ void dequote_entry(struct autofs_point *
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->remopts) {
6bbd11
+	if (entry->remopts && *entry->remopts) {
6bbd11
 		res = dequote(entry->remopts, strlen(entry->remopts), ap->logopt);
6bbd11
 		if (res) {
6bbd11
 			debug(ap->logopt,
6bbd11
@@ -1426,7 +1453,7 @@ void dequote_entry(struct autofs_point *
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
-	if (entry->addopts) {
6bbd11
+	if (entry->addopts && *entry->addopts) {
6bbd11
 		res = dequote(entry->addopts, strlen(entry->addopts), ap->logopt);
6bbd11
 		if (res) {
6bbd11
 			debug(ap->logopt,
6bbd11
@@ -1446,6 +1473,10 @@ static void normalize_sublink(unsigned i
6bbd11
 	char *new;
6bbd11
 	size_t len;
6bbd11
 
6bbd11
+	/* Normalizing sublink requires a non-blank fs option */
6bbd11
+	if (!*entry->fs)
6bbd11
+		return;
6bbd11
+
6bbd11
 	if (entry->sublink && *entry->sublink != '/') {
6bbd11
 		len = strlen(entry->fs) + strlen(entry->sublink) + 2;
6bbd11
 		new = malloc(len);
6bbd11
@@ -1559,37 +1590,39 @@ static struct amd_entry *dup_defaults_en
6bbd11
 			entry->fs = tmp;
6bbd11
 	}
6bbd11
 
6bbd11
-	if (defaults->rfs) {
6bbd11
+	/* These shouldn't be blank in a defaults entry but ... */
6bbd11
+
6bbd11
+	if (defaults->rfs && *defaults->rfs) {
6bbd11
 		tmp = strdup(defaults->rfs);
6bbd11
 		if (tmp)
6bbd11
 			entry->rfs = tmp;
6bbd11
 	}
6bbd11
 
6bbd11
-	if (defaults->rhost) {
6bbd11
+	if (defaults->rhost && *defaults->rfs) {
6bbd11
 		tmp = strdup(defaults->rhost);
6bbd11
 		if (tmp)
6bbd11
 			entry->rhost = tmp;
6bbd11
 	}
6bbd11
 
6bbd11
-	if (defaults->dev) {
6bbd11
+	if (defaults->dev && *defaults->dev) {
6bbd11
 		tmp = strdup(defaults->dev);
6bbd11
 		if (tmp)
6bbd11
 			entry->dev = tmp;
6bbd11
 	}
6bbd11
 
6bbd11
-	if (defaults->opts) {
6bbd11
+	if (defaults->opts && *defaults->opts) {
6bbd11
 		tmp = strdup(defaults->opts);
6bbd11
 		if (tmp)
6bbd11
 			entry->opts = tmp;
6bbd11
 	}
6bbd11
 
6bbd11
-	if (defaults->addopts) {
6bbd11
+	if (defaults->addopts && *defaults->addopts) {
6bbd11
 		tmp = strdup(defaults->addopts);
6bbd11
 		if (tmp)
6bbd11
 			entry->addopts = tmp;
6bbd11
 	}
6bbd11
 
6bbd11
-	if (defaults->remopts) {
6bbd11
+	if (defaults->remopts && *defaults->remopts) {
6bbd11
 		tmp = strdup(defaults->remopts);
6bbd11
 		if (tmp)
6bbd11
 			entry->remopts = tmp;