getpwuid vs. getpwnam

Ben Lindstrom mouring at etoh.eviladmin.org
Wed Dec 1 07:29:40 EST 2004



On Tue, 30 Nov 2004, John Cecere wrote:

> This issue has probably been brought up before, but I'll mention it anyway.
>
> I just downloaded and built openssh 3.9p1 on Solaris 8. In my
> environment, I have two root accounts. The normal one and an alternate
> one (rjohn - uid 0) with it's own home directory (/export/home/rjohn).
> After building and installing openssh, I was having trouble getting my
> RSA authentication to work. In investigating it, I noticed that it was
> attempting to use /.ssh/id_rsa.pub as my public key file instead of
> /export/home/rjohn/.ssh/id_rsa.pub.  Digging a little deeper, I found
> that, in the client modules ssh.c and tildexpand.c, it uses the call
> getpwuid(uid) as the basis for determining what the user's home
> directory is. In my case, this resolves to / instead of /export/home/rjohn.
>
> Wouldn't it be more appropriate to use something like
> getpwnam(getenv("LOGNAME")) instead ? Since the login program itself (in
> both Linux and Solaris) sets LOGNAME, it's a reasonably safe assumption
> that it will get set correctly. Even if it's not set, the program could

We don't call /sbin/login by default.  Therefor who would set it?

 - Ben




More information about the openssh-unix-dev mailing list