From 0bd39701b4018896788712ac3e8aa732458b8fe1 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 21 Apr 2020 11:05:30 -0600 Subject: [PATCH] Do not remove sudoedit temporary files if we cannot overwrite the real file. The warning message says the files were preserved but they actually got removed. --- src/sudo_edit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sudo_edit.c b/src/sudo_edit.c index d99a5658a..0b67ca0cf 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -1110,8 +1110,10 @@ sudo_edit(struct command_details *command_details) else #endif errors = sudo_edit_copy_tfiles(command_details, tf, nfiles, times); - if (errors) - goto cleanup; + if (errors) { + /* Preserve the edited temporary files. */ + rc = W_EXITCODE(1, 0); + } for (i = 0; i < nfiles; i++) free(tf[i].tfile);