From 07f1c7aa9db7a98e0ba1eb1b0d42f171925fc5eb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Feb 2023 12:23:54 +0100 Subject: [PATCH] journal-file: allow opening journal files for write when machine ID is not initialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We allow reading them, and we allow creating them, but we so far did not allow opening existing ones for write – if the machine ID is not initialized. Let's fix that. (This is just to fix an asymmetry. I have no immediate use for this. But test code should in theory be able to use this, if it runs in an incompletely initialized environment.) --- src/libsystemd/sd-journal/journal-file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 3e721ef937..05c66815ae 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -511,8 +511,12 @@ static int journal_file_verify_header(JournalFile *f) { int r; r = sd_id128_get_machine(&machine_id); - if (r < 0) - return r; + if (r < 0) { + if (!ERRNO_IS_MACHINE_ID_UNSET(r)) /* handle graceful if machine ID is not initialized yet */ + return r; + + machine_id = SD_ID128_NULL; + } if (!sd_id128_equal(machine_id, f->header->machine_id)) return log_debug_errno(SYNTHETIC_ERRNO(EHOSTDOWN),