Commit Graph
81385 Commits
Author SHA1 Message Date
Igor Opaniuk 6f7639f0fe man: fix systemd-boot-clear-sysfail description
Fix s/systemd-boot-random-seed/systemd-boot-clear-sysfail/g
copypaste.

Fixes: https://github.com/systemd/systemd/issues/37415
Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
2025-05-14 09:33:57 +02:00
Mike Yuan b431092675 Update description and uid checks when invoking pager (#37419) 2025-05-14 03:01:41 +02:00
Yu Watanabe 5884fafcd7 systemctl: make systemctl clean --what= values more discoverable (#37418) 2025-05-14 02:16:47 +09:00
Daan De Meyer 8ebe9f1da2 Prepare for reducing transitive includes in tests.h (#37414) 2025-05-13 19:02:12 +02:00
Zbigniew Jędrzejewski-Szmek cd93478af8 pager: also check for $SUDO_UID
This returns to the original approach proposed in
https://github.com/systemd/systemd/pull/17270. After review, the approach was
changed to use sd_pid_get_owner_uid() instead. Back then, when running in a
typical graphical session, sd_pid_get_owner_uid() would usually return the user
UID, and when running under sudo, geteuid() would return 0, so we'd trigger the
secure path.

sudo may allocate a new session if is invoked outside of a session (depending
on the PAM config). Since nowadays desktop environments usually start the user
shell through user units, the typical shell in a terminal emulator is not part
of a session, and when sudo is invoked, a new session is allocated, and
sd_pid_get_owner_uid() returns 0 too. Technically, the code still works as
documented in the man page, but in the common case, it doesn't do the expected
thing.

$ build/test-sd-login |& rg 'get_(owner_uid|cgroup|session)'
sd_pid_get_session(0) → No data available
sd_pid_get_owner_uid(0) → 1000
sd_pid_get_cgroup(0) → /user.slice/user-1000.slice/user@1000.service/app.slice/app-ghostty-transient-5088.scope/surfaces/556FAF50BA40.scope

$ sudo build/test-sd-login |& rg 'get_(owner_uid|cgroup|session)'
sd_pid_get_session(0) → c289
sd_pid_get_owner_uid(0) → 0
sd_pid_get_cgroup(0) → /user.slice/user-0.slice/session-c289.scope

I think it's worth checking for sudo because it is a common case used by users.
There obviously are other mechanims, so the man page is extended to say that
only some common mechanisms are supported, and to (again) recommend setting
SYSTEMD_LESSSECURE explicitly. The other option would be to set "secure mode"
by default. But this would create an inconvenience for users doing the right
thing, running systemctl and other tools directly, because then they can't run
privileged commands from the pager, e.g. to save the output to a file. (Or the
user would need to explicitly set SYSTEMD_LESSSECURE. One option would be to
set it always in the environment and to rely on sudo and other tools stripping
it from the environment before running privileged code. But that is also fairly
fragile and it obviously relies on the user doing a complicated setup to
support a fairly common use case. I think this decreases usability of the
system quite a bit. I don't think we should build solutions that work in
priniciple, but are painfully inconvenient in common cases.)

Fixes https://yeswehack.com/vulnerability-center/reports/346802.

Also see https://github.com/polkit-org/polkit/pull/562, which adds support for
$SUDO_UID/$SUDO_GID to pkexec.
2025-05-13 18:08:49 +02:00
Lennart Poettering 44beeef7be systemctl: add "systemctl start -v" mode, which shows unit's logs while starting the unit (#36858) 2025-05-13 18:03:16 +02:00
Jörg Behrmann 68b6289a9e systemct: show all in output of systemctl clean --what=help 2025-05-13 17:21:02 +02:00
Jörg Behrmann 652e4dd743 man: note for systemctl clean --what that commas separate values 2025-05-13 17:20:37 +02:00
Jörg Behrmann 028de7292d man, systemctl: document --what=help 2025-05-13 17:19:39 +02:00
Jörg Behrmann 5689365a90 man: add missing fdstore in systemctl clean --what documentation 2025-05-13 17:19:02 +02:00
Yu Watanabe f51c6da8a7 hwdb: add bladeRF SDR devices (#37413) 2025-05-13 23:44:29 +09:00
Lennart Poettering 682413d577 bash: add shell completion
No idea what I am doing, but this might be enough.
2025-05-13 15:39:57 +02:00
Lennart Poettering bbc4cf83b7 update TODO 2025-05-13 15:39:57 +02:00
Lennart Poettering 559795fa46 compress: deal with zstd decoder issues gracefully
If zstd frames are corrupted the initial size returned for the current
frame might be wrong. Don#t assert() on that, but handle it gracefully,
as EBADMSG
2025-05-13 15:39:57 +02:00
Lennart Poettering 6427d0fbed logs-show: use memory_startswith() rather than startswith()
Let's be strict here: this data is conceptually not NUL terminated,
hence use memory_startswith() rather than startswith() (which implies
NUL termination). All other similar cases in logs-show.c got this right.
Fix the remaining three, too.
2025-05-13 15:39:57 +02:00
Lennart Poettering 010e2562dd logs-show: handle bad messages like EOF
Similar to the previous commit, but for logs-show.c
2025-05-13 15:39:57 +02:00
Lennart Poettering 3a8d562a21 logs-show: drop unused function parameter 2025-05-13 15:39:57 +02:00
Lennart Poettering cf2d660f2f journal-upload-journal: handle partially written fields gracefully
With the more efficient sync semantics it's more likely that
journal-upload-journal will try to read a partially written message.
Previously we'd fail then. Let's instead treat this gracefully,
expecting that this is either the end or will be fixed shortly (and
we'll get notified via inotify about it and recheck).
2025-05-13 15:39:57 +02:00
Lennart Poettering 3017ddfcc8 journal-upload-journal: reduce indentation a bit 2025-05-13 15:39:57 +02:00
Lennart Poettering 6f77c31f63 journal-remote: destroy event sources before MHD context
The MHD context owns the fd we watch via our event source, hence when we
destroy the context before the event source the event source might still
reference the fd that is now invalid. Hence swap the order.
2025-05-13 15:39:57 +02:00
Lennart Poettering f9b186c21a test: add test for "systemd-run -v" 2025-05-13 15:39:57 +02:00
Lennart Poettering 6e9deb8f7b run: rework final status output to be based on format-table.h APIs 2025-05-13 15:39:57 +02:00
Lennart Poettering d548e1d860 run: split out result display code into separate helper call 2025-05-13 15:39:57 +02:00
Lennart Poettering a388f007e0 journald: make journal Varlink IPC accessible to unpriv clients
The Synchronize() function is just too useful for clients, so that we
can make "systemd-run -v --user" actually useful. Hence let's make the
socket accessible without privs. Deny most method calls however, except
for the Synchronize() call.
2025-05-13 15:39:57 +02:00
Lennart Poettering 0aaae3eb3d journalctl: make Synchronize() call more lighweight, by not asking for offlining 2025-05-13 15:39:57 +02:00
Lennart Poettering fb687fe62a journald: rework the Synchronize() varlink logic
Previously, if the Synchronize() varlink call is issued we'd wait for
journald to become idle before returning success. That is problematic
however: on a busy system journald might never become idle. Hence, let's
beef up the logic to ensure that we do not wait longer than necessary:
i.e. we make sure we process any data enqueued before the sync request
was submitted, but not more.

Implementing this isn't trivial unfortunately. To deal with this
reasonably, we need to determine somehow for incoming log messages
whether they are from before or after the point in time where the sync
requested was received.

For AF_UNIX/SOCK_DGRAM we can use SO_TIMESTAMP to directly compare
timestamps of incoming messages with the timestamp of the sync request
(unfortunately only CLOCK_REALTIME).

For AF_UNIX/SOCK_STREAM we can call SIOCINQ at the moment we initiate
the sync, and then continue processing incoming traffic, counting down
the bytes until the SIOCINQ returned bytes have been processed. All
further data must have been enqueued later hence.

With those two mechanisms in place we can relatively reliably
synchronize the journal.

This also adds a boolean argument "offline" to the Synchronize() call,
which controls whether to offline the journal after processing the
pending messages. it defaults to true, for compat with the status quo
ante. But for most cases the offlining is probably not necessary, and is
cheaper to do without, hence allow not to do it.
2025-05-13 15:39:57 +02:00
Lennart Poettering a7550558fb journald: downgrade event source priority of kmsg to same as native/syslog inputs
So far we schduled kmsg events at higher priority than native/syslog
ones. But that's quite problematic, since it means that kmsg events can
drown out native/syslog log events. And this actually shows up in some
CI tests.

Address that, and schedule all three sources at the same priority, so
that the earlier event always is processed first, regarding which
protocol is used.
2025-05-13 15:39:57 +02:00
Lennart Poettering c8aff47a9c systemctl: add --verbose mode 2025-05-13 15:39:57 +02:00
Lennart Poettering 744ca8f616 run: add --verbose mode 2025-05-13 15:39:57 +02:00
Lennart Poettering d2f45c7681 journalctl: optionally delay --follow exit for a journal synchronization
Let's optionally issue a Varlink Synchronize() call in --follow mode
when asked to terminate. This is useful so that the tool can be called
and it is guaranteed it processed all messages generated before the
request to exit before it exits.

We want this in "systemd-run -v" in particular, so that we can be sure
we are not missing any log output from the invoked service before it
exits
2025-05-13 15:39:57 +02:00
Lennart Poettering 5be930db9f journalctl: make arg_image_policy non-static, just like all other arg_xyz variables
Some refactoring to normalize behaviour here, and make arg_image_policy
less special for no reason.
2025-05-13 15:38:36 +02:00
Lennart Poettering a18b80b15d fork-journal: add helpers for spawning off journalctl from 'systemctl start' or 'systemd-run'
This is modelled after the polkit or askpw agents, but simply invokes
journalctl for the specified unit name, to show logs.
2025-05-13 15:38:36 +02:00
Ryan Thompson eea9ba8409 hwdb: append ID_SOFTWARE_RADIO to hwdb parser 2025-05-13 08:09:55 -05:00
Ryan Thompson 951e8cb060 hwdb: add bladeRF SDR devices
Add hwdb entries for bladeRF 1.x, legacy 1.x, and 2.0 micro devices to
enable non-root access through preexisting ID_SOFTWARE_RADIO tag.

References #20561
2025-05-13 08:09:55 -05:00
Lennart Poettering a067173fd0 journalctl: send READY=1
Allow callers to synchronize on the point in time where the journal file
watches are fully established, in --follow mode.

Tools can invoke journalctl using this, knowing that any log message
happening after the READY=1 is definitely going to be processed by the
journalctl invocation.
2025-05-13 14:42:34 +02:00
Lennart Poettering ac3caa2f77 journalctl: if there's not a single matching log entry, seek to head 2025-05-13 14:42:34 +02:00
Lennart Poettering 80ab0e04d3 test: add sync request until all logging about the test unit is done 2025-05-13 14:42:34 +02:00
Lennart Poettering daf96eea73 journald: use log_warning_errno() where appropriate 2025-05-13 14:42:34 +02:00
Lennart Poettering 4a3bf440f2 socket-util: add af_unix_get_qlen() helper to determine number of queued connections on AF_UNIX listener socket 2025-05-13 14:42:34 +02:00
Lennart Poettering 89e546e927 sd-netlink: add minimal support for sock_diag netlink sockets
This is just enough of the type info to determine AF_UNIX queue lengths
information.
2025-05-13 14:42:34 +02:00
Lennart Poettering 6e196011ca sd-netlink: allow configuration of flags parameter when creating message object
We soon want to add for sock_diag(7) netlink sockets. Those reuse the
same message type codes for request and response but with different
message formats. Hence we need to look at NLM_F_REQUEST to determine
which message policy to apply. Hence it is essential to know the flags
parameters right away when creating a message, since we cannot do early
validation otherwise.

This only adds support for setting the flags value right at the moment
of creation of the message object, it does not otherwise add
sock_diag(7) support, that is added in a later message.

This also corrects the flag for synthetic NLMSG_ERROR messages which
should not have the NLM_F_REQUEST flag set (since they are responses,
not requests).
2025-05-13 14:42:33 +02:00
Lennart Poettering a2ab433a60 socket-util: make return parameter to socket_autobind() optional 2025-05-13 14:42:33 +02:00
Lennart Poettering 0da0b3f81d notify-recv: optionally return event source from notify_socket_prepare() 2025-05-13 14:42:33 +02:00
Daan De Meyer a16f650bd4 meson: Add missing conditions
Follow up for 6350d2dbd9
2025-05-13 14:07:42 +02:00
Daan De Meyer cfc9d3bef9 tests.h: Get rid of TEST_REQ_RUNNING_SYSTEMD()
This only has a single user, let's just inline it and get rid of
the macro.
2025-05-13 13:52:49 +02:00
Daan De Meyer 22571018e2 tests.h: Move some implementation details into tests.c. 2025-05-13 13:52:46 +02:00
Daan De Meyer e4e8946a16 core: introduce io.systemd.Manager.Describe method (#35098)
Let's extend pid1's varlink interface and add a Describe method to get
the global Manager object information as a JSON object
(io.systemd.Manager.Describe).

Because the new varlink interface should be available on both the user
managers and the system manager, we also make the necessary changes to
expose a varlink server on user managers.

This PR is first part of https://github.com/systemd/systemd/pull/33965
with minimal changes to address feedback.

Fixes: #22654
2025-05-13 11:57:58 +02:00
Lennart Poettering f9d76a8d15 sd-boot: add support for a sysfail entry (#34856)
Add support for a sysfail boot entry. Sysfail boot entries can be used
for optional tweaking the automatic selection order in case a failure
state of the system in some form is detected (boot firmware failure
etc).

The EFI variable `LoaderEntrySysFail` contains the sysfail boot loader
entry to use. It can be set using bootctl:
```
$ bootctl set-sysfail sysfail.conf
```

The `LoaderEntrySysFail` EFI variable would be unset automatically
during next boot by `systemd-boot-clear-sysfail.service` if no system
failure occured, otherwise it would be kept as it is and a system
failure reason will be saved to `LoaderSysFailReason` EFI variable.

`sysfail_check()` expected to be extented to support possibleconditions
when we should boot sysfail("recovery") boot entry.

Also add support for using a sysfail boot entry in case of UEFI firmware
capsule update failure [1]. The status of a firmware update is obtained
from the EFI System Resource Table (ESRT), which provides an optional
mechanism for identifying device and system firmware resources for the
purposes of targeting firmware updates to those resources.
    
Current implementation uses the value of LastAttemptStatus field from
ESRT, which describes the result of the last firmware update attempt for
the firmware resource entry. The field is updated each time an
`UpdateCapsule()` is attempted for an ESRT entry and is preserved across
reboots (non-volatile).
    
This can be be used in setups with support for A/B OTA updates, where
the boot firmware and Linux/RootFS might be updated synchronously.
    
The check is activated by adding "sysfail-firmware-upd" to loader.conf
    
[1]
https://uefi.org/specs/UEFI/2.10/23_Firmware_Update_and_Reporting.html
2025-05-13 11:23:26 +02:00
Ivan Kruglov f08c134661 tests: tests for io.systemd.manager.Describe 2025-05-13 01:55:15 -07:00
Ivan Kruglov 736349958e core: introduce io.systemd.Manager.Describe method
Let's extend pid1's varlink interface and add a Describe method to
get the global Manager object information as a JSON object
(io.systemd.Manager.Describe).

Because the new varlink interface should be available on both the
user managers and the system manager, we also make the necessary
changes to expose a varlink server on user managers.
2025-05-13 01:55:15 -07:00