Fix regression: report if a group already exists when creating it

This commit is contained in:
Baptiste Daroussin 2015-08-02 12:56:25 +00:00
parent a64b90fbaa
commit f4124312a1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286199

View File

@ -546,6 +546,8 @@ pw_group_add(int argc, char **argv, char *arg1)
freopen(_PATH_DEVNULL, "w", stderr);
if (name == NULL)
errx(EX_DATAERR, "group name required");
if (GETGRNAM(name) != NULL)
errx(EX_DATAERR, "group name `%s' already exists", name);
cnf = get_userconfig(cfg);
rc = groupadd(cnf, name, gr_gidpolicy(cnf, id), members, fd, dryrun,
pretty, precrypted);