]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
15 months agoprocess-util: always retry with pidfd_spawn() w/o cgroup first 34053/head
Mike Yuan [Tue, 20 Aug 2024 18:04:46 +0000 (20:04 +0200)] 
process-util: always retry with pidfd_spawn() w/o cgroup first

Follow-up for 7ac58157ca67ab001307f1fd72e0cc7c0c4e846a

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.

15 months agoprocess-util: check the flag instead of 'cgroup' param
Mike Yuan [Tue, 20 Aug 2024 20:01:09 +0000 (22:01 +0200)] 
process-util: check the flag instead of 'cgroup' param

We might skip CLONE_INTO_CGROUP wholly if not supported.

15 months agoman: use standard-options for --no-ask-password everywhere
Mike Yuan [Tue, 20 Aug 2024 10:32:57 +0000 (12:32 +0200)] 
man: use standard-options for --no-ask-password everywhere

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 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

15 months agoudev-builtin-net_id: add NAMING_DEVICETREE_PORT_ALIASES to check of_node of netdevs...
Matthias Schiffer [Wed, 7 Aug 2024 10:01:24 +0000 (12:01 +0200)] 
udev-builtin-net_id: add NAMING_DEVICETREE_PORT_ALIASES to check of_node of netdevs before their parents

The net_id builtin only checked the of_node of a netdev's parent device,
not that of the netdev itself. While it is common that netdevs don't have
an OF node assigned themselves, as they are derived from some parent
device, this is not always the case. In particular when a single
controller provides multiple ports that can be referenced indiviually in
the Device Tree (both for aliases/MAC address assignment and phandle
references), the correct of_node will be that of the netdev itself, not
that of the parent, so it needs to be checked, too.

A new naming scheme flag NAMING_DEVICETREE_PORT_ALIASES is added to
allow selecting the new behavior.

15 months agoMerge pull request #34000 from yuwata/test-remove-temporary-directories
Yu Watanabe [Thu, 15 Aug 2024 09:54:16 +0000 (18:54 +0900)] 
Merge pull request #34000 from yuwata/test-remove-temporary-directories

test: remove temporary directories

15 months agotest: sync journal after all invocations finished
Yu Watanabe [Thu, 15 Aug 2024 07:33:51 +0000 (16:33 +0900)] 
test: sync journal after all invocations finished

Otherwise, several messages for the last invocation have not been
stored to journal yet.

Hopefully fixes the following race:
===
[  603.037765] H systemd-run[10503]: Running as unit: invocation-id-test-26448.service; invocation ID: 1a49edeb05a641aaa2def72411134822
[  603.099587] H bash[10504]: invocation 10 1a49edeb05a641aaa2def72411134822
[  603.212069] H systemd[1]: invocation-id-test-26448.service: Deactivated successfully.
[  603.225092] H systemd-run[10503]: Finished with result: success
[  603.225163] H TEST-04-JOURNAL.sh[10506]: + journalctl --list-invocation -u invocation-id-test-26448.service
[  603.225318] H systemd-run[10503]: Main processes terminated with: code=exited, status=0/SUCCESS
[  603.225357] H TEST-04-JOURNAL.sh[10507]: + tee /tmp/tmp.UzSmYamXyg/10
[  603.225357] H TEST-04-JOURNAL.sh[10507]: IDX INVOCATION ID                    FIRST ENTRY                 LAST ENTRY
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -9 d6efabb546014027b6bd7ee3a78386d6 Wed 2024-08-14 22:12:16 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -8 3e402b81c28d4a8fa2c5e8e31dffd9ee Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -7 5ebd0ba07d4f4f52bc84275f55a3ee2e Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -6 bc53c49d6ce24bb7acd438c3e61cfb23 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -5 24680907919e4839a75378117bb5a816 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -4 ec364ed7673c4a1fa22929f95ce7047b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -3 2e8a4dea43044d1a9faf922f7a2f3d42 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -2 ac610b6e6c9c4a29bf8947890685478b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -1 9b7d52c3620948f9831e323910f605f5 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:   0 1a49edeb05a641aaa2def72411134822 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225823] H systemd-run[10503]: Service runtime: 174ms
[  603.225866] H TEST-04-JOURNAL.sh[10508]: + journalctl --list-invocation -u invocation-id-test-26448.service --reverse
[  603.226110] H systemd-run[10503]: CPU time consumed: 12ms
[  603.226142] H TEST-04-JOURNAL.sh[10509]: + tee /tmp/tmp.UzSmYamXyg/10-r
[  603.226378] H systemd-run[10503]: Memory peak: 1.4M (swap: 0B)
[  603.230161] H TEST-04-JOURNAL.sh[10509]: IDX INVOCATION ID                    FIRST ENTRY                 LAST ENTRY
[  603.230161] H TEST-04-JOURNAL.sh[10509]:   0 1a49edeb05a641aaa2def72411134822 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:18 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -1 9b7d52c3620948f9831e323910f605f5 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -2 ac610b6e6c9c4a29bf8947890685478b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -3 2e8a4dea43044d1a9faf922f7a2f3d42 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -4 ec364ed7673c4a1fa22929f95ce7047b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -5 24680907919e4839a75378117bb5a816 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -6 bc53c49d6ce24bb7acd438c3e61cfb23 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -7 5ebd0ba07d4f4f52bc84275f55a3ee2e Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -8 3e402b81c28d4a8fa2c5e8e31dffd9ee Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -9 d6efabb546014027b6bd7ee3a78386d6 Wed 2024-08-14 22:12:16 UTC Wed 2024-08-14 22:12:17 UTC
===

15 months agotest: add TEST_SKIP to mkosi integration test wrapper
Luca Boccassi [Wed, 14 Aug 2024 21:49:10 +0000 (22:49 +0100)] 
test: add TEST_SKIP to mkosi integration test wrapper

Takes a space-separate list of test names, allows to skip one or more tests

15 months agounits: drop "-p" flag from agetty's login options
Ronan Pigott [Wed, 14 Aug 2024 18:42:03 +0000 (11:42 -0700)] 
units: drop "-p" flag from agetty's login options

This flag was added in db6aedab9292 with the justification that locale
environment variables should be preserved by the user session. However,
the companion patch to drop the UnsetEnvironment= directive blocking
these variables was never merged, so the intended change was never
effected.

While the patch was ineffective toward its stated goal, the "-p" option
does have material negative consequences for the user session in
systemd — environment variables to support the use of
credentials and memory pressure directives, such as
$CREDENTIALS_DIRECTORY and $MEMORY_PRESSURE_WATCH, which are now
directly used by agetty and login, get leaked into the user session
potentially breaking applications that rely on these values.

E.g. systemd-ask-password fails from the tty when $CREDENTIALS_DIRECTORY
has been leaked from agetty, because it expects to be able to access
credentials in $CREDENTIALS_DIRECTORY.

This effectively reverts db6aedab9292.

References: db6aedab9292 (units: Tell login to preserve environment (#6023), 2017-05-24)

15 months agotest: remove temporary directory for test-ukify on success 34000/head
Yu Watanabe [Thu, 15 Aug 2024 07:14:37 +0000 (16:14 +0900)] 
test: remove temporary directory for test-ukify on success

15 months agotest: remove temporary directory on success
Yu Watanabe [Thu, 15 Aug 2024 06:58:29 +0000 (15:58 +0900)] 
test: remove temporary directory on success

Also use mkdtemp_open() with specific template.

Follow-up for e7e52ff9b6d6bbfcdcc298ef3c156420b51d58b8.

15 months agomkosi: Fix debian/not-installed build logic
Daan De Meyer [Wed, 14 Aug 2024 14:51:11 +0000 (16:51 +0200)] 
mkosi: Fix debian/not-installed build logic

- Expand globs
- Filter out directories
- Append to the list of packaged files, not the list of installed files

Fixes the issue in https://github.com/systemd/systemd/pull/32363

15 months agoudev: Handle PTP device symlink properly on udev action 'change'
Chengen Du [Mon, 12 Aug 2024 03:41:52 +0000 (11:41 +0800)] 
udev: Handle PTP device symlink properly on udev action 'change'

PTP device symlink creation rules are currently executed only when the
udev action is 'add'. If a user reloads the rules and runs the udevadm
trigger command to reapply changes, the symlink may be deleted, which
can prevent the chronyd service from restarting properly.

Signed-off-by: Chengen Du <chengen.du@canonical.com>
15 months agoMerge pull request #33955 from yuwata/sd-journal-fix-sd_journal_seek_monotonic_usec
Yu Watanabe [Thu, 15 Aug 2024 06:38:19 +0000 (15:38 +0900)] 
Merge pull request #33955 from yuwata/sd-journal-fix-sd_journal_seek_monotonic_usec

sd-journal: fix sd_journal_seek_monotonic_usec()

15 months agorepart: Fix misleading typo in GPT partition flag
Thorsten Scherer [Wed, 14 Aug 2024 20:32:44 +0000 (22:32 +0200)] 
repart: Fix misleading typo in GPT partition flag

Bit 60 is the one corresponding to ReadOnly, not 50.  Fix this.

15 months agoMerge pull request #32067 from ssahani/bareudp1
Yu Watanabe [Wed, 14 Aug 2024 20:35:32 +0000 (05:35 +0900)] 
Merge pull request #32067 from ssahani/bareudp1

network: netdev - BareUDP Add support for srcportmin

15 months agosd-journal: rename offset -> ret_offset 33955/head
Yu Watanabe [Thu, 8 Aug 2024 14:38:41 +0000 (23:38 +0900)] 
sd-journal: rename offset -> ret_offset

15 months agosd-journal: swap condition to reduce indentation
Yu Watanabe [Wed, 7 Aug 2024 02:20:39 +0000 (11:20 +0900)] 
sd-journal: swap condition to reduce indentation

No functional change, just refactoring.

15 months agosd-journal: drop unnecessary temporal variable 'k'
Yu Watanabe [Tue, 6 Aug 2024 02:09:10 +0000 (11:09 +0900)] 
sd-journal: drop unnecessary temporal variable 'k'

No functional change, just refactoring.

15 months agosd-journal: add trailing comma
Yu Watanabe [Thu, 8 Aug 2024 14:24:11 +0000 (23:24 +0900)] 
sd-journal: add trailing comma