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

fileio.c: fix incorrect mtime

A regression was introduced that caused the mtime of /etc/.updated
and /var/.updated to be the current time when systemd-update-done
ran instead of being copied from /usr.

This was nearly fixed, but due to fflush being called after mtime
was carefully set, it was overwritten with the current time.

Regression introduced in 872c403963

A fix was just missed in 39c38d773f

Fixes #8806
This commit is contained in:
Chris Lesiak 2018-04-24 09:50:42 -05:00
parent 9dfcc1df07
commit be83711c7e

View File

@ -50,6 +50,7 @@ int write_string_stream_ts(
struct timespec *ts) {
bool needs_nl;
int r;
assert(f);
assert(line);
@ -74,6 +75,13 @@ int write_string_stream_ts(
if (fputc('\n', f) == EOF)
return -errno;
if (flags & WRITE_STRING_FILE_SYNC)
r = fflush_sync_and_check(f);
else
r = fflush_and_check(f);
if (r < 0)
return r;
if (ts) {
struct timespec twice[2] = {*ts, *ts};
@ -81,10 +89,7 @@ int write_string_stream_ts(
return -errno;
}
if (flags & WRITE_STRING_FILE_SYNC)
return fflush_sync_and_check(f);
else
return fflush_and_check(f);
return 0;
}
static int write_string_file_atomic(