summaryrefslogtreecommitdiffstats
path: root/libutil/pw_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'libutil/pw_util.c')
-rw-r--r--libutil/pw_util.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c
index 94db720..4d708c0 100644
--- a/libutil/pw_util.c
+++ b/libutil/pw_util.c
@@ -308,12 +308,13 @@ pw_edit(int notsetuid)
sigaction(SIGQUIT, &sa_quit, NULL);
sigprocmask(SIG_SETMASK, &oldsigset, NULL);
if (notsetuid) {
- (void)setgid(getgid());
- (void)setuid(getuid());
+ if (setgid(getgid()) == -1)
+ err(1, "setgid");
+ if (setuid(getuid()) == -1)
+ err(1, "setuid");
}
- errno = 0;
execlp(editor, editor, tempname, (char *)NULL);
- _exit(errno);
+ err(1, "%s", editor);
default:
/* parent */
break;
@@ -327,7 +328,9 @@ pw_edit(int notsetuid)
break;
} else if (WIFSTOPPED(pstat)) {
raise(WSTOPSIG(pstat));
- } else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0) {
+ } else if (WIFEXITED(pstat)) {
+ if (WEXITSTATUS(pstat) != 0)
+ errx(1, "\"%s\" exited with status %d", editor, WEXITSTATUS(pstat));
editpid = -1;
break;
} else {