Skip to content

Commit

Permalink
sd-journal: refuse to write entry without boot ID
Browse files Browse the repository at this point in the history
To make journal entries always contain valid boot ID.
  • Loading branch information
yuwata committed Sep 26, 2023
1 parent b761ae0 commit 1eede15
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libsystemd/sd-journal/journal-file.c
Expand Up @@ -2299,6 +2299,7 @@ static int journal_file_append_entry_internal(
assert(f->header);
assert(ts);
assert(boot_id);
assert(!sd_id128_is_null(*boot_id));
assert(items || n_items == 0);

if (f->strict_order) {
Expand Down Expand Up @@ -2528,7 +2529,10 @@ int journal_file_append_entry(
ts = &_ts;
}

if (!boot_id) {
if (boot_id) {
if (sd_id128_is_null(*boot_id))
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "Empty boot ID, refusing entry.");
} else {
r = sd_id128_get_boot(&_boot_id);
if (r < 0)
return r;
Expand Down

0 comments on commit 1eede15

Please sign in to comment.