From: Zbigniew Jędrzejewski-Szmek Date: Wed, 16 May 2018 12:02:24 +0000 (+0200) Subject: journal: allow writing journal files even if machine-id is missing X-Git-Tag: v239~172^2~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fd4885df947a23b8f40c08f08ac7f7d13a8abdf4;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 606ca604acf..da663f01964 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);