Commit Graph
2737 Commits
Author SHA1 Message Date
Yu Watanabe c60a16ba8f journal: check filtering after parsing timestamp, identifier, pid, and so on
Otherwise, filtering regex with '^' does not work.

Fixes a bug in 87a13dabbd (v253).
Fixes #38361.
2025-07-28 16:29:31 +09:00
Yu Watanabe 8cfffab0e5 journal: clear cached journal storage space before vacuum journals
Otherwise, the cached storage space may be calculated based on the old
journald.conf settings.

Follow-up for 922d037f34 and
df5b3426f6.
2025-07-24 21:18:16 +09:00
Yu Watanabe de69562623 tree-wide: add missing '=' in short comments for function argument 2025-07-22 03:05:54 +09:00
Yu Watanabe 7f6086d530 tree-wide: do not use %m with SYNTHETIC_ERRNO() 2025-07-22 03:05:54 +09:00
Yu Watanabe 922d037f34 journald-manager: rework reopening journal files on reload
Previous implementations had several issues:
- user journals were not updated,
- transition from volatile -> persistent storage transition was not
  handled.

Let's make all journal files closed when at least one journal file
related configurations are changed, and reopen necessary journals with
requested settings.
2025-07-18 15:27:37 +09:00
Yu Watanabe 7b1f842d44 journald-context: update ratelimit interval and burst on reload 2025-07-18 15:27:37 +09:00
Yu Watanabe c029cb45a8 journald-config: ForwardToSocket= is not supported in non-default namespace instance 2025-07-18 15:27:37 +09:00
Yu Watanabe 20f23d13b4 journald-socket: close previous socket when ForwardToSocket= is changed on reload 2025-07-18 15:27:37 +09:00
Yu Watanabe cbf59f4bb2 journald-audit: apply new Audit= setting on reload 2025-07-18 15:27:37 +09:00
Yu Watanabe 884274cbe6 journald-audit: make enable_audit() take Manager object
And rename it to manager_set_kernel_audit(), and make it log failures.
2025-07-18 15:27:37 +09:00
Yu Watanabe 63e990308f journald-kmsg: merge manager_kmsg_mode() into manager_open_dev_kmsg()
As it is now only used by the function.
2025-07-18 15:27:37 +09:00
Yu Watanabe 7bc133fe56 journald-kmsg: fix reopening /dev/kmsg
The previous logic was completely broken:
- the access mode comparison is broken,
- flushing kmsg did not work, as the configuration is already disabled,
- seqnum file is not opened when previously disabled,
- failure in reopening /dev/kmsg should not be critical.

This fixes the above issues.
2025-07-18 15:27:37 +09:00
Yu Watanabe 1416a3df43 journald: introduce manager_unlink_seqnum_file()
Currently unused, but will be used later.
2025-07-18 15:27:37 +09:00
Yu Watanabe 059efb97e3 journald-kmsg: introduce manager_close_kernel_seqnum() helper function 2025-07-18 15:27:37 +09:00
Yu Watanabe 61b1f7d2d3 journald-kmsg: shorten manager_flush_dev_kmsg() a bit 2025-07-18 15:27:37 +09:00
Yu Watanabe f1bd0007c0 journald: rename fuzz-journald.[ch] -> fuzz-journald-util.[ch] 2025-07-18 15:27:37 +09:00
Yu Watanabe 32bd43d768 journald: do not read configs by journald fuzzers 2025-07-18 15:27:37 +09:00
Yu Watanabe f48cf2a96d journald: move all config entries from Manager to JournalConfig
Previously, only config entries controlled by multiple sources were located in
JournalConfig, and still other config entries were in Manager.
That's hard to maintain. Let's move all config entries to JournalConfig.

This also makes JournalConfig.forward_to_kmsg and friends tristate.
Otherwise, even if a higher precedence config source disables the
feature, it may be enabled by a lower precedence config.
2025-07-18 15:27:35 +09:00
Yu Watanabe 9f819a7791 journald-config: modernize config_parse_line_max() and config_parse_forward_to_socket()
No functional change, just refactoring.
2025-07-18 15:27:03 +09:00
Yu Watanabe 208c9cf988 journald-config: always clear threshold_bytes even when boolean value is specified
Otherwise, previously specified threshold may not be cleared.
2025-07-18 15:27:03 +09:00
Yu Watanabe d13a471c45 journald-config: make kernel command line parser take JournalConfig 2025-07-18 15:27:03 +09:00
Yu Watanabe 5b585edd2f journald-config: use char* for credential data
This also slightly update log messages, and make
manager_load_credentials() take JournalConfig.
No functional change, just refactoring.
2025-07-18 15:27:03 +09:00
Yu Watanabe 3941032c6c journald-audit: do not control kernel auditing by non-default namespace instances by default
The kernel (thus system-wide) auditing should not be controlled by
non-default namespace instances, unless explicitly requested.
2025-07-18 15:27:03 +09:00
Yu Watanabe 31b25d4290 journald-manager: use manager_get_file_flags() more
This also adds one missing assertion and drop spurious empty line.
No functional change, just refactoring.
2025-07-18 15:27:03 +09:00
Yu Watanabe a322e43ba9 journald-manager: make manager_get_file_flags() return JournalFileFlags
This also adds a missing assertion.
2025-07-18 15:26:44 +09:00
Yu Watanabe ef69668db2 journald: move several configuration related definitions to journald-config.[ch]
No functional change, just refactoring and preparation for later changes.
2025-07-18 15:25:35 +09:00
Mike Yuan f11e882721 journalctl: track more closely whether we're within --until= range
Follow-up for 81fb5375b3

The offending commit fails to account for the case where
we have fewer lines before --until= than what's specified
in --lines=. Aside from that, if --grep= + --lines=+N are used,
we might also seek forward in the middle of the loop,
breaking the --until= boundary.

Let's turn the logic around then. Context.until_safe will
be set iff we're certain that there's enough to output,
and it gets reset whenever we seek forward.

Fixes #38121
Replaces #38122
2025-07-16 17:01:25 +09:00
DaanDeMeyer bd427d005c journal: Fix socket max level initialization
Follow up for df5b3426f6
2025-07-12 07:18:45 +02:00
Yu Watanabe 4d7851380a Cleanups for missing_xyz.h headers (#37904)
Continuation of #37960.

The same concern as expalined in #37960 exists also in
missing_syscall.h. If we use enough new glibc, a function we want to use
may be already provided by glibc, but our baseline glibc may not. And it
is hard to detect in our daily development.

This moves all prototypes of syscalls to relevant headers, and missing
syscall functions are defined in relevant .c files of libc wrapper. This
way, we can use usual header as is, e.g. when we want to write code with
`move_mount()`, we can simply use sys/mount.h without checking if it is
supported by our baseline glibc.
2025-07-11 15:20:10 +09:00
Yu Watanabe 7b869ff949 journal: fix typo
Follow-up for df5b3426f6.
2025-07-11 14:12:42 +09:00
Yu Watanabe 3fc2a44043 include: move trivial kernel header wrappers to src/include/override/ 2025-07-11 13:05:46 +09:00
Yu Watanabe 390097724b journalctl: do not fail on SIGTERM/SIGINT, or when STDOUT is disconnected
The current behavior is not useful when e.g. pipefail is enabled.
Let's exit cleanly in such cases.

Closes #38114.
2025-07-11 08:41:10 +09:00
Ubuntu df5b3426f6 journald: support reloading configuration at runtime 2025-07-10 21:38:36 +02:00
Yu Watanabe 237bdd2771 basic: move missing_sched.h -> include/sched.h 2025-07-01 12:29:15 +09:00
Yu Watanabe bb66c2e480 basic: move missing_mman.h -> include/sys/mman.h
This also makes memfd-util.h include sys/mman.h, as it is necessary for
specifying flags to memfd_create_wrapper() or memfd_new_full().
2025-07-01 12:27:27 +09:00
Yu Watanabe 4f18ff2e29 tree-wide: include unistd.h where necessary
We use symbols provided by unistd.h without including it. E.g.
open(), close(), read(), write(), access(), symlink(), unlink(), rmdir(),
fsync(), syncfs(), lseek(), ftruncate(), fchown(), dup2(), pipe2(),
getuid(), getgid(), gettid(), getppid(), pipe2(), execv(), _exit(),
environ, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, F_OK, and their
friends and variants, so on.

Currently, unistd.h is indirectly included mainly in the following two paths:
- through missing_syscall.h, which is planned to covert to .c file.
- through signal.h -> bits/sigstksz.h, which is new since glibc-2.34.
  Note, signal.h is included by sd-eevent.h. So, many source files
  indirectly include unistd.h if newer glibc is used.

Currently, our baseline on glibc is 2.31. We need to support glibc older
than 2.34, but unfortunately, we do not have any CI environments with
such old glibc. CIFuzz uses glibc-2.31, but it builds only fuzzers, and
many files are even not compiled.
2025-06-30 09:19:15 +02:00
Zbigniew Jędrzejewski-Szmek 7d247d3cb8 meson: drop explicit custom_target names
[1] says:
> Since 0.60.0 the name argument is optional and defaults to the basename of
> the first output
We specify >= 0.62 as the supported version, so drop the duplicate name in all cases
where it is the same as outputs[0], i.e. almost all cases.

[1] https://mesonbuild.com/Reference-manual_functions.html#custom_target
2025-06-28 17:14:50 +02:00
Yu Watanabe 4ae1589249 tree-wide: reindent arguments of conf parsers
Also fixes 'const char* unit' -> 'const char *unit'.
2025-06-24 00:20:20 +09:00
Mike Yuan 85352c095e various: turn off SO_PASSRIGHTS where fds are not expected 2025-06-17 13:16:44 +02:00
Lennart Poettering d83ceacc7e tree-wide: say in log message that we ignore error conditions of certain sockopts
Follow our usual style on this.

Follow-up for: #37793
2025-06-10 16:34:51 +09:00
Luca Boccassi bb887cf22e socket: downgrade not-supported logging for SO_PASSSEC
Kernel 6.16 started returning EOPNOTSUPP when a required kconfig
is disabled. Downgrade to debug level in that case.

Fixes https://github.com/systemd/systemd/issues/37783
2025-06-09 21:51:39 +02:00
Yu Watanabe 8139906eaa journal: use poll.h rather than sys/poll.h
This does not change anything, as poll.h is a one-line wrapper of sys/poll.h.
Note that man pages e.g. poll(2) indicate to include poll.h rather than sys/poll.h.
So, let's use poll.h.
2025-06-09 22:45:23 +09:00
Daan De Meyer 1b4645d762 forward: Drop socklen_t forward declaration
This is glibc specific and doesn't exist on musl, since removing only
means adding one more include in selinux-util.h, let's drop it.

Fixes #37779
2025-06-08 10:58:56 +09:00
Lennart Poettering 137a8ce14d journalctl: politely refuse if non-root usernames are specified for --machine=
We currently cannot support that (supporting that would probably require
some active component in the machine, or alternatively idmapped mounts
or so), hence politely refuse it.

See: https://github.com/systemd/systemd/issues/32997#issuecomment-2127700945
2025-06-05 12:49:35 +02:00
Zbigniew Jędrzejewski-Szmek 42ba99748d various: do not include file names directly in error messages
git grep -l 'Failed to open /'|xargs sed -r -i 's|"Failed to open (/[^ ]+): %m"|"Failed to open %s: %m", "\1"|g'
git grep -l $'Failed to open \'/'|xargs sed -r -i $'s|"Failed to open \'(/[^ ]+)\': %m"|"Failed to open %s: %m", "\\1"|g'
git grep -l "Failed to open /"|xargs sed -r -i $'s|"Failed to open (/[^ ]+), ignoring: %m"|"Failed to open %s, ignoring: %m", "\\1"|g'
+ some manual fixups.
2025-06-02 11:10:38 +02:00
Lennart Poettering 1105f8d20f tree-wide: only use .si_pid field in siginfo_t, if .si_code indicates that's safe
Fixes: #37498
2025-05-31 14:48:37 +02:00
Mike Yuan 7b4022bdb0 cgroup-util: rename cg_get_xattr_malloc -> cg_get_xattr
This is not a trivial wrapper around user-created-buffer-based
syscall, so do not use _malloc suffix. Most of our functions
return an internally allocated buffer and this one's not special.
2025-05-27 14:28:08 +02:00
Daan De Meyer f1ee656d4d tree-wide: Handle EINVAL as not supported for chattr_xxx()
F2FS returns EINVAL from FS_IOC_SETFLAGS when trying to set
FS_NOCOW_FL. Let's handle this by treating EINVAL as not supported.
While we're at it, make sure we use ERRNO_IS_IOCTL_NOT_SUPPORTED()
across the tree instead of ERRNO_IS_NOT_SUPPORTED() when calling any
of the chattr_xxx() functions.

Fixes #37593
2025-05-26 21:59:08 +02:00
Daan De Meyer b416ac0e15 basic: Move ratelimit logging functions to log-ratelimit.h 2025-05-25 03:28:50 +09:00
Daan De Meyer 1e35e81b2c tree-wide: Clean up includes
Preparation for cleaning up includes in src/shared.
2025-05-22 21:10:15 +02:00