summaryrefslogtreecommitdiffstats
path: root/src/journal (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* copy: Move chattr arguments to full function signaturesDaan De Meyer2023-03-211-4/+5
| | | | | These are almost never used, so let's move them to the _full() functions signatures.
* journald-console: Add colors when forwarding to consoleDaan De Meyer2023-03-161-2/+6
| | | | | | Let's color output when we're forwarding to the console. To make this work, we inherit TERM from pid 1 and use it to decide whether we should output colors or not.
* conf: replace config_parse_many_nulstr() with config_parse_config_file()Franck Bui2023-03-131-26/+6
| | | | | | | | | | | | | | | | | All daemons use a similar scheme to read their main config files and theirs drop-ins. The main config files are always stored in /etc/systemd directory and it's easy enough to construct the name of the drop-in directories based on the name of the main config file. Hence the new helper does that internally, which allows to reduce and simplify the args passed previously to config_parse_many_nulstr(). Besides the overall code simplification it results: 16 files changed, 87 insertions(+), 159 deletions(-) it allows to identify clearly the locations in the code where configuration files are parsed.
* Merge pull request #26641 from medhefgo/boot-elf2efiYu Watanabe2023-03-111-1/+2
|\ | | | | boot: Drop gnu-efi / Add elf2efi.py
| * meson: Introduce userspace depJan Janssen2023-03-101-1/+2
| | | | | | | | This will help in a later commit to separate userspace from EFI builds.
* | Merge pull request #26726 from DaanDeMeyer/cleanupsDaan De Meyer2023-03-101-4/+1
|\ \ | |/ |/| Various small cleanups
| * memfd-util: Add memfd_new_and_seal()Daan De Meyer2023-03-091-4/+1
| |
* | journalctl: fix when --since, --until and --lines are used altogetherMike Yuan2023-03-091-1/+6
|/ | | | | | | | | | | | | | | This is a follow-up for #26669 (81fb5375b3b3bfc22d023d7908ad9eee4b3c1ffb). After the mentioned commit, we stopped checking if the entry is within the range of --until if --lines is used. However, when --since, --until and --lines=N are used altogether, and the number of lines between --since and --until is smaller than N, we would seek to --since later (f58269510727964cb5c10e7d2f9849c442ea1f80). This breaks the assumption that if --lines is set, the boundary is never exceeded because the counter of outputs gets us covered.
* journalctl: fix output when --since is used with --linesMike Yuan2023-03-051-11/+31
| | | | | | | | | | Before this commit, if --since is used with --lines=N, we seek to the place of --since and search afterwards there, resulting in outputing the first N lines. After this commit, we only do the above if --since is used without --reverse and --lines. Otherwise we seek to the tail first and check if the entry is within the range of --since later.
* journalctl: fix output when --until is used with --linesMike Yuan2023-03-051-3/+12
| | | | | | | | | | | | Before this commit, when --lines is specified, we jump to the tail and search afterwards from there, thus breaking --until if used together. After this commit: If both --until and any of --reverse and --lines is specified, things get a little tricky. We seek to the place of --until first. If only --reverse or --reverse and --lines is specified, we search backwards and let the output counter handle --lines for us. If only --lines is used, we just jump backwards arg_lines and search afterwards from there.
* journald: hook up journald with the memory pressure and SIGRTMIN+18 logicLennart Poettering2023-03-014-2/+56
|
* journald: remove triplicate logging about failure to write log linesLennart Poettering2023-02-281-11/+7
| | | | | | | | | | | | | | | | | | | Let's log exactly at one place about failed writing of log lines to journal file: in shall_try_append_again(). Then, if we decide to suppress a retry-after-vacuum because we already vacuumed anyway then say this explicitly as "supressed rotation", because that's what we do here. This removes triplicate logging about the same error, and logs exactly once, plus optional one "suppressed rotation" message. (plus more debug output). The triplicate logging was bad in particular because it had no understanding of the actual error codes and just showed generic UNIX error strings ("Not a XENIX named type file"). By relying on shall_try_append_again() to do all logging we now get very clean error strings for all conditions. Fixes: #26496
* journald: always pass error code to logging function, even if we don't use ↵Lennart Poettering2023-02-281-13/+13
| | | | | | | | it with %m We always want to pass the error code along with the log call, so that it can add it to structured logging, even if the format string does not contain %m.
* journald: upgrade log message about missing mmap() support to LOG_ERRLennart Poettering2023-02-281-1/+1
| | | | | in this case we really cannot proceed and fail. Let's log about this loudly, since we simply fail the operation to write anything.
* journald: downgrade various log messages from LOG_WARNING to LOG_INFOLennart Poettering2023-02-281-6/+6
| | | | | | | | | | | | | None of these conditions are real issues, but they can simply happen because we just swtched from /run to /var as backend for logging and there are old files from different boots with different systemd versions and so on. Let's not make more noise than necessary: still log, but not consider it a warning, but just some normal thing. We are handling these issues safely after all: by rotating and starting anew, i.e. there's no reason to be concerned.
* journald: start log message uppercase, like every other one aroundLennart Poettering2023-02-281-1/+1
|
* journald: make sure shall_try_append_again() logs about all return codes ↵Lennart Poettering2023-02-281-0/+1
| | | | passed in, not just some
* Merge pull request #26203 from medhefgo/mesonYu Watanabe2023-02-221-69/+90
|\ | | | | meson: Use dicts for test/fuzzer definitions
| * meson: Use dicts for fuzzer definitionsJan Janssen2023-02-211-35/+47
| |
| * meson: Use dicts for test definitionsJan Janssen2023-02-211-34/+43
| | | | | | | | | | | | | | Although this slightly more verbose it makes it much easier to reason about. The code that produces the tests heavily benefits from this. Test lists are also now sorted by test name.
* | journal-file: drop checking if files are from the future at time of openLennart Poettering2023-02-212-6/+1
| | | | | | | | | | | | | | | | We nowadays check for ordering anyway at time of writing entries, hence we don't have to do that at moment of opening, too. Benefit of dropping this check: we can safely archive files from the future instead of marking them as broken.
* | journal-file: don't update boot_id in journal header on openLennart Poettering2023-02-211-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | The header of the journal file contains a boot ID field that is currently updated whenever we open the journal file. This is not ideal: pretty often we want to archive a journal file, and need to open it for that. Archiving a foreign journal file should not mark it as ours, it should just change the status flag in the file header. The boot ID in the header is aleady rewritten whenever we write a journal entry to the file anyway, hence all this patch effectively does is slightly "delay" when the boot ID in the header is updated: instead of immediately on open it is updated on the first entry that is written. Net effect: archived journal files don't all look like they were written to on a boot newer then they actually were And more importantly: the "tail_entry_monotonic" field suddenly becomes useful, since we know which boot it belongs to. Generally, monotonic timestamps without boot ID information are useless, and this fixes it. A new (compatible) header flag marks file where the boot_id can be understood this way. This can be used by code that wants to make use of the "tail_entry_monotonic" field to ensure it actually can do so safely. This also renames the structure definition in journal-def accordingly, to indicate we now follow the stricter semantics for it.
* journalctl: fix output when --lines is used with --grepMike Yuan2023-02-181-0/+5
| | | | | | | | | | | | Previously, we skip the entries before arg_lines unconditionally, which doesn't behave correctly when used with --grep. After this commit, when a pattern is specified, we don't skip the entries early, but rely on the count of the lines shown to tell us when to stop. To achieve that we would have to search backwards instead. Fixes #25147
* Correct journal misspellWinterhuman2023-02-171-1/+1
|
* dissect-image: Return mount point fd if requestedDaan De Meyer2023-02-171-0/+1
|
* journalctl: fix fd leakYu Watanabe2023-02-171-5/+4
|
* journalctl: use DEFINE_MAIN_FUNCTION() macroYu Watanabe2023-02-171-170/+110
|
* journalctl: actually run the static destructorsFrantisek Sumsal2023-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In journalctl we don't run the static destructors defined via the STATIC_DESTRUCTOR_REGISTER() macro, since it requires a corresponding static_destruct() call. In most cases this is handled by the DEFINE_(TEST_)?MAIN*() macros, but journalctl defines its own main function, so let's handle that as well. $ valgrind --suppressions=valgrind.supp --show-leak-kinds=all --leak-check=full build/journalctl --no-pager -u system.slice -n 10 >/dev/null ==2778093== Memcheck, a memory error detector ==2778093== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==2778093== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info ==2778093== Command: build/journalctl --no-pager -u system.slice -n 10 ==2778093== ==2778093== ==2778093== HEAP SUMMARY: ==2778093== in use at exit: 8,221 bytes in 4 blocks ==2778093== total heap usage: 458 allocs, 454 frees, 255,182 bytes allocated ==2778093== ==2778093== 13 bytes in 1 blocks are still reachable in loss record 1 of 4 ==2778093== at 0x484586F: malloc (vg_replace_malloc.c:381) ==2778093== by 0x4DA256D: strdup (strdup.c:42) ==2778093== by 0x4ADB747: strv_extend_with_size (strv.c:544) ==2778093== by 0x405386: strv_extend (strv.h:45) ==2778093== by 0x40816F: parse_argv (journalctl.c:933) ==2778093== by 0x40EAB5: main (journalctl.c:2111) ==2778093== ==2778093== 16 bytes in 1 blocks are still reachable in loss record 2 of 4 ==2778093== at 0x484578A: malloc (vg_replace_malloc.c:380) ==2778093== by 0x484A70B: realloc (vg_replace_malloc.c:1437) ==2778093== by 0x4ADB2A3: strv_push_with_size (strv.c:423) ==2778093== by 0x4ADB620: strv_consume_with_size (strv.c:496) ==2778093== by 0x4ADB770: strv_extend_with_size (strv.c:548) ==2778093== by 0x405386: strv_extend (strv.h:45) ==2778093== by 0x40816F: parse_argv (journalctl.c:933) ==2778093== by 0x40EAB5: main (journalctl.c:2111) ==2778093== ==2778093== LEAK SUMMARY: ==2778093== definitely lost: 0 bytes in 0 blocks ==2778093== indirectly lost: 0 bytes in 0 blocks ==2778093== possibly lost: 0 bytes in 0 blocks ==2778093== still reachable: 29 bytes in 2 blocks ==2778093== suppressed: 8,192 bytes in 2 blocks ==2778093== ==2778093== For lists of detected and suppressed errors, rerun with: -s ==2778093== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
* journal: cat: set JOURNAL_STREAM before exec-ingMike Yuan2023-02-151-1/+18
| | | | | | | Make the behavior of systemd-cat match that of core/execute. Closes #25880
* Merge pull request #26213 from poettering/journal-rework-seqnumLuca Boccassi2023-02-158-44/+119
|\ | | | | journal sequence number rework
| * journald: maintain entry seqnum counter in mmap()ed file in /run/Lennart Poettering2023-02-088-44/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's ensure that entry seqnums remain stable and monotonic across the entire runtime of the system, even if local storage is turned off. Let's do this by maintainer a counter file in /run/ which we mmap() and wherein we maintain the counter from early-boot on till late shutdown. This takes inspiration of the kernel-seqnum file we already maintain like that that tracks which kmsg messages we already processed. In fact, we reuse the same code for maintaining it. This should allow the behaviour entry seqnums to be more predictable, in particular when journal local storage is turned off. Previously, we'd maintain the seqnum simply by always bumping it to the maximum of the last written entry seqnum plus one, and the biggest seqnum so far written to the journal file on disk. If we'd never write a file on disk, or if no journal file was existing during the initrd→seqnum transition we'd completely lose the current seqnum position during daemon restarts (such as the one happening during the switch-root operation). This also will cause a journal file rotation whenever we try to write to a journal file with multiple sequence number IDs, so that we know that from early boot trhough the entire runtime we'll have stable sequence numbers that do not jump, and thus can be used to determine "lost" messages.
* | journald: fix ignored filtering patterns for delegated cgroupsQuentin Deslandes2023-02-081-3/+7
|/ | | | | | | | If a service defines Delegate=yes, its subcgroup won't inherit the LogFilterPatterns= option, because the option is stored on the unit's cgroup attributes, not on the subcgroup. Fixed by using the unit's cgroup attributes instead.
* test-journal-flush: minor modernizationsLennart Poettering2023-02-011-8/+6
| | | | let's automatically destroy test dirs, instead of manually.
* journald: some minor modernizationsLennart Poettering2023-02-011-8/+27
|
* journald: don't check for -EREMCHG on open, given that open doesn't generate itLennart Poettering2023-01-271-2/+1
| | | | | We generate EREMCHG when writing entries, but not during open, hence don't bother with checking for it.
* journal: use TAKE_PTR() at one more placeLennart Poettering2023-01-271-2/+1
|
* journal: prefix all functions with "server_" that operate on Server objectsLennart Poettering2023-01-261-40/+44
| | | | | | | Just some search/replace, no real code changes. The majority of functions already followed this rule, but some did not. Fix that.
* journald: minor modernizations in kmsg handling codeLennart Poettering2023-01-261-22/+14
| | | | | Nothing earth shattering. Mostly just fixes (and some more careful checking of the boolean variables we keep)
* journal: add some line breaks/commentsLennart Poettering2023-01-251-13/+39
|
* journal-file: make strict order optionalLennart Poettering2023-01-251-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow-up for 1d8d483f59ffa62974772fb58a8ef4abe88550ec and makes the strict ordering by realtime clock within each journal file optional, not mandatory. It then enables it for all journal files written by journald, but leaves it off on others (for example those written by journald-remote). This relaxes the logic behind writing journal files to the status quo ante for all cases where the journal files are not generated, but are merged/processed/propagated. Typically when processing journal records from many files ordering by realtime clock and monotonic clock are contradictory, and cannot be universally guaranteed as the records are interleaved. By enforcing strict rules we would thus end up generating myriads of separate journal files, each with just a few records in them. Hence, let's losen restrictions again, but continue to enforce them in journald, i.e. when we original create the journal files locally. Note that generally there's nothing really wring with having journal files with non-monotonically ordered entries by realtime clock. Looking for records will not be deterministic anymore, but that's inherent to a realtime clock that jumps up and down. So you won't get the "only" answer, but still *a* answer that is correct if you seek for a realtime clock. This also adds similar logic on the monotonic clock, which is also only enabled when generating journal files locally. This should be harder to trigger (as journald will generate the messages, and should run with a stable boot id and monotonic clock), but let's better be safe than sorry, and refuse on the lower layer what makes no sense, even if it's unlikely the higher layer will ever generate records that aren't ordered by their monotonic clock.
* meson: Do not include headers in source listsJan Janssen2023-01-241-13/+0
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* journalctl: don't convert between strv/Set for each log lineLennart Poettering2023-01-201-9/+6
| | | | | | | | If output fields are specified, let's store this in a Set right-away, instead of converting between strv and Set again and again for each line. This is not only faster, but also simpler and shorter.
* tree-wide: Use __func__ in assertsJan Janssen2023-01-181-1/+1
| | | | | | clang puts the whole function signature in __PRETTY_FUNCTION__, which is a bit excessive for something that can already be figured out by using the line number.
* journald: split find_journal() upFranck Bui2023-01-161-28/+44
| | | | No functional change.
* journald: introduce journal_file_parse_uid_from_filename() helperFranck Bui2023-01-161-16/+5
|
* journald: rename vacuum_offline_user_journals()Franck Bui2023-01-161-2/+2
| | | | | | | The name was misleading because the function actually archives offline journals, ie it doesn't try to remove them to make some room. No functional change.
* journal: give the ability to enable/disable systemd-journald-audit.socketFranck Bui2023-01-111-1/+4
| | | | | | | | | | Before this patch the only way to prevent journald from reading the audit messages was to mask systemd-journald-audit.socket. However this had main drawback that downstream couldn't ship the socket disabled by default (beside the fact that masking units is not supposed to be the usual way to disable them). Fixes #15777
* journal: handle clock rollback error in managed_journal_file_open_reliablymsizanoen12023-01-091-1/+2
| | | | | -EREMCHG was introduced to denote a clock rollback detection error. Handle this in managed_journal_file_open_reliably.
* test-journal-flush: don't fail on -EREMCHGmsizanoen12023-01-091-1/+2
| | | | | -EREMCHG on write is now used to denote clock rollback conditions detected during journal write.
* journal: enforce strict consistency for realtime timestamps on writemsizanoen12023-01-091-0/+4
| | | | | | | | | | | | | | Ensure all realtime timestamps in a journal file are strictly ordered on write as a defense-in-depth measure. All known callers of journal_file_append_entry and journal_file_copy_entry, which call this function, should be able to handle the error by rotating the journal. This is especially helpful for systems with RTC local time enabled, where all log entries from initramfs might be recorded as several hours later than it actually is, which won't get caught by journald during log flushing. In those cases, the resulting inconsistency can cause libsystemd to loop infinitely through journal files as observed in `abrt-dump-journal-oops`.