1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

edit-util: do not try to recreate temp file if missing

We initially read from temp file, then strip it, and write
back to it. If the file suddenly disappeared during the process,
it indicates someone else is touching our temp file
behind our back. Let's not silently continue.

(cherry picked from commit 3b5b2ff8fa)
This commit is contained in:
Mike Yuan 2024-08-11 15:41:30 +02:00 committed by Luca Boccassi
parent b628d4dfa6
commit e608023bc8

View File

@ -357,7 +357,7 @@ static int strip_edit_temp_file(EditFile *e) {
return 1; /* Contents have real changes */
r = write_string_file(e->temp, new_contents,
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_TRUNCATE | WRITE_STRING_FILE_AVOID_NEWLINE);
WRITE_STRING_FILE_TRUNCATE | WRITE_STRING_FILE_AVOID_NEWLINE);
if (r < 0)
return log_error_errno(r, "Failed to strip temporary file '%s': %m", e->temp);