summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Percossi <germano.percossi@citrix.com>2016-11-18 18:54:50 +0000
committerJeff Layton <jlayton@samba.org>2016-11-27 06:29:48 -0500
commit57e4e22de7ea79f56471e7eb8cec9db926087f8d (patch)
treeda2161129ae250007b666723fd9f7a573d90e470
parent76da9405575d484b33eb4e56466366c8dbe87046 (diff)
downloadcifs-utils-57e4e22de7ea79f56471e7eb8cec9db926087f8d.tar.gz
cifs-utils-57e4e22de7ea79f56471e7eb8cec9db926087f8d.tar.bz2
cifs-utils-57e4e22de7ea79f56471e7eb8cec9db926087f8d.zip
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>
-rw-r--r--mount.cifs.c15
1 files 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: