[Bug 238995] adduser does not check for pre-existing user field entries in /etc/group

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 06 Jul 2023 12:39:52 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238995

--- Comment #3 from Dennis Clarke <dclarke@blastwave.org> ---
Here in middle of 2023 and adduser and groupmod options to pw seem to be
just plain wrong.

pluto# uname -apKU
FreeBSD pluto 13.2-RELEASE-p1 FreeBSD 13.2-RELEASE-p1 GENERIC amd64 amd64
1302001 1302001
pluto# 

This is a perfectly stable server that does nothing much but serve NFSv3
as well as iSCSI over 10Gbit links. Runs great.

For the sake of experiment I am thinking of planting a QEMU emulation of
a RISC-V instance on that very idle server.

First I create a group :

pluto# pw groupadd -n riscv -g 14142 

Then add a user :

pluto# adduser
Username: riscv
Full name: qemu rv64imafdc
Uid (Leave empty for default): 14142
Login group [riscv]: 
Login group is riscv. Invite riscv into other groups? []: 
Login class [default]: 
Shell (sh csh tcsh nologin) [sh]: 
Home directory [/home/riscv]: 
Home directory permissions (Leave empty for default): 
Use password-based authentication? [yes]: 
Use an empty password? (yes/no) [no]: 
Use a random password? (yes/no) [no]: 
Enter password: 
Enter password again: 
Lock out the account after creation? [no]: 
Username   : riscv
Password   : *****
Full Name  : qemu rv64imafdc
Uid        : 14142
Class      : 
Groups     : riscv 
Home       : /home/riscv
Home Mode  : 
Shell      : /bin/sh
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (riscv) to the user database.
Add another user? (yes/no): no
Goodbye!
pluto# 

If I look at that group I see that the user does not exist as a member :

pluto# pw groupshow -n riscv
riscv:*:14142:

I have to manually add in the member myself :

pluto# pw groupmod -n riscv -g 14142 -m riscv

Since I have no reason to trust the pw command I need to verify :

pluto# grep 'riscv' /etc/group
riscv:*:14142:riscv

Seems like broken behavior that is very counterintuitive. 

related to : 

    pw(8) usermod: numeric ID (uid) in lieu of name for option -n
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269193

    pw accepts an "illegal option" but completes the command without error
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263188

      Oh joy! bug 263188 seems to have been fixed!


-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional

-- 
You are receiving this mail because:
You are the assignee for the bug.