summaryrefslogtreecommitdiffstats
path: root/src/journal (follow)
Commit message (Collapse)AuthorAgeFilesLines
* audit-util: return -ENODATA from audit_{session|loginuid}_from_pid() if ↵Lennart Poettering2024-11-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | invoked in a container The auditing subsystem is still not virtualized for containers, hence the two values don't really make sense inside them, they will just leak information from outside into the container. Hence don't make use of the data if we detect we are run inside of a container. This has visible effects: logind will no longer try to reuse the auditing session ids as its own session ids when run inside a container. While are at it, modernize the calls in more ways: 1. switch to pidref behaviour, all but one of our uses are using pidref anyway already. 2. use read_virtual_file() + proc_mounted() 3. reasonable distinguish ENOENT errors when reading the process proc files: distinguish the case where /proc is not mounted, from the case where the process is already gone, from where auditing is not enabled in the kernel build.
* Fix display of qrcodes by bsod and other related cleanups (#34914)Lennart Poettering2024-10-302-7/+7
|\
| * cryptenroll,homectl,journalctl: adjust messages before qrcodesZbigniew Jędrzejewski-Szmek2024-10-301-3/+1
| | | | | | | | | | | | | | | | | | | | Users will generally know what a qrcode is, so let's not treat them as dumb and explain that it can be scanned. OTOH, we should say what the qrcode contains and it is useful to give a hint why the users would want to scan it. Reword messages accordingly. (Also, don't say "to your phone", when somebody might be using a stolen phone, or something else then a phone.)
| * bsod: make message for qrcode more usefulZbigniew Jędrzejewski-Szmek2024-10-301-4/+4
| | | | | | | | | | | | | | People know what a qrcode is. We don't need to tell them to scan it. Instead, we should say what the code contains. While at it, rename "stream" to "f" in line with the usual style.
| * bsod: do not check for color supportZbigniew Jędrzejewski-Szmek2024-10-291-1/+3
| | | | | | | | | | | | When invoked on a running system, bsod would not print the qrcode. The check for "color support" on stdout is pointless, since we're not printing to stdout but to a terminal fd that is opened separately.
* | sd-json,tree-wide: add sd_json_format_enabled() and use it everwhereZbigniew Jędrzejewski-Szmek2024-10-281-1/+1
|/ | | | | | | | | | | | | | | | | | | We often used a pattern like if (!FLAGS_SET(flags, SD_JSON_FORMAT_OFF)), which is rather verbose and also contains a double negative, which we try to avoid. Add a little helper to avoid an explicit bit check. This change clarifies an aditional thing: in some cases we treated SD_JSON_FORMAT_OFF as a flag (flags & SD_JSON_FORMAT_OFF), while in other cases we treated it as an independent enum value (flags == SD_JSON_FORMAT_OFF). In the first form, flags like SD_JSON_FORMAT_SSE do _not_ turn the json output on, while in the second form they do. Let's use the first form everywhere. No functional change intended. Initially I wasn't sure if this helper should be made public or just internal, but it seems such a common pattern that if we expose the flags, we might just as well expose it too, to make life easier for any consumers.
* journalctl: do not directly use optarg, but copy optarg before useYu Watanabe2024-10-162-29/+57
| | | | | | | Otherwise, if the process forks child processes, then the arguments cannot be used from them. To avoid potential issues like the one fixed by 6d3012bab4ce4c1ed260598d05b4e9f2ea471658.
* journalctl: erase verify key before freeYu Watanabe2024-10-161-4/+6
| | | | | Even optarg is erased, copied string was not erased. Let's erase the copied key for safety.
* tree-wide: drop doubled empty linesYu Watanabe2024-10-071-1/+0
|
* basic/memory-util: introduce mempcpy_typesafeMike Yuan2024-09-202-8/+8
|
* tree-wide: make sigprocmask() changes more automaticLennart Poettering2024-09-131-8/+6
| | | | | | | | | | | | | This tries to get rid of most manual sigprocmask() changes, in favour of: 1. The SD_EVENT_SIGNAL_PROCMASK flag to sd_event_add_signal() 2. The sd_event_set_signal_exit() call for handling SIGTERM/SIGINT 3. Move masking of SIGWINCH into ptyfwd, out of nspawn/vmspawn/run And while we are at it get rid of a bunch of event source fields whose lifetime is bound to the sd_event object they belong to anyway, and make use of the "floating" event source feature of sd-event instead.
* journald: mention the access mode we tried to open /dev/kmsg inLennart Poettering2024-09-061-6/+4
| | | | | | | | | | Let's make clearer what we are going to use /dev/kmsg for: read/write or just writing. This hopefully should avoid confusion, such as the one #33975 is result of. (Also while we are at it, add one extra debug message). Fixes: #33975
* time-util: rework localtime_or_gmtime() into localtime_or_gmtime_usec()Lennart Poettering2024-09-051-3/+1
| | | | | | | | | | | | We typically want to deal in usec_t, hence let's change the prototype accordingly, and do proper range checks. Also, make sure are not confused by negative times. Do something similar for mktime_or_timegm(). This is a more comprehensive alternative to #34065 Replaces: #34065
* socket-util: make recvmsg_safe() handle MSG_TRUNC tooMike Yuan2024-09-041-18/+21
| | | | Also, unify MSG_TRUNC handling all across the codebase.
* tree-wide: drop msg argument for DEFINE_CONFIG_PARSE() macro and friendsYu Watanabe2024-09-011-2/+2
| | | | | This makes the macros use log_syntax_parse_error(), hopefully which provides more informative log message in general, and reduces binary size.
* shared/logs-show: introduce journal_browse_prepare()Mike Yuan2024-08-222-9/+3
| | | | which combines sigbus_install() and bumping fd limit.
* tree-wide: use isatty_safe() moreLennart Poettering2024-08-201-1/+1
|
* Merge pull request #33944 from yuwata/journal-max-retention-secLuca Boccassi2024-08-052-3/+2
|\ | | | | journal: do not rotate journal when MaxRetentionSec= is set
| * journal: comment the default value in journald.confYu Watanabe2024-08-051-1/+1
| |
| * journal: do not rotate journal when MaxRetentionSec= is setYu Watanabe2024-08-051-2/+1
| | | | | | | | | | | | | | | | The setting is about vacuuming archived journal files. It is not necessary to rotate the current journal. Note, journal file rotation is controlled by MaxFileSec=. Fixes #31315.
* | journal: set flushed flag even if we fail to open runtime journalsYu Watanabe2024-08-051-3/+4
|/ | | | | | | As at this stage, a persistent journal file has been already opened, and saved seqnum has been reset, and any later journal entries will be stored to the file. Hence we should not open the runtime journal file by server_system_journal_open() again.
* journalctl: fix compile error on i386Yu Watanabe2024-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Fixes the following error: === In file included from ../src/basic/macro.h:13, from ../src/basic/dirent-util.h:8, from ../src/journal/journalctl-misc.c:3: ../src/journal/journalctl-misc.c: In function 'show_log_ids': ../src/journal/journalctl-misc.c:107:22: error: comparison is always true due to limited range of data type [-Werror=type-limits] 107 | assert(n_ids < INT64_MAX); | ^ ../src/fundamental/macro-fundamental.h:70:44: note: in definition of macro '_unlikely_' 70 | #define _unlikely_(x) (__builtin_expect(!!(x), 0)) | ^ ../src/basic/macro.h:165:22: note: in expansion of macro 'assert_message_se' 165 | #define assert(expr) assert_message_se(expr, #expr) | ^~~~~~~~~~~~~~~~~ ../src/journal/journalctl-misc.c:107:9: note: in expansion of macro 'assert' 107 | assert(n_ids < INT64_MAX); | ^~~~~~ cc1: all warnings being treated as errors === Follow-up for 0a8c1f6212a874b542a57ed5416e7d3575d2da93.
* journalctl: add --list-invocations command and -I/--invocation optionsYu Watanabe2024-08-017-9/+189
| | | | | | | | | The --list-invocations command is similar to --list-boots, but shows invocation IDs of specified unit. This should be useful when showing a specific invocation of a unit. The --invocation option is similar to --boot, but takes a invocation ID or an offset. The -I option is equivalent to --invocation=0.
* use int64_t for index in show_log_ids()Yu Watanabe2024-08-011-5/+6
|
* journalctl: split out show_log_ids() from action_list_boots()Yu Watanabe2024-08-011-21/+31
| | | | No functional change, just refactoring and prepraration for later change.
* journalctl: update log messagesYu Watanabe2024-08-011-2/+2
|
* logs-show: rename BootId -> LogIdYu Watanabe2024-08-011-8/+8
| | | | | | | The struct itself is generic, and can be used for other ID. Let's rename it to more generic one. No functional change, just refactoring and preparation for later commits.
* terminal-util: split out color macros/helpers into its own headerLennart Poettering2024-07-192-0/+2
| | | | | | | | | This is a lot of stuff, and sometimes quite wild, let's turn this into its own header. All stuff color-related that just generates sequences is now in ansi-color.h (no .c file!), and everything more complex that probes/ineracts with terminals remains in termina-util.[ch]
* terminal-util: rename set_terminal_cursor_position() → ↵Lennart Poettering2024-07-191-3/+3
| | | | | | | | terminal_set_cursor_position() Let's prefix these functions with the subsystem name, and clean them up a bit. Specifically, drop the error logging, it's entirely duplicative, since every single caller does it anyway.
* sd-varlink: make our internal Varlink API public as sd-varlink.[ch]Lennart Poettering2024-07-163-44/+46
| | | | | | | | | | It's time. sd-json was already done earlier in this cycle, let's now make sd-varlink public too. This is mostly just a search/replace job of epical proportions. I left some functions internal (mostly IDL handling), and I turned some static inline calls into regular calls.
* Merge pull request #33401 from yuwata/journal-revert-source-boottime-timestampMike Yuan2024-06-241-4/+2
|\ | | | | journal: partially revert recent changes
| * journal: drop mapping from CLOCK_BOOTTIME -> CLOCK_MONOTONICYu Watanabe2024-06-191-4/+2
| | | | | | | | | | | | | | | | | | This partially reverts commit a9357c2ce2d188b5b63592fd271f14d335867c23. Some kmsg sent before sleep may be received by systemd-journald after sleep. In that case, map_clock_usec() does not provide correct timestamp. So, we cannot provide reliable _SOURCE_MONOTONIC_TIMESTAMP.
* | various: move const ptr indicator to return valueZbigniew Jędrzejewski-Szmek2024-06-191-2/+2
|/
* journal: introduce _SOURCE_BOOTTIME_TIMESTAMP fieldYu Watanabe2024-06-181-3/+11
| | | | | | | | | Then, fix the monotonic timestamp. The _SOURCE_MONOTONIC_TIMESTAMP field is already used in other projects. Hence, we cannot remove the field. But, let's store the correct value. The existence of the new _SOURCE_BOOTTIME_TIMESTAMP field can indicate that the monotonic timestamp field is reliable or not.
* libsystemd: turn json.[ch] into a public APILennart Poettering2024-06-125-14/+15
| | | | | | | | | | | | | | | This is preparation for making our Varlink API a public API. Since our Varlink API is built on top of our JSON API we need to make that public first (it's a nice API, but JSON APIs there are already enough, this is purely about the Varlink angle). I made most of the json.h APIs public, and just placed them in sd-json.h. Sometimes I wasn't so sure however, since the underlying data structures would have to be made public too. If in doubt I didn#t risk it, and moved the relevant API to src/libsystemd/sd-json/json-util.h instead (without any sd_* symbol prefixes). This is mostly a giant search/replace patch.
* various: remove unnecessary check before sd_event_source_set_enabled()Zbigniew Jędrzejewski-Szmek2024-05-301-6/+4
| | | | sd_event_source_set_enabled() does the same check internally.
* journald: always unset flushed flag when the runtime journal is openedYu Watanabe2024-05-251-6/+15
| | | | | | If the runtime journal is opened, we will anyway write journal entries to the runtime journal, even if the persistent journal is writable. Hence, we need to flush the runtime journal file later.
* journald: log removal of runtime journal directoriesYu Watanabe2024-05-251-3/+12
|
* journald: close runtime journal earlierYu Watanabe2024-05-251-4/+5
| | | | | Then, we can use SD_JOURNAL_ASSUME_IMMUTABLE flag, and the performance of reading runtime journal should be improved.
* journald-server: drop another invalid assert()David Tardon2024-05-161-1/+0
| | | | | | | config_parse_forward_to_socket() is not used for parsing unit files either. Follow-up-for: f31cff849d3db074d0d8157e4117d9b8372c03e8
* journald-server: drop invalid assert()David Tardon2024-05-161-1/+0
| | | | | | | | | config_parse_compress() is not used for parsing unit files, hence unit is always NULL. Fixes #32856 Follow-up-for: 6813be2eba24a2f864d5d47326437dbff38cd675
* journal-rate-limit: replace in-house management of JournalRateLimitGroup ↵Yu Watanabe2024-05-135-123/+60
| | | | | | with OrderedHashmap No functional change, just refactoring.
* journal-rate-limit: split out journal_ratelimit_group_acquire()Yu Watanabe2024-05-121-18/+37
| | | | No functional change, just refactoring.
* journal-rate-limit: introduce cleanup function for JournalRateLimitGroupYu Watanabe2024-05-121-18/+21
| | | | This also makes journal_ratelimit_group_new() use structured initializer.
* journal-rate-limit: rename variablesYu Watanabe2024-05-122-15/+33
| | | | 'r' is usually used for storing return value.
* journal-rate-limit: use FOREACH_ELEMENT() and usec_add()Yu Watanabe2024-05-121-5/+3
|
* journal-rate-limit: make journal_ratelimit_group_free() return NULLYu Watanabe2024-05-121-3/+4
| | | | To make it follow our recent coding style.
* journal-rate-limit: add trailing comma in tableYu Watanabe2024-05-121-1/+1
|
* test: introduce test cases for journal_ratelimit_test()Yu Watanabe2024-05-122-0/+50
|
* tree-wide: use LOG_PRI() and LOG_FAC()Yu Watanabe2024-05-125-9/+15
|