Blame SOURCES/0009-mount.cifs-Accept-empty-domains-on-the-command-line.patch

97823b
From 61ef4ecfa58f28ab7c98bac7ae2a4b826d843204 Mon Sep 17 00:00:00 2001
97823b
From: Germano Percossi <germano.percossi@citrix.com>
97823b
Date: Fri, 18 Nov 2016 18:54:50 +0000
97823b
Subject: [PATCH 09/12] mount.cifs: Accept empty domains on the command line
97823b
97823b
If we do not allow empty domains on the command line we are preventing
97823b
the kernel module from taking different actions if the domain has not
97823b
been specified at all or just passed empty.
97823b
97823b
In fact, with this fix the cifs module behaves differently once an empty
97823b
domain is passed: the find_domain_name function is not invoked when an
97823b
empty domain is passed.
97823b
97823b
It is possible to pass both 'domain=' or 'domain=""' even though the
97823b
kernel module will accept the former only when associated with the
97823b
sloppy option.
97823b
97823b
Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
97823b
(cherry picked from commit 57e4e22de7ea79f56471e7eb8cec9db926087f8d)
97823b
97823b
Resolves bz: 1427337
97823b
97823b
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
97823b
---
97823b
 mount.cifs.c | 15 ++++++++++++---
97823b
 1 file changed, 12 insertions(+), 3 deletions(-)
97823b
97823b
diff --git a/mount.cifs.c b/mount.cifs.c
97823b
index ebb4260..88a3618 100644
97823b
--- a/mount.cifs.c
97823b
+++ b/mount.cifs.c
97823b
@@ -189,6 +189,7 @@ struct parsed_mount_info {
97823b
 	unsigned int nomtab:1;
97823b
 	unsigned int verboseflag:1;
97823b
 	unsigned int nofail:1;
97823b
+	unsigned int got_domain:1;
97823b
 };
97823b
 
97823b
 static const char *thisprogram;
97823b
@@ -904,9 +905,14 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
97823b
 
97823b
 		/* dom || workgroup */
97823b
 		case OPT_DOM:
97823b
-			if (!value || !*value) {
97823b
-				fprintf(stderr, "CIFS: invalid domain name\n");
97823b
-				return EX_USAGE;
97823b
+			if (!value) {
97823b
+				/*
97823b
+				 * An empty domain has been passed
97823b
+				 */
97823b
+				/* not necessary but better safe than.. */
97823b
+				parsed_info->domain[0] = '\0';
97823b
+				parsed_info->got_domain = 1;
97823b
+				goto nocopy;
97823b
 			}
97823b
 			if (strnlen(value, sizeof(parsed_info->domain)) >=
97823b
 			    sizeof(parsed_info->domain)) {
97823b
@@ -1812,6 +1818,9 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info,
97823b
 			sizeof(parsed_info->options));
97823b
 		strlcat(parsed_info->options, parsed_info->domain,
97823b
 			sizeof(parsed_info->options));
97823b
+	} else if (parsed_info->got_domain) {
97823b
+		strlcat(parsed_info->options, ",domain=",
97823b
+			sizeof(parsed_info->options));
97823b
 	}
97823b
 
97823b
 assemble_exit:
97823b
-- 
97823b
2.9.3
97823b