NetBSD Problem Report #11123
Received: (qmail 3989 invoked from network); 3 Oct 2000 12:32:55 -0000
Message-Id: <200010031229.e93CTBK28420@serafina-pekkala.dme.org>
Date: Tue, 3 Oct 2000 13:29:11 +0100 (BST)
From: dme@dme.org
Reply-To: dme@dme.org
To: gnats-bugs@gnats.netbsd.org
Subject: user(8) and useradd(8) do not support -G
X-Send-Pr-Version: 3.95
>Number: 11123
>Category: bin
>Synopsis: user(8) and useradd(8) do not support -G
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 03 12:33:00 +0000 2000
>Closed-Date: Tue Oct 17 05:32:07 +0000 2000
>Last-Modified: Tue Oct 17 05:32:07 +0000 2000
>Originator: David Edmondson
>Release: gnats-3.101
>Organization:
None.
>Environment:
System: NetBSD serafina-pekkala.dme.org 1.5_ALPHA2 NetBSD 1.5_ALPHA2 (S-P) #3: Wed Sep 20 22:16:37 BST 2000 dme@serafina-pekkala.dme.org:/home/dme/netbsd/1.5_ALPHA2/sys/arch/i386/compile/S-P i386
>Description:
The manual pages and usage messages for user(8) and useradd(8)
indicate that a list of supplemental groups can be indicated
using the -G argument. Neither user(8) nor useradd(8)
actually support this.
>How-To-Repeat:
As root:
# useradd -G wheel idontexist
check /etc/group - idontexist has not been added to group
wheel.
>Fix:
The following patch adds support for -G to user(8) (and
therefore to useradd(8)).
There is also new code to issue a warning if a non-existent
group is used.
The patch should be applied in basesrc/usr.sbin/user.
Index: user.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/user/user.c,v
retrieving revision 1.24
diff -c -r1.24 user.c
*** user.c 2000/10/01 08:56:28 1.24
--- user.c 2000/10/03 12:24:54
***************
*** 414,420 ****
int j;
for (i = 0 ; i < ngroups ; i++) {
! if ((grp = getgrnam(groups[i])) != NULL) {
for (j = 0 ; grp->gr_mem[j] ; j++) {
if (strcmp(user, grp->gr_mem[j]) == 0) {
/* already in it */
--- 414,424 ----
int j;
for (i = 0 ; i < ngroups ; i++) {
! if ((grp = getgrnam(groups[i])) == NULL) {
! warn("can't append group %s for %s",
! groups[i], user);
! groups[i] = "";
! } else {
for (j = 0 ; grp->gr_mem[j] ; j++) {
if (strcmp(user, grp->gr_mem[j]) == 0) {
/* already in it */
***************
*** 853,858 ****
--- 857,870 ----
(void) close(ptmpfd);
(void) pw_abort();
err(EXIT_FAILURE, "can't create gid %d for login name %s", gid, login);
+ }
+ if (up->u_groupc > 0 &&
+ !append_group(login, up->u_groupc, up->u_groupv)) {
+ (void) close(ptmpfd);
+ (void) pw_abort();
+ errx(EXIT_FAILURE,
+ "can't append `%s' to new groups",
+ login);
}
(void) close(ptmpfd);
if (pw_mkdb() < 0) {
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: simonb
State-Changed-When: Mon Oct 16 22:30:21 PDT 2000
State-Changed-Why:
Patch applied.
Thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.