summaryrefslogtreecommitdiffstats
path: root/pw/pw_group.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-05-31 11:23:19 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-05-31 11:23:19 +0000
commite2434c7f83a53c8fb2288cf5c58a73ac2f3e0130 (patch)
treedd646303bc3f0d3efbc934aaf19db875eee25d53 /pw/pw_group.c
parent08520f443624966a4c8aa144284e58effedea404 (diff)
downloadpw-darwin-e2434c7f83a53c8fb2288cf5c58a73ac2f3e0130.tar.gz
pw-darwin-e2434c7f83a53c8fb2288cf5c58a73ac2f3e0130.tar.zst
pw-darwin-e2434c7f83a53c8fb2288cf5c58a73ac2f3e0130.zip
Make pw_user()/pw_group() more consitent about errors
Some of errors were returned to the main function, some others caused a direct exit via err(3). The main function is only interested in EXIT_SUCCESS, so in all other cases replace warn(3) + return err by err(3)
Diffstat (limited to 'pw/pw_group.c')
-rw-r--r--pw/pw_group.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/pw/pw_group.c b/pw/pw_group.c
index b20ce88..78adbf1 100644
--- a/pw/pw_group.c
+++ b/pw/pw_group.c
@@ -135,8 +135,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
if (rc == -1)
err(EX_IOERR, "group '%s' not available (NIS?)", grp->gr_name);
else if (rc != 0) {
- warn("group update");
- return EX_IOERR;
+ err(EX_IOERR, "group update");
}
pw_log(cnf, mode, W_GROUP, "%s(%ld) removed", a_name->val, (long) gid);
return EXIT_SUCCESS;
@@ -201,10 +200,8 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
fputc('\n', stdout);
fflush(stdout);
}
- if (b < 0) {
- warn("-h file descriptor");
- return EX_OSERR;
- }
+ if (b < 0)
+ err(EX_OSERR, "-h file descriptor");
line[b] = '\0';
if ((p = strpbrk(line, " \t\r\n")) != NULL)
*p = '\0';
@@ -265,16 +262,16 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
if (mode == M_ADD && (rc = addgrent(grp)) != 0) {
if (rc == -1)
- warnx("group '%s' already exists", grp->gr_name);
+ errx(EX_IOERR, "group '%s' already exists",
+ grp->gr_name);
else
- warn("group update");
- return EX_IOERR;
+ err(EX_IOERR, "group update");
} else if (mode == M_UPDATE && (rc = chggrent(a_name->val, grp)) != 0) {
if (rc == -1)
- warnx("group '%s' not available (NIS?)", grp->gr_name);
+ errx(EX_IOERR, "group '%s' not available (NIS?)",
+ grp->gr_name);
else
- warn("group update");
- return EX_IOERR;
+ err(EX_IOERR, "group update");
}
arg = a_newname != NULL ? a_newname : a_name;