Commit Graph

1743 Commits

Author SHA1 Message Date
Yu Watanabe
8c0cad97c7 units: portabled requires /dev/loop-control
Fixes #38692.
2025-08-29 14:49:26 +09:00
Michal Sekletar
fb56da5b6e coredump: drop RestrictSUIDSGID= option (#38640)
systemd-coredump sandbox already has ProtectSystem=strict hence all non
API filesystems are made read-only, thus RestrictSUIDSGID= doesn't buy
us much.

On top of that systemd-coredump's EnterNamespace= feature requires
openat2() to work correctly and that is implicitly blocked by
RestrictSUIDSGID=.

Follow-up for 8f8148cb08
2025-08-20 11:42:30 +01:00
Mike Yuan
8c7dfa0ff4 units/ssh-access.target: enable StopWhenUnneeded=
This combines nicely with the X_SYSTEMD_UNIT_INACTIVE= notification
we send out, to ensure when all sshd units go down the actual
status is always reflected on the target.
2025-07-22 15:01:26 +01:00
Yu Watanabe
dba4fe9a60 quotacheck: add quotacheck.mode credential support 2025-07-16 05:47:38 +09:00
Yu Watanabe
fff4dcc6de man: fix reference to systemd-quotacheck@.service
Also this makes the man page mentions systemd-quotacheck-root.service.
2025-07-16 05:47:38 +09:00
Yu Watanabe
059afcadfd fsck: add fsck.mode and fsck.repair credentials support
Maybe useful when kernel command line is hard to change, e.g. when UKI
is used.
2025-07-16 05:47:38 +09:00
Yu Watanabe
e58ba80a40 units: drop runlevel[0-6].target 2025-07-13 05:49:09 +09:00
Yu Watanabe
dc1505555b utmp: drop setting runlevel entry in utmp
This removes systemd-update-utmp-runlevel.service and related command.
2025-07-13 05:49:00 +09:00
Yu Watanabe
8ba48d4bf8 core,initctl,systemctl: kill /dev/initctl support
This also kills support for controlling system state through
/sbin/init, initctl, and telinit.
2025-07-13 05:38:14 +09:00
Yu Watanabe
7c208a64ba units: check if kmod command exists
We already check existences of quotaon in quotaon@.service and
quotacheck in systemd-quotacheck@.service.
Let's also check if kmod command exists.

Closes #38179.
2025-07-12 07:18:17 +02:00
Mike Yuan
f22187bd7e units/machines.target: fix typo
Follow-up for 48cb009afc
2025-07-11 21:38:58 +02:00
Lennart Poettering
b2f23bd2b1 Support global sysext/confext in systemd-stub/systemd-sysext (#38113)
Systemd-stub supports loading addons, credentials, system and
configuration
extensions from ESP and while addons and credentials can be both global
and
per-UKI, sysext/confext are only per-UKI. 

Add support for global sysext/confext to systemd-stub/systemd-sysext.

Fixes #37993
2025-07-11 21:10:51 +02:00
Lennart Poettering
3405b84d8c units: systems might take a while to boot
vmspawn systems might take quite a while to boot in particular if they
go through uefi and wait for a network lease. Hence let's increase the
start timeout to 2min (from 45s). We'll do that for both nspawn and
vmspawn, even though the UEFI thing certainly doesn't apply there (but
the DHCP thing still does).
2025-07-11 18:17:04 +02:00
Lennart Poettering
48cb009afc units: add units for vmspawn/nspawn in --user mode too 2025-07-11 18:17:04 +02:00
Vitaly Kuznetsov
8d07a8d6b1 sysext: Support global sysext/confext
Load global sysext/confext from /.extra/global_{sysext,confext} which
systemd-stub puts there from ESP/loader/credentials/*.{sysext,confext}.raw.
Global extensions are handled the exact same way as per-UKI ones.
2025-07-11 13:08:26 +02:00
Ubuntu
df5b3426f6 journald: support reloading configuration at runtime 2025-07-10 21:38:36 +02:00
DaanDeMeyer
cc43510a13 userdb: Add userdb.transient credentials
To implement --bind-user in systemd-vmspawn, we need a transient
version of these credentials. These are useful when the home directory
of the user is mounted into the container/vm and every trace of the user
will be (mostly) gone again when the container/vm is shut down.
2025-07-10 21:36:09 +02:00
Yu Watanabe
1cf5b39d64 core: add 'DefaultRestrictSUIDSGID' config option (#38126)
closes #37602, see there for extra motivation and considered
alternatives.

On typical systems, only few services need to create SUID/SGID files.
This often is limited to the user explicitly setting suid/sgid, the
`systemd-tmpfiles*` services, and the package manager. Allowing a
default to globally restrict creation of suid/sgid files makes it easier
to apply this restriction precisely.

## testing done
- built on aarch64-linux and x86_64-linux
- ran a VM test on x86_64-linux, checking for:
    - VM system boots successfully
    - defaults apply (both `yes`, `no`, and undefined)
    - systemd tmpfiles can set suid/sgid on journal log path
- Other services explicitly defining `RestrictSUIDSGID=no` can create
suid files
2025-07-10 13:30:07 +09:00
Grimmauld
fd3b207011 units/systemd-tmpfiles-setup.service: explicitly set RestrictSUIDSGID=no
The tmpfiles service is used to set file permissions, e.g. for setting
suid bit on the journal log directory [1].

[1] 48e0f7bc2f/tmpfiles.d/systemd.conf.in (L24-L25)
2025-07-09 11:08:31 +02:00
Fabian Vogt
e21cd6db9c units/initrd-cleanup.service: Conflict with emergency.target
This is very similar to 327cd2d3db:

If emergency.target is started while initrd-cleanup.service/start is queued,
the initrd-cleanup job did not get canceled. In parallel to the emergency
units, it eventually runs the service, which in turn isolates and starts
initrd-switch-root.target. This stops the emergency units and effectively
starts the initrd boot process again, which likely fails again like the
initial attempt. The system is thus stuck in a loop, never really reaching
emergency.target.

This can be triggered if a service in between initrd-parse-etc.service
and initrd.target fails.

With this conflict added, starting emergency.target automatically cancels
initrd-cleanup.service/start, avoiding the loop.
2025-07-09 10:28:29 +02:00
Lennart Poettering
0fa3ac436c ssh-generator: generate /etc/issue.d/ with VSOCK ssh info data (#37819)
ssh-generator: generate /etc/issue.d/ with VSOCK ssh info data
    
I find myself trying to log into a fresh ParticleOS VM started via
systemd-vmspawn all the time, but I don't know its CID. Let's show it on
the getty screen, to make it immediately visible.
2025-07-04 10:45:45 +02:00
Lennart Poettering
864a5e9ded getty: support /run/issue.d/
By default agetty will not display /run/issue.d/ if /etc/issue exists.
This is quite unfortunate and has actually been fixed upstream in:

508fb0e7ac

However, no release has been tagged with this yet, and it doesn't look
like this will happen any time soon. Hence, for now, let's add a
work-around and manually override the issue files to include.

This should be reverted once a new util-linux/agetty release has been
tagged, and found its way into the relevant distributions. Given this is
mostly about cosmetics we do not have to precisely sync the package
updates on this, but only roughly.
2025-07-03 16:46:28 +02:00
Daan De Meyer
0470754f9d login: Add varlink socket unit 2025-07-03 11:22:34 +02:00
Daan De Meyer
b0ea79c5b5 network: Add varlink socket unit 2025-07-03 11:22:34 +02:00
Mike Yuan
a2b34106e7 units/systemd-{udevd,journald}*.socket: enable DeferTrigger=
Refer to d766c75acd for the rationale
behind the udevd change.

systemd-journald.service conflicts with soft-reboot.target,
so make sure anything surviving soft-reboot and trying
to log to journal doesn't fail the socket units.
2025-06-30 13:10:43 +02:00
Mike Yuan
286c61732f units/initrd-cleanup.service: drop --job-mode=replace-irreversibly hack
This partially reverts d766c75acd.

The offending commit tries to block systemd-udevd.service
from being activated during switch-root, but it is a dirty hack
and causes problems with e.g. Ctrl-Alt-Delete handling which
actually need to start a conflicting target. Let's revert
this here, and the original issue will be resolved in a cleaner
fashion in later commits.
2025-06-30 13:10:28 +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
Mike Yuan
85352c095e various: turn off SO_PASSRIGHTS where fds are not expected 2025-06-17 13:16:44 +02:00
Mike Yuan
9453a92ad7 units/systemd-journald@.socket: enable SO_TIMESTAMP
Follow-up for 02229dff2b

This applies the change to journal namespace instances too.
2025-06-17 13:16:07 +02:00
Lennart Poettering
008818ec96 units: make sure the network tap driver is actually loaded
We have the After= line, but not the Wants= line. Fix that.
2025-06-14 13:29:14 +09:00
Lennart Poettering
273d14f5dd nsresourced: make sure "tun" driver is properly loaded and accessible
We need access to /dev/net/tun, hence make sure we can actually see
/dev/. Also make sure the module is properly loaded before we operate,
given that we run with limit caps. But then again give the CAP_NET_ADMIN
cap, since we need to configure the network tap/tun devices.

Follow-up for: 1365034727
2025-06-14 00:59:37 +02:00
Lennart Poettering
0cca16a836 units: enable watchdog notifications for vmspawn
nspawn supports it and enables it. Let's do this for vmspawn too. It
already supports it in code. Let's make it also work in the unit file.
2025-05-26 13:23:45 +02:00
Yu Watanabe
d766c75acd units: kill only udev services and keep udev sockets on switching root
This also makes initrd-cleanup.service explicitly start
initrd-switch-root.service with replace-irreversibly mode, to avoid
systemd-udevd.service being triggered by kernel events and the start
job of initrd-switch-root.service being cancelled.

Follow-ups for 676fb42aae.
Addresses https://github.com/systemd/systemd/pull/37374#issuecomment-2875990471.
2025-05-17 12:47:52 +01:00
Igor Opaniuk
8130af42e2 units: 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:34:07 +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
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
Yu Watanabe
676fb42aae units: enable IgnoreOnIsolate=yes on systemd-udevd-kernel.socket
Otherwise, initrd-cleanup.service requests isolation thus the socket
is stopped before switching root, and several early events after
switching root may be lost.
2025-05-08 01:29:53 +09:00
Mike Yuan
fd66dc60a0 units: enable RemoveOnStop= for oomd and userdbd sockets
We usually don't care, but here the existence of socket
is public API to a certain degree and signals availability
of the service (userdbd in particular, oomd is checked in
core-varlink.c). Hence let's be more careful and remove them
if stopped.
2025-04-30 21:30:53 +02:00
Mike Yuan
e803ec1e25 units: unify deps between service and socket units
The current arrangement of service and socket units is
sort of all over the place. Let's clean it up a little,
roughly following the principles below:

- socket units have implicit ordering deps (not to be confused
  with default ones which are subject to DefaultDependencies=)
  before associated service, so drop any explicit After=

- If socket can be enabled, remember to link to it in service
  via Also= and Sockets= (the latter replaces Wants=).
  If the service Requires= socket however, Sockets= is omitted.

- If socket is statically enabled, no need for service
  to pull it in - machined
2025-04-30 21:27:37 +02:00
Nick Rosbrook
0fa188307b resolved: support socket activation via varlink sockets
Add two new socket units, one for each of systemd-resolved's varlink
servers:

 systemd-resolved-varlink.socket
 systemd-resolved-monitor.socket

Add logic to grab socket fds via sd_varlink_server_listen_name(), but
fallback to the existing sd_varlink_server_listen_address() calls if no
fds were given.

This will be used to make systemd-networkd-wait-online --dns more robust
against systemd-resolved restarts etc.
2025-04-30 11:12:15 -04:00
Daan De Meyer
29257d927d udev: Enable delegation without delegating any controllers
Delegation is enabled for udev so that it can mess around with the
cgroup hierarchy to avoid killing control processes when it calls
cg_kill in on_post() when it goes idle. We don't actually care about
any specific cgroup controllers in udev, so set Delegate= to enable
delegation without delegating any controllers

Follow up for https://github.com/systemd/systemd/pull/22752
2025-04-29 20:03:34 +02:00
Yu Watanabe
0d1819e791 units: stop systemd-udevd before soft-reboot
Otherwise, queued uevents may be lost on soft-reboot.

Similar to f89985ca49, but for
systemd-udevd.
2025-04-23 10:48:51 +09:00
Mike Yuan
a04da2db6b oomd: it's safe to assume cgv2 now 2025-04-13 18:09:40 +02:00
Yu Watanabe
b5d68c6ded units: update comment
Follow-up for f89985ca49.
2025-04-07 17:34:08 +09:00
Yu Watanabe
beaf7e04eb udev: push inotify fd to file descriptor store
Then, if we get inotify fd on start, it is not necessary to re-enable
inotify watch.
2025-04-05 17:33:14 +09:00
Yu Watanabe
011360eed3 meson: rename RC_LOCAL_PATH -> SYSTEM_SYSVRCLOCAL_PATH
No functional change, but just for emphasizing that this is for
SysV compatibility.
2025-04-03 00:19:49 +09:00
Mike Yuan
0a7d86d53d units/systemd-validatefs@.service: FailureAction= is a [Unit] knob 2025-03-31 19:23:51 +02:00
Lennart Poettering
0bdd5ccc81 validatefs: add new tool that enforces mount constraints
This new tool looks for a three xattr on the root inode of a file system
that encode mount constraints of the file system. The tool is supposed
to be hooke into the mount logic and is supposed to protect against
misappropriating trusted file systems in unintended ways.

Consider the following scenario: we boot up on first boot and create a
tpm-locked pair of /var/ and /srv/ partitions via systemd-repart. An
attacker then offline modifies the partition table, exchanging the
metadata of the /var/ and /srv/ partition. So far we'd happily accept
that, honour the modified metadata and boot up. This could be used to
revert changes to /var/ or similar. And all that even though both
partitions are encrypted and locked to TPM!

With this new mechanism we can encode in the protected contents of the
file systems the ways it can be used: the partition type uuid, the
partition label and the intended mount point can be stored in xattrs,
and we can check them automatically on mount, and take action on
mismatch. (action would typically be immediate reboot).
2025-03-31 15:14:13 +02:00
Yu Watanabe
5578f8e974 homed: move things over to quotactl_fd() (#36902)
Let's use quotactl_fd() wherever we can, it's 2025. quotactl() is such a
mess after all.
2025-03-31 21:15:03 +09:00
Lennart Poettering
8b21bbd6f0 pcrextend: whenever we fail to extend PCRs, reboot immediately
PCR extensions are supposed to be useful for "destroying" the ability to
access TPM bound secrets. Hence, if for some reason we fail to extend a
PCR, it's safer to just reboot, instead of going on without the
extension, leaving secrets potentially accessible which should not be
accessible.

Note that the services exit gracefully if no TPM is found, hence this
should not be triggered on TPM-less systems. However, this enforces that
if there is a TPM that is accessible to Linux and that works properly,
the PCR measurement must complete too.

Inspired by this thread:

https://lists.freedesktop.org/archives/systemd-devel/2025-March/051244.html
2025-03-31 21:13:33 +09:00