]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
12 months agoIntroduce systemd-sbsign to do secure boot signing
Daan De Meyer [Mon, 4 Nov 2024 23:36:32 +0000 (00:36 +0100)] 
Introduce systemd-sbsign to do secure boot signing

Currently in mkosi and ukify we use sbsigntools to do secure boot
signing. This has multiple issues:

- sbsigntools is practically unmaintained, sbvarsign is completely
broken with the latest gnu-efi when built without -fshort-wchar and
upstream has completely ignored my bug report about this.
- sbsigntools only supports openssl engines and not the new providers
API.
- sbsigntools doesn't allow us to cache hardware token pins in the
kernel keyring like we do nowadays when we sign stuff ourselves in
systemd-repart or systemd-measure

There are alternative tools like sbctl and pesign but these do not
support caching hardware token pins in the kernel keyring either.

To get around the issues with sbsigntools, let's introduce our own
tool systemd-sbsign to do secure boot signing. This allows us to
take advantage of our own openssl infra so that hardware token pins
are cached in the kernel keyring as expected and we get openssl
provider support as well.

12 months agoopenssl-util: Set default UI method instead of setting engine method
Daan De Meyer [Tue, 5 Nov 2024 13:48:59 +0000 (14:48 +0100)] 
openssl-util: Set default UI method instead of setting engine method

While for engines we have ENGINE_ctrl() to set the UI method for the
second PIN prompt, for openssl providers we don't have such a feature
which means we get the default openssl UI for the second pin prompt.

Instead, let's set the default UI method which does get used for the
second pin prompt by the pkcs11 provider.

12 months agopcrlock: Move pe_hash() and uki_hash() to pe-binary.h
Daan De Meyer [Sun, 3 Nov 2024 17:48:53 +0000 (18:48 +0100)] 
pcrlock: Move pe_hash() and uki_hash() to pe-binary.h

Let's move these to shared so we can reuse pe_hash() in the upcoming
systemd-sbsign.

12 months agomkosi: Add ruff and mypy to tools tree packages
Daan De Meyer [Tue, 5 Nov 2024 13:14:03 +0000 (14:14 +0100)] 
mkosi: Add ruff and mypy to tools tree packages

12 months agoresolved: log error messages for openssl/gnutls context creation
Zbigniew Jędrzejewski-Szmek [Sun, 3 Nov 2024 11:58:12 +0000 (12:58 +0100)] 
resolved: log error messages for openssl/gnutls context creation

In https://bugzilla.redhat.com/show_bug.cgi?id=2322937 we're getting
an error message:
Okt 29 22:21:03 fedora systemd-resolved[29311]: Could not create manager: Cannot allocate memory
I expect that this actually comes from dnstls_manager_init(), the
openssl version. But without real logs it's hard to know for sure.

Use EIO instead of ENOMEM, because the problem is unlikely to be actually
related to memory.

12 months agonetwork: limit the total number of Encrypted DNS options processed
Ronan Pigott [Tue, 5 Nov 2024 03:45:27 +0000 (20:45 -0700)] 
network: limit the total number of Encrypted DNS options processed

We need a sensible limit on the number of Encrypted DNS options allowed
so that the set of resolvers per link does not grow without bound.

Fixes: 0c90d1d2f243 ("ndisc: Parse RFC9463 encrypted DNS (DNR) option")
12 months agosd-daemon: some tweaks (#35011)
Luca Boccassi [Tue, 5 Nov 2024 00:56:28 +0000 (00:56 +0000)] 
sd-daemon: some tweaks (#35011)

12 months agoci: add coverage for builds without sd-boot (#35016)
Luca Boccassi [Mon, 4 Nov 2024 21:46:19 +0000 (21:46 +0000)] 
ci: add coverage for builds without sd-boot (#35016)

This should catch compilation issues such as:
https://github.com/systemd/systemd/pull/35014

12 months agoci: add coverage for builds without sd-boot 35016/head
Luca Boccassi [Mon, 4 Nov 2024 19:43:02 +0000 (19:43 +0000)] 
ci: add coverage for builds without sd-boot

This should catch compilation issues such as:
https://github.com/systemd/systemd/pull/35014

12 months agotest: set nullglob to avoid failure when building without sd-boot
Luca Boccassi [Mon, 4 Nov 2024 20:26:34 +0000 (20:26 +0000)] 
test: set nullglob to avoid failure when building without sd-boot

2024-11-04T20:13:17.3258095Z + for loader in build/src/boot/efi/*{.efi,.efi.stub}
2024-11-04T20:13:17.3258275Z ++ sbverify --list 'build/src/boot/efi/*.efi'
2024-11-04T20:13:17.3258525Z + [[ Error reading file build/src/boot/efi/*.efi: No such file or directory
2024-11-04T20:13:17.3258952Z Can't open image build/src/boot/efi/*.efi != \N\o\ \s\i\g\n\a\t\u\r\e\ \t\a\b\l\e\ \p\r\e\s\e\n\t ]]

12 months agotest: fix tool name in comment
Luca Boccassi [Mon, 4 Nov 2024 20:22:01 +0000 (20:22 +0000)] 
test: fix tool name in comment

12 months agonetwork: sevearal random trivial cleanups (#34994)
Yu Watanabe [Mon, 4 Nov 2024 19:16:44 +0000 (04:16 +0900)] 
network: sevearal random trivial cleanups (#34994)

split-out of #34989.

12 months agotmpfiles: Implement L? to only create symlinks if source exists
Daan De Meyer [Mon, 4 Nov 2024 11:21:21 +0000 (12:21 +0100)] 
tmpfiles: Implement L? to only create symlinks if source exists

This allows a single tmpfiles snippet with lines to symlink directories
from /usr/share/factory to be shared across many different configurations
while making sure symlinks only get created if the source actually exists.

12 months agonetwork/dhcp4: keep DHCP address and routes on stop even when SendDecline=yes 34994/head
Yu Watanabe [Fri, 1 Nov 2024 14:47:59 +0000 (23:47 +0900)] 
network/dhcp4: keep DHCP address and routes on stop even when SendDecline=yes

KeepConfiguration=dhcp or dhcp-on-stop already violate RFC. It is not
necessary to honor the RFC about sending decline message on stop.

12 months agonetwork: expose log_route_debug() and log_address_debug()
Yu Watanabe [Sat, 2 Nov 2024 09:32:02 +0000 (18:32 +0900)] 
network: expose log_route_debug() and log_address_debug()

They will be used in another file in a later commit.

12 months agonetwork: add more debugging logs
Yu Watanabe [Sat, 2 Nov 2024 09:26:43 +0000 (18:26 +0900)] 
network: add more debugging logs

This also fixes the position of the logging "Enumeration completed.",
and downgrade its log level.

12 months agonetwork: check if interface is initialized after enumeration completed
Yu Watanabe [Fri, 1 Nov 2024 21:31:25 +0000 (06:31 +0900)] 
network: check if interface is initialized after enumeration completed

We enumerate interfaces at first, then enumerate other configurations
like addresses and so on. If we are running on a container, previously
we started to configure the enumerated interfaces before enumerating other
configurations.
Let's configure interfaces after all configurations are enumerated.

12 months agonetwork: check earlier if we are running in test mode
Yu Watanabe [Fri, 1 Nov 2024 21:23:55 +0000 (06:23 +0900)] 
network: check earlier if we are running in test mode

12 months agonetwork: introduce network_config_source_from_string()
Yu Watanabe [Fri, 1 Nov 2024 21:05:23 +0000 (06:05 +0900)] 
network: introduce network_config_source_from_string()

It is currently unused, but will be used later.
Preparation for later commits.

12 months agonetwork/json: add missing entries for route properties
Yu Watanabe [Fri, 1 Nov 2024 21:02:21 +0000 (06:02 +0900)] 
network/json: add missing entries for route properties

12 months agonetwork: remove unexpected netlink socket from service manager
Yu Watanabe [Fri, 1 Nov 2024 21:00:29 +0000 (06:00 +0900)] 
network: remove unexpected netlink socket from service manager

12 months agodaemon-util: expose notify_push_fd()
Yu Watanabe [Fri, 1 Nov 2024 20:57:46 +0000 (05:57 +0900)] 
daemon-util: expose notify_push_fd()

It will be used in a later commit.

12 months agonetwork/address: slightly optimize link_address_is_dynamic()
Yu Watanabe [Fri, 1 Nov 2024 16:01:30 +0000 (01:01 +0900)] 
network/address: slightly optimize link_address_is_dynamic()

12 months agonetwork: realign string table
Yu Watanabe [Fri, 1 Nov 2024 14:07:07 +0000 (23:07 +0900)] 
network: realign string table

12 months agoefi-loader: add missing stub for efi_stub_get_device_part_uuid()
Franck Bui [Mon, 4 Nov 2024 15:07:45 +0000 (16:07 +0100)] 
efi-loader: add missing stub for efi_stub_get_device_part_uuid()

12 months agojson: add json_dispatch_ifindex() helper (#34982)
Lennart Poettering [Mon, 4 Nov 2024 14:19:51 +0000 (15:19 +0100)] 
json: add json_dispatch_ifindex() helper (#34982)

Inspired by: #34640

12 months agopcrlock: Pad pe hash to a multiple of 8 bytes
Daan De Meyer [Sun, 3 Nov 2024 20:45:29 +0000 (21:45 +0100)] 
pcrlock: Pad pe hash to a multiple of 8 bytes

All other tools (sbsigntools, osslsigncode, sbctl, goblin) do this
as well so let's follow suite.

12 months agonetwork: refuse new requests on stop (#35004)
Luca Boccassi [Mon, 4 Nov 2024 12:12:31 +0000 (12:12 +0000)] 
network: refuse new requests on stop (#35004)

split-out of #34989..

12 months agonetwork: cleanups for IPv4LL (#34995)
Luca Boccassi [Mon, 4 Nov 2024 12:08:27 +0000 (12:08 +0000)] 
network: cleanups for IPv4LL (#34995)

split-out of #34989.

12 months agotest-dhcp-client: utilize log_info instead of printf
Colin Foster [Fri, 1 Nov 2024 20:39:11 +0000 (15:39 -0500)] 
test-dhcp-client: utilize log_info instead of printf

log_info appears to be the preferred method to convey information from
tests. Convert all the printfs to log_info to follow this standard.

12 months agoupdate NEWS
Lennart Poettering [Mon, 4 Nov 2024 11:42:40 +0000 (12:42 +0100)] 
update NEWS

12 months agosd-daemon: add fd array size safety check to sd_notify_with_fds() 35011/head
Lennart Poettering [Mon, 4 Nov 2024 10:18:29 +0000 (11:18 +0100)] 
sd-daemon: add fd array size safety check to sd_notify_with_fds()

The previous commit removed the UINT_MAX check for the fd array. Let's
now re-add one, but at a better place, and with a more useful limit. As
it turns out the kernel does not allow passing more than 253 fds at the
same time, hence use that as limit. And do so immediately before
calculating the control buffer size, so that we catch multiplication
overflows.

12 months agotree-wide: port things over to new json_dispatch_ifindex() 34982/head
Lennart Poettering [Fri, 1 Nov 2024 17:12:30 +0000 (18:12 +0100)] 
tree-wide: port things over to new json_dispatch_ifindex()

12 months agojson-util: generalize json_dispatch_ifindex()
Lennart Poettering [Fri, 1 Nov 2024 17:01:08 +0000 (18:01 +0100)] 
json-util: generalize json_dispatch_ifindex()

Let's move the helper from nss-resolve.c to generic code, as it's going
to be useful in #34640.

Also, let's tighten the rules, and refuse negative ifindexes, because
they are invalid.

12 months agosd-daemon: count array elements in size_t
Lennart Poettering [Mon, 4 Nov 2024 10:01:23 +0000 (11:01 +0100)] 
sd-daemon: count array elements in size_t

We fucked that up in the original sd_listen() calls, and then we fixed
that on the newer flavours. But pour internal common implementation
should of course use the full range size_t, as it should be.

This then allows us to drop a redundant range check.

12 months agosd-daemon: drop some redundant 'else'
Lennart Poettering [Mon, 4 Nov 2024 10:01:07 +0000 (11:01 +0100)] 
sd-daemon: drop some redundant 'else'

12 months agosd-daemon: clean up env var unsetting
Lennart Poettering [Mon, 4 Nov 2024 09:46:37 +0000 (10:46 +0100)] 
sd-daemon: clean up env var unsetting

This cleans up the handling of the "unset_environment" parameter to
sd_listen() and related calls: the man pages claim we operate on it on
error too. Hence, actually do so in strictly all error paths. Previously
we'd miss out on some, because wrapper functions mishandled them.

This was addressed before in 362dcfc5db0271cd6b3a564c528cabf0ac0e7993
but some codepaths were missed. Complete the work now.

This establishes a common pattern: a function to unset the relevant env
vars, that is called from a goto section at the botom on both success
and failure.

12 months agoupdate TODO
Lennart Poettering [Mon, 4 Nov 2024 09:45:26 +0000 (10:45 +0100)] 
update TODO

12 months agoudev-builtin-path_id: SAS wide ports must have num_phys > 1
Martin Wilck [Wed, 30 Oct 2024 15:57:39 +0000 (16:57 +0100)] 
udev-builtin-path_id: SAS wide ports must have num_phys > 1

Some kernel SAS drivers (e.g. smartpqi) expose ports with num_phys = 0. udev
shouldn't treat these ports as wide ports.  SAS wide ports always have
num_phys > 1. See comments for sas_port_add_phy() in the kernel sources.

Sample data from a smartpqi system to illustrate the issue below.
Here the phy device is attached to port 0:0, which has no end devices attached
and the SAS end device (where sda is attached) is associated with SAS
port 0:1, which has no associated phy device. Thus num_phys for port-0:1 is 0.
This is arguably wrong, but it's how smartpqi has always set up its devices in
sysfs.

/sys/class/sas_phy/phy-0:0 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/sas_phy/phy-0:0
/sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:0/phy-0:0 -> ../phy-0:0
/sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/port -> ../port-0:0

/sys/class/sas_device/end_device-0:1 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/sas_device/end_device-0:1
/sys/class/block/sda -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/target0:0:0/0:0:0:0/block/sda

Signed-off-by: Martin Wilck <mwilck@suse.com>
12 months agoopenssl-util: Query engine/provider pin via ask-password (#34948)
Daan De Meyer [Sun, 3 Nov 2024 11:54:20 +0000 (12:54 +0100)] 
openssl-util: Query engine/provider pin via ask-password (#34948)

In mkosi, we want to support signing via a hardware token. We already
support this in systemd-repart and systemd-measure. However, if the
hardware token is protected by a pin, the pin is asked as many as 20
times when building an image as the pin is not cached and thus requested
again for every operation.

Let's introduce a custom openssl ui when we use engines and providers
and plug systemd-ask-password into the process. With
systemd-ask-password, the pin can be cached in the kernel keyring,
allowing us to reuse it without querying the user again every time to
enter the pin.

We use the private key URI as the keyring identifier so that the cached
pin can be shared across multiple tools.

12 months agobootctl: Add --secure-boot-auto-enroll 34948/head
Daan De Meyer [Thu, 31 Oct 2024 22:33:36 +0000 (23:33 +0100)] 
bootctl: Add --secure-boot-auto-enroll

When specified, bootctl install will also set up secure boot
auto-enrollment. For now, We sign all variables using the same
certificate and key pair.

12 months agoopenssl-util: Query engine/provider pin via ask-password
Daan De Meyer [Wed, 30 Oct 2024 14:47:58 +0000 (15:47 +0100)] 
openssl-util: Query engine/provider pin via ask-password

In mkosi, we want to support signing via a hardware token. We already
support this in systemd-repart and systemd-measure. However, if the
hardware token is protected by a pin, the pin is asked as many as 20
times when building an image as the pin is not cached and thus requested
again for every operation.

Let's introduce a custom openssl ui when we use engines and providers
and plug systemd-ask-password into the process. With systemd-ask-password,
the pin can be cached in the kernel keyring, allowing us to reuse it without
querying the user again every time to enter the pin.

We use the private key URI as the keyring identifier so that the cached pin
can be shared across multiple tools.

Note that if the private key is pin protected, openssl will prompt both when
loading the private key using the pkcs11 engine and when actually signing the
roothash. To make sure our custom UI is used when signing the roothash, we have
to also configure it with ENGINE_ctrl() which takes a non-owning pointer to
the UI_METHOD object and its userdata object which we have to keep alive so we
introduce a new AskPasswordUserInterface struct which we use to keep both objects
alive together with the EVP_PKEY object.

Because the AskPasswordRequest struct stores non-owning pointers to its fields,
we change repart to store the private key URI as a global variable again instead
of the EVP_PKEY object so that we can use the private key argument as the keyring
field of the AskPasswordRequest instance without running into lifetime issues.

12 months agonetwork: free DHCP client and friends in link_free() 35004/head
Yu Watanabe [Sat, 2 Nov 2024 20:07:55 +0000 (05:07 +0900)] 
network: free DHCP client and friends in link_free()

No functional change, at least now. Preparation for later commits.

But we are planning to extend KeepConfiguration= and also keep
addresses and so on assigned by other dynamic configuration protocol
like DHCPv6 or NDisc.
However, when link_free_engines() is called here, acquired addresses so
on by NDisc will be removed, even if link_stop_engines() handles
restarting networkd or KeepConfiguration= gracefully.
So, let's not free engines here, but free them later in link_free().
It is not necessary to be called here anyway.

12 months agonetwork: refuse further requests when manager is in MANAGER_STOPPED
Yu Watanabe [Sat, 2 Nov 2024 19:56:32 +0000 (04:56 +0900)] 
network: refuse further requests when manager is in MANAGER_STOPPED

In that case, requests will never be processed anyway. But further more,
we cannot call link_ref() at that stage. Otherwise, we trigger assertion.

12 months agoefivars: Remove STRINGIFY() helper macros
Daan De Meyer [Thu, 31 Oct 2024 12:54:33 +0000 (13:54 +0100)] 
efivars: Remove STRINGIFY() helper macros

The names of these conflict with macros from efi.h that we'll move
to efi-fundamental.h in a later commit. Let's avoid the conflict by
getting rid of these helpers. Arguably this also improves readability
by clearly indicating we're passing arbitrary strings and not constants
to the macros when we invoke them.

12 months agoask-password: Add $SYSTEMD_ASK_PASSWORD_KEYRING_TYPE
Daan De Meyer [Wed, 30 Oct 2024 22:45:38 +0000 (23:45 +0100)] 
ask-password: Add $SYSTEMD_ASK_PASSWORD_KEYRING_TYPE

Currently ask_password_auto() will always try to store the password into
the user keyring. Let's make this configurable so that we can configure
ask_password_auto() into the session keyring. This is required when working
with user namespaces, as the user keyring is namespaced by user namespaces
which makes it impossible to share cached keys across user namespaces by using
the user namespace while this is possible with the session keyring.

12 months agoask-password: Drop "default" for SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC
Daan De Meyer [Fri, 1 Nov 2024 11:45:29 +0000 (12:45 +0100)] 
ask-password: Drop "default" for SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC

Users can simply unset the environment variable to achieve the same effect.

12 months agoask-password: Use default timeout if SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC is...
Daan De Meyer [Fri, 1 Nov 2024 12:48:58 +0000 (13:48 +0100)] 
ask-password: Use default timeout if SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC is unset

Follow-up for d9f4dad986dcebd51bdaeb8ba3d2c00cdc0d701e

12 months agomkosi: Add extra tools tree packages required to run integration tests
Daan De Meyer [Sat, 2 Nov 2024 21:13:31 +0000 (22:13 +0100)] 
mkosi: Add extra tools tree packages required to run integration tests

With https://github.com/systemd/mkosi/pull/3164, we'll be able to run
arbitrary commands in the mkosi sandbox, which has /usr from the tools
tree if one is configured. Let's add the required packages to be able to
run meson to setup the integration tests. This allows running the integration
tests without having to install meson or other build dependencies on the
host system.

"""
mkosi sandbox meson setup build
mkosi sandbox meson compile -C build mkosi
mkosi sandbox env SYSTEMD_INTEGRATION_TESTS=1 meson test -C build ...
"""

12 months agobuild(deps): bump systemd/mkosi
dependabot[bot] [Sat, 2 Nov 2024 21:18:57 +0000 (21:18 +0000)] 
build(deps): bump systemd/mkosi

Bumps [systemd/mkosi](https://github.com/systemd/mkosi) from 2a35f9958bc6b82d95d1eac02dc245e9bb068765 to 8976a0abb19221e65300222f2d33067970cca0f1.
- [Release notes](https://github.com/systemd/mkosi/releases)
- [Commits](https://github.com/systemd/mkosi/compare/2a35f9958bc6b82d95d1eac02dc245e9bb068765...8976a0abb19221e65300222f2d33067970cca0f1)

---
updated-dependencies:
- dependency-name: systemd/mkosi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
12 months agoTwo integration test fixes (#34984)
Daan De Meyer [Sat, 2 Nov 2024 21:12:27 +0000 (22:12 +0100)] 
Two integration test fixes (#34984)

12 months agoTEST-64-UDEV-STORAGE: Don't hardcode device name in long-sysfs-path test 34984/head
Daan De Meyer [Fri, 1 Nov 2024 20:27:52 +0000 (21:27 +0100)] 
TEST-64-UDEV-STORAGE: Don't hardcode device name in long-sysfs-path test

There's no guarantee our device will be named /dev/vda, so give it
a serial so we can query for its devname inside the test.

12 months agoTEST-17-UDEV: Don't hardcode root device name
Daan De Meyer [Fri, 1 Nov 2024 20:27:08 +0000 (21:27 +0100)] 
TEST-17-UDEV: Don't hardcode root device name

There's no guarantee the root device will be /dev/sda, so let's use
bootctl to get the actual path instead of harcoding it.

12 months agopam: quiet a spurious debug message
Ronan Pigott [Sat, 2 Nov 2024 02:44:18 +0000 (19:44 -0700)] 
pam: quiet a spurious debug message

This singular debug message gets printed even if debug is not enabled.
Quiet this message when debug is not enabled for consistency.

12 months agouser-record: add missing comma to list of strings
Luca Boccassi [Sat, 2 Nov 2024 11:06:18 +0000 (11:06 +0000)] 
user-record: add missing comma to list of strings

Follow-up for ad03f2d5f0d7f87b775357e5a2727dbcbc973fce

12 months agonetwork/ipv4ll: not necessary to set initial address on each start 34995/head
Yu Watanabe [Fri, 1 Nov 2024 15:13:00 +0000 (00:13 +0900)] 
network/ipv4ll: not necessary to set initial address on each start

12 months agonetwork/dhcp4: do not restart IPv4LL client when KeepConfiguration=dhcp
Yu Watanabe [Fri, 1 Nov 2024 14:52:58 +0000 (23:52 +0900)] 
network/dhcp4: do not restart IPv4LL client when KeepConfiguration=dhcp

When KeepConfiguration=dhcp, we do not remove acquired address, hence
not necessary to restart IPv4LL client.

12 months agomachine: introduce io.systemd.MachineImage.{Clone, Remove} methods (#34853)
Luca Boccassi [Sat, 2 Nov 2024 12:06:23 +0000 (12:06 +0000)] 
machine: introduce io.systemd.MachineImage.{Clone, Remove} methods (#34853)

This PR introduces io.systemd.MachineImage.Clone and Remove methods.
They are 1:1 mapping to DBus alternatives.

12 months agoAdd support for id-mapped mounts to Exec directories (#34078)
Luca Boccassi [Sat, 2 Nov 2024 12:04:49 +0000 (12:04 +0000)] 
Add support for id-mapped mounts to Exec directories (#34078)

Currently, bind-mounted directories within a user/mount namespace get
the uid/gid stored on their files. If the host creates a file in the
source directory, it will still show as root in the namespace.
Id-mapping is a filesystem feature that allows a mount namespace to show
a different uid than what is actually stored on a file. Add support for
id-mappings to exec directories, so that the files within the mount
namespace are owned by the unprivileged uid/gid.

Example:

Using unit:
```
[Unit]
Description=Sample service

[Service]
MountAPIVFS=yes
DynamicUser=yes
PrivateUsers=yes
TemporaryFileSystem=/run /var/opt /var/lib /vol
UMask=0000
ExecStart=/bin/bash -c 'while true; do echo "ping"; sleep 5; done'
StateDirectory=andresstatedir:sampleservice

[Install]
WantedBy=multi-user.target
```

In the host namespace, creating a file "test":
```
root@abeltran-test:/var/lib/andresstatedir# ls -lah
total 8.0K
drwxr-xr-x 2 root root 4.0K Aug 21 23:48 .
drwx------ 3 root root 4.0K Aug 21 23:47 ..
-rw-r--r-- 1 root root    0 Aug 21 23:48 test
```

Within the unit namespace:
```
root@abeltran-test:/var/lib/sampleservice# ls -lah
total 4.0K
drwxr-xr-x 2 63750 63750 4.0K Aug 21 23:48 .
drwxr-xr-x 3 root  root    60 Aug 21 23:47 ..
-rw-r--r-- 1 63750 63750    0 Aug 21 23:48 test
```
```
root@abeltran-test:/# mount | grep and
/dev/sda1 on /var/lib/private/andresstatedir type ext4 (rw,nosuid,noexec,relatime,idmapped,discard,errors=remount-ro,commit=30)
```

12 months agologind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers (#34969)
Luca Boccassi [Sat, 2 Nov 2024 11:27:28 +0000 (11:27 +0000)] 
logind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers (#34969)

The check for the old flag was not restored when the weak blocker was
added, add it back. Also skip polkit check for root for the weak
blocker, to keep compatibility with the previous behaviour.

Partially fixes https://github.com/systemd/systemd/issues/34091

Follow-up for 804874d26ac73e0af07c4c5d7165c95372f03f6d

12 months agocore: add id-mapped mount support for Exec directories 34078/head
Andres Beltran [Mon, 5 Aug 2024 23:43:29 +0000 (23:43 +0000)] 
core: add id-mapped mount support for Exec directories

12 months agonamespace-util: add util function to check if id-mapped mounts are supported for...
Andres Beltran [Wed, 30 Oct 2024 17:51:53 +0000 (17:51 +0000)] 
namespace-util: add util function to check if id-mapped mounts are supported for a given path

12 months agocore/service: don't propagate stop jobs if RestartMode=direct (#34768)
Lennart Poettering [Fri, 1 Nov 2024 16:25:49 +0000 (17:25 +0100)] 
core/service: don't propagate stop jobs if RestartMode=direct (#34768)

Fixes https://github.com/systemd/systemd/issues/34758

12 months agoresolve: remove always-true superflous check and rename label
Luca Boccassi [Fri, 1 Nov 2024 13:51:57 +0000 (13:51 +0000)] 
resolve: remove always-true superflous check and rename label

Fixes https://github.com/systemd/systemd/security/code-scanning/2900

12 months agologind: ensure the stronger inhibitor currently in place is taken into account 34969/head
Luca Boccassi [Fri, 1 Nov 2024 14:39:51 +0000 (14:39 +0000)] 
logind: ensure the stronger inhibitor currently in place is taken into account

12 months agologind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers
Luca Boccassi [Thu, 31 Oct 2024 16:02:38 +0000 (16:02 +0000)] 
logind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers

The check for the old flag was not restored when the weak
blocker was added, add it back. Also skip polkit check for
root for the weak blocker, to keep compatibility with the
previous behaviour.

Partially fixes https://github.com/systemd/systemd/issues/34091

Follow-up for 804874d26ac73e0af07c4c5d7165c95372f03f6d

12 months agomachine: remove redundant --more in TEST-13-NSPAWN.machined 34853/head
Ivan Kruglov [Tue, 22 Oct 2024 09:16:53 +0000 (11:16 +0200)] 
machine: remove redundant --more in TEST-13-NSPAWN.machined

12 months agomachine: tests for io.systemd.MachineImage.{Clone, Remove} methods
Ivan Kruglov [Mon, 21 Oct 2024 11:58:30 +0000 (13:58 +0200)] 
machine: tests for io.systemd.MachineImage.{Clone, Remove} methods

12 months agomachine: use ImageUpdateParameters in io.systemd.MachineImage.Update
Ivan Kruglov [Tue, 22 Oct 2024 09:00:41 +0000 (11:00 +0200)] 
machine: use ImageUpdateParameters in io.systemd.MachineImage.Update

12 months agomachine: reuse VARLINK_DEFINE_IMAGE_LOOKUP_AND_POLKIT_FIELDS in io.systemd.MachineIma...
Ivan Kruglov [Mon, 21 Oct 2024 11:54:58 +0000 (13:54 +0200)] 
machine: reuse VARLINK_DEFINE_IMAGE_LOOKUP_AND_POLKIT_FIELDS in io.systemd.MachineImage.Update declaration

12 months agomachine: introduce io.systemd.MachineImage.Remove method
Ivan Kruglov [Mon, 21 Oct 2024 11:54:42 +0000 (13:54 +0200)] 
machine: introduce io.systemd.MachineImage.Remove method

12 months agomachine: introduce io.systemd.MachineImage.Clone method
Ivan Kruglov [Mon, 21 Oct 2024 11:53:38 +0000 (13:53 +0200)] 
machine: introduce io.systemd.MachineImage.Clone method

12 months agomachine: use report_errno_and_exit() in dbus code
Ivan Kruglov [Thu, 31 Oct 2024 10:01:16 +0000 (11:01 +0100)] 
machine: use report_errno_and_exit() in dbus code

12 months agomachine: introduce report_errno_and_exit()
Ivan Kruglov [Thu, 31 Oct 2024 09:58:21 +0000 (10:58 +0100)] 
machine: introduce report_errno_and_exit()

12 months agomachine: align polkit verb of io.systemd.MachineImage.Update with the rest of the...
Ivan Kruglov [Mon, 21 Oct 2024 11:51:22 +0000 (13:51 +0200)] 
machine: align polkit verb of io.systemd.MachineImage.Update with the rest of the code

12 months agohwdb: update for v257 (#34976)
Luca Boccassi [Fri, 1 Nov 2024 12:32:56 +0000 (12:32 +0000)] 
hwdb: update for v257 (#34976)

12 months agoupdate hwdb 34976/head
Lennart Poettering [Fri, 1 Nov 2024 09:17:58 +0000 (10:17 +0100)] 
update hwdb

12 months agohwdb: import newest autosuspend rules from chromeos
Lennart Poettering [Fri, 1 Nov 2024 09:14:09 +0000 (10:14 +0100)] 
hwdb: import newest autosuspend rules from chromeos

12 months agomkosi: Set BuildSourcesEphemeral=no in mkosi.clangd
Daan De Meyer [Fri, 1 Nov 2024 12:05:46 +0000 (13:05 +0100)] 
mkosi: Set BuildSourcesEphemeral=no in mkosi.clangd

We're just running a language server so no need to put a writable
overlay on top of the build sources to prevent modifications. This
hopefully helps the language server track modifications to the source
files better.

12 months agocoredump: lock down EnterNamespace= mount even more (#34975)
Luca Boccassi [Fri, 1 Nov 2024 12:25:35 +0000 (12:25 +0000)] 
coredump: lock down EnterNamespace= mount even more (#34975)

Let's disable symlink following if we attach a container's mount tree to
our own mount namespace. We afte rall mount the tree to a different
location in the mount tree than where it was inside the container, hence
symlinks (if they exist) will all point to the wrong places (even if
relative, some might point to other places). And since symlink attacks
are a thing, and we let libdw operate on the tree, let's lock this down
as much as we can and simply disable symlink traversal entirely.

12 months agobuild(deps): bump meson from 1.5.2 to 1.6.0 in /.github/workflows
dependabot[bot] [Fri, 1 Nov 2024 09:28:07 +0000 (09:28 +0000)] 
build(deps): bump meson from 1.5.2 to 1.6.0 in /.github/workflows

Bumps [meson](https://github.com/mesonbuild/meson) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.5.2...1.6.0)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
12 months agoUpdate NEWS
Luca Boccassi [Fri, 1 Nov 2024 11:39:26 +0000 (11:39 +0000)] 
Update NEWS

12 months agoutil-lib/systemd-run: implement race-free PTY peer opening (#34953)
Luca Boccassi [Fri, 1 Nov 2024 11:29:19 +0000 (11:29 +0000)] 
util-lib/systemd-run: implement race-free PTY peer opening (#34953)

This makes use of the new TIOCGPTPEER pty ioctl() for directly opening a
PTY peer, without going via path names. This is nice because it closes a
race around allocating and opening the peer. And also has the nice
benefit that if we acquired an fd originating from some other
namespace/container, we can directly derive the peer fd from it, without
having to reenter the namespace again.

12 months agotweaks to ANSI sequence (OSC) handling (#34964)
Luca Boccassi [Fri, 1 Nov 2024 11:18:57 +0000 (11:18 +0000)] 
tweaks to ANSI sequence (OSC) handling (#34964)

Fixes: #34604
Prompted by that I realized we do not correctly recognize both "ST"
sequences we want to recognize, fix that.

12 months agoHomed update policy: user changing own settings (#31153)
Luca Boccassi [Fri, 1 Nov 2024 11:14:04 +0000 (11:14 +0000)] 
Homed update policy: user changing own settings (#31153)

Rework of #30109 to deal with changes in #30840 and discussed changes to
behavior

Depends on and includes #30840

Fixes https://github.com/systemd/systemd/issues/34268

12 months agonetwork: update tunnel or vxlan with Local=dhcp4 and friends (#34957)
Luca Boccassi [Fri, 1 Nov 2024 11:10:21 +0000 (11:10 +0000)] 
network: update tunnel or vxlan with Local=dhcp4 and friends (#34957)

Fixes #24854.

12 months agocore: add read-only flag for exec directories
Luca Boccassi [Mon, 28 Oct 2024 19:58:58 +0000 (19:58 +0000)] 
core: add read-only flag for exec directories

When an exec directory is shared between services, this allows one of the
service to be the producer of files, and the other the consumer, without
letting the consumer modify the shared files.
This will be especially useful in conjunction with id-mapped exec directories
so that fully sandboxed services can share directories in one direction, safely.

12 months agotest: Test user record selfModifiable behavior 31153/head
Adrian Vovk [Wed, 24 Apr 2024 23:41:03 +0000 (19:41 -0400)] 
test: Test user record selfModifiable behavior

12 months agohomed: Allow user to change parts of their record
Adrian Vovk [Fri, 2 Feb 2024 03:53:09 +0000 (22:53 -0500)] 
homed: Allow user to change parts of their record

This allows an unprivileged user that is active at the console to change
the fields that are in the selfModifiable allowlists (introduced in a
previous commit) without authenticating as a system administrator.

Administrators can disable this behavior per-user by setting the
relevant selfModifiable allowlists, or system-wide by changing the
policy of the org.freedesktop.home1.update-home-by-owner Polkit action.

12 months agouser-record: Introduce selfModifiable fields
Adrian Vovk [Wed, 24 Apr 2024 22:12:54 +0000 (18:12 -0400)] 
user-record: Introduce selfModifiable fields

Allows the system administrator to configure what fields the user is
allowed to edit about themself, along with hard-coded defaults.

12 months agobuild(deps): bump actions/checkout from 4.2.0 to 4.2.2
dependabot[bot] [Fri, 1 Nov 2024 09:01:41 +0000 (09:01 +0000)] 
build(deps): bump actions/checkout from 4.2.0 to 4.2.2

Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/d632683dd7b4114ad314bca15554477dd762a938...11bd71901bbe5b1630ceea73d27597364c9af683)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
12 months agoman: <strong> is not a valid docbook tag, but <emphasis> is
Lennart Poettering [Fri, 1 Nov 2024 09:03:15 +0000 (10:03 +0100)] 
man: <strong> is not a valid docbook tag, but <emphasis> is

12 months agoupdate NEWS
Lennart Poettering [Fri, 1 Nov 2024 09:02:55 +0000 (10:02 +0100)] 
update NEWS

12 months agocoredump: rename gather_pid_mount_tree_fd() → acquire_pid_mount_tree_fd() 34975/head
Lennart Poettering [Fri, 1 Nov 2024 09:05:32 +0000 (10:05 +0100)] 
coredump: rename gather_pid_mount_tree_fd() → acquire_pid_mount_tree_fd()

From my understanding of the english language "gather" imples there are
multiple things to gather. But here there's only one, hence use
"acquire"

12 months agocoredump: lock down EnterNamespace= mount even more
Lennart Poettering [Fri, 1 Nov 2024 09:03:26 +0000 (10:03 +0100)] 
coredump: lock down EnterNamespace= mount even more

Let's disable symlink following if we attach a container's mount tree to
our own mount namespace. We afte rall mount the tree to a different
location in the mount tree than where it was inside the container, hence
symlinks (if they exist) will all point to the wrong places (even if
relative, some might point to other places). And since symlink attacks
are a thing, and we let libdw operate on the tree, let's lock this down
as much as we can and simply disable symlink traversal entirely.

12 months agocoredump: rework protocol between coredump pattern handler and processing service...
Lennart Poettering [Fri, 1 Nov 2024 07:15:05 +0000 (08:15 +0100)] 
coredump: rework protocol between coredump pattern handler and processing service (#34970)

In
https://github.com/systemd/systemd/commit/68511cebe58977ea68ae4f57c6462e979efd1cff
the ability to pass the
coredump's mount namespace fd from the coredump patter handler was added
to systemd-coredump. For this the protocol was augmented, in attempt to
provide both forward and backward compatibility.

The protocol as of v256: one or more datagrams with journal log fields
about the coredump are sent via an SOCK_SEQPACKET connection. It is
finished with a zero length datagram which carries the coredump fd (this
last datagram is called "sentinel" sometimes).

The protocol after
https://github.com/systemd/systemd/commit/68511cebe58977ea68ae4f57c6462e979efd1cff
is extended
so that after the sentinal a 2nd sentinel is sent, with a pair of fds:
the coredump fd *again* and a mount fd (acquired via open_tree()) of the
container's mount tree. It's a bit ugly to send the coredump fd a 2nd
time, but what's more important the implementation didn't work: since on
SOCK_SEQPACKET a zero sized datagram cannot be distinguished from EOF
(which is a Linux API design mistake), an early EOF would be
misunderstood as a zero size datagram lacking any fd, which resulted in
protocol termination.

Moreover, I think if we touch the protocol we should make the move to
pidfs at the same time.

All of the above is what this protocol rework addresses.

1. A pidfd is now sent as well

2. The protocol is now payload, followed by the coredump fd datagram (as
   before).  But now followed by a second empty datagram with a pidfd,
   and a third empty datagram with the mount tree fd. Of this the latter
   two or last are optional. Thus, it's now a stream of payload
   datagrams with one, two or three fd-laden datagrams as sentinel. If
   we read the 2nd or 3rd sentinel without an attached fd we assume this
   is actually an EOF (whether it actually is one or not doesn't matter
   here). This should provide nice up and down compatibility.

3. The mount_tree_fd is moved into the Context object. The pidfd is
   placed there too, as a PidRef. Thus the data we pass around is now
   the coredump fd plus the context, which is simpler and makes a lot
   more semantical sense I think.

4. The "first" boolean is replaced by an explicit state engine enum

Fixes: https://github.com/systemd/systemd/issues/34130
12 months agocoredump: make check that all argv[] meta data fields are passed strict 34970/head
Lennart Poettering [Thu, 31 Oct 2024 16:02:59 +0000 (17:02 +0100)] 
coredump: make check that all argv[] meta data fields are passed strict

Otherwise, if some field is not supplied we might end up parsing a NULL
string later. Let's catch that early.

12 months agocoredump: use memory_startswith() when looking at a data blob
Lennart Poettering [Thu, 31 Oct 2024 15:53:39 +0000 (16:53 +0100)] 
coredump: use memory_startswith() when looking at a data blob

12 months agoiovw: normalize destructors
Lennart Poettering [Thu, 31 Oct 2024 15:05:49 +0000 (16:05 +0100)] 
iovw: normalize destructors

instead of passing a boolean picking the destruction method just have
different functions. That's much nicer in context of _cleanup_, and how
we usually do things.

12 months agoiovw: add simpler iovw_done() destructor
Lennart Poettering [Thu, 31 Oct 2024 15:00:13 +0000 (16:00 +0100)] 
iovw: add simpler iovw_done() destructor