summaryrefslogtreecommitdiff
path: root/src/journal/journald-server.c
Commit message (Collapse)AuthorAgeFilesLines
* journal: handle EADDRNOTAVAIL in two more cases gracefullyLennart Poettering2023-05-031-0/+1
| | | | Follow-up for #27488.
* Drop log level of header limits log messageDaan De Meyer2023-04-251-4/+3
| | | | | Especially when using in-memory logging, these are too noisy so let's drop them back to debug level.
* tree-wide: copy timestamp data from cmsgYu Watanabe2023-04-161-3/+3
| | | | | | | On RISCV32, time_t is 64bit and size_t is 32bit, hence the timestamp data in message header may not be aligned. Fixes #27241.
* tree-wide: port more code over to CMSG_TYPED_DATA()Lennart Poettering2023-04-131-4/+4
|
* journald: fix log messageYu Watanabe2023-04-041-1/+1
|
* conf: replace config_parse_many_nulstr() with config_parse_config_file()Franck Bui2023-03-141-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.
* journald: hook up journald with the memory pressure and SIGRTMIN+18 logicLennart Poettering2023-03-011-1/+48
|
* 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
* journal-file: drop checking if files are from the future at time of openLennart Poettering2023-02-211-4/+0
| | | | | | | | 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.
* Correct journal misspellWinterhuman2023-02-171-1/+1
|
* journald: maintain entry seqnum counter in mmap()ed file in /run/Lennart Poettering2023-02-081-10/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* 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.
* 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.
* 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: 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`.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-9/+9
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* journald: fix build errorLuca Boccassi2022-12-061-1/+1
| | | | | | Follow-up for: 379864f89079a92ff09917e25b3aea0fadd228ac Two PRs clashed with each other and were merged before we noticed
* log: Switch logging to runtime when FS becomes read-onlyRichard Phibel2022-12-061-0/+8
| | | | | | | | | | | | The journal has a mechanism to log to the runtime journal if it fails to log to the system journal. This mechanism is not triggered when the file system becomes read-only. We enable it here. When appending an entry fails if shall_try_append_again returns true, the journal is rotated. If the FS is read-only, rotation will fail and s->system_journal will be set to NULL. After that, when find_journal will try to open the journal since s->system_journal will be NULL, it will open the runtime journal.
* journal: Use shared log ratelimit constantDaan De Meyer2022-12-051-42/+42
| | | | | Instead of maintaining two different constants, move the constant to journal-internal.h and share it between files.
* tree-wide: make constant ratelimit compound actually constLennart Poettering2022-11-221-1/+1
| | | | | | The compiler should recognize that these are constant expressions, but let's better make this explicit, so that the linker can safely share the initializations all over the place.
* log: Remove log_ratelimit_debug() macrosDaan De Meyer2022-11-171-16/+11
| | | | | These don't make sense anymore since we disable log ratelimiting when logging at debug level.
* journal: Ratelimit more journald log messagesDaan De Meyer2022-11-101-62/+100
| | | | | | systemd-journald is prone to spamming logs if the system gets into a messy state. Let's improve the situation by ratelimiting logs on the hot code paths to 3 times per minute.
* log: Add ratelimit argument to ratelimit log macrosDaan De Meyer2022-11-101-3/+11
| | | | Allows configuring the ratelimit per logging statement.
* basic: create new basic/initrd-util.[ch] for initrd-related functionsZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
| | | | | | | | | I changed imports of util.h to initrd-util.h, or added an import of initrd-util.h, to keep compilation working. It turns out that many files didn't import util.h directly. When viewing the patch, don't be confused by git rename detection logic: a new .c file is added and two functions moved into it.
* core,logind,systemctl,journald: replace calls to strerror() with setting ↵Zbigniew Jędrzejewski-Szmek2022-10-111-1/+2
| | | | | | | | | | | | | errno + %m strerror() is not thread safe and calling it just isn't worth the effort required to justify why it would be safe in those cases. It's easier to just use %m which is thread-safe out of the box. I don't think that any of the changes in the patch cause any functional difference. This is just about getting rid of calls to strerror() in general. When we print an error message and fail to format the string, using something like "(null)" is good enough. This is very very unlikely to happen anyway.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-46/+19
|
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-4/+4
| | | | gcc will complain about all these with -Wformat-signedness.
* journal: rename special journal field _SYSTEM_CONTEXT= → _RUNTIME_SCOPE=Lennart Poettering2022-08-251-5/+1
| | | | | | | | | | | | | | | | | | Previously the field "_SYSTEM_CONTEXT" knew he values "initrd" + "main". Let's change this to "_RUNTIME_SCOPE" and "initrd" + "system". Why? The sysext logic has a very similar concept of "scopes", declaring whether a sysext image is intended for the initrd or the main system. Let's thus use the same naming for both. sysext's extension-release files hence know SYSEXT_SCOPE=initrd|system, and the journal messages know _RUNTIME_SCOPE=initrd|system, which makes this reasonably systematic. Follow-up for: cae8edd93ca2ef90c41cb9b6322b6908d12947b5 (This is not an API break, since no version with this commit has ever been released.)
* journald: use rate-limited logging to log 'Failed to write entry' messageRichard Phibel2022-08-241-3/+3
|
* journal: Add new _INITRD fieldDaan De Meyer2022-08-231-0/+5
| | | | | The _INITRD field is a boolean field (0 or 1) that specifies whether a message was processed by systemd-journald in the initrd or not.
* tree-wide: pass proper values (not bools) to sd_event_source_set_enabled()Lennart Poettering2022-08-191-1/+1
|
* config-parser: Add list of drop-in files as return argument of config_parse_manyRichard Phibel2022-08-121-1/+1
| | | | This will be used to save the list of drop-in files for each partition
* src: The return value of server_vacuum () is not used and could be modified ↵Li kunyu2022-06-011-3/+1
| | | | to void type
* journald: make use of CLAMP() in cache_space_refresh()Franck Bui2022-04-041-1/+1
|
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* Merge pull request #22861 from poettering/journald-sigtermYu Watanabe2022-03-261-3/+73
|\ | | | | journald: don't let SIGTERM starve indefinitely
| * journald: make sure SIGTERM handling doesn't get starved outLennart Poettering2022-03-251-3/+73
| | | | | | | | Fixes: #22642
* | journal-file: merge compress/seal bool args into a single flags paramLennart Poettering2022-03-251-20/+47
|/ | | | | | | Just some modernization/refactoring. No change in behaviour, just let's do how we do things these days: use flags param instead of list of bools.
* journal: Rename JournaldFile to ManagedJournalFileDaan De Meyer2022-02-021-35/+34
| | | | | JournalFile and JournaldFile are hard to distinguish from each other. Let's use ManagedJournalFile instead to make the distinction more clear.
* journal: Log filename when we fail to write an entryDaan De Meyer2022-01-051-2/+2
|