Commit Graph

57129 Commits

Author SHA1 Message Date
Lennart Poettering
5615ac1f0d networkd: rename manager_connect_varlink() → manager_varlink_init()
This function doesn't "connect" to Varlink (i.e. it isn't a client) but
it binds a Varlink socket (i.e. it is server), hence let's remove the
verb "connect" from its name. let's copy how machined/resolved name the
counterpart for this function: manager_varlink_init()
2025-11-15 07:52:42 +01:00
Lennart Poettering
a7fa29b1b5 networkd: add support for resolved hook for DHCP server
Let's synthesize DNS RRs for leases handed out by our DHCP server. This
way local VMs can have resolvable hostnames locally.

This does not implement reverse look ups for now. We can add this
later in similar fashion.
2025-11-15 07:52:42 +01:00
Lennart Poettering
4408db6908 sd-dhcp-server: add api to get address from hostname, based on lease data 2025-11-15 07:44:24 +01:00
Lennart Poettering
3cd929f837 machined: implement resolve hook in machined
This basically implements nss-myhostname, but natively in
systemd-resolved, so that the logic becomes available also for clients
using the local DNS stub for resolution or the D-Bus or Varlink APIs.
2025-11-15 07:44:24 +01:00
Lennart Poettering
594352611b machine: minor refactoring, making machine_send_signal() invocations more readable 2025-11-15 07:44:24 +01:00
Lennart Poettering
8209f4adcd resolved: add hook api
This introduces /run/systemd/resolve.hook/ as a new directory that local
(privileged) programs can bind a Varlink socket into. If they do they'll
get a method call for each attempted resolved lookup, which they can
then either process themselves (and generate new records for, or return
errors to block stuff) or let pass so that the regular resolution is
done.

Usecase for this is primarily two things:

1. in machined we can add local resolution of machine names to their IP
   addresses, similar in fashion to nss-mymachines, but working also if
   the non-NSS interfaces to name resolution are used, i.e. the local
   DNS responder. In fact, I think we should eventually remove
   nss-mymachines from our tree, as soon as this code in resolved is
   setlled.

2. in networkd we can add local resolution of names specified in DHCP
   leases we hand out.

But beyond that there should be many other uses, for example people
could write "dns firewalls" with this if they like where they
dynamically block certain names from resolution.

Fixes: #8518
2025-11-15 07:44:24 +01:00
Yu Watanabe
fe9bccb2b7 Make new sd-path configuration search functionality generic (#39684)
Reverts systemd/systemd#38680

After taking a closer look I'm not convinced by the approach, see below.

First of all, all other SD_PATH_SEARCH_* are either somewhat generic,
i.e. encode the common prefix for configurations, binaries, etc., or are
subdirectories under systemd/ hence in our own "domain". The
tmpfiles/sysctl/binfmt we don't prefix with "systemd" precisely because
the concept is generic and there're actually other impls of them. A
specific SD_PATH_SEARCH_SYSCTL doesn't fit into our existing scheme.
Instead something along the lines of "SEARCH_SYSTEM_CONFIGURATION" shall
be introduced, and consumers will just suffix
sysctl.d/tmpfiles.d/binfmt.d for the final result.

And secondly, I don't grok why systemd-sysctl now unnecessarily calls
into sd-path to obtain the fixed search path. None of our other tools do
that.

-----------

An alternate approach, SD_PATH_SYSTEM_SEARCH_CONFIGURATION, which does
exactly above, will be introduced instead. It provides a universal
interface for querying any system config with our idiomatic
/etc/:/run/:/usr/local/lib/:/usr/lib/ hierarchy.
2025-11-15 10:09:19 +09:00
Yu Watanabe
6412e540bc path-util: add generic ignore extension to the hidden files (#39554) 2025-11-15 10:05:38 +09:00
Luca Boccassi
555d878749 varlink: say which socket failed to bind in log message
Makes it a lot easier to debug failures
2025-11-15 10:02:10 +09:00
Yu Watanabe
c7b31a64ee fd-util: do not block O_TMPFILE with -EISDIR (#39736) 2025-11-15 10:01:19 +09:00
Lennart Poettering
b2b8fb8105 boot: report missing GetActivePcrBanks() call in formware as UINT32_MAX PCR bank mask
Fixes: #39150
2025-11-14 22:22:39 +01:00
Lennart Poettering
7643e4a89c tpm2-util: use LoaderTpm2ActivePcrBanks efi var when figuring out best+good banks to use
We nowadays have clear reporting which PCR banks the firmware is using
via LoaderTpm2ActivePcrBanks, hence rely on that.
2025-11-14 22:22:39 +01:00
Lennart Poettering
867e64737a units: measure a separator event into PCR 9 after completing NvPCR initialization
We do this in a separate service (rather than inside of
systemd-tpm2-setup), since we want failures of this measurement to
result in an instant reboot, like for most our measurements.

Failures to initialize nvpcrs, or allocate an SRK are somewhat OK (and
more likely), as long as this separator communicates clearly where they
have to have taken place, if they worked.
2025-11-14 22:22:39 +01:00
Lennart Poettering
86dc140b9f pcrextend: allow setting the event type for the event log on the command line
This makes the tool more powerful as we can invoke it for any type of
measurement correctly
2025-11-14 22:04:58 +01:00
Lennart Poettering
d70296bb56 tpm2-setup: measure information about NvPCR initialization to PCR 9
This locks down NvPCR initilization a bit more: we'll measure each
initialization of an NvPCR into PCR 9, thus chaining the NvPCRs to the
PCR set. After all NvPCRs are initialized we measure a barrier into PCR
9 as well.

This ensures that later additions of NvPCRs are clearly recognizable and
distuingishable from those done at boot.
2025-11-14 22:04:58 +01:00
Lennart Poettering
89bfa9239e tpm2-util: add missing entry in string table
Follow-up for: e5a2e78665
2025-11-14 22:04:58 +01:00
Mike Yuan
0cb7dd5b96 fd-util: do not block O_TMPFILE with -EISDIR
Follow-up for 7cf4f07567
2025-11-14 21:51:28 +01:00
Mike Yuan
87ed096657 fs-util: simplify open_parent_at() a bit
Let's refrain from specifying any access mode when opening
a directory, which matches our usual style and allows us
to drop one condition.
2025-11-14 21:51:28 +01:00
Yu Watanabe
384e88a238 musl: stdio: check if stream is writable earlier in fputs() and friends 2025-11-15 05:10:33 +09:00
Yu Watanabe
08d207ba73 musl: introduce two wrappers (#39700) 2025-11-15 04:18:48 +09: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
Yu Watanabe
1569b1e25f tree-wide: use SD_JSON_BUILD_PAIR_* macros if possible (#39732) 2025-11-15 04:02:51 +09:00
Yu Watanabe
46ea7c3e32 musl: make strtoll() accept strings start with dot
glibc accepts strings start with '.' and returns 0, but musl refuses
them. Let's accept them, as our code assumes the function accept such
strings.
2025-11-15 03:41:40 +09:00
Yu Watanabe
bb7d5e52a2 musl: test-bus-error: drop ._need_free flag checks
Its value depends on how strerror_r() implemented, and the
implementations of the function in glibc and musl are actually
different. Let's drop the checks.
2025-11-15 03:39:35 +09:00
Yu Watanabe
ebb422dd2b musl: introduce GNU specific version of strerror_r()
musl provides XSI compliant strerror_r(), and it is slightly different
from the one by glibc.
Let's introduce a tiny wrapper to convert XSI strerror_r() to GNU one.

The wrapper also patches musl's spurious catchall error message.
2025-11-15 03:37:30 +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
Jelle van der Waa
1b636f1d3f ssh-generator: prefer using SD_JSON_BUILD_PAIR_STRING
No functional change, just refactoring.
2025-11-14 15:43:30 +01:00
Jelle van der Waa
7e5d718046 userdb: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR(
No functional change, just refactoring.
2025-11-14 15:19:57 +01:00
Jelle van der Waa
8ef5e56f97 sd-json: prefer using SD_JSON_BUILD_PAIR_UNSIGNED
No functional change, just refactoring.
2025-11-14 15:19:54 +01:00
Daan De Meyer
6aff6d3ffc sd-event: Move SOURCE_POST check into mark_post_sources_pending()
Rename to maybe_mark_post_sources_pending() as well to match the new
behavior.

Follow up for 4c8b6d636c
2025-11-14 15:18:33 +01:00
Daan De Meyer
c71a8e68ce sd-event: Add comment in event_source_offline() for memory pressure
Follow up for d0ddb0aafb
2025-11-14 15:18:33 +01:00
Daan De Meyer
10c79431a0 Three new sd-event features + various fixes (#39608) 2025-11-14 12:05:12 +01:00
Daan De Meyer
bc8aebdce9 log-context: Don't add log context if value is NULL
This avoids if conditions at the callsite which mess up stack based
lifetimes.
2025-11-14 11:38:59 +01:00
Daan De Meyer
5cf894ad58 basic-forward: Add WaitFlags forward decl 2025-11-14 11:38:59 +01:00
Daan De Meyer
a3dd54c097 sd-event: Make sure iterations of defer and exit sources are updated
Defer and exit event sources are marked pending once when they are added
and never again afterwards. This means their pending_iteration is never
incremented after they are initially added, which breaks fairness among
event sources with equal priority which depend on the pending_iteration
variable getting updated in source_set_pending(). To fix this, let's assign
iterations for defer and exit sources in source_dispatch() instead so that
those get their pending_iteration updated as well.
2025-11-14 11:38:59 +01:00
Daan De Meyer
5a5cb6ba50 sd-event: Add exit-on-idle support
Sometimes it's hard to assign responsibility to a specific event source
for exiting when there's no more work to be done. So let's add exit-on-idle
support where we exit when there are no more event sources.
2025-11-14 11:38:56 +01:00
Daan De Meyer
475729b805 run0: Make --same-root-dir available for run0
This enables running something like
"mkosi box -- run0 --empower --same-root-dir -E PATH" to get an
empowered session as the current user within the "mkosi box" environment.
2025-11-14 10:36:53 +01:00
Daan De Meyer
c11e1001db sd-event: Allow passing WNOWAIT to sd_event_add_child()
This allows doing the reaping outside of the callback, we'll use this
when adding fibers in a later commit.
2025-11-14 10:34:32 +01:00
Daan De Meyer
0a79791d0a sd-event: Drop faulty shortcut
We can't take this shortcut, as we might have to drop the
EPOLLONESHOT flag for some event sources, so drop the shortcut.
2025-11-14 10:34:32 +01:00
Daan De Meyer
d0ddb0aafb sd-event: Only register memory presure if write buffer size is zero
As documented in sd_event_add_memory_pressure(), we can only add
the memory pressure fd to epoll once we've written the watch string,
so make sure we don't register the memory pressure in
event_source_online() until we've written the watch string.
2025-11-14 10:34:32 +01:00
Daan De Meyer
4c8b6d636c sd-event: Mark post sources as pending after dispatching
More post event sources might get added during dispatching, we want
to make sure those become pending as well if we're dispatching a non-post
event source.
2025-11-14 10:34:30 +01:00
Daan De Meyer
6403a81b28 test-cgroup-util: Skip test on ESTALE
The kernel converts a bunch of errors to ESTALE in the open_by_handle_at()
codepath so we treat it as missing privs but it could be absolutely
anything really.
2025-11-14 09:19:01 +01:00
Daan De Meyer
1312353fdd test-rm-rf: Check capabilities
The assertion will succeed if we have the right capability, causing the
test to fail.
2025-11-14 09:19:01 +01:00
Daan De Meyer
a0fb74153d test-id128: Check capability instead of uid 2025-11-14 09:19:01 +01:00
Luca Boccassi
98ae19d9fe integritysetup: Add support for hmac-sha512 and wrapped key HMAC algorithms phmac-sha256 and phmac-sha512 (#39719)
Currently the only supported integrity algorithm using HMAC is
`hmac-sha256`. Add `hmac-sha512` to the list of supported algorithms as
well.

Also add the `PHMAC` integrity algorithm to the list of supported
algorithms. The `PHMAC` algorithm is like the regular HMAC algorithm,
but it takes a wrapped key as input. A key for the `PHMAC` algorithm is
an opaque key blob, who's physical size has nothing to do with the
cryptographic size. Such a wrapped key can for example be a HSM
protected key. Currently PHMAC is only available for the s390x
architecture (Linux on IBM Z).

Support for PHMAC has just been added to the cryptsetup project via MR
https://gitlab.com/cryptsetup/cryptsetup/-/merge_requests/693 by commit

296eb39c60

To allow automatic opening of integrity protected volumes that use PHMAC
via `/etc/integritytab`, this change in systemd's integritysetup tool is
needed as well.
2025-11-14 00:12:34 +00: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
c83f3f0837 musl: add several missing symbols (#39701) 2025-11-14 07:49:16 +09:00
Mike Yuan
fa0ac03a56 stdio-bridge: remove unreachable return 2025-11-13 21:28:17 +01:00
Mike Yuan
045b8d761e run: refuse --root-directory= in --scope mode
As discussed in #39669, let's reject this for now.
2025-11-13 21:17:32 +01:00
Mike Yuan
b0e7c6141f efivars: insert a newline below fstat() call 2025-11-13 21:17:32 +01:00