diff options
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journal-authenticate.c | 19 | ||||
-rw-r--r-- | src/journal/journal-authenticate.h | 2 | ||||
-rw-r--r-- | src/journal/journal-verify.c | 8 | ||||
-rw-r--r-- | src/journal/journalctl.c | 1 | ||||
-rw-r--r-- | src/journal/journald.c | 41 |
5 files changed, 55 insertions, 16 deletions
diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c index 435481000d..fd81797cf9 100644 --- a/src/journal/journal-authenticate.c +++ b/src/journal/journal-authenticate.c @@ -211,6 +211,9 @@ int journal_file_maybe_append_tag(JournalFile *f, uint64_t realtime) { if (!f->seal) return 0; + if (realtime <= 0) + realtime = now(CLOCK_MONOTONIC); + r = journal_file_fsprg_need_evolve(f, realtime); if (r <= 0) return 0; @@ -517,3 +520,19 @@ int journal_file_parse_verification_key(JournalFile *f, const char *key) { return 0; } + +bool journal_file_next_evolve_usec(JournalFile *f, usec_t *u) { + uint64_t epoch; + + assert(f); + assert(u); + + if (!f->seal) + return false; + + epoch = FSPRG_GetEpoch(f->fsprg_state); + + *u = (usec_t) (f->fss_start_usec + f->fss_interval_usec * epoch + f->fss_interval_usec); + + return true; +} diff --git a/src/journal/journal-authenticate.h b/src/journal/journal-authenticate.h index 447c7b4657..3586464d1e 100644 --- a/src/journal/journal-authenticate.h +++ b/src/journal/journal-authenticate.h @@ -40,3 +40,5 @@ int journal_file_parse_verification_key(JournalFile *f, const char *key); int journal_file_fsprg_evolve(JournalFile *f, uint64_t realtime); int journal_file_fsprg_seek(JournalFile *f, uint64_t epoch); + +bool journal_file_next_evolve_usec(JournalFile *f, usec_t *u); diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index 29a9229e53..8604b6e7cb 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -34,14 +34,6 @@ #include "compress.h" #include "fsprg.h" -/* FIXME: - * - * - evolve key even if nothing happened in regular intervals - * - * - check with sparse - * - * */ - static int journal_file_object_verify(JournalFile *f, Object *o) { uint64_t i; diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 1dee74a935..0bbf4a045d 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -233,6 +233,7 @@ static int parse_argv(int argc, char *argv[]) { case ARG_VERIFY_KEY: arg_action = ACTION_VERIFY; arg_verify_key = optarg; + arg_local = true; break; case ARG_INTERVAL: diff --git a/src/journal/journald.c b/src/journal/journald.c index 7b3b6471de..f2dd4050b6 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -48,6 +48,7 @@ #include "journal-rate-limit.h" #include "journal-internal.h" #include "journal-vacuum.h" +#include "journal-authenticate.h" #include "conf-parser.h" #include "journald.h" #include "virt.h" @@ -2969,8 +2970,26 @@ int main(int argc, char *argv[]) { for (;;) { struct epoll_event event; + int t; - r = epoll_wait(server.epoll_fd, &event, 1, -1); +#ifdef HAVE_GCRYPT + usec_t u; + + if (server.system_journal && + journal_file_next_evolve_usec(server.system_journal, &u)) { + usec_t n; + + n = now(CLOCK_MONOTONIC); + + if (n >= u) + t = 0; + else + t = (int) ((u - n + USEC_PER_MSEC - 1) / USEC_PER_MSEC); + } else +#endif + t = -1; + + r = epoll_wait(server.epoll_fd, &event, 1, t); if (r < 0) { if (errno == EINTR) @@ -2979,14 +2998,20 @@ int main(int argc, char *argv[]) { log_error("epoll_wait() failed: %m"); r = -errno; goto finish; - } else if (r == 0) - break; + } - r = process_event(&server, &event); - if (r < 0) - goto finish; - else if (r == 0) - break; + if (r > 0) { + r = process_event(&server, &event); + if (r < 0) + goto finish; + else if (r == 0) + break; + } + +#ifdef HAVE_GCRYPT + if (server.system_journal) + journal_file_maybe_append_tag(server.system_journal, 0); +#endif } log_debug("systemd-journald stopped as pid %lu", (unsigned long) getpid()); |