man: document .membership files that nss-systemd processes
This has been a glaring omission the docs: when people create
.user/.group/.user-privileged/.group-privileged drop-in files, they
should also create matching .membership files.
Alyssa Ross [Wed, 21 Aug 2024 12:21:47 +0000 (14:21 +0200)]
bootctl: don't load etc/machine-info from cwd
arg_root defaults to null, so if --root isn't given, this would try reading
etc/machine-info from the current working directory, which is likely to fail.
Fixes: 77db9ef2ab ("boot: Make sure we take --root into account everywhere.")
Yu Watanabe [Wed, 21 Aug 2024 19:11:52 +0000 (04:11 +0900)]
network/routing-policy-rule: use address family of existing rule when judging if existing rule can be updated
Otherwise, the other RoutingPolicyRule object may not have a valid
address family yet, and the existing rule may be wrongly handled as
that it is not requested by any interface, and it may be removed.
Ronan Pigott [Wed, 21 Aug 2024 14:49:59 +0000 (07:49 -0700)]
resolved: demote the fallback dns servers
This softens the behavior originally introduced in eded61e410df to apply
only to the fallback dns servers.
The intent is that the global FallbackDNS (instead of DNS) can now be
used in conjunction with the per-link dns, providing a fallback behavior
without introducing a scope overlap.
References: eded61e410df (resolved: demote the global unicast scope, 2024-08-19)
Ronan Pigott [Tue, 20 Aug 2024 17:25:28 +0000 (10:25 -0700)]
resolved: use the fallback servers when no default dns is configured
This expands the role of fallback servers so they are applied not only
when there are no dns servers configured, but when all the configured
dns servers are configured only for non-default-route links.
Ronan Pigott [Wed, 21 Aug 2024 13:59:22 +0000 (06:59 -0700)]
Revert "resolved: demote the global unicast scope"
This commit may have been a breaking change for sd-resolved foreign
resolv.conf mode, where a legacy network management daemon directly
modifies resolv.conf and sd-resolved consumes that.
With the mentioned commit, iff E2BIG we'd retry pidfd_spawn()
with POSIX_SPAWN_SETCGROUP disabled. However, the same strategy
should actually apply to EOPNOTSUPP/ENOSYS/EPERM too -
they can mean two things here: no clone3() or no CLONE_PIDFD.
Therefore, let's first try clone() + CLONE_PIDFD, and fall further back
to plain clone() (posix_spawn()) only as last resort. Plus, record
the fact so that we don't unnecessarily retry every single time
if CLONE_PIDFD is the one that's unavailable.
Daan De Meyer [Wed, 26 Jun 2024 18:33:06 +0000 (20:33 +0200)]
repart: Allow Subvolumes= and DefaultSubvolume= when running offline
mkfs.btrfs has recently learned new options --subvol and --default-subvol
so let's stop failing when Subvolumes= and DefaultSubvolume= are used offline
and use the new --subvol and --default-subvol options instead to create subvolumes
in the generated root filesystem without root privileges or loop devices.
Peter Hutterer [Mon, 12 Aug 2024 04:05:13 +0000 (14:05 +1000)]
logind: warn about EVIOCREVOKE errors other than EINVAL too
EINVAL means the kernel doesn't support it, ENODEV means it's
already revoked or the device is no longer there which has the same
effect anyway. All others - let's print an error to the logs.
Yu Watanabe [Wed, 21 Aug 2024 01:23:06 +0000 (10:23 +0900)]
sd-dhcp-client: refuse to send RELEASE or friends gracefully when the daemon is stopped or so
We can easily hit the assertions without checking the internal states of
the DHCP client before calling these functions. That's annoying.
Let's do more gracefully.
Yu Watanabe [Wed, 21 Aug 2024 02:24:14 +0000 (11:24 +0900)]
sd-dhcp-client: do not call callback with SD_DHCP_CLIENT_EVENT_STOP if already stopped
When an interface enters the failed state, even if the DHCP client is
stopped, the acquired DHCP lease is not unreferenced, as the callback
dhcp4_handler() do nothing in that case. When the failed interface is
being reconfigured after that, the DHCP client is stopped again
(though it is already stopped), and SD_DHCP_CLIENT_EVENT_STOP event is
triggered and sd_dhcp_client_send_release() is called, and the
assertion in the function is triggered.
E.g.
===
systemd-networkd[98588]: wlp59s0: DHCPv4 address 192.168.86.250/24, gateway 192.168.86.1 acquired from 192.168.86.1
systemd-networkd[98588]: wlp59s0: Could not set DHCPv4 route: Nexthop has invalid gateway. Network is unreachable
systemd-networkd[98588]: wlp59s0: Failed
systemd-networkd[98588]: wlp59s0: State changed: configuring -> failed
systemd-networkd[98588]: wlp59s0: The interface entered the failed state frequently, refusing to reconfigure it automatically.
systemd-networkd[98588]: wlp59s0: DHCPv4 client: STOPPED
systemd-networkd[98588]: wlp59s0: DHCPv4 client: State changed: bound -> stopped
systemd-networkd[98588]: Got message type=method_call sender=:1.449 destination=org.freedesktop.network1 path=/org/freedesktop/network1 interface=org.freedesktop.network1.Manager member=ReconfigureLink ...
systemd-networkd[98588]: wlp59s0: State changed: failed -> initialized
systemd-networkd[98588]: wlp59s0: found matching network '/etc/systemd/network/50-wifi.network'.
systemd-networkd[98588]: wlp59s0: Configuring with /etc/systemd/network/50-wifi.network.
systemd-networkd[98588]: wlp59s0: DHCPv4 client: STOPPED
systemd-networkd[98588]: Assertion 'sd_dhcp_client_is_running(client)' failed at src/libsystemd-network/sd-dhcp-client.c:2197, function sd_dhcp_client_send_release(). Aborting.
===
Yu Watanabe [Tue, 20 Aug 2024 22:01:47 +0000 (07:01 +0900)]
network: enter initialized state when the interface will be reconfigured
When the interface is in the failed state, link_getlink_handler_internal()
will do nothing and return zero, thus the interface will not be
reconfigured, especially when the reconfiguration is triggered in
link_enter_failed().
In some kernels (specifically, 5.4) even though the clone3 syscall is
supported, setting CLONE_INTO_CGROUP is not. The error message returned
in this case is E2BIG.
If posix_spawn_wrapper encounters this error, it does not retry, and
cannot spawn any programs in said kernels.
This commit adds a check for the E2BIG error and retries pidfd_spawn()
without the POSIX_SPAWN_SETCGROUP flag.
If we encounter an E2BIG error, and the pidfd_spawn() succeeds after
removing the POSIX_SPAWN_SETCGROUP flag, then we cache the result so
that we do not retry every time.
Originally, this issue was reported in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1077204.
Yu Watanabe [Tue, 20 Aug 2024 11:56:35 +0000 (20:56 +0900)]
test-network: do not pass '[detached]' to 'ip rule del'
That indicates the interface name in 'iif' or 'oif' cannot be resolved
when 'ip rule' command is invoked. That's natural when networkd fail to
remove rule but the corresponding interface is already removed.
To make not the residual rules interfere subsequent test cases, let's
ignore the flag and actually remove unwanted rules.
Yu Watanabe [Mon, 19 Aug 2024 22:00:44 +0000 (07:00 +0900)]
network/routing-policy-rule: also manage remaining attributes
Currently, these attributes are not configured by us, but there may be a
existing rule created by user manually with one of these attribute.
To correctly manage such foreign rules, let's read these attributes.
Yu Watanabe [Mon, 19 Aug 2024 21:19:46 +0000 (06:19 +0900)]
network/routing-policy-rule: remove rules that have conflicting flags
The kernel does not distinguish rules with different flags in
rule_exists(), but the flags of an existing rule cannot be updated.
Let's remove rules that have conflicting flags, and configure new rules
later with requested flags.
Yu Watanabe [Mon, 19 Aug 2024 19:11:19 +0000 (04:11 +0900)]
network/routing-policy-rule: anyway detach rule even when we fail to remove it
When we fail to remove a rule, that mostly means the rule does not exist
in the kernel anymore, e.g. already removed manually and we have not
received notification about that yet.
Let's detach the rule in that case.
Yu Watanabe [Mon, 19 Aug 2024 19:02:46 +0000 (04:02 +0900)]
network/routing-policy-rule: do not save rule to Manager before it is configured
Otherwise, if we fail to configure the rule, then the manager will keep
nonexistent rule forever. So, let's first copy the rule and put it on
Request, then on success generate a new copy based on the netlink
notification and store it to Manager.
Yu Watanabe [Mon, 19 Aug 2024 18:56:33 +0000 (03:56 +0900)]
network/routing-policy-rule: skip requesting when rule is already requested
If it is already requested, the new request will be anyway silently refused by
link_queue_request_safe(), which returns 0 in such case. Let's return earlier.
There should be no functional change, just refactoring.
Ronan Pigott [Mon, 19 Aug 2024 20:18:10 +0000 (13:18 -0700)]
resolved: demote the global unicast scope
This will greatly reduce the number of cases where the global unicast
scope overlaps with link scopes configured as default-route, making it
feasible to use the global DNS setting in conjunction with per-link dns
servers configured by the network.
This change is preferred over demoting links to default-route=no where
the user prefers to use the network provided DNS servers, and I expect
it is non-disruptive in that it should not degrade the efficacy of any
existing configuration.
terminal-util: don't assume errno is correctly set when using isatty_safe()
let's instead generate ENOTTY on our own. This is more correct with out
coding style (since we generally do not propagate errors via errno), and
also addresses #34039 as side effect. (#34039 really needs to be fixed
in musl though, too, this is just a work-around as side-effect).
maia x. [Mon, 19 Aug 2024 19:47:21 +0000 (12:47 -0700)]
namespace: Fix extension release memory leak
In apply_one_mount(), in the MOUNT_EXTENSION_DIRECTORY case,
char **extension_release was used as a return pointer twice but only
cleaned up once in the end. Fix it by removing duplicate code that
was causing this issue.
Yu Watanabe [Sat, 17 Aug 2024 11:13:12 +0000 (20:13 +0900)]
network/routing-policy-rule: use int32_t for suppress_prefixlen
The kernel parses FRA_SUPPRESS_PREFIXLEN as uint32_t, but internally
handled as signed integer and negative values as unset. Let's explicitly
specify the size of the variable.