The branch main has been updated by jrm:

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

commit 1a8d37b8cffc805626a3954496845b7a14a45bea
Author:     Naman Sood <[email protected]>
AuthorDate: 2023-07-19 13:06:06 +0000
Commit:     Joseph Mingrone <[email protected]>
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;

Reply via email to