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

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