Re: [PATCH 1/6] mount.cifs: treat uid=,gid=,cruid= options as name before assuming they're a number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 4 Dec 2012 10:45:19 -0500
Scott Lovenberg <scott.lovenberg@xxxxxxxxx> wrote:

> On Tue, Dec 4, 2012 at 10:16 AM, Jeff Layton <jlayton@xxxxxxxxx> wrote:
> > Sergio Conrad reported a problem trying to set up an autofs map to do
> > a krb5 mount. In his environment, many users have usernames that are
> > comprised entirely of numbers. While that's a bit odd, POSIX apparently
> > allows for it.
> >
> > The current code assumes that when a numeric argument is passed to one
> > of the above options, that it's a uid or gid. Instead, try to treat the
> > argument as a user or group name first, and only try to treat it as a
> > number if that fails.
> >
> > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxx>
> 
> Yuck.  What happens when a number is both a valid user name and uid?
> IE, I add a user named "0" (uid=5001).  Does getpwnam() return root
> (uid=0) or 0 (uid=5001)?
> 

You'd get back uid=5001:

       The getpwnam() function returns a pointer to a structure containing the
       broken-out  fields  of  the  record in the password database (e.g., the
       local password file /etc/passwd, NIS, and LDAP) that matches the  user‐
       name name.

If you wanted to get back a struct passwd for uid=0 then you'd need to
use getpwuid() there.

-- 
Jeff Layton <jlayton@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux