Commit Graph

9495 Commits

Author SHA1 Message Date
TheHillBright
3308414531 journald: clarify doc for usage-related values cap (#37528)
The old description makes users wrongly assume that the cap of 4G
applied, even when the user specifies a value that will result in higher
than 4G. This commit avoids this misunderstanding.
2025-05-21 19:38:12 +09:00
Lennart Poettering
89768b601b man: document dns-delegate files 2025-05-20 23:00:53 +02:00
Lennart Poettering
7928c0e0a1 resolved: add concept of delegating lookups below certain domains to specific DNS servers
This permits configuration of additional "delegates" which ensure that
lookups for certain DNS zones are routed to specific sets of DNS
servers, in addition to the routes we create for each network interface.

For now, this allows only static configuration, but eventually we should
open this up to IPC.

Fixes: #5573 #14159 #20485 #21260 #24532 #32022

(Fixes #32022, because now redundant)
2025-05-20 23:00:03 +02:00
Luca Boccassi
82d3551fbf repart: add --append-fstab parameter (#37238)
If --generate-fstab=PATH is used, there is the possibility that the
fstab file already exists, making systemd-repart fail.

This commit will add a new --append-fstab= parameter, that will read
the file and merge it with the new generated content.  Using the
comments, the command can separate the automatic-generated section from
the user-provided section, allowing for the next append the replacement
only of the automatic-generated section, keeping the user one.
2025-05-20 14:49:43 +01:00
Luca Boccassi
6946eed3fa core: Also refresh confext extensions when reloading notify-reload service (#33995)
`ExtensionImages=` and `ExtensionDirectories=` now let you specify
vpick-named extensions; however, since they just get set up once when
the service is started, you can't see newer versions without restarting
the service entirely. Here, also reload confext extensions when you
reload a service. This allows you to deploy a new version of some
configuration and have it picked up at reload time without interruption
to your workload.

Right now, we would only reload confext extensions and leave the sysext
ones behind, since it didn't seem prudent to swap out what is likely
program code at reload. This is made possible by only going for the
`SYSTEMD_CONFEXT_HIERARCHIES` overlays (which only contains `/etc`).

This PR:
- Adjusts `service.c` to also refresh extensions when needed. 
- Adds integration tests to check that a confext reload actually
occurred.
- Adds to the `systemd.exec` man pages to document this behavior.

This is a follow up to #24864 and #31364. Thank you to @bluca and
@goenkam for help in getting this up.
2025-05-20 11:27:34 +01:00
Alberto Planas
fc0cc3065c repart: add --append-fstab parameter
If --generate-fstab=PATH is used, there is the possibility that the
fstab file already exists, making systemd-repart fail.

This commit will add a new --append-fstab= parameter, that will read
the file and merge it with the new generated content.  Using the
comments, the command can separate the automatic-generated section from
the user-provided section, allowing for the next append the replacement
only of the automatic-generated section, keeping the user one.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2025-05-20 10:32:14 +02:00
maia x.
67ecc2c7fe man: document confext reload behavior for ExtensionDirectories/Images 2025-05-19 13:36:21 +01:00
Lennart Poettering
fbf43297dd man: reword recommendations around Accept=
Accept=yes has very valid usecases (i.e. for sporadically invoked
services) and strong benefits (i.e. better security because connections
can be sandboxed nicely, isolating them). Let's hence reword things and
stop claiming that Accept=yes was a legacy thing, because it really
isn't.

Some other man fixes, too
2025-05-16 21:47:46 +09:00
Yu Watanabe
8e958263d0 man/systemctl: fix typo
Follow-up for 652e4dd743.
2025-05-16 17:49:14 +09:00
Lennart Poettering
edecb56216 man: document how to hook stuff into system wakeup
Fixes: #6364
2025-05-15 22:01:12 +01:00
Yu Watanabe
9fd936df77 man: fix path to version.h
Follow-up for 30d20907bd.
2025-05-15 15:42:33 +02:00
Mike Yuan
7762e9bbb2 core: always enable CPU accounting; cgtop: drop cgv1 handling (#37448) 2025-05-15 14:41:07 +02:00
Lennart Poettering
bfb1f9e2c9 core: pass the socket cookie to invoked per-connection service instances as $SO_COOKIE env var
The socket cookie is just too useful for identifying connections, let's
emphasize this a bit and pass it as environment variable.
2025-05-15 09:45:32 +02:00
Lennart Poettering
3bdcd994cd man: correct version information when $REMOTE_ADDR/$REMOTE_PORT where added
This was in commit 3b1c524154, i.e. in the
v220 cycle.
2025-05-15 09:45:19 +02:00
Lennart Poettering
99d52ab51f man: don't claim REMOTE_PORT= was initialized to the protocol for AF_RAW sockets
This claim has no basis in reality, not even in the original commit
where the sentence was added this was true, see
3b1c524154.

Hence removing.
2025-05-15 09:33:34 +02:00
Mike Yuan
29da53dde3 core: always enable CPU accounting
Our baseline is v5.4 and cgroup v2 is enforced now,
which means CPU accounting is cheap everywhere without
requiring any controller, hence just remove the directive.
2025-05-15 02:19:16 +02:00
Mike Yuan
7d71b23304 man: don't duplicate version in History section 2025-05-15 02:19:16 +02:00
Mike Yuan
72594d6771 man/systemd-run: --wait shows more than CPU accounting data 2025-05-15 02:19:16 +02:00
Yu Watanabe
e71ff6639c man: fix typo
Follow-up for 778cfac5fb.
Addresses https://github.com/systemd/systemd/pull/37434#discussion_r2088882005.
2025-05-15 02:56:30 +09:00
Lennart Poettering
778cfac5fb man: document that gpt-label/gpt-type uuid xattrs are now lists 2025-05-14 15:44:54 +02:00
Igor Opaniuk
51e1c882fa man: run update-man-rules
Re-generate meson rules (as systemd-boot-clear-sysfail.service.xml
man page was added).

Fixes: https://github.com/systemd/systemd/issues/37415
Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
2025-05-14 09:34:07 +02:00
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
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
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
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
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
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
Mike Yuan
2950fb1b9b run0: drop -a short switch for --area=
Follow-up for f44e7a8c11

This breaks the rule stated at the beginning of help_sudo_mode():

> NB: Let's not go overboard with short options: we try to keep a modicum of compatibility with
> sudo's short switches, hence please do not introduce new short switches unless they have a roughly
> equivalent purpose on sudo. Use long options for everything private to run0.
2025-05-13 08:33:10 +09:00
Mike Yuan
81d5eda6c5 core: accept "|" ExecStart= prefix to spawn target user's shell; teach run0 about the new logic (#37071)
I've always been reluctant to invoke the current user's shell in another
user's context, hence was fully grounded in `sudo -i`. With this bit in
place `run0` will finally be feature-complete on my side ;-)
2025-05-12 16:10:03 +02:00
Yu Watanabe
6ea555f913 core/namespace: fix issue in PrivateTmp=disconnected vs var.mount (#37271)
Fixes #37258.
Replaces #37259.
2025-05-12 23:05:24 +09:00
Igor Opaniuk
2857a83975 bootctl: configure a sysfail entry
You can configure the sysfail boot entry using the bootctl command:
$ bootctl set-sysfail sysfail.conf

The value will be stored in the `LoaderEntrySysFail` EFI variable.

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.

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
2025-05-12 15:37:47 +02:00
Igor Opaniuk
004e3e4082 sd-boot: add support for a sysfail entry
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` holds the boot loader entry to
be used in the event of a system failure. If a failure occurs, the reason
will be stored in the `LoaderSysFailReason` EFI variable.

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

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
2025-05-12 15:37:46 +02:00
Lennart Poettering
9420a0e6cb bless-boot: in "status" output report bad state from prev boot as "dirty"
The bless-boot logic currently assumes that if the name of the boot
entry reported via the EFI var matches the name on disk that the state
is "indeterminate", as we haven't counted down the counter (to mark it
bad) or drop the counter (to mark it good) yet. But there's one corner
case we so far didn't care about: what if the entry already reached 0
left tries in a previous boot, i.e. if the user invoked an entry already
known to be completely bad. In that case we'd still return
"indeterminate", but that's kinda misleading, because we *know* the
currently booted entry is bad, however we inherited that fact from a
previous boot, we didn't determine it on the current.

hence, let's introduce a new status we report in this case, that is both
distinct from "bad" (which indicates whether the *current* boot is bad)
and "indirect" (which indicates the current boot has not been decided on
yet): "dirty".

Why "dirty"? To mirror "clean" which we already have, which indicates a
boot already marked good in a previous boot, which is a relatively
symmetric state.

This is a really weak api break of sorts, because it introduces a new
state we never reported before, but I think it's fine, because the old
reporting was just wrong, and in a way this is bugfix, that we now
report correctly something where previously returned kind of rubbish
(though systematic rubbish).

Replaces:  #37350
2025-05-12 13:04:16 +02:00
Yu Watanabe
8ac5b047fc man/systemd.exec: update documents for PrivateTmp= 2025-05-11 03:33:02 +09:00
Zbigniew Jędrzejewski-Szmek
b6b78170e1 man: rework the description of $SYSTEMD_PAGER and $PAGER
$PAGER wasn't documented, but actually we treat it same as $SYSTEMD_PAGER,
except for lower priority. And the two variables can be used to disable the
pager, even if $SYSTEMD_PAGERSECURE is not set.

Behaviour is (obviously) not changed by this patch, it intentionally just
updates the docs to match the code.
2025-05-09 12:38:30 +02:00
Zbigniew Jędrzejewski-Szmek
718dbdb2ca man: reword the description of "secure pager" handling
The existing description was not *wrong*, but it was a bit muddled. Let's
reorder the text to give a short intro and then describe what the options
actually do and the clear "true" and "false" cases first, and then describe
autodetection.

Related to https://yeswehack.com/vulnerability-center/reports/346802.
2025-05-09 12:38:29 +02:00
Itxaka
03eae2a402 boot: add an option to control action after SecureBoot enrollment (#36684)
This PR provides a new option for systemd-boot
`secure-boot-enroll-action` which allows to configure the behavior after
SecureBoot keys are enrolled.

Provides the option to either reboot or power off.

The current behavior is not changed, it will by default reboot as it did
before.

It also provides a small message about the action its going to take with
a small delay so the user can read it.
2025-05-08 13:28:41 +09:00
Yu Watanabe
ecad362d7e man: fix typo
Follow-up for a50fa2a40f.
2025-05-08 03:37:38 +09:00
Mike Yuan
e61d2011d1 run0: introduce --via-shell for invoking target user's shell, and -i shortcut
-i/--login has exact sudo semantics. But we only document
the short option and advertise expressly specifying
--via-shell --chdir='~' otherwise.
2025-05-07 18:32:20 +02:00
Mike Yuan
5b8bcbcf00 core: accept "|" ExecStart= prefix to spawn target user's shell
When switching to another user it's oftentimes desirable to also spawn
the target user's shell. sudo supports this via -i flag, run0 currently
doesn't. We don't want to proactively query NSS ourselves, since
that would fall short when operating remotely. Let's instead teach
the service manager to spawn the command using the user's default shell.

I opted for "|" instead of "." in the end because the latter seems
a bit obscure. But happy to change it to something else if a better option
comes up.
2025-05-07 18:32:19 +02:00
Mike Yuan
72fc33fe20 man/systemd.service: drop dangling reference to "!!" prefix
Follow-up for 00a415fc8f
2025-05-07 18:32:15 +02:00
anonymix007
9fed4ec252 analyze-chid: Support EDID CHIDs 2025-05-07 18:52:49 +03:00
Zbigniew Jędrzejewski-Szmek
2dc4e87849 man/systemd.exec: reword description of RestrictAddressFamilies=
The text is reordered and broken into more paragraphs.
A recommendation to combine RestrictAddressFamilies= with
SystemCallFilter=@service is added.
2025-05-06 21:14:03 +02:00
Zbigniew Jędrzejewski-Szmek
802d23fcfb man/systemd.exec: reword description of SystemCallFilter=
The existing text grew organically as features were added and was
not very organized. Reorder it and break into paragraphs grouped
by topic. The description of the :errno syntax is replaced by a short
reference to the SystemCallErrorNumber= setting. This makes the
text shorter and makes it easier to explain how the two settings combine.
2025-05-06 21:14:03 +02:00