From 57e4e22de7ea79f56471e7eb8cec9db926087f8d Mon Sep 17 00:00:00 2001 From: Germano Percossi Date: Fri, 18 Nov 2016 18:54:50 +0000 Subject: 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 --- 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: -- cgit v1.2.3