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

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