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

Jeff Layton jlayton at redhat.com
Thu Feb 19 23:54:24 GMT 2009


On Thu, 19 Feb 2009 10:51:29 -0600
Shirish Pargaonkar <shirishpargaonkar at gmail.com> wrote:

> On Wed, Feb 18, 2009 at 3:07 PM, Jeff Layton <jlayton at redhat.com> wrote:
> > 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>
> >
> 
> Jeff,
> 
> -o user=
> 
> would prompt you for a password.  -o guest is not supposed to.
> 

mount.cifs is what prompts you for the password. I'm simply suggesting
that if "guest" is specified that we don't prompt for a password and
send the "user=" option in such a way that you get an anonymous login.
That should give you the effect you want without needing to add any
more stuff to the option parsing code in the kernel.

My main point is that we already have code to handle guest logins in
the kernel -- that's what the "nullauth" thing is all about. If you're
going to add something like this, then that should probably be ripped
out.

PS: setting username=NULL may be problematic as well. I made that
change at one point (maybe when I did some changes for sec=none ?). It
led to oopses and I had to revert it. If you want to do that, it's fine
but you'll need to make sure that nothing assumes that it's a valid
pointer.

-- 
Jeff Layton <jlayton at redhat.com>


More information about the linux-cifs-client mailing list