diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-05-16 14:02:24 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-05-31 13:04:18 +0200 |
commit | fd4885df947a23b8f40c08f08ac7f7d13a8abdf4 (patch) | |
tree | 09dfac1c5f9091e598e3250ada951fd07a531686 /src/journal | |
parent | sd-id128: return -ENOMEDIUM on null id (diff) | |
download | systemd-fd4885df947a23b8f40c08f08ac7f7d13a8abdf4.tar.xz systemd-fd4885df947a23b8f40c08f08ac7f7d13a8abdf4.zip |
journal: allow writing journal files even if machine-id is missing
The code to open journal files seems like the wrong place to enforce this. We
already check during boot and refuse to boot if machine-id is missing, no need
to enforce this here. In particular, it seems better to write logs from
journald even if they are not completely functional rather than refuse to
operate at all, and systemd-journal-remote also writes journal files and may
even be run on a system without systemd at all.
The docker image that oss-fuzz uses has an empty /etc/machine-id. Obviously
this is an error in the docker, but docker is fact of life, and it seems better
for systemd-journal-remote to work in such an incomplete environment.
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journal-file.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 606ca604ac..da663f0196 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -453,7 +453,10 @@ static int journal_file_refresh_header(JournalFile *f) { assert(f->header); r = sd_id128_get_machine(&f->header->machine_id); - if (r < 0) + if (IN_SET(r, -ENOENT, -ENOMEDIUM)) + /* We don't have a machine-id, let's continue without */ + zero(f->header->machine_id); + else if (r < 0) return r; r = sd_id128_get_boot(&boot_id); |