Commit Graph

77399 Commits

Author SHA1 Message Date
Daan De Meyer
cf0238d854 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.
2024-11-05 14:26:21 +01:00
Daan De Meyer
48c5a4cd67 mkosi: Add ruff and mypy to tools tree packages 2024-11-05 14:26:21 +01:00
Zbigniew Jędrzejewski-Szmek
ee95e86ae1 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.
2024-11-05 11:59:29 +01:00
Ronan Pigott
a791fea0d6 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: 0c90d1d2f2 ("ndisc: Parse RFC9463 encrypted DNS (DNR) option")
2024-11-05 09:33:35 +01:00
Luca Boccassi
1da80d2ca3
sd-daemon: some tweaks (#35011) 2024-11-05 00:56:28 +00:00
Luca Boccassi
cf95ad41b0
ci: add coverage for builds without sd-boot (#35016)
This should catch compilation issues such as:
https://github.com/systemd/systemd/pull/35014
2024-11-04 21:46:19 +00:00
Luca Boccassi
8a3ac7afa6 ci: add coverage for builds without sd-boot
This should catch compilation issues such as:
https://github.com/systemd/systemd/pull/35014
2024-11-04 20:27:00 +00:00
Luca Boccassi
441922336b 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 ]]
2024-11-04 20:27:00 +00:00
Luca Boccassi
c53df275d5 test: fix tool name in comment 2024-11-04 20:27:00 +00:00
Yu Watanabe
995d0296e9
network: sevearal random trivial cleanups (#34994)
split-out of #34989.
2024-11-05 04:16:44 +09:00
Daan De Meyer
b5dc805583 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.
2024-11-04 19:04:21 +01:00
Yu Watanabe
8c3d6d7150 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.
2024-11-05 02:56:48 +09:00
Yu Watanabe
2afd12e0a1 network: expose log_route_debug() and log_address_debug()
They will be used in another file in a later commit.
2024-11-05 02:55:15 +09:00
Yu Watanabe
6119221afa network: add more debugging logs
This also fixes the position of the logging "Enumeration completed.",
and downgrade its log level.
2024-11-05 02:55:15 +09:00
Yu Watanabe
9c402e3ae2 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.
2024-11-05 02:55:15 +09:00
Yu Watanabe
30d5d11be0 network: check earlier if we are running in test mode 2024-11-05 02:55:15 +09:00
Yu Watanabe
bf6e9b383d network: introduce network_config_source_from_string()
It is currently unused, but will be used later.
Preparation for later commits.
2024-11-05 02:55:15 +09:00
Yu Watanabe
5ca212a984 network/json: add missing entries for route properties 2024-11-05 02:55:15 +09:00
Yu Watanabe
ae65974883 network: remove unexpected netlink socket from service manager 2024-11-05 02:55:15 +09:00
Yu Watanabe
20465bcb1e daemon-util: expose notify_push_fd()
It will be used in a later commit.
2024-11-05 02:55:15 +09:00
Yu Watanabe
dc12457bfd network/address: slightly optimize link_address_is_dynamic() 2024-11-05 02:55:03 +09:00
Yu Watanabe
b5a8440f55 network: realign string table 2024-11-05 02:54:02 +09:00
Franck Bui
c52f6c1f33 efi-loader: add missing stub for efi_stub_get_device_part_uuid() 2024-11-04 17:18:23 +00:00
Lennart Poettering
679a95593d
json: add json_dispatch_ifindex() helper (#34982)
Inspired by: #34640
2024-11-04 15:19:51 +01:00
Daan De Meyer
e37701a8cd 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.
2024-11-04 14:08:54 +01:00
Luca Boccassi
867e2c2a60
network: refuse new requests on stop (#35004)
split-out of #34989..
2024-11-04 12:12:31 +00:00
Luca Boccassi
c990f96ea1
network: cleanups for IPv4LL (#34995)
split-out of #34989.
2024-11-04 12:08:27 +00:00
Colin Foster
38557d9ffb 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.
2024-11-04 11:57:32 +00:00
Lennart Poettering
f57efb3d6c update NEWS 2024-11-04 12:42:40 +01:00
Lennart Poettering
cb42df5310 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.
2024-11-04 12:10:09 +01:00
Lennart Poettering
c4c04e2c2e tree-wide: port things over to new json_dispatch_ifindex() 2024-11-04 11:42:38 +01:00
Lennart Poettering
dfaff662a0 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.
2024-11-04 11:42:37 +01:00
Lennart Poettering
74806f7116 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.
2024-11-04 11:02:38 +01:00
Lennart Poettering
bea2237f67 sd-daemon: drop some redundant 'else' 2024-11-04 11:01:07 +01:00
Lennart Poettering
6606348981 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 362dcfc5db
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.
2024-11-04 11:00:13 +01:00
Lennart Poettering
0e44f02e2f update TODO 2024-11-04 10:45:26 +01:00
Martin Wilck
7f6674624e 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>
2024-11-04 09:55:48 +01:00
Daan De Meyer
c32e54456e
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.
2024-11-03 12:54:20 +01:00
Daan De Meyer
a07864a4fe 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.
2024-11-03 10:46:17 +01:00
Daan De Meyer
eac5336c27 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.
2024-11-03 10:46:14 +01:00
Yu Watanabe
49e5013432 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.
2024-11-03 09:14:36 +09:00
Yu Watanabe
ef45f5c8d0 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.
2024-11-03 09:14:36 +09:00
Daan De Meyer
d5c12da904 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.
2024-11-02 23:20:57 +01:00
Daan De Meyer
36c6c696a7 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.
2024-11-02 23:20:57 +01:00
Daan De Meyer
01d138b990 ask-password: Drop "default" for SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC
Users can simply unset the environment variable to achieve the same effect.
2024-11-02 23:20:57 +01:00
Daan De Meyer
b3bca11c18 ask-password: Use default timeout if SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC is unset
Follow-up for d9f4dad986
2024-11-02 23:20:57 +01:00
Daan De Meyer
d980aee1e8 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 ...
"""
2024-11-02 23:18:41 +01:00
dependabot[bot]
4839fb527f 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](2a35f9958b...8976a0abb1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-02 23:18:12 +01:00
Daan De Meyer
e1a105a6f9
Two integration test fixes (#34984) 2024-11-02 22:12:27 +01:00
Daan De Meyer
2ec809dd3b 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.
2024-11-02 20:43:22 +01:00