Solved pw: can't add numeric user name

Hi Forum,

I use numeric only user names like "123456". Before FreeBSD10.2-release iI could add such users without any problems. But on FreeBSD 10.2-RELEASE, pw won't add numeric user names saying:
Code:
# pw adduser 123
pw: login name required

Is it a bug? Thanks in advance for help.
 
It seems like it's something to do with changes to the way the name/uid are handled. Seems like a bug to me though. Even the documentation doesn't seem to make much sense.

On CURRENT I get the same error, unless I use -n
Code:
# pw useradd 123
pw: login name required
# pw useradd -n 123
#
# pw userdel 123
pw: no such uid `123'
# pw userdel -n 123
#
It seems it's interpreting it as a UID unless you specifically tell it it's a login name using -n.

Documentation for 10.2 shows the following, in which case you could understand it treating a number as a UID.
pw useradd [name|uid]

However on 11, the documentation has changed to the following, which suggests pw useradd 123 'should' work, as you need to use -u for the UID, but it still functions the same as 10.2:
pw useradd [-n] name [-u uid]

All in all, seems a bit of a mess. I don't know why they can't just stuck to using -u, and only that, if you want to specify the UID.
 
In my case it has the same effect [FreeBSD 10.2-RELEASE]:
Code:
pw adduser -n 123
pw: login name required
 
Thanks for your answers. I'm on
Code:
# uname -a
10.2-RELEASE FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12 15:26:37 UTC 2015     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
 
Thanks everybody for prompt responses. I'll try to apply this patch on my system and post the result here.
 
Adding numeric logins runs smoothly after update, but locking numerical logins still fails with error:

# pw adduser 123
Code:
pw: login name required
# pw adduser -n 123
# pw lock 123

Code:
pw: no such uid `123'
# pw lock -n 123
Code:
pw: illegal option -- n
pw: unknown switch
 
I think you better file a bug report. I am really confused if numeric user names are even properly supported. chown(1) explicitly mentions supporting them, but pw(8) does not AFAICT. Would be nice to have a quote from a developer if it is or is not supported.

In the meantime you can use vipw(8) and prefix the password hash with *LOCKED* to lock accounts (see passwd(5)).
 
  • Thanks
Reactions: Raf
Back
Top