[linux-cifs-client] [patch][linux-cifs] login as anonymous for -o guest option

Jeff Layton jlayton at redhat.com
Wed Feb 18 21:07:37 GMT 2009


On Wed, 18 Feb 2009 14:47:16 -0600
Shirish Pargaonkar <shirishpargaonkar at gmail.com> wrote:

> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index d6a3c1c..dc05bf9 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -69,6 +69,7 @@ struct smb_vol {
>  	mode_t file_mode;
>  	mode_t dir_mode;
>  	unsigned secFlg;
> +	unsigned guest;
>  	bool rw:1;
>  	bool retry:1;
>  	bool intr:1;
> @@ -1183,7 +1184,7 @@ cifs_parse_mount_options(char *options,
>  		} else if (strnicmp(data, "version", 3) == 0) {
>  			/* ignore */
>  		} else if (strnicmp(data, "guest", 5) == 0) {
> -			/* ignore */
> +			vol->guest = true;
>  		} else if (strnicmp(data, "rw", 2) == 0) {
>  			vol->rw = true;
>  		} else if (strnicmp(data, "noblocksend", 11) == 0) {
> @@ -2266,6 +2267,13 @@ cifs_mount(struct super_block *sb, struc
>  		list_add(&pSesInfo->smb_ses_list, &srvTcp->smb_ses_list);
>  		write_unlock(&cifs_tcp_ses_lock);
>  
> +		if (volume_info->guest) {
> +			volume_info->guest = false;
> +			volume_info->username = NULL;
> +			volume_info->password = NULL;
> +			strcpy(pSesInfo->userName, ""); /* anonymous user */
> +		}
> +
>  		/* volume_info->password freed at unmount */
>  		if (volume_info->password) {
>  			pSesInfo->password = volume_info->password;

We already have the ability to do a guest login. You just send a blank
user= option and that just ensures that volume_info->nullauth gets
set. A better scheme to me would be to have mount.cifs just turn the
username into an empty string. It seems like that should do what you
want...

-- 
Jeff Layton <jlayton at redhat.com>


More information about the linux-cifs-client mailing list