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

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 19 Jul 2023 13:57:17 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238995

--- Comment #7 from Naman Sood <naman@freebsdfoundation.org> ---
Hello! I just finished looking into this, and a few things to note:

1. Your 2023 example is expected behavior - `pw groupshow` will list the groups
as in /etc/group, but group(5) notes that "A user is automatically in a group
if that group specified in their /etc/passwd entry and does not need to be
added that group in the group file." Since in that example, the user riscv's
login group was riscv, pw did not add it to the group file. If you'd like to
get group membership that keeps such things in mind, `id riscv` shows that.

root@neon-testvm:~ # pw groupadd -n testuser -g 4242
root@neon-testvm:~ # adduser
Username: testuser
Full name: 
Uid (Leave empty for default): 4242
Login group [testuser]: 
Login group is testuser. Invite testuser into other groups? []: 
Login class [default]: 
Shell (sh csh tcsh nologin) [sh]: 
Home directory [/home/testuser]: 
Home directory permissions (Leave empty for default): 
Use password-based authentication? [yes]: no
Lock out the account after creation? [no]: 
Username   : testuser
Password   : <disabled>
Full Name  : 
Uid        : 4242
Class      : 
Groups     : testuser 
Home       : /home/testuser
Home Mode  : 
Shell      : /bin/sh
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (testuser) to the user database.
Add another user? (yes/no): no
Goodbye!
root@neon-testvm:~ # cat /etc/group | grep testuser
testuser:*:4242:
root@neon-testvm:~ # pw groupshow testuser
testuser:*:4242:
root@neon-testvm:~ # id testuser
uid=4242(testuser) gid=4242(testuser) groups=4242(testuser)

The bugs exposed by your 2021 and 2019 examples have been fixed in the commits
above.

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