NetBSD Problem Report #59415
From triaxx@netbsd.org Sat May 10 05:26:15 2025
Return-Path: <triaxx@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id BF6991A9242
for <gnats-bugs@gnats.NetBSD.org>; Sat, 10 May 2025 05:26:14 +0000 (UTC)
Message-Id: <20250510052613.B23581A9243@mollari.NetBSD.org>
Date: Sat, 10 May 2025 05:26:13 +0000 (UTC)
From: triaxx@netbsd.org
Reply-To: triaxx@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: group(8) can rename a group to an existing group name
X-Send-Pr-Version: 3.95
>Number: 59415
>Category: bin
>Synopsis: group(8) can rename a group to an existing group name
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 10 05:30:00 +0000 2025
>Last-Modified: Tue Mar 17 17:40:01 +0000 2026
>Originator: Frédéric Fauberteau
>Release: NetBSD 10.1
>Organization:
>Environment:
System: NetBSD ghost.triaxx.online 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC 2024 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
groupmod(8) doesn't seem to check whether a new group name is already in use or not.
>How-To-Repeat:
# tail -n2 /etc/group
foo:*:1003:
bar:*:1004:
# group mod -n foo bar
# tail -n2 /etc/group
foo:*:1003:
foo:*:1004:
>Fix:
>Audit-Trail:
From: ssszcmawo <ssszcmawo@gmail.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/59415 add necessary checks
Date: Sun, 15 Mar 2026 20:51:48 +0100
Here is a fix for your problem.I added a check for already existed
group names so now it works appropriately.
>From 2d031f6a4eebb34055149fa9c719d272759b2951 Mon Sep 17 00:00:00 2001
From: ssszcmawo <belan2470@gmail.com>
Date: Sun, 15 Mar 2026 20:43:15 +0100
Subject: [PATCH] add check for already existed group names in groupmod
---
usr.sbin/user/user.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c
index 84b790423..34c8175c2 100644
--- a/usr.sbin/user/user.c
+++ b/usr.sbin/user/user.c
@@ -2425,8 +2425,14 @@ groupmod(int argc, char **argv)
errx(EXIT_FAILURE, "Group `%s' must be a local group", *argv);
}
if (newname != NULL && !valid_group(newname)) {
- warnx("Invalid group name `%s'", newname);
+ errx(EXIT_FAILURE, "Invalid group name `%s'", newname);
}
+ if (newname != NULL && getgrnam(newname))
+ {
+ errx(EXIT_FAILURE, "Can't rename group %s to %s: group already exists",
+ *argv, newname);
+ }
+
cc = snprintf(buf, sizeof(buf), "%s:%s:%d:",
(newname) ? newname : grp->gr_name,
grp->gr_passwd,
--
2.47.3
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59415 CVS commit: src/usr.sbin/user
Date: Tue, 17 Mar 2026 13:37:50 -0400
Module Name: src
Committed By: christos
Date: Tue Mar 17 17:37:50 UTC 2026
Modified Files:
src/usr.sbin/user: user.c
Log Message:
PR/59415: ssszcmawo: group(8) can rename a group to an existing group name
To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/usr.sbin/user/user.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.49 2026/05/14 01:52:41 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.