Commit Graph

82251 Commits

Author SHA1 Message Date
Yu Watanabe
cef4ec347f ioprio-util: move from basic/ to shared/
It is not used by libsystemd.
2025-06-19 19:08:45 +09:00
Yu Watanabe
d26faa3186 missing_network: IPPROTO_MPTCP is already defined in linux/in.h
And the header is already included through (our implementation of)
netinet/in.h, hence we can safely drop the definition here.
2025-06-19 19:08:45 +09:00
Yu Watanabe
92b64168f6 sd-lldp: replace ETHERTYPE_LLDP with ETH_P_LLDP
ETH_P_LLDP is defined in linux/if_ether.h.
2025-06-19 19:08:45 +09:00
Yu Watanabe
dbfe2faa48 port write_env_file() to label_os_pre() + teach firstboot a bit of relabelling (#37869)
This is a clean-up, and also addresses some of the points of #37857.
2025-06-19 18:03:12 +09:00
Yu Watanabe
079a135eee test-cpu-set-util: use ASSERT_XYZ() macros 2025-06-18 16:36:14 +01:00
Lukas Nykryn
64fcb07199 man: encourage the creation of empty machine-id instead of deleting it
Current text hints that machine-id in template image should be empty
if the system is read-only. But most of the bare metal systems and
regular VMs have /etc read-only at this phase of boot.
2025-06-18 16:58:18 +02:00
Lennart Poettering
ea71d34738 fd-util: move cmsg_close_all() to socket-util.[ch]
This call only makes sense on sockets, it's not a generic fd concept,
hence let's move this over.
2025-06-18 19:06:11 +09:00
Matteo Croce
030b227cec test: add test for systemd upgrade
Add a basic test to check that systemd works after an upgrade
2025-06-18 09:51:21 +01:00
Yu Watanabe
43aacae83a dirent-util: use getdents64() as is
This partially reverts e86a492ff0.

The function getdents64() was introduced in glibc-2.30, and our baseline
on glibc is 2.31. Hence, we can assume the function always exists.
The posix_getdents() wrapper was introduced for compatibility with musl.
However, even the latest release of musl does not provide posix_getdents()
yet. Also, even with musl, by defining _LARGEFILE64_SOURCE, we can get
getdents64() and struct dirent64. Hence, the wrapper is anyway not
necessary.
2025-06-18 10:45:49 +02:00
Yu Watanabe
abb99d3168 mallinfo-util: assume mallinfo() exists
The check existed for musl. Let's remove it, as we explicitly request glibc.

While removing the check, this also drops generic_mallinfo, introduces
a tiny converter from struct mallinfo to struct mallinfo2 if mallinfo2()
does not exist, and renames mallinfo-util.h to malloc.h.

With this change, we can drop many ifdefs and casts in .c files.
2025-06-18 10:45:27 +02:00
Lennart Poettering
17f2b40f22 sd-bus: several coding style cleanups (#37867)
- replace `type *func()` -> `type* func()`,
- rename arguments for storing results,
- add several missing assertions.
2025-06-18 10:39:48 +02:00
Lennart Poettering
f4bcda39f2 update TODO 2025-06-18 10:29:55 +02:00
Lennart Poettering
611bb28dc3 firstboot: make sure labelling is enabled
Preparation to address #37857.
2025-06-18 10:29:29 +02:00
Lennart Poettering
ee8e7000f2 tmpfiles: fix symlink creation when replacing
When we remove an existing inode in order to create a symlink we need to
create the symlink via a pinned directory again, instead of using an
absolute path, otherwise this will not work in the --root= case.

Let's fix this, and switch this over to symlinkat_atomic_full().
2025-06-18 10:23:44 +02:00
Lennart Poettering
f6e213e86a firstboot: use WRITE_STRING_FILE_LABEL more
Let's explicitly label 3 key files we generate in systemd-firstboot.

Addresses some more of #37857.
2025-06-18 10:21:26 +02:00
Lennart Poettering
3e5320e27d env-file: port write_env_file() to label_ops_pre()
Let's make more use of label_ops_pre()/label_ops_post(), and replace
write_env_file_label() by a flag to write_env_file().

This simplifies and normalizes the code.

This also makes one relevant change: it sets the new
WRITE_ENV_FILE_LABEL flag in firstboot.c when we write locale.conf,
where we previously did not (but should have). This should address one
detail of #37857.
2025-06-18 10:21:26 +02:00
Lennart Poettering
9ea5a6e7d6 fs-util: replace symlink_atomic_full_label() by a flag to symlinkat_atomic_full()
More porting work to label_ops_pre()/label_ops_post()

This also enables labelling of the /etc/localtime symlink in
systemd-firstboot, which should address one small facet of #37857
2025-06-18 10:21:25 +02:00
Yu Watanabe
2c7f35b144 sd-lldp: several improvements (#37845)
This makes
- sd-lldp-tx not send machine ID as chassis ID, but use application
specific machine ID,
- sd-lldp-tx emit vlan ID if it is running on a vlan interface,
- Describe() DBus method also reply LLDP configurations,
- io.systemd.Network.GetLLDPNeighbors varlink method provides vlan ID,
if received.

Closes #37613.
2025-06-18 04:58:04 +09:00
George Tsiamasiotis
c60d2a626b resolved: Tweak link-local addresses relevancy
We now consider link-local addresses routable when we have configured
unicast link-local dns servers. This allows creating the DNS scope, even
when the interface doesn't get a routable address.
2025-06-18 04:57:27 +09:00
Yu Watanabe
9d5f05ae22 bus-util: coding style cleanups
- replace `type *func()` -> `type* func()`,
- rename arguments for storing results.
2025-06-18 01:55:46 +09:00
Yu Watanabe
31a1e15ccb sd-bus: coding style cleanups
- replace `type *func()` -> `type* func()`,
- rename arguments for storing results,
- add several missing assertions.
2025-06-18 01:54:07 +09:00
Yu Watanabe
8cec3cbeb1 sd-bus: BusMessageContainer.begin is always zero in sd_bus_message_open_container() 2025-06-18 01:54:07 +09:00
Yu Watanabe
e08fdfdd7d test-network: compare LLDP sender and receiver information 2025-06-18 01:51:19 +09:00
Yu Watanabe
f0a05209f9 network: also include information about LLDP sender in reply for Describe() method
Addresses https://github.com/systemd/systemd/pull/37845#issuecomment-2973257825.
2025-06-18 01:51:19 +09:00
Yu Watanabe
b6f96f635f sd-lldp-tx: introduce sd_lldp_tx_describe() to dump current settings 2025-06-18 01:51:16 +09:00
Yu Watanabe
aeac400d1b boot: fix typo
Follow-up for cab9c7b5a4.
2025-06-18 01:47:49 +09:00
Yu Watanabe
4c45437b60 sd-lldp-rx: also dump received MUD URL 2025-06-18 00:53:24 +09:00
Yu Watanabe
2da3957b63 network/lldp-tx: also emit VLAN ID 2025-06-18 00:53:24 +09:00
Yu Watanabe
898513783e sd-lldp-tx: allow to emit VLAN ID 2025-06-18 00:53:24 +09:00
Yu Watanabe
0597109ddf sd-lldp-tx: append capabilities before MUD URL
No functional change, but let's append vendor specific informations
after others to sort the TLVs with their type.
2025-06-18 00:53:24 +09:00
Yu Watanabe
27546b769c sd-lldp-tx: do not expose machine ID by default
Previously, systemd-networkd sent machine ID as chassis ID.
Let's use application specific machine ID.

This is a kind of backward compat breaking. Hence, this also introduces
the support of $SD_LLDP_SEND_MACHINE_ID environment variable.

Closes #37613.
2025-06-18 00:53:20 +09:00
Daan De Meyer
4fe348cfdf cgroup-util: Always open cgroupv2 attribute files in O_NONBLOCK mode
As explained in https://lore.kernel.org/all/20250419183545.1982187-1-shakeel.butt@linux.dev/,
writing to memory.max or memory.high triggers synchronous memory reclaim
if the limit is lowered. This can end up taking nonnegligible amounts
of time, completely blocking pid1 from doing any other work while the
reclaim is ongoing.

To address this problem, the kernel going to add O_NONBLOCK semantics
to memory.max and memory.high. If the file is opened with O_NONBLOCK,
the synchronous memory reclaim is skipped and only triggered later
without blocking the process writing the file. Let's make sure we make
use of this by opening cgroupv2 attribute files with O_NONBLOCK.

We opt to do this for all cgroupv2 attribute files, to make sure that
if the same problem happens elsewhere in the future and is fixed in the
same way, we immediately take advantage of that fix without having to
make changes in systemd as well. We probably never want to block when
writing cgroupv2 attributes and any cases where we do want to block should
indicate so explicitly instead of blocking by default.
2025-06-17 15:07:32 +01:00
Lennart Poettering
279962a9e8 core/timer: Introduce RandomOffsetSec= knob (#36437)
This is like RandomDelaySec, but it doesn't reset whenever the manager
restarts.

Fixes https://github.com/systemd/systemd/issues/21166
2025-06-17 16:05:12 +02:00
Lennart Poettering
ef3a0ed834 various: turn off SO_PASSRIGHTS where fds are not expected (#37759) 2025-06-17 15:37:35 +02:00
Lennart Poettering
6e13b284ee stub: call inner kernel directly (#37372)
Since shim 16, it is not possible anymore to override the security arch
protocol to avoid signature check and measurements.

Also on Dell servers, EFI_SECURITY2_ARCH_PROTOCOL is not implemented, so
unexpected measurements on PCR 4 were still happening.

This just loads and run the kernel pe. We verify that there is no
relocation needed. Also for simplification, we assume and verify that
the base address is expected to be 0.
2025-06-17 14:34:53 +02:00
Lennart Poettering
f2a365b982 network/dhcp-server: improvements for saving/loading leases (#37835) 2025-06-17 14:31:22 +02:00
Luca Boccassi
5cdf2c4d40 man: fix varname copypasta 2025-06-17 14:16:36 +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
ed6b7b6ace sd-varlink: hook up fd passing control with SO_PASSRIGHTS
This is a tricky one, because we effectively turn fd passing input
toggle into a tristate: unset, disabled, and enabled; whereas unset
and disabled were identical previously. *Unset* state silently
ignores SCM_RIGHTS passed by invoking recv() instead of recvmsg(),
and for disabled we now disable SO_PASSRIGHTS completely.

The plot thickens when it comes to the server, since we want to
turn off the SO_PASSRIGHTS already on the listening socket so that
there's no race between accept() and recvmsg() wrt SO_PASSRIGHTS state.
However, if we do this unconditionally, the existing use case of
creating a custom connection callback and enabling fd passing there
would be broken.

Hence, let's introduce a new flag,
SD_VARLINK_SERVER_FD_PASSING_INPUT_STRICT, which when set
ties the enablement of fd passing to SO_PASSRIGHTS in server,
and set it for all our varlink servers.

Refer to the previous commit for the rationale behind return value
change in sd_varlink_set_allow_fd_passing_input().
2025-06-17 13:16:44 +02:00
Mike Yuan
72098df843 sd-varlink: unify AF_UNIX check in sd_varlink_set_allow_fd_passing_output()
Currently, the socket type is only checked if the fd passing is
being enabled. The special handling seems unnecessary though,
as in the disable case, either fd passing is already false and
would be caught by the (... == !!b) shortcut at the beginning,
or the AF_UNIX check wouldn't have succeeded in the first place,
for the initial toggle to true. Hence, just uniformly check
AF_UNIX.

While at it, sd_varlink_set_allow_fd_passing_*() oddly return 1
iff changed and !b, which doesn't fit into our coding style and
I can't come up with any use case for such behavior. Let's
return 1 on changed and 0 otherwise.

sd_varlink_set_allow_fd_passing_input() will be fixed in the later
commits with other enhancements.
2025-06-17 13:16:43 +02:00
Mike Yuan
60483ea14c sd-varlink: remove unneeded strdup() 2025-06-17 13:16:43 +02:00
Mike Yuan
9b255107c2 logind: port one remaining varlink server allocation to varlink_server_new() 2025-06-17 13:16:43 +02:00
Mike Yuan
718e7eb184 notify-recv: disable SO_PASSRIGHTS by default in notify_socket_prepare() 2025-06-17 13:16:43 +02:00
Mike Yuan
5c12797fc3 core/socket: introduce AcceptFileDescriptors=
This controls the new SO_PASSRIGHTS socket option in kernel v6.16.
Note that I intentionally choose a different naming scheme than
Pass*=, since all other Pass*= options controls whether some extra
bits are attached to the message, while this one's about denying
file descriptor transfer and it feels more explicit this way.
And diverging from underlying socket option name is precedented
by Timestamping=. But happy to change it to just say PassRights=
if people disagree.
2025-06-17 13:16:42 +02:00
Mike Yuan
f66eeedf6f missing_socket: add SO_PASSRIGHTS 2025-06-17 13:16:42 +02:00
Mike Yuan
35462aa14a core/socket: add PassPIDFD= 2025-06-17 13:16:41 +02:00
Mike Yuan
b81a14b91e core/socket: use universal format string for socket option warnings 2025-06-17 13:16:08 +02:00
Mike Yuan
b36ab0d4ce core/socket: don't suggest PassFileDescriptorsToExec= is a socket option
by not interleaving it among socket options.
2025-06-17 13:16:07 +02:00
Mike Yuan
58f3be82ce udev-ctrl: enable SO_PASSCREDS on listening socket already rather than on accept()
This matches what systemd-udevd-control.socket does.
2025-06-17 13:16:07 +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