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

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