Do not allow duplicate group id in groupmod unless -o is specified.

Closes PR bin/40393
This commit is contained in:
mike 2009-03-18 04:59:45 +00:00
parent 7ae7c6b0f8
commit 0779b10efc
1 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: user.c,v 1.121 2009/03/11 14:18:03 christos Exp $ */
/* $NetBSD: user.c,v 1.122 2009/03/18 04:59:45 mike Exp $ */
/*
* Copyright (c) 1999 Alistair G. Crooks. All rights reserved.
@ -33,7 +33,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1999\
The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: user.c,v 1.121 2009/03/11 14:18:03 christos Exp $");
__RCSID("$NetBSD: user.c,v 1.122 2009/03/18 04:59:45 mike Exp $");
#endif
#include <sys/types.h>
@ -2350,6 +2350,10 @@ groupmod(int argc, char **argv)
if (dupgid && gid < 0) {
errx(EXIT_FAILURE, "Duplicate which gid?");
}
if (!dupgid && getgrgid((gid_t) gid) != NULL) {
errx(EXIT_FAILURE, "Can't modify group: gid %d is a duplicate",
gid);
}
if ((grp = find_group_info(*argv)) == NULL) {
errx(EXIT_FAILURE, "Can't find group `%s' to modify", *argv);
}