Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2023 13:41:54 GMT
From:      Joseph Mingrone <jrm@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 1a8d37b8cffc - main - pw: Use existing group entry, even if it already has members
Message-ID:  <202307191341.36JDfs6j045347@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jrm:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a8d37b8cffc805626a3954496845b7a14a45bea

commit 1a8d37b8cffc805626a3954496845b7a14a45bea
Author:     Naman Sood <mail@nsood.in>
AuthorDate: 2023-07-19 13:06:06 +0000
Commit:     Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2023-07-19 13:40:53 +0000

    pw: Use existing group entry, even if it already has members
    
    Fix the following problem:
    
    1. A nonexistent user, someuser, is added to /etc/group as
       someuser:*:12345:someuser.
    2. someuser is then created with the default login group.
    
    A second group entry for someuser will be created.
    
       someuser:*:12345:someuser
       someuser:*:12346:
    
    With this fix, the existing group entry will be used.
    
    PR:             238995
    Reviewed by:    bapt, jrm
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D41057
---
 usr.sbin/pw/pw_user.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 9029069c6a9f..3e5a9841c5f3 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -378,8 +378,7 @@ pw_gidpolicy(struct userconf *cnf, char *grname, char *nam, gid_t prefer, bool d
 			grp = GETGRGID(gid);
 		}
 		gid = grp->gr_gid;
-	} else if ((grp = GETGRNAM(nam)) != NULL &&
-	    (grp->gr_mem == NULL || grp->gr_mem[0] == NULL)) {
+	} else if ((grp = GETGRNAM(nam)) != NULL) {
 		gid = grp->gr_gid;  /* Already created? Use it anyway... */
 	} else {
 		intmax_t		grid = -1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307191341.36JDfs6j045347>