summaryrefslogtreecommitdiffstats
path: root/pw/pw_group.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2014-10-28 11:20:30 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2014-10-28 11:20:30 +0000
commita08b5497602c225f5c7ae8e8bbf2ac55615158f9 (patch)
tree3e65b2be588ffa464d4fbae95f358a75d8e06ae9 /pw/pw_group.c
parent9a00d5bef48e2e002e065c8db0ac7ae0629b5625 (diff)
downloadpw-darwin-a08b5497602c225f5c7ae8e8bbf2ac55615158f9.tar.gz
pw-darwin-a08b5497602c225f5c7ae8e8bbf2ac55615158f9.tar.zst
pw-darwin-a08b5497602c225f5c7ae8e8bbf2ac55615158f9.zip
When a group is renamed then the group has been invalidated for sure.
In that case get the group information using the new name. Add a regression test about this bug PR: 193704 Reported by: az
Diffstat (limited to 'pw/pw_group.c')
-rw-r--r--pw/pw_group.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/pw/pw_group.c b/pw/pw_group.c
index 391e477..4ed6ea9 100644
--- a/pw/pw_group.c
+++ b/pw/pw_group.c
@@ -51,6 +51,7 @@ int
pw_group(struct userconf * cnf, int mode, struct cargs * args)
{
int rc;
+ struct carg *a_newname = getarg(args, 'l');
struct carg *a_name = getarg(args, 'n');
struct carg *a_gid = getarg(args, 'g');
struct carg *arg;
@@ -140,8 +141,8 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
if (a_gid)
grp->gr_gid = (gid_t) atoi(a_gid->val);
- if ((arg = getarg(args, 'l')) != NULL)
- grp->gr_name = pw_checkname((u_char *)arg->val, 0);
+ if (a_newname != NULL)
+ grp->gr_name = pw_checkname((u_char *)a_newname->val, 0);
} else {
if (a_name == NULL) /* Required */
errx(EX_DATAERR, "group name required");
@@ -270,8 +271,10 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
warn("group update");
return EX_IOERR;
}
+
+ arg = a_newname != NULL ? a_newname : a_name;
/* grp may have been invalidated */
- if ((grp = GETGRNAM(a_name->val)) == NULL)
+ if ((grp = GETGRNAM(arg->val)) == NULL)
errx(EX_SOFTWARE, "group disappeared during update");
pw_log(cnf, mode, W_GROUP, "%s(%ld)", grp->gr_name, (long) grp->gr_gid);