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

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