Blob Blame History Raw
From 61ef4ecfa58f28ab7c98bac7ae2a4b826d843204 Mon Sep 17 00:00:00 2001
From: Germano Percossi <germano.percossi@citrix.com>
Date: Fri, 18 Nov 2016 18:54:50 +0000
Subject: [PATCH 09/12] mount.cifs: Accept empty domains on the command line

If we do not allow empty domains on the command line we are preventing
the kernel module from taking different actions if the domain has not
been specified at all or just passed empty.

In fact, with this fix the cifs module behaves differently once an empty
domain is passed: the find_domain_name function is not invoked when an
empty domain is passed.

It is possible to pass both 'domain=' or 'domain=""' even though the
kernel module will accept the former only when associated with the
sloppy option.

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
(cherry picked from commit 57e4e22de7ea79f56471e7eb8cec9db926087f8d)

Resolves bz: 1427337

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
---
 mount.cifs.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/mount.cifs.c b/mount.cifs.c
index ebb4260..88a3618 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -189,6 +189,7 @@ struct parsed_mount_info {
 	unsigned int nomtab:1;
 	unsigned int verboseflag:1;
 	unsigned int nofail:1;
+	unsigned int got_domain:1;
 };
 
 static const char *thisprogram;
@@ -904,9 +905,14 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
 
 		/* dom || workgroup */
 		case OPT_DOM:
-			if (!value || !*value) {
-				fprintf(stderr, "CIFS: invalid domain name\n");
-				return EX_USAGE;
+			if (!value) {
+				/*
+				 * An empty domain has been passed
+				 */
+				/* not necessary but better safe than.. */
+				parsed_info->domain[0] = '\0';
+				parsed_info->got_domain = 1;
+				goto nocopy;
 			}
 			if (strnlen(value, sizeof(parsed_info->domain)) >=
 			    sizeof(parsed_info->domain)) {
@@ -1812,6 +1818,9 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info,
 			sizeof(parsed_info->options));
 		strlcat(parsed_info->options, parsed_info->domain,
 			sizeof(parsed_info->options));
+	} else if (parsed_info->got_domain) {
+		strlcat(parsed_info->options, ",domain=",
+			sizeof(parsed_info->options));
 	}
 
 assemble_exit:
-- 
2.9.3