Commit Graph

10376 Commits

Author SHA1 Message Date
Lennart Poettering
89bfa9239e tpm2-util: add missing entry in string table
Follow-up for: e5a2e78665
2025-11-14 22:04:58 +01:00
Yu Watanabe
fd7d749494 core: add varlink Reload/Reexecute methods (#39561)
Same as the D-Bus ones
2025-11-15 04:17:01 +09:00
Jelle van der Waa
887db52362 elf-util: prefer using SD_JSON_BUILD_PAIR_* macros
No functional change, just refactoring.
2025-11-14 15:47:15 +01:00
Chris Down
7f9c0c31d2 sd-dhcp-server: Add Hostname= option to static leases
This adds a new `Hostname=` option to the [DHCPServerStaticLease]
section in .network files, allowing an administrator to assign a
specific hostname to a client receiving a static lease.

We automatically select the correct DHCP option to use based on the
format of the provided string:

- Single DNS labels are sent as Option 12.
- Names with multiple DNS labels are sent as Option 81 in wire format.

Fixes: #39634
2025-11-14 07:50:13 +09:00
Yu Watanabe
be33b202e6 core: record transactions that have seen ordering cycles and expose them via IPC (#39210)
Closes #3829.
2025-11-14 00:41:46 +09:00
Yu Watanabe
3db66ed388 Make systemd stdio bridge quiet (#39718) 2025-11-14 00:39:15 +09:00
Daan De Meyer
0d91a204cb bus-wait-for-jobs: Make sure we always debug log
If we're not logging at a higher priority level, let's still log
at debug log level to help with debugging.
2025-11-13 14:45:51 +01:00
Daan De Meyer
164fc38888 shared: Forward declare InstallChange in shared-forward.h 2025-11-13 14:41:25 +01:00
Luca Boccassi
55a1b36e91 core: add varlink Reload/Reexecute methods
Same as the D-Bus ones
2025-11-13 00:07:23 +00:00
Yu Watanabe
ebbc0ea7fd musl: avoid multiple evaluations in CPU_ISSET_S() macro
musl's CPU_ISSET_S() macro does not avoid multiple evaluations, and it
only accepts simple variable or constant.

Fixes the following error.
```
../src/shared/cpu-set-util.c: In function ‘cpu_set_to_mask_string’:
../src/shared/cpu-set-util.c:101:41: warning: operation on ‘i’ may be undefined [-Werror=sequence-point]
  101 |                         if (CPU_ISSET_S(--i, c->allocated, c->set))
      |                                         ^
```
2025-11-13 08:02:05 +09:00
Yu Watanabe
5bb9063505 musl: hostname-util: introduce LINUX_HOST_NAME_MAX
glibc defines HOST_NAME_MAX as 64 and our code rely on that, but musl
defines the constant as 255. Let's provide our own definition for the
maximum length.
2025-11-13 08:02:05 +09:00
Mike Yuan
58686034eb core: expose transactions with ordering cycle
Closes #3829
Alternative to #35417

I don't think the individual "WasOnDependencyCycle" attrs on units
are particularly helpful and comprehensible, as it's really about
the dep relationship between them. And as discussed, the dependency
cycle is not something persistent, rather local to the currently
loaded set of units and shall be reset with daemon-reload (see also
https://github.com/systemd/systemd/issues/35642#issuecomment-2591296586).

Hence, let's report system state as degraded and point users to
the involved transactions when ordering cycles are encountered instead.
Combined with log messages added in 6912eb315f
it should achieve the goal of making ordering cycles more observable,
while avoiding all sorts of subtle bookkeeping in the service manager.
The degraded state can be reset via the existing ResetFailed() manager-wide
method.
2025-11-12 23:47:39 +01:00
Yu Watanabe
6431f2e072 musl: time-util: introduce get_tzname() helper function
musl leaves the DST timezone name unset if there is no DST.
The helper function maps that back to no DST.
2025-11-13 03:13:55 +09:00
Daan De Meyer
0d21ab7377 tests: Return result from some ASSERT() macros 2025-11-12 14:20:24 +01:00
Yu Watanabe
a2366debce core/exec-credentials: port to new mount API, ensure atomicity for creds installation (#39637) 2025-11-12 09:00:23 +09:00
Luca Boccassi
98ca65c36a dissect: check that roothash in signature matches before selecting partition
If there are multiple verity sig partitions (e.g.: sysupdate and A/B
scheme), dissection will simply pick the last sig partition it encounters,
as no checks are done on the content (like for the usr/root and verity data).

Check that the JSON content matches the requested roothash, if any.

Before:

sda: /usr/lib/udev/rules.d/90-image-dissect.rules:34 IMPORT{builtin}="dissect_image probe": Importing properties from results of builtin command "dissect_image probe".
Dissecting esp partition with label esp and UUID b80070bd-ea4f-49ea-94ab-41a4e4125f80.
Dissecting usr-verity-sig partition with label ParticleOS_27.178_verity_sig and UUID a6d47959-39f7-4686-99b0-660b301d1488.
Dissecting usr-verity partition with label ParticleOS_27.178_verity and UUID d7acad57-995d-297d-bf6c-a58821dcd28a.
Dissecting usr partition with label ParticleOS_27.178 and UUID f5b6aff5-945d-946e-faf4-d482c07f9968.
Dissecting usr-verity-sig partition with label ParticleOS_118.26_verity_sig and UUID c9151ec9-3264-434a-8f42-7b125432d676.
Dissecting usr-verity partition with label ParticleOS_118.26_verity and UUID 88fa8c85-8161-ea32-bf4a-fc8df18d27ae.
Partition UUID '88fa8c85-8161-ea32-bf4a-fc8df18d27ae' does not match expected UUID 'f5b6aff5-945d-946e-faf4-d482c07f9968' derived from usr verity hash, ignoring.
Dissecting usr partition with label ParticleOS_118.26 and UUID 52df1859-e144-348d-2cb1-8d6440254719.
Partition UUID '52df1859-e144-348d-2cb1-8d6440254719' does not match expected UUID 'f5b6aff5-945d-946e-faf4-d482c07f9968' derived from usr verity hash, ignoring.
Dissecting swap partition with label ParticleOS-swap and UUID 7fe77f77-32fb-4957-8c1e-6c04bd2e435f.
Dissecting root partition with label ParticleOS-root and UUID a5c89fc4-e92c-4e83-913f-8c866b94592e.
Dissecting home partition with label ParticleOS-home and UUID 25885d07-baa2-4992-b6aa-56813aa70cef.
Found for designator root: encrypted+unprotected+unused.
Found for designator usr: verity+signed+encrypted+unprotected+unused.
Found for designator home: encrypted+unprotected+unused.
Found for designator srv: absent.
Found for designator esp: encrypted+unprotected+unused.
Found for designator xbootldr: absent.
Found for designator swap: encrypted+unprotected+unused.
Found for designator root-verity: absent.
Found for designator usr-verity: encrypted+unprotected+unused.
Found for designator root-verity-sig: absent.
Found for designator usr-verity-sig: encrypted+unprotected+unused.
Found for designator tmp: absent.
Found for designator var: absent.
Probed fstype 'btrfs' on partition /dev/sda9.
Probed fstype 'erofs' on partition /dev/sda4.
Probed fstype 'btrfs' on partition /dev/sda10.
Probed fstype 'swap' on partition /dev/sda8.
Root hash in signature JSON data (52df1859e144348d2cb18d644025471988fa8c858161ea32bf4afc8df18d27ae) doesn't match configured hash (f5b6aff5945d946efaf4d482c07f9968d7acad57995d297dbf6ca58821dcd28a).
sda: Failed to load verity signature data from image: Invalid argument

After:

Dissecting usr-verity-sig partition with label ParticleOS_27.178_verity_sig and UUID a6d47959-39f7-4686-99b0-660b301d1488.
Dissecting usr-verity partition with label ParticleOS_27.178_verity and UUID d7acad57-995d-297d-bf6c-a58821dcd28a.
Dissecting usr partition with label ParticleOS_27.178 and UUID f5b6aff5-945d-946e-faf4-d482c07f9968.
Dissecting usr-verity-sig partition with label ParticleOS_118.26_verity_sig and UUID c9151ec9-3264-434a-8f42-7b125432d676.
Root hash in signature JSON data (52df1859e144348d2cb18d644025471988fa8c858161ea32bf4afc8df18d27ae) doesn't match configured hash (f5b6aff5945d946efaf4d482c07f9968d7acad57995d297dbf6ca58821dcd28a).
Dissecting usr-verity partition with label ParticleOS_118.26_verity and UUID 88fa8c85-8161-ea32-bf4a-fc8df18d27ae.
Partition UUID '88fa8c85-8161-ea32-bf4a-fc8df18d27ae' does not match expected UUID 'f5b6aff5-945d-946e-faf4-d482c07f9968' derived from usr verity hash, ignoring.
Dissecting usr partition with label ParticleOS_118.26 and UUID 52df1859-e144-348d-2cb1-8d6440254719.
Partition UUID '52df1859-e144-348d-2cb1-8d6440254719' does not match expected UUID 'f5b6aff5-945d-946e-faf4-d482c07f9968' derived from usr verity hash, ignoring.
<...>
  ID_DISSECT_PART2_DESIGNATOR=usr-verity-sig
  ID_DISSECT_PART3_ARCHITECTURE=x86-64
  ID_DISSECT_PART3_DESIGNATOR=usr-verity
  ID_DISSECT_PART4_ARCHITECTURE=x86-64
  ID_DISSECT_PART4_DESIGNATOR=usr
  ID_DISSECT_PART4_HAS_VERITY=1
  ID_DISSECT_PART4_HAS_VERITY_SIG=1
  ID_DISSECT_PART4_ROOTHASH=f5b6aff5945d946efaf4d482c07f9968d7acad57995d297dbf6ca58821dcd28a
  ID_DISSECT_PART4_ROOTHASH_SIG=<...>
  ID_DISSECT_PART4_VERITY_DEVICE=/dev/disk/by-diskseq/9-part3
  ID_DISSECT_PART4_VERITY_SIG_DEVICE=/dev/disk/by-diskseq/9-part2

Fixes https://github.com/systemd/systemd/issues/39655
2025-11-11 17:43:24 +00:00
Mike Yuan
2a64b56da4 acl-util: fall back to fchmod() if libacl is not around, too 2025-11-10 23:06:14 +01:00
Mike Yuan
4175cd4f40 acl-util: drop now unused fd_acl_make_writable() 2025-11-10 23:06:14 +01:00
Mike Yuan
e4c7e4c27a mount-util: introduce fsmount_credentials_fs()
While at it, remove effectively unused size and ro params.
2025-11-10 22:38:21 +01:00
Mike Yuan
c7b5f7f30f creds-util: use U64_* macros where appropriate 2025-11-10 22:38:21 +01:00
Yu Watanabe
9485379850 resolve: several follow-ups for json output (#39605)
Follow-ups for #38960.
2025-11-10 22:32:28 +09:00
Yu Watanabe
39adbedafc various: assorted cleanups for safe_fork (#39661) 2025-11-10 18:40:16 +09:00
Yu Watanabe
f50f785737 dissect: getenv_fstype() is unused when LIBBLKID support is disabled
Follow-up for aad0d11e7c.
2025-11-10 18:38:32 +09:00
Yu Watanabe
76c674ec25 resolve: use enum for several fields
Unfortunately, we have already exposed dnssec with hyphen, so we cannot
change it as enum.
2025-11-10 11:02:33 +09:00
Mike Yuan
d9f993dd86 hostname-setup: prefix helper process name with "sd-" 2025-11-10 02:55:40 +01:00
Yu Watanabe
445b7073c7 repart: Correctly handle btrfs compression (#39597)
systemd-repart is incorrectly choosing the loop-mount
code path to copy files after formatting, instead of using the --rootdir
path, which is required by mkfs.btrfs to apply compression (since it's
on files, not the fs).

So two fixes (and an integ test):

1. If Btrfs compression is requested without a root directory (e.g.,
Compression= without CopyFiles=), we now log a warning and skip the
--compress flag. This prevents the mkfs.btrfs failure, and it's
meaningless anyway without any files.
2. The logic in repart now uses the --rootdir code path whenever the
partition is btrfs and compression is requested. Otherwise it still
won't work even in the legitimate case because use the loop mounting
code, which is too late to use --compress.

Fixes: https://github.com/systemd/systemd/issues/39584
2025-11-10 01:52:19 +09:00
Yu Watanabe
b3c117172f bpf-compat: coding style cleanups 2025-11-09 18:13:44 +09:00
Yu Watanabe
7304557ea9 reread-partition-table: fix error code check
flock() sets EAGAIN rather than EBUSY when a node is already locked.

Follow-up for d8e38d4aaa.
Fixes #39544.
2025-11-09 18:12:38 +09:00
Yu Watanabe
0213b68969 libarchive-util: several cleanups
- use loop for checking existence of functions,
- rename HAVE_LIBARCHIVE_XYZ -> HAVE_ARCHIVE_XYZ to make them match with
  the function name,
- do not conditionally include user-util.h in libarchive-util.h,
- sort library function symbols.
2025-11-09 18:09:31 +09:00
Lennart Poettering
aae054e1ab nsresource: allow multiple userns from the same process in parallel
When generating a name for a transient userns automatically we so far
just included our PID to make it unique. That doens't really work if
multiple userns shall be kept in parallel by a single process. Let's hence
include a counter as well.
2025-11-08 18:32:37 +01:00
Yu Watanabe
9d6c34a297 network: fix typo
Follow-up for dd2934d44e.
2025-11-08 04:27:57 +09:00
Yu Watanabe
88f6611260 tar-util: make sure we can unpack hardlinked symlinks (#39619) 2025-11-08 00:08:44 +09:00
Anton Tiurin
dd2934d44e network: expose Describe Varlink, use for networkctl list & status
Both `list` and `status` with `--json=pretty|short` show the description.
It is fetched via D-Bus by org.freedesktop.network1.Manager.Describe

This change exposes the same data via Varlink API `io.systemd.Network.Describe`
and migrates networkctl list and status commands to use Varlink API.

Update GetStates IDL to use enums for link states.
2025-11-08 00:08:00 +09:00
Lennart Poettering
36e10dc5a5 tar-util: make sure we can unpack hardlinked symlinks
This is something ostree does. Yuck. But let's make t work.
2025-11-07 14:04:36 +01:00
Chris Down
adf88771ff mkfs-util: Ignore btrfs compression when there is no dir to copy
mkfs.btrfs requires that the --compress option be used together with
--rootdir, as compression only makes sense in that context (because
compression is not a persistent setting).

Right now, If --compress is specified without --rootdir, mkfs.btrfs
fails with:

  ERROR: --compression must be used with --rootdir

This can occur when repart is configured with Compression= but the
partition populate logic doesn't use the --rootdir code path (eg. when
using loop device mounting to copy files after mkfs).

Add a defensive check to skip compression and emit a user-friendly
warning when compression is requested but no root directory is
provided. The warning message references the repart directive names
(Compression= and CopyFiles=) rather than low-level mkfs options to
help users understand the requirement.

This prevents crashes but doesn't enable compression, that requires
ensuring the --rootdir code path is used, which it currently is not and
will be addressed in the next patch.

Fixes: https://github.com/systemd/systemd/issues/39584
2025-11-07 18:17:08 +08:00
Yu Watanabe
d8e38d4aaa reread-partition-table: trigger change events when we failed to lock device
Before aa47d8ade1, when we failed to lock
the device node, we simply trigger change events for the device and its
partitions. But the commit killed the fallback logic. Let's restore that.

Fixes #39544.
2025-11-07 16:35:44 +09:00
Yu Watanabe
d1676fdfbd Two fixes for homectl (#39591) 2025-11-07 05:52:20 +09:00
Luca Boccassi
74c0ed07a1 reread-part: fix error propagation
[   49.514556] (udev-synth)[1385]: Assertion '(_error) != 0' failed at src/shared/reread-partition-table.c:260, function reread_partition_table_full(). Aborting.

Follow-up for 757887d01d

Fixes https://github.com/systemd/systemd/issues/39603
2025-11-07 05:50:20 +09:00
David Tardon
399c9f847e ask-password-api: return if read_credential() failed
The current code causes assertion in strv_parse_nulstr() if
read_credential() results in an error different from ENXIO or ENOENT
(strace shows I'm getting EACCES):

 # homectl create waldo --real-name=Waldo --disk-size=200M

Before:

 Assertion 's || l <= 0' failed at src/basic/nulstr-util.c:32, function strv_parse_nulstr_full(). Aborting.

After:

 Failed to acquire password: Permission denied

Follow-up-for: 8806bb4bc7
2025-11-06 14:23:35 +01:00
Nick Rosbrook
01278ceba0 resolve: add DumpDNSConfiguration to varlink API
Add io.systemd.Resolve.DumpDNSConfiguration. This provides the same
information as io.systemd.Resolve.Monitor.SubscribeDNSConfiguration,
but just returns the configuration once without the subscription logic.

In order to use the same definitions for DNSConfiguration et al. between
both interfaces, move the definitions to io.systemd.Resolve, and include
them in io.systemd.Resolve.Monitor.

This will be used to implement --json for resolvectl status.
2025-11-06 05:17:59 -05:00
Nick Rosbrook
0d9e5b39d3 resolve: add formatted address string to DNSServer
Although the JSON output is mostly intended to be machine readable,
humans also consume the output through logs and scripts.

Add an addressString field to DNSServer to improve human-readability.
2025-11-06 05:17:59 -05:00
Nick Rosbrook
f5d5ef9cb4 resolve: add fallback servers list to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook
9f9264e3f6 resolve: add resolv.conf mode to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook
ed4d43f88f resolve: add all protocol modes to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook
306375c368 resolve: add DNS scope info to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:58 -05:00
Nick Rosbrook
a80f9291cc resolve: add negative trust anchors to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:58 -05:00
Nick Rosbrook
34be1fadde resolve: add delegate info to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:58 -05:00
Chris Down
8ab6925c5e systemctl: Support --timestamp for otherwise named properties
`systemctl show`'s `--timestamp` flag is supposed to reformat all
timestamp-based properties. However, the logic for detecting these
properties was incomplete and only checked if the name ended in
Timestamp.

Expand the check to explicitly include some non-"timestamp" named
properties that really are timestamps.

Fixes: https://github.com/systemd/systemd/issues/39282
2025-11-06 07:45:06 +09:00
Yu Watanabe
f91fd8d5a1 tar-util: fix typo
Follow-up for 4ded7f7a43.
2025-11-05 18:17:23 +09:00
Yu Watanabe
5963cdf498 tree-wide: add missing '#pragma once' 2025-11-05 05:16:34 +09:00