NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/59415 add necessary checks



The following reply was made to PR bin/59415; it has been noted by GNATS.

From: ssszcmawo <ssszcmawo%gmail.com@localhost>
To: gnats-bugs%netbsd.org@localhost
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@localhost>
 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
 



Home | Main Index | Thread Index | Old Index