Skip to content

Commit 2495425

Browse files
committed
visudo: further reduce the number of sudo_fatal() calls
Memory allocation errors still use sudo_fatalx().
1 parent abf187d commit 2495425

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

plugins/sudoers/visudo.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,10 @@ install_sudoers(struct sudoersfile *sp, bool set_owner, bool set_mode)
808808
*/
809809
if (!set_owner || !set_mode) {
810810
/* Preserve owner/perms of the existing file. */
811-
if (fstat(sp->fd, &sb) == -1)
812-
sudo_fatal(U_("unable to stat %s"), sp->opath);
811+
if (fstat(sp->fd, &sb) == -1) {
812+
sudo_warn(U_("unable to stat %s"), sp->opath);
813+
goto done;
814+
}
813815
}
814816
if (set_owner) {
815817
if (chown(sp->tpath, sudoers_file_uid(), sudoers_file_gid()) != 0) {
@@ -942,8 +944,10 @@ run_command(const char *path, char *const *argv)
942944

943945
switch (pid = sudo_debug_fork()) {
944946
case -1:
945-
sudo_fatal(U_("unable to execute %s"), path);
947+
sudo_warn(U_("unable to execute %s"), path);
948+
debug_return_int(-1);
946949
case 0:
950+
/* child */
947951
closefrom(STDERR_FILENO + 1);
948952
execv(path, argv);
949953
sudo_warn(U_("unable to run %s"), path);

0 commit comments

Comments
 (0)