getent does not work for usernames with numbers
Hi All,
Here is the output of getent, which I am finding strange. Code:
[3001@CDCTGIMCLSA ~]$ sudo getent passwd 3001 But the user 3001 exists in the system. Code:
[3001@CDCTGIMCLSA ~]$ cat /etc/passwd | grep 3001 Code:
[3001@CDCTGIMCLSA ~]$ sudo getent passwd test |
what is the content of your /etc/nsswitch.conf file?
|
Quote:
Code:
passwd: files |
Any idea on this behavior of getent ?
|
You probably should contact the programmer of the tool.
But I think that it will try to find a userid if the parameter is a pure numerical value in stead of trying to find a user with that name. Try using something like u3021 _______________ gerrard |
try adding another user with numbers, eg useradd 3002. useradd will complain. Did you add 3001 using useradd? or did someone just create an entry in passwd ?
|
Worked fine for me when adding a user by the name of 4000. just typed - getent passwd | grep 4000
and it found this - getent passwd | grep 4000 4000:x:525:527::/home/4000:/bin/bash Definitely no bug. Using Ubuntu 10.04 It also worked just fine on a RHEL 5.5 Server that I have available to me. |
Quote:
i.e when you run sudo getent passwd 3001 it will detect 3001 as UID not username. if uid not present then your exit status return 2 quote from getent man page Quote:
i.e Code:
$ sudo getent passwd UID |
Quote:
i.e try to run below command Code:
getent passwd 4000 |
Thanks for all your comments.
We cannot add a user with username 3001 in fedora. But we can add in RHEL and CentOS. So getnent is not working as expected when it comes to numerical usernames. Can we consider this as a bug in getent? |
Quote:
It is not bug. |
Interestingly, I can add a user called "3001" in Fedora 13 without a problem.
But if I then use Code:
getent passwd 3001 System is standalone. |
I didn't think the system allowed you to create accounts (or groups) beginning with a numeric or special character.
I assume changing the usernames is out of the question? It might be worth reviewing naming conventions to ensure that the issue doesn't get any worse (just a thought) |
Hi,
Officially this is the legal template for a username: [a-z_][a-z0-9_-]* Some distro's do allow other characters and might let you start a username with a number, but this could get you into trouble. Hope this helps. |
Quote:
|
All times are GMT -5. The time now is 09:03 PM. |