For a long time, this configuration (a non one-to-one mapping of usernames and IDs) was explicitly not supported by glibc.

In particular, the 'nscd' program used to assume that every user ID corresponded to exactly one username, and vice versa. If this was not the case in /etc/passwd, you would see behavior like this:

        % id root
        uid=0(root) gid=0(root) 
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
        % ls -ld /
        drwxr-xr-x   19 root     root         4096 Feb 23  2007 /

        % id alsoroot
        uid=0(alsoroot) gid=0(root) 
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
        % ls -ld /
        drwxr-xr-x   19 alsoroot root         4096 Feb 23  2007 /


In other words, getpwnam() triggers the caching of both ID -> username and username -> ID, and subsequent calls to getpwuid() will return the most recently cached value instead of the "first entry in /etc/passwd" like you assumed. (the nscd daemon is what does the actual caching here)


As of glibc 2.5, it is possible to disable this behavior so that at least nscd will work in your environment. Add the following to /etc/nscd.conf:

        auto-propagate  no


On older systems (i.e. prior to RHEL5), you cannot run nscd if you have multiple users with the same uid in /etc/passwd.



It's certainly possible that programs might implement their own username<->uid mapping, which might get confused by having multiple names with the name id. I don't know if this is the case for lsof or not.


We used to have /etc/passwd similar to you, but we ended up eliminating all multiple usernames with same ID in our linux environment- basically because we understood this to be an unsupported configuration.

Some references:

        http://sourceware.org/ml/glibc-bugs/2004-10/msg00148.html
        http://sourceware.org/ml/glibc-bugs/2004-10/msg00149.html

        http://sourceware.org/ml/libc-alpha/2006-09/msg00065.html

This is also apparently RH bugzilla #177154, but ordinary mortals don't have permission to view it.


Thanks,

Chris Wing
[EMAIL PROTECTED]




On Mon, 15 Oct 2007, Jos Vos wrote:

Yes, the listed username (I only saw one, but I don't trace that script
by default, so I did see only the error that it couldn't find "root" in
its output many times duing heavy load) is a uid 0 user.

I can create all kinds of alternative methods and workarounds, that not
the issue, but I really would like to know what's going on here, as
until now I blindly trusted getpwuid to give then first occurance back.

_______________________________________________
rhelv5-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/rhelv5-list

Reply via email to