]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
15 months agotest-network: find routing policy rule by priority
Yu Watanabe [Wed, 21 Aug 2024 19:16:09 +0000 (04:16 +0900)] 
test-network: find routing policy rule by priority

We usually configure a test rule with a unique priority. Hence, finding
rule by priority reduces the lines of output, and we can debug easily.

Also print short comments on check. That's helpful when the check is
called several times.

15 months agonetwork/routing-policy-rule: use address family of existing rule when judging if...
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.

Follow-up for 727235006a7e8904f8493d32376cffa6969c5fa9.
Fixes #34068.

15 months agoMerge pull request #34055 from whot/wip/eviocrevoke-warnings
Yu Watanabe [Wed, 21 Aug 2024 16:34:35 +0000 (01:34 +0900)] 
Merge pull request #34055 from whot/wip/eviocrevoke-warnings

Update warnings for failed EVIOCREVOKE invocations

15 months agoMerge pull request #34054 from yuwata/network-failed-state
Yu Watanabe [Wed, 21 Aug 2024 16:22:29 +0000 (01:22 +0900)] 
Merge pull request #34054 from yuwata/network-failed-state

network: several fixlets for reconfiguration after entered failed state

15 months agonetworkctl: split networkctl.c into small pieces
Yu Watanabe [Wed, 21 Aug 2024 06:31:57 +0000 (15:31 +0900)] 
networkctl: split networkctl.c into small pieces

No functional change, just refactoring.

15 months agoMerge pull request #33498 from DaanDeMeyer/btrfs
Daan De Meyer [Wed, 21 Aug 2024 15:19:09 +0000 (17:19 +0200)] 
Merge pull request #33498 from DaanDeMeyer/btrfs

repart: Allow Subvolumes= when running offline

15 months agoRevert "cgroup-util: Don't try to open pidfd for kernel threads"
Daan De Meyer [Wed, 21 Aug 2024 09:25:46 +0000 (11:25 +0200)] 
Revert "cgroup-util: Don't try to open pidfd for kernel threads"

The kernel patch was reverted so let's try again to open pidfds
for kernel threads.

This reverts commit ead48ec35c863650944352a3455f26ce3b393058.

15 months agoMerge pull request #34049 from yuwata/network-routing-policy-rule
Luca Boccassi [Wed, 21 Aug 2024 10:46:37 +0000 (12:46 +0200)] 
Merge pull request #34049 from yuwata/network-routing-policy-rule

network: further rework for routing policy rule

15 months agorepart: Allow Subvolumes= and DefaultSubvolume= when running offline 33498/head
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.

15 months agorepart: Don't add same dir to MakeDirectories= or Subvolumes= twice
Daan De Meyer [Wed, 14 Aug 2024 15:31:30 +0000 (17:31 +0200)] 
repart: Don't add same dir to MakeDirectories= or Subvolumes= twice

15 months agorepart: Constify partition_needs_populate()
Daan De Meyer [Thu, 8 Aug 2024 18:16:55 +0000 (20:16 +0200)] 
repart: Constify partition_needs_populate()

15 months agorepart: Use loop_device_error_is_fatal() in one more place
Daan De Meyer [Wed, 26 Jun 2024 18:32:13 +0000 (20:32 +0200)] 
repart: Use loop_device_error_is_fatal() in one more place

15 months agologind: warn about EVIOCREVOKE errors other than EINVAL too 34055/head
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.

15 months agonetwork/ipv4acd: adjust comment and logging 34054/head
Yu Watanabe [Wed, 21 Aug 2024 01:47:09 +0000 (10:47 +0900)] 
network/ipv4acd: adjust comment and logging

15 months agosd-dhcp-client: actually restart daemon after sending DECLINE message
Yu Watanabe [Wed, 21 Aug 2024 01:31:34 +0000 (10:31 +0900)] 
sd-dhcp-client: actually restart daemon after sending DECLINE message

client_stop() sets DHCP_STATE_STOPPED to client->state, thus the server
never restarted.

15 months agosd-dhcp-client: stop client without calling notification after sending RELEASE
Yu Watanabe [Wed, 21 Aug 2024 01:24:44 +0000 (10:24 +0900)] 
sd-dhcp-client: stop client without calling notification after sending RELEASE

Otherwise, even the acquired lease is released, the client may be in
e.g. BOUND state or so, and may send renew or rebind after timeout
later.

15 months agosd-dhcp-client: refuse to send RELEASE or friends gracefully when the daemon is stopp...
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.

15 months agosd-dhcp-client: do not call callback with SD_DHCP_CLIENT_EVENT_STOP if already stopped
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.
===

15 months agonetwork: log and enter failed state in link_reconfigure()
Yu Watanabe [Tue, 20 Aug 2024 22:07:05 +0000 (07:07 +0900)] 
network: log and enter failed state in link_reconfigure()

No functional change, just refactoring.

15 months agonetwork: enter initialized state when the interface will be reconfigured
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().

Follow-up for c2eb7753dd47ec04ae0d66400e70bc87fbf1adcc.

15 months agonetwork: introduce reconfigure_data_free() and _freep()
Yu Watanabe [Tue, 20 Aug 2024 22:17:19 +0000 (07:17 +0900)] 
network: introduce reconfigure_data_free() and _freep()

No functional change, just refactoring.

15 months agoMerge pull request #34018 from yuwata/network-address-label
Yu Watanabe [Tue, 20 Aug 2024 17:05:22 +0000 (02:05 +0900)] 
Merge pull request #34018 from yuwata/network-address-label

network: allow to configure IPv6 address label in networkd.conf

15 months agoprocess-util: handle pidfd_spawn() returning E2BIG
Kornilios Kourtis [Thu, 15 Aug 2024 15:22:35 +0000 (17:22 +0200)] 
process-util: handle pidfd_spawn() returning E2BIG

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.

Signed-off-by: Kornilios Kourtis <kornilios@gmail.com>
15 months agotests: Don't override QemuKvm= value if TEST_NO_KVM=0
Daan De Meyer [Tue, 20 Aug 2024 12:39:45 +0000 (14:39 +0200)] 
tests: Don't override QemuKvm= value if TEST_NO_KVM=0

Let's disable KVM if TEST_NO_KVM=1 is set but let's not specify anything
if it's not set so the QemuKvm= setting from mkosi.conf is used.

15 months agotest-network: add test for ManageForeignRoutingPolicyRules= 34049/head
Yu Watanabe [Tue, 20 Aug 2024 01:33:42 +0000 (10:33 +0900)] 
test-network: add test for ManageForeignRoutingPolicyRules=

15 months agotest-network: add tests for Type=table, goto, and nop
Yu Watanabe [Tue, 20 Aug 2024 01:07:10 +0000 (10:07 +0900)] 
test-network: add tests for Type=table, goto, and nop

15 months agotest-network: do not pass '[detached]' to 'ip rule del'
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.

15 months agonetwork/routing-policy-rule: support all known type of rule
Yu Watanabe [Mon, 19 Aug 2024 20:16:53 +0000 (05:16 +0900)] 
network/routing-policy-rule: support all known type of rule

This also adds GoTo= to specify the target priority of goto rule.

Note, table was the default but could not be specified in Type=.

15 months agonetwork/routing-policy-rule: also manage remaining attributes
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.

15 months agosd-netlink: introduce sd_netlink_message_read_u64()
Yu Watanabe [Mon, 19 Aug 2024 21:56:53 +0000 (06:56 +0900)] 
sd-netlink: introduce sd_netlink_message_read_u64()

15 months agonetwork/routing-policy-rule: remove rules that have conflicting flags
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.

15 months agonetwork/routing-policy-rule: anyway detach rule even when we fail to remove it
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.

15 months agonetwork/routing-policy-rule: do not save rule to Manager before it is configured
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.

This is the same as 0a0c2672dbd22dc85d660e5baa7e1bef701beb88, but for
routing policy rule.

15 months agonetwork/routing-policy-rule: skip requesting when rule is already requested
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.

15 months agonetwork/address-label: allow to configure IPv6 address label in networkd.conf 34018/head
Yu Watanabe [Sat, 17 Aug 2024 04:33:35 +0000 (13:33 +0900)] 
network/address-label: allow to configure IPv6 address label in networkd.conf

Closes #23159.

15 months agonetwork/queue: introduce manager_queue_request_full()
Yu Watanabe [Sat, 17 Aug 2024 04:04:03 +0000 (13:04 +0900)] 
network/queue: introduce manager_queue_request_full()

Currently it is not used, but will be used later.

15 months agonetwork/address-label: split out address_label_fill_message()
Yu Watanabe [Sat, 17 Aug 2024 04:02:06 +0000 (13:02 +0900)] 
network/address-label: split out address_label_fill_message()

No functional change, just refactoring and preparation for later
commits.

15 months agonetwork/address-label: several cleanups for conf parsers
Yu Watanabe [Sat, 17 Aug 2024 03:38:44 +0000 (12:38 +0900)] 
network/address-label: several cleanups for conf parsers

- Check userdata, instead of data, though they point to the same
  position.
- Support an empty string.
- Use UINT32_MAX, as the label is uint32_t.

15 months agonetwork/address-label: introduce custom hash_ops
Yu Watanabe [Sat, 17 Aug 2024 03:36:18 +0000 (12:36 +0900)] 
network/address-label: introduce custom hash_ops

No functional change, just refactoring.

15 months agonetwork/routing-policy-rule: add trailing period to the log message
Yu Watanabe [Mon, 19 Aug 2024 18:52:47 +0000 (03:52 +0900)] 
network/routing-policy-rule: add trailing period to the log message

15 months agonetwork/routing-policy-rule: do not modify RountingPolicyRule objects managed by...
Yu Watanabe [Mon, 19 Aug 2024 18:36:40 +0000 (03:36 +0900)] 
network/routing-policy-rule: do not modify RountingPolicyRule objects managed by Manager or Network

They are stored in Manager.rules set or Network.rules_by_section hashmap.
For safety, let's not edit them even temporarily.

No functional change, just refactoring.

15 months agoshared: invoke agents only when we have a controlling TTY
Lennart Poettering [Tue, 20 Aug 2024 08:52:20 +0000 (10:52 +0200)] 
shared: invoke agents only when we have a controlling TTY

being connected to a TTY is not really enough to determine
interactivity in many cases. Let's also check if we have a controlling
TTY.

Inspired by #34016

15 months agoMerge pull request #34044 from poettering/isatty-fixes
Yu Watanabe [Tue, 20 Aug 2024 11:36:07 +0000 (20:36 +0900)] 
Merge pull request #34044 from poettering/isatty-fixes

fixes around isatty() handling

15 months agoman: fix ID_NET_LABEL_ONBOARD= documentation
Lennart Poettering [Tue, 20 Aug 2024 08:28:53 +0000 (10:28 +0200)] 
man: fix ID_NET_LABEL_ONBOARD= documentation

We do not prefix the field with anything, since
8c053c83ae3c18342c4faaa0043d787884056614.

15 months agoMerge pull request #34009 from yuwata/network-resolve-polkit
Luca Boccassi [Tue, 20 Aug 2024 10:14:03 +0000 (12:14 +0200)] 
Merge pull request #34009 from yuwata/network-resolve-polkit

network,resolve: support interactive authentication

15 months agoMerge pull request #34014 from yuwata/network-ip-masquerade
Luca Boccassi [Tue, 20 Aug 2024 09:59:30 +0000 (11:59 +0200)] 
Merge pull request #34014 from yuwata/network-ip-masquerade

network: make IPMasquerade= imply global IP forwarding settings again

15 months agoMerge pull request #34021 from yuwata/network-routing-policy-rule
Luca Boccassi [Tue, 20 Aug 2024 09:49:02 +0000 (11:49 +0200)] 
Merge pull request #34021 from yuwata/network-routing-policy-rule

network/routing-policy-rule: several cleanups

15 months agoresolved: demote the global unicast scope
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.

15 months agotree-wide: use isatty_safe() more 34044/head
Lennart Poettering [Tue, 20 Aug 2024 08:33:52 +0000 (10:33 +0200)] 
tree-wide: use isatty_safe() more

15 months agoterminal-util: don't assume errno is correctly set when using isatty_safe()
Lennart Poettering [Tue, 20 Aug 2024 08:32:14 +0000 (10:32 +0200)] 
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).

Fixes: #34039
15 months agoterminal-util: fix isatty_safe() on hung-up TTYs
Lennart Poettering [Tue, 20 Aug 2024 08:30:19 +0000 (10:30 +0200)] 
terminal-util: fix isatty_safe() on hung-up TTYs

glibc returs EIO on ttys that are hung up. That's not really correct,
POSIX seems to disagree.

Work around this in our code, and turn this into a clean "1", since a
hung up tty doesn't stop being a tty just because it is hung up.

Background: https://github.com/systemd/systemd/pull/34039

15 months agotest-network: make kernel send NA with router flag
Yu Watanabe [Tue, 20 Aug 2024 04:08:59 +0000 (13:08 +0900)] 
test-network: make kernel send NA with router flag

If the router interface send NA without router flag, client interface will drop
SLAAC addresses. To make the router interface send NA with router flag,
IPv6 forwarding needs to be enabled.
===
client: NDISC: Received Neighbor Advertisement from fe80::1034:56ff:fe78:9a99: Router=no, Solicited=yes, Override=no
client: NDISC: Invoking callback for 'neighbor' event.
client: Removing NDisc route (configured): dst: 2002:da8:1:99::/64, src: n/a, gw: n/a, prefsrc: n/a, table: main(254), priority: 1024, proto: ra, scope: global, type: unicast, flags: n/a
client: Removing NDisc route (configured): dst: n/a, src: n/a, gw: fe80::1034:56ff:fe78:9a99, prefsrc: n/a, table: main(254), priority: 1024, proto: ra, scope: global, type: unicast, flags: n/a
client: Removing NDisc address (configured): 2002:da8:1:99:1034:56ff:fe78:9a00/64 (valid for 23h 59min 58s, preferred for 3h 59min 58s), flags: manage-temporary-address,no-prefixroute, scope: global
===

15 months agonamespace: Fix extension release memory leak
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.

Fixes issue introduced in 55ea4ef096543d2bceea9315868d5aca945d7a57.

15 months agonetwork/routing-policy-rule: drop unused argument 34021/head
Yu Watanabe [Mon, 19 Aug 2024 03:36:17 +0000 (12:36 +0900)] 
network/routing-policy-rule: drop unused argument

15 months agonetwork/routing-policy-rule: introduce ref and unref functions for RoutingPolicyRule
Yu Watanabe [Sat, 17 Aug 2024 07:14:31 +0000 (16:14 +0900)] 
network/routing-policy-rule: introduce ref and unref functions for RoutingPolicyRule

No functional change, just refactoring and preparation for later change.

15 months agonetwork/routing-policy-rule: manage all flags
Yu Watanabe [Sat, 17 Aug 2024 11:24:07 +0000 (20:24 +0900)] 
network/routing-policy-rule: manage all flags

Currently, only FIB_RULE_INVERT flag can be configurable, but for
simplicity and future extension, let's manage all flags.

No functional change, just refactoring.

15 months agonetwork/routing-policy-rule: use int32_t for suppress_prefixlen
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.

No functional change, just refactoring.

15 months agonetwork/routing-policy-rule: reorder elements of RoutingPolicyRule and add comments
Yu Watanabe [Sat, 17 Aug 2024 06:25:04 +0000 (15:25 +0900)] 
network/routing-policy-rule: reorder elements of RoutingPolicyRule and add comments

No functional change, just refactoring.

15 months agonetwork/routing-policy-rule: update hash and compare function for fib rule
Yu Watanabe [Sat, 17 Aug 2024 05:55:41 +0000 (14:55 +0900)] 
network/routing-policy-rule: update hash and compare function for fib rule

Let's manage fib rules with the logic used by the kernel.

Should not change any behavior.

15 months agotest-dhcp-server: Gracefully handle the network being down
Daan De Meyer [Sun, 18 Aug 2024 22:13:47 +0000 (00:13 +0200)] 
test-dhcp-server: Gracefully handle the network being down

15 months agorun: also enable interactive authentication on opening pty 34009/head
Yu Watanabe [Fri, 16 Aug 2024 11:00:25 +0000 (20:00 +0900)] 
run: also enable interactive authentication on opening pty

15 months agorun: use sd_bus_set_allow_interactive_authorization()
Yu Watanabe [Fri, 16 Aug 2024 10:59:30 +0000 (19:59 +0900)] 
run: use sd_bus_set_allow_interactive_authorization()

15 months agomount: use sd_bus_set_allow_interactive_authorization()
Yu Watanabe [Fri, 16 Aug 2024 10:58:45 +0000 (19:58 +0900)] 
mount: use sd_bus_set_allow_interactive_authorization()

15 months agotimedatectl: drop unnecessary temporal variables
Yu Watanabe [Fri, 16 Aug 2024 10:34:09 +0000 (19:34 +0900)] 
timedatectl: drop unnecessary temporal variables

Also drop unnecessary spaces.

15 months agotree-wide: voidify polkit_agent_open_if_enabled()
Yu Watanabe [Fri, 16 Aug 2024 10:33:41 +0000 (19:33 +0900)] 
tree-wide: voidify polkit_agent_open_if_enabled()

15 months agotimedatectl: enable interactive authentication for DBus methods
Yu Watanabe [Fri, 16 Aug 2024 10:30:44 +0000 (19:30 +0900)] 
timedatectl: enable interactive authentication for DBus methods

15 months agoresolve: inherit server userdata
Yu Watanabe [Fri, 16 Aug 2024 09:06:50 +0000 (18:06 +0900)] 
resolve: inherit server userdata

No functional change, just refactoring.

15 months agoresolve: support polkit authentication for io.systemd.Resolve.Monitor
Yu Watanabe [Fri, 16 Aug 2024 00:27:46 +0000 (09:27 +0900)] 
resolve: support polkit authentication for io.systemd.Resolve.Monitor

Then, non-privilege user can call e.g. 'resolvectl monitor' with
authentication.

15 months agosd-varlink: allow to dispatch method again on pending-method-more state
Yu Watanabe [Fri, 16 Aug 2024 00:25:52 +0000 (09:25 +0900)] 
sd-varlink: allow to dispatch method again on pending-method-more state

Otherwise, polkit authentication does not work for methods that require
the MORE flag.

15 months agoresolvectl: acquire DBus connection only when necessary
Yu Watanabe [Mon, 19 Aug 2024 02:14:44 +0000 (11:14 +0900)] 
resolvectl: acquire DBus connection only when necessary

When e.g. `resolvectl monitor` is called, it is not necessary to acquire
DBus connection.

15 months agoresolvectl: several coding style cleanups
Yu Watanabe [Mon, 19 Aug 2024 02:02:08 +0000 (11:02 +0900)] 
resolvectl: several coding style cleanups

Use RET_GATHER(), FOREACH_ARRAY(), and strv_skip().

15 months agoresolvectl: introduce --no-ask-password option
Yu Watanabe [Mon, 19 Aug 2024 02:36:22 +0000 (11:36 +0900)] 
resolvectl: introduce --no-ask-password option

15 months agoresolvectl: enable interactive authentication for dbus method call
Yu Watanabe [Thu, 15 Aug 2024 23:12:14 +0000 (08:12 +0900)] 
resolvectl: enable interactive authentication for dbus method call

Even the server side supports polkit authentication, previously
the client side did not support polkit authentication.

15 months agonetworkctl: introduce --no-ask-password option
Yu Watanabe [Mon, 19 Aug 2024 02:28:22 +0000 (11:28 +0900)] 
networkctl: introduce --no-ask-password option

15 months agonetworkctl: enable interactive authentication for dbus method call
Yu Watanabe [Thu, 15 Aug 2024 22:31:41 +0000 (07:31 +0900)] 
networkctl: enable interactive authentication for dbus method call

Previously, e.g. 'networkctl reload' did not ask password through
polkit.

15 months agoMerge pull request #34026 from DaanDeMeyer/tests
Daan De Meyer [Sun, 18 Aug 2024 21:31:10 +0000 (23:31 +0200)] 
Merge pull request #34026 from DaanDeMeyer/tests

Handle unprivileged user namespaces gracefully in tests

15 months agotest: Gracefully handle running within user namespace with single user 34026/head
Daan De Meyer [Sun, 18 Aug 2024 11:20:14 +0000 (13:20 +0200)] 
test: Gracefully handle running within user namespace with single user

Unprivileged users often make themselves root by unsharing a user namespace
and then mapping their current user to root which does not require privileges.
Let's make sure our tests don't fail in such an environment by adding checks
where required to see if we're not running in a user namespace with only a
single user.

15 months agoMerge pull request #34025 from YHNdnzj/edit-util-wrong-place
Yu Watanabe [Sun, 18 Aug 2024 19:33:56 +0000 (04:33 +0900)] 
Merge pull request #34025 from YHNdnzj/edit-util-wrong-place

edit-util: catch and warn about edits outside of markers

15 months agoMerge pull request #34022 from YHNdnzj/unit-is-filtered
Yu Watanabe [Sun, 18 Aug 2024 19:29:54 +0000 (04:29 +0900)] 
Merge pull request #34022 from YHNdnzj/unit-is-filtered

core/unit: two trivial cleanups

15 months agoMerge pull request #34020 from YHNdnzj/cred-no-mountover
Yu Watanabe [Sun, 18 Aug 2024 19:29:42 +0000 (04:29 +0900)] 
Merge pull request #34020 from YHNdnzj/cred-no-mountover

core/dbus-service: refuse bind mounting over /run/credentials/

15 months agoanalyze: introduce --instance= option to control instance name for template units
Yu Watanabe [Sat, 17 Aug 2024 02:26:32 +0000 (11:26 +0900)] 
analyze: introduce --instance= option to control instance name for template units

Note, `systemd-analyze foo@.service --instance=hoge` is equivalent to
`systemd-analyze foo@hoge.service`. But, the option may be useful when
e.g. passing multiple template units that have restriction on their
instance name:
```
$ ls
template_aaa@.service   template_bbb@.service   template_ccc@.service
$ systemd-analyze ./template_* --instance=hoge
```
Without the option, we need to embed an instance name into each unit
name, so cannot use globs.

Prompted by #33681.

15 months agoedit-util: catch and warn about edits outside of markers 34025/head
Mike Yuan [Sat, 17 Aug 2024 20:36:19 +0000 (22:36 +0200)] 
edit-util: catch and warn about edits outside of markers

The users still periodically come back to #24208.
Let's add a detection for this hence.

15 months agostring-util: update ptr declaration to match our coding style
Mike Yuan [Sun, 18 Aug 2024 10:05:11 +0000 (12:05 +0200)] 
string-util: update ptr declaration to match our coding style

15 months agobasic/process-util: modernize setpriority_closest()
Mike Yuan [Fri, 9 Aug 2024 15:36:07 +0000 (17:36 +0200)] 
basic/process-util: modernize setpriority_closest()

Before this commit, the "Cannot raise nice level" branch
is rather confusing, as we're actually lowering the nice.
Also, it's better to log about the final nice value
for both cases, no matter whether we need to set to limit
or not.

15 months agotest-netlink: Gracefully handle the loopback interface being down
Daan De Meyer [Sun, 18 Aug 2024 11:19:30 +0000 (13:19 +0200)] 
test-netlink: Gracefully handle the loopback interface being down

15 months agocore/unit: unit_is_filtered() -> unit_passes_filter() and invert logic 34022/head
Mike Yuan [Sat, 17 Aug 2024 11:18:31 +0000 (13:18 +0200)] 
core/unit: unit_is_filtered() -> unit_passes_filter() and invert logic

Follow-up for 6d2984d21bf2a8f71d379ef6bc13a761bb2e2756

The current semantics of "filtered" in unit_is_filtered()
are actually the contrary of ListUnitsFiltered(). Let's
make things consistent, i.e. return true when the unit
shall be included.

15 months agocore/unit: rename set_unit_path() -> setenv_unit_path()
Mike Yuan [Sat, 17 Aug 2024 11:20:09 +0000 (13:20 +0200)] 
core/unit: rename set_unit_path() -> setenv_unit_path()

The previous name is quite vague on what this precisely
do.

15 months agocore/dbus-service: refuse bind mounting over /run/credentials/ 34020/head
Mike Yuan [Tue, 23 Jul 2024 14:09:53 +0000 (16:09 +0200)] 
core/dbus-service: refuse bind mounting over /run/credentials/

The credential mounts should be managed singlehandedly by pid1.
Preparation for the future introduction of RefreshOnReload=credential,
where refreshing creds will be properly supported on reload.

15 months agocore/dbus-service: some modernization for bus_service_method_mount()
Mike Yuan [Mon, 10 Jun 2024 15:27:51 +0000 (17:27 +0200)] 
core/dbus-service: some modernization for bus_service_method_mount()

Perform some checks earlier to avoid pointless polkit auth.

Plus, the missing unit_get_exec_context() shall not be
a formalized error. As it's our internal representation
and in the normal operation should never happen.

15 months agonetwork: refuse files under API VFS specified in PrivateKeyFile= and friends
Yu Watanabe [Fri, 16 Aug 2024 17:01:51 +0000 (02:01 +0900)] 
network: refuse files under API VFS specified in PrivateKeyFile= and friends

Addresses https://github.com/systemd/systemd/pull/34013#discussion_r1719890231.

15 months agotest: add test case that 'nspawn --network-veth' enables IP forwarding 34014/head
Yu Watanabe [Fri, 16 Aug 2024 16:48:50 +0000 (01:48 +0900)] 
test: add test case that 'nspawn --network-veth' enables IP forwarding

15 months agonetwork/wireguard: introduce [WireGuardPeer] PublicKeyFile=
Yu Watanabe [Fri, 16 Aug 2024 13:13:23 +0000 (22:13 +0900)] 
network/wireguard: introduce [WireGuardPeer] PublicKeyFile=

Similar to PresharedKeyFile=, but for public key.

Closes #34012.

15 months agotest: allow to skip matrix_run_one() if $TEST_MATCH_TESTCASE is set
Yu Watanabe [Fri, 16 Aug 2024 16:47:33 +0000 (01:47 +0900)] 
test: allow to skip matrix_run_one() if $TEST_MATCH_TESTCASE is set

15 months agonetwork: make IPMasquerade= imply global IP forwarding settings again
Yu Watanabe [Fri, 16 Aug 2024 15:00:32 +0000 (00:00 +0900)] 
network: make IPMasquerade= imply global IP forwarding settings again

After 3976c430927e1bfefa0413f80ebac84ab9a64350 (#31423), IPMasquerade=
implies only per-interface IP forwarding. That means, nspawn users need
to manually enable IPv4/IPv6Forwarding= in networkd.conf when
--network-veth or friend is used. Even the change was announced in NEWS,
the change itself breaks backward compatibility and extremely reduces
usability.

Let's make the setting imply the global setting again.

Fixes #34010.

15 months agonetwork/lldp-tx: introduce link_lldp_tx_update_capabilities()
Yu Watanabe [Fri, 16 Aug 2024 14:30:02 +0000 (23:30 +0900)] 
network/lldp-tx: introduce link_lldp_tx_update_capabilities()

Currently it is unused, but it will be used later.

15 months agosd-lldp-tx: insert missing empty line
Yu Watanabe [Fri, 16 Aug 2024 14:29:36 +0000 (23:29 +0900)] 
sd-lldp-tx: insert missing empty line

15 months agokernel-install: discard comments in cmdline files
rindeal [Fri, 16 Aug 2024 00:16:57 +0000 (02:16 +0200)] 
kernel-install: discard comments in cmdline files

It was quite a surprise to find my comments in a booted kernel cmdline.

15 months agoAdd $SYSTEMD_IN_CHROOT to override chroot detection
Daan De Meyer [Wed, 14 Aug 2024 10:43:05 +0000 (12:43 +0200)] 
Add $SYSTEMD_IN_CHROOT to override chroot detection

When running unprivileged, checking /proc/1/root doesn't work because
it requires privileges. Instead, let's add an environment variable so
the process that chroot's can tell (systemd) subprocesses whether
they're running in a chroot or not.

15 months agotest: fix typo
Yu Watanabe [Fri, 16 Aug 2024 00:44:08 +0000 (09:44 +0900)] 
test: fix typo

Follow-up for 538766ddf47cfd457d9c69f108c035d4d97eaba1.

15 months agoshell-completion: zsh: fix incorrect unescaping
bryango [Thu, 15 Aug 2024 05:18:17 +0000 (13:18 +0800)] 
shell-completion: zsh: fix incorrect unescaping

Previously the `_filter_units_by_property` completion function
outputs with a [zsh parameter expansion flag] `g:o:`. This means
that the returned result is unescaped as the zsh builtin `echo`,
except that octal escapes don’t take a leading zero. This seemed to
have worked back in the days when it was first introduced:

  6c9414a700a040be1d3160bd2336baac58a1da3e

But it now leads to incorrect over-unescaping; for example,

  system-systemd\\x2djournald.slice (correct)

is incorrectly completed by zsh in commands such as
`systemctl kill`:

  system-systemd-journald.slice (incorrect)

This commit fixes such problems by removing the `g:o:` flag.

See:
[zsh parameter expansion flag]: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags