[PATCH 2/4] [cifs-utils] Accept empty domains on the command line

Jeff Layton jlayton at samba.org
Fri Nov 18 20:46:30 UTC 2016


On Fri, 2016-11-18 at 18:54 +0000, Germano Percossi wrote:
> 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.
> 


Umm...ok. So what's the meaningful difference then? How does the client
behave differently between the two cases?

> Signed-off-by: Germano Percossi <germano.percossi at citrix.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:




More information about the samba-technical mailing list