diff options
author | Chris Morin <cmtm@google.com> | 2019-03-14 11:24:52 -0700 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-04-02 10:32:21 +0200 |
commit | 924426a703a6923eedd63d23e6656655805598aa (patch) | |
tree | 72e4095e21e1bfbb6c3dc2e160e19afe86552495 /src/journal-remote | |
parent | 52cf2b13a091c759ed3d2bcab90e1b054c710704 (diff) | |
download | systemd-924426a703a6923eedd63d23e6656655805598aa.tar.gz systemd-924426a703a6923eedd63d23e6656655805598aa.tar.bz2 systemd-924426a703a6923eedd63d23e6656655805598aa.zip |
journal-remote: use source's boot-id
systemd-journal-remote always wrote the boot-id of the device it was running on
to the header of its journal files. When the source had a different boot-id
(because it was generated on a different boot, or a different device), the
boot-ids in the file were inconsistent. The _BOOT_ID field was that of the
source, but the journal file header and each entry object header were that of
the device systemd-journal-remote ran on. This breaks journalctl --list-boots
on any of these files.
Set the boot-id in the header to be that of the source. This also fixes the
entry object headers.
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/journal-remote-parse.c | 6 | ||||
-rw-r--r-- | src/journal-remote/journal-remote-write.c | 5 | ||||
-rw-r--r-- | src/journal-remote/journal-remote-write.h | 1 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index 535d06ac76..ebcae2fcaa 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -68,7 +68,11 @@ int process_source(RemoteSource *source, bool compress, bool seal) { assert(source->importer.iovw.iovec); - r = writer_write(source->writer, &source->importer.iovw, &source->importer.ts, compress, seal); + r = writer_write(source->writer, + &source->importer.iovw, + &source->importer.ts, + &source->importer.boot_id, + compress, seal); if (r == -EBADMSG) { log_error_errno(r, "Entry is invalid, ignoring."); r = 0; diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c index 188ff3582d..ab5e03ab5a 100644 --- a/src/journal-remote/journal-remote-write.c +++ b/src/journal-remote/journal-remote-write.c @@ -59,6 +59,7 @@ DEFINE_TRIVIAL_REF_UNREF_FUNC(Writer, writer, writer_free); int writer_write(Writer *w, struct iovec_wrapper *iovw, dual_timestamp *ts, + sd_id128_t *boot_id, bool compress, bool seal) { int r; @@ -75,7 +76,7 @@ int writer_write(Writer *w, return r; } - r = journal_file_append_entry(w->journal, ts, NULL, + r = journal_file_append_entry(w->journal, ts, boot_id, iovw->iovec, iovw->count, &w->seqnum, NULL, NULL); if (r >= 0) { @@ -93,7 +94,7 @@ int writer_write(Writer *w, log_debug("%s: Successfully rotated journal", w->journal->path); log_debug("Retrying write."); - r = journal_file_append_entry(w->journal, ts, NULL, + r = journal_file_append_entry(w->journal, ts, boot_id, iovw->iovec, iovw->count, &w->seqnum, NULL, NULL); if (r < 0) diff --git a/src/journal-remote/journal-remote-write.h b/src/journal-remote/journal-remote-write.h index e445859ecf..d42256e673 100644 --- a/src/journal-remote/journal-remote-write.h +++ b/src/journal-remote/journal-remote-write.h @@ -28,6 +28,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref); int writer_write(Writer *s, struct iovec_wrapper *iovw, dual_timestamp *ts, + sd_id128_t *boot_id, bool compress, bool seal); |