systemd/.git
4 years agorfkill: use short writes and accept long reads
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 09:48:08 +0000 (10:48 +0100)]
rfkill: use short writes and accept long reads

I'm seeing the following with kernel-core-5.10.16-200.fc33.x86_64:

$ sudo SYSTEMD_LOG_LEVEL=debug build/systemd-rfkill
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 0 and type bluetooth.
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
rfkill0: Operating on rfkill device 'tpacpi_bluetooth_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 1 and type wwan.
rfkill1: Operating on rfkill device 'tpacpi_wwan_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:wwan.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 2 and type bluetooth.
rfkill2: Operating on rfkill device 'hci0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:00:14.0-usb-0:7:1.0:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 3 and type wlan.
rfkill3: Operating on rfkill device 'phy0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:04:00.0:wlan.
All events read and idle, exiting.

We were expecting a read of exactly RFKILL_EVENT_SIZE_V1==8 bytes. But the
structure has 9 after [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=14486c82612a177cb910980c70ba900827ca0894

For some reason the kernel does not accept the full structure size, but cuts
the write short after 8 bytes:

static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{
struct rfkill_event ev;

/* we don't need the 'hard' variable but accept it */
if (count < RFKILL_EVENT_SIZE_V1 - 1)
return -EINVAL;

/*
 * Copy as much data as we can accept into our 'ev' buffer,
 * but tell userspace how much we've copied so it can determine
 * our API version even in a write() call, if it cares.
 */
count = min(count, sizeof(ev));
if (copy_from_user(&ev, buf, count))
return -EFAULT;

... so it should accept the full size. I'm not sure what is going on here.

But we don't care about the extra fields, so let's accept a write as long as
it's at least RFKILL_EVENT_SIZE_V1.

Fixes #18677.

(cherry picked from commit a71c09685021cbcecb7566a00342421f635cc002)

4 years agorfkill: improve error logging
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 09:40:16 +0000 (10:40 +0100)]
rfkill: improve error logging

If we get something of unexpected size, log the sizes. Also, don't log twice.

(cherry picked from commit 6c7afdeab010025c80508effd2b0039bc5181b82)

4 years agojournald: when we fail to add a new entry to a journal, return the seqno
Lennart Poettering [Wed, 17 Feb 2021 22:11:42 +0000 (23:11 +0100)]
journald: when we fail to add a new entry to a journal, return the seqno

Fixes: #18005
(cherry picked from commit 0eaee8281d4699903b8b2cce18c836d4a144aee3)

4 years agoRemove outdated disable_ipv6 docs
Richard Laager [Thu, 18 Feb 2021 07:11:53 +0000 (01:11 -0600)]
Remove outdated disable_ipv6 docs

This was changed in commit 482efedc081b0c4bf2e77a3dee6b979d9c9a5765,
which was released in v243, to only enable and never disable IPv6.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
(cherry picked from commit f542f3b2ed3cf3e71692d1736f3fdd0ebdc226ef)

4 years agojournal-file: fix archiving offline journals
Vito Caputo [Sun, 29 Nov 2020 00:28:08 +0000 (16:28 -0800)]
journal-file: fix archiving offline journals

The existing set_offline() short-circuit erroneously included
when f->archive was true and header->state was STATE_OFFLINE.

This commit makes the short-circuit f->archive aware, so it will
only catch scenarios where there's not an offlining in progress
and the header state matches the target state of either archived
or offline.

Fixes https://github.com/systemd/systemd/issues/17770

(cherry picked from commit bb1296b55a222cbab24d533006e730529009258c)

4 years agostat-util: fix dir_is_empty_at without path
Luca Boccassi [Mon, 18 Jan 2021 20:15:03 +0000 (20:15 +0000)]
stat-util: fix dir_is_empty_at without path

Use the right FD, and do a fd_reopen instead of a dup, since the
latter will still share the internal pointer which then gets
moved by FOREACH_DIRENT, affecting the caller's FD.

(cherry picked from commit b8f762f2fe59c94323c95d2aadea68612dca2b04)

4 years agojournalctl: rotation is not a reason to warn, but certainly noteworthy
Lennart Poettering [Mon, 15 Feb 2021 22:31:54 +0000 (23:31 +0100)]
journalctl: rotation is not a reason to warn, but certainly noteworthy

Downgrade the phrasing, since it is a bit misleading.

Fixes: #18465
(cherry picked from commit 71311efe2377d7e37a6af76f110882eed2332f4e)

4 years agono blkid for mmcblk[0-9]boot[0-9]
Alan Perry [Sat, 13 Feb 2021 03:08:28 +0000 (19:08 -0800)]
no blkid for mmcblk[0-9]boot[0-9]

Don't run blkid on mmcblk[0-9]boot[0-9] devices because they contain
bootloaders or boot parameters, and not partitions or file systems.

(cherry picked from commit 8db704b28b4fd4d13e376cf3495005010443937e)

4 years agoudev: make net_setup_link builtin quiet when link vanishes while we operate on it
Lennart Poettering [Fri, 12 Feb 2021 20:16:27 +0000 (21:16 +0100)]
udev: make net_setup_link builtin quiet when link vanishes while we operate on it

Fixes: #16175
(cherry picked from commit 3ec2f7f2e3fc04699d8de27d3cc2e5eecf9a3698)

4 years agonetwork: dhcp6: fix condtion check
Yu Watanabe [Wed, 3 Feb 2021 15:52:28 +0000 (00:52 +0900)]
network: dhcp6: fix condtion check

(cherry picked from commit b54aed29c61b9b86dc9cfa214c946586ea1f4972)

4 years agohomework: fix unitialized variable
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 11:00:09 +0000 (12:00 +0100)]
homework: fix unitialized variable

Coverity CID#1444703.

(cherry picked from commit a4aa5742f75f0753c4dfa812059af608c9bab7b6)

4 years agofsck: make sure we don't read an unitialized variable
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:50:49 +0000 (09:50 +0100)]
fsck: make sure we don't read an unitialized variable

This use on %n was completely unnecessary: fprintf returns the number of
characters written. And the issue was that if fprintf failed for whatever
reason, it would not process the %n and m would be unitialized. Rework the
code a bit to simplify it.

Coverity CID#1444708.

(cherry picked from commit 333ab199a12c7b060d3a3f4d50a8f73ee4fd5ebd)

4 years agosd-journal: add forgotten unmap in error path
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:35:52 +0000 (09:35 +0100)]
sd-journal: add forgotten unmap in error path

Bug introduced in 4b5bc5396c090ee41c45cab9052372d296c4a2f4 :(

Coverity CID#1444709.

(cherry picked from commit 363729c4704b9838f351eaba3acb8b1ed16fae0e)

4 years agoanalyze: slightly reword PrivatTmp= message
Lennart Poettering [Wed, 10 Feb 2021 09:50:23 +0000 (10:50 +0100)]
analyze: slightly reword PrivatTmp= message

Apparently there way confusion about "does not apply". Let's say "is not
appropriate".

Fixes: #13095
(cherry picked from commit 77552b9520ba0d47cbf33cdbe1ddedb9ce9b5bf3)

4 years agoinhibit: cut off overly long "who" fields
Lennart Poettering [Tue, 9 Feb 2021 14:03:46 +0000 (15:03 +0100)]
inhibit: cut off overly long "who" fields

systemd-inhibit when invoked with a command line will put the whole
command line in the "who" field of the inhibitor lock. This can get
extremely long for shell expressions, making the table "systemd-inhibit
--list" shows ridiculously weirdly formatted. Let's put a limit on the
column width: half of the screen, not more.

(cherry picked from commit 619b0c077cbb12b85c9d752779095b99cfd2c66c)

4 years agoformat-table: don't hit assert if column got less width than it asked for
Lennart Poettering [Tue, 9 Feb 2021 14:02:21 +0000 (15:02 +0100)]
format-table: don't hit assert if column got less width than it asked for

If one field in a specific column has a maximum size limit, other fields
in the same column might affected by it and get less than they asked
for. Let's make sure we can handle this, and don't assert on this
because surprisingly we got less than what we asked for.

(cherry picked from commit 2cd9f773e29873df1b9f9b09c6c4f78853b16215)

4 years agoUse correct config parser for MountAPIVFS (#18501)
Antonius Frie [Mon, 8 Feb 2021 08:15:15 +0000 (09:15 +0100)]
Use correct config parser for MountAPIVFS (#18501)

As far as I can see, at some point the parser function for MountAPIVFS
was changed from the generic bool parser to a custom implementation, to
allow the context to keep track of whether MountAPIVFS had been set
explicitly. If not, exec_context_get_effective_mount_apivfs would fall
back to a default value. However, the corresponding entry in the big
parser table wasn't updated, meaning that the old bool parser was still
used, meaning that context->mount_apivfs_set remained at its default
value of false, meaning that the default value was always used and the
config option was effectively ignored.

Fix for 5e98086d1629f5c5b73645ba2568de4b09b7d958.

(cherry picked from commit 4d0052d52f1359a054e83037c733bb3330ba4124)

4 years agoman: fix misspellings of "NameSeviceSwitch"
Julia Cartwright [Fri, 5 Feb 2021 21:16:18 +0000 (15:16 -0600)]
man: fix misspellings of "NameSeviceSwitch"

Fixup NameSeviceSwitch -> NameServiceSwitch spelling error in
documentation.

Found through inspection of documentation.

(cherry picked from commit afe6a9c48e956c8ddfaa0f201cf371b01a22f970)

4 years agoresolved: suppress ifindex info in varlink JSON responses if zero
Lennart Poettering [Fri, 5 Feb 2021 17:43:55 +0000 (18:43 +0100)]
resolved: suppress ifindex info in varlink JSON responses if zero

If we don't have ifindex info, don't set the field for it.

We already do that for parsed IP address replies, let's do it for all
cases: it's a bit nicer to suppress the ifindex prop if it doesn't apply
than to pass it invalid.

This is the other side of #18482, i.e. fixes things so that the parser
doesn't get tripped up by this.

(This too makes a problem go away we should track down properly, i.e.
figure out how the ifindex got lost in
https://github.com/systemd/systemd/pull/17823#issuecomment-742439422 )

(cherry picked from commit f8f5b8d864d3d034dbbfb84fdad4f2cbeb7790f9)

4 years agonss-resolve: shortcut fixing of ifindex if it's zero anyway
Lennart Poettering [Fri, 5 Feb 2021 17:46:18 +0000 (18:46 +0100)]
nss-resolve: shortcut fixing of ifindex if it's zero anyway

(cherry picked from commit 425ed13991153bd274a86009459b00ec8a709f30)

4 years agonss-resolve: accept zero ifindex when parsing resolved reply
Lennart Poettering [Fri, 5 Feb 2021 17:44:22 +0000 (18:44 +0100)]
nss-resolve: accept zero ifindex when parsing resolved reply

Sometimes a reply isn't associated to any specific interface, it might
be a general truth (for example served from /etc/hosts or so). In this
case the server might pass ifindex == 0. Accept that.

https://github.com/systemd/systemd/pull/17823#issuecomment-742439422
(cherry picked from commit 6da52ca861a1cae3f453d50dbb6fac6666a73f4b)

4 years agoPATCH] Always free deserialized_subscribed on reload
Ali Abdallah [Thu, 21 Jan 2021 06:37:21 +0000 (07:37 +0100)]
PATCH] Always free deserialized_subscribed on reload

Otherwise, it will keep consuming memory on systemctl daemon-reload.

(cherry picked from commit 3deed59afdc2c18ecb76fe90b9bba0cd66045dfa)

4 years agocore: map io.bfq.weight to 1..1000
Zbigniew Jędrzejewski-Szmek [Thu, 4 Feb 2021 08:48:19 +0000 (09:48 +0100)]
core: map io.bfq.weight to 1..1000

Aaargh. See the comment in the code.

Apparently the range is like that:
$ sudo bash -c 'echo "default 1001" >/sys/fs/cgroup/user.slice/io.bfq.weight'
bash: line 0: echo: write error: Numerical result out of range

$ uname -r
5.11.0-0.rc4.129.fc34.x86_64

(cherry picked from commit 29eb0eefd14afc9a2424781a28b376db47c3c570)

4 years agoman: reword the description of "main conf file"
Zbigniew Jędrzejewski-Szmek [Thu, 4 Feb 2021 10:05:39 +0000 (11:05 +0100)]
man: reword the description of "main conf file"

While not really "wrong", the text we had could use a little editing.

Fixes #18458.

(cherry picked from commit a7a1887869695f16a1114c355c13d731ed7be109)

4 years agotest-network: add tests for fib rules with Family=both vs networkctl reload or reconf...
Yu Watanabe [Tue, 29 Dec 2020 18:32:07 +0000 (03:32 +0900)]
test-network: add tests for fib rules with Family=both vs networkctl reload or reconfigure

[#18109,7/7] cherry-picked from 49ff3f34d549ad214924548f46a71315b5cd23c6

4 years agonetwork: drop fib rules configured with Family=both
Yu Watanabe [Tue, 29 Dec 2020 18:15:44 +0000 (03:15 +0900)]
network: drop fib rules configured with Family=both

[#18109,6/7] cherry-picked from a75466ed198fad0f50054b4715cfc55c17ffba09

4 years agonetwork: set RoutingPolicyRule::family based on Family= setting
Yu Watanabe [Tue, 29 Dec 2020 18:07:33 +0000 (03:07 +0900)]
network: set RoutingPolicyRule::family based on Family= setting

[#18109,5/7] cherry-picked from 49de8d5cedc9f381a8b61cc9dcd40781cacf7e68

4 years agonetwork: always re-configure rules even if already exist
Yu Watanabe [Tue, 29 Dec 2020 17:45:25 +0000 (02:45 +0900)]
network: always re-configure rules even if already exist

routing_policy_rule_get() in link_set_routing_policy_rules() does not
work when [RoutingPolicyRule] section does not have From= or To=.

[#18109,4/7] cherry-picked from c1934a8f2f37b8e64d4b65f465d823c2a96abbc7

4 years agonetwork: drop unnecessary checks
Yu Watanabe [Tue, 29 Dec 2020 18:17:35 +0000 (03:17 +0900)]
network: drop unnecessary checks

By the previous commit, the checks are not necessary any more.

[#18109,3/7] cherry-picked from 57fe5a42f0975ca12ff856ca221c081a1ad3e87e

4 years agonetwork: constify several arguments
Yu Watanabe [Tue, 29 Dec 2020 17:03:48 +0000 (02:03 +0900)]
network: constify several arguments

[#18109,1/7] cherry-picked from 3141c8173632c100654144faa3d78b84bdffd72f

4 years agonetwork: do not serialize/deserialize routing policy rules
Yu Watanabe [Wed, 28 Oct 2020 08:02:41 +0000 (17:02 +0900)]
network: do not serialize/deserialize routing policy rules

We already handle foreign routing policy rules correctly by the previous
commit. So, the serialization/deserialization of rules are not necessary
anymore.

[#17477,5/5] cherry-picked from a9d240f4bfefcd85de22381f6250e1e1ab58ea55

4 years agonetwork: drop unnecessary routing policy rules
Yu Watanabe [Wed, 28 Oct 2020 11:27:23 +0000 (20:27 +0900)]
network: drop unnecessary routing policy rules

networkd already drop foreign address, routes, and nexthops on startup,
except those created by kernel. However, previously, routing policy
rules were not. The logic of serialization/deserialization of rules only
works for rules created by previous invocation of networkd, and does not
work for one created by other tools like `ip rule`.

This makes networkd drop foreign routing policy rules except created by
kernel on startup. Also, remove rules created by networkd when the
corresponding links are dropped or networkd is stopping.

[#17477,4/5] cherry-picked from 0b81225e5791f660506f7db0ab88078cf296b771

4 years agonetwork: treat rule which has l3mdev flag as created by kernel
Yu Watanabe [Thu, 29 Oct 2020 02:55:12 +0000 (11:55 +0900)]
network: treat rule which has l3mdev flag as created by kernel

[#17477,3/5] cherry-picked from e737dce5445ac2359f4f260aa462056b02d68d54

4 years agonetwork: adjust protocol of rules sent from kernel when kernel does not support FRA_P...
Yu Watanabe [Thu, 29 Oct 2020 02:34:36 +0000 (11:34 +0900)]
network: adjust protocol of rules sent from kernel when kernel does not support FRA_PROTOCOL

Otherwise, each configured rule is treated as foreign.

[#17477,2/5] cherry-picked from 569eeb0c059047601f16b9f6df2bbbc1582793a1

4 years agonetwork: set FRA_PROTOCOL to RTPROT_STATIC by default
Yu Watanabe [Wed, 28 Oct 2020 07:54:51 +0000 (16:54 +0900)]
network: set FRA_PROTOCOL to RTPROT_STATIC by default

[#17477,1/5] cherry-picked from 1e5fd3216a8c73b636ad61e6ebee0c161b6c2063

4 years agonetwork: use netlink_message_read_in_addr_union() where applicable
Yu Watanabe [Wed, 28 Oct 2020 08:28:36 +0000 (17:28 +0900)]
network: use netlink_message_read_in_addr_union() where applicable

[#17960,4/4] cherry-picked from c18c53c36e39f873a7a83e1c0fad1a12c3a650d3

4 years agonetwork: introduce log_routing_policy_rule_debug()
Yu Watanabe [Wed, 28 Oct 2020 08:22:58 +0000 (17:22 +0900)]
network: introduce log_routing_policy_rule_debug()

[#17960,3/4] cherry-picked from ea81208f03afdc03e7e6efd1b5d9515c1ebd4e72

4 years agonetwork: introduce routing_policy_rule_equal()
Yu Watanabe [Thu, 29 Oct 2020 02:41:01 +0000 (11:41 +0900)]
network: introduce routing_policy_rule_equal()

[#17960,2/4] cherry-picked from 40424f1ad97db59958e40a395986a5e248da6f05

4 years agonetwork: make routing_policy_rule_remove() take Manager instead of Link
Yu Watanabe [Wed, 28 Oct 2020 07:16:58 +0000 (16:16 +0900)]
network: make routing_policy_rule_remove() take Manager instead of Link

As routing policy rules are managed by Manager.

[#17960,1/4] cherry-picked from 18f2ee33102d1ff4f658829f971697895d813cfd

4 years agoMountImages: parse unit specifiers after permissive hyphen
Luca Boccassi [Mon, 22 Feb 2021 21:31:44 +0000 (21:31 +0000)]
MountImages: parse unit specifiers after permissive hyphen

The permissive bit it not something a specifier might synthetise

(cherry picked from commit 6c3f7ca036829825f344ffb364354faee5db174e)

4 years agoMountImages: fix exec_context_dump printf
Luca Boccassi [Mon, 22 Feb 2021 10:12:34 +0000 (10:12 +0000)]
MountImages: fix exec_context_dump printf

Use strempty as options might not be set, and add the separator
for each option tuple

(cherry picked from commit 79e20ceb59157662eb32fdf3a7eb1e4d9d8bf00b)

4 years agoMountImages: actually support optional paths
Luca Boccassi [Thu, 28 Jan 2021 13:25:41 +0000 (13:25 +0000)]
MountImages: actually support optional paths

ENOENT did not cause an image mount to be skipped, fix it

(cherry picked from commit b850a9b29f2bc14836415f0c85d42e7d4990285d)

Conflicts:
src/core/namespace.c

4 years agoportablectl: start/stop path/timer units too
Luca Boccassi [Fri, 5 Mar 2021 14:53:20 +0000 (14:53 +0000)]
portablectl: start/stop path/timer units too

Partial backport from:

https://github.com/systemd/systemd/commit/e26fe5f91158a0d9133e61347650dfb73aadd6bb

4 years agosd-netlink: spread out sequence numbers a bit
Lennart Poettering [Wed, 10 Feb 2021 22:05:51 +0000 (23:05 +0100)]
sd-netlink: spread out sequence numbers a bit

An (imperfect) fix for #14760.

This makes collisions unlikely, but still theoretically possible.

Fixes: #14760
(cherry picked from commit ac3bc1b819b66f925145629a5c2ccb0a098f0446)

4 years agosd-netlink: reduce indentation levels a bit
Lennart Poettering [Wed, 10 Feb 2021 17:12:58 +0000 (18:12 +0100)]
sd-netlink: reduce indentation levels a bit

(cherry picked from commit baf78f1a51793c3dbbeb2b420783573d627f85a8)

4 years agosd-netlink: use getsockopt_int() where appropriate
Lennart Poettering [Wed, 10 Feb 2021 17:11:20 +0000 (18:11 +0100)]
sd-netlink: use getsockopt_int() where appropriate

(cherry picked from commit 13ec9f103b53ecc555a16048c3901d3320b26ef3)

4 years agosd-netlink: revamp message serial handling
Lennart Poettering [Wed, 10 Feb 2021 16:59:46 +0000 (17:59 +0100)]
sd-netlink: revamp message serial handling

Let's use uint32_t everywhere to maintain the seqno, since that's what
the kernel does. Prviously in the reply_callback logic we used 64bit,
for no apparent reason.

Using 32bit also provides us with the benefit that we can avoid using
uint64_hash_ops, and can use trivial_hash_ops instead for the reply
hashmap, so that we can store the seqno in the key pointer directly.

While we are at it, let's make sure we never run into serial collisions
internally (32bit is a lot, but not that much), and let's put a limit on
outstanding serials, to catch programming errors.

(cherry picked from commit b522c4b92a1a8999e008002f0a30acbaf58b55e4)

4 years agosocket-util: add getsockopt_int() helper
Lennart Poettering [Mon, 16 Nov 2020 11:41:39 +0000 (12:41 +0100)]
socket-util: add getsockopt_int() helper

(cherry picked from commit 4e25d4cf0f78ef7c960f2b77c941e3d8751535df)

4 years agoresolved: gracefully handle with packets with too large RR count
Lennart Poettering [Tue, 10 Nov 2020 13:48:13 +0000 (14:48 +0100)]
resolved: gracefully handle with packets with too large RR count

Apparently, there are plenty routers in place that report an incorrect
RR count in the packets: they declare more RRs than are actually
included.

Let's accept these responses, but let's downgrade them to baseline, i.e.
let's suppress OPT in this case: if they don't even get the RR count
right, let's operate on the absolute baseline, and not bother with
anything fancier such as EDNS.

Prompted-by: https://github.com/systemd/systemd/issues/12841#issuecomment-724063973
Fixes: #3980
Most likely fixes: #12841

(cherry picked from commit 18674159ebbf622a9e6e5a45cc36b38f74dae315)

4 years agotest: fix fd_is_mount_point() check v247.3
Lennart Poettering [Thu, 17 Dec 2020 15:19:09 +0000 (16:19 +0100)]
test: fix fd_is_mount_point() check

So the currentl and only fd_is_mount_point() check is actually entirely
bogus: it passes "/" as filename argument, but that's not actually a
a valid filename, but an absolute path.

fd_is_mount_point() is written in a way tha the fd refers to a directory
and the specified path is a file directly below it that shall be
checked. The test call actually violated that rule, but still expected
success.

Let's fix this, and check for this explicitly, and refuse it.

Let's extend the test and move it to test-mountpoint-util.c where the
rest of the tests for related calls are placed.

Replaces: #18004
Fixes: #17950
(cherry picked from commit 95231c7215c3ff14c491eb1d2a93312a8fe0c4f6)

4 years agosd-device: make TAGS= property prefixed and suffixed with ":"
Yu Watanabe [Thu, 10 Dec 2020 23:34:13 +0000 (08:34 +0900)]
sd-device: make TAGS= property prefixed and suffixed with ":"

The commit 6f3ac0d51766b0b9101676cefe5c4ba81feba436 drops the prefix and
suffix in TAGS= property. But there exists several rules that have like
`TAGS=="*:tag:*"`. So, the property must be always prefixed and suffixed
with ":".

Fixes #17930.

(cherry picked from commit 8d80f275303385eb9e2452f97f9c11be5c196862)

4 years agosd-device: keep escaped strings in DEVLINK= property
Yu Watanabe [Sun, 6 Dec 2020 12:10:34 +0000 (21:10 +0900)]
sd-device: keep escaped strings in DEVLINK= property

This fixes a bug introduced by 87a4d416e5126b6fb2528ae192a6a6a8033539ce.

Fixes #17772.

(cherry picked from commit 31063db0b4842a452c6eadde5b969aaee2a0516a)

4 years agosd-device: use set_strjoin()
Yu Watanabe [Sun, 6 Dec 2020 11:11:37 +0000 (20:11 +0900)]
sd-device: use set_strjoin()

This slightly changes TAGS= and CURRENT_TAGS= properties:

Before
E: TAGS=:aaa:bbb:

After
E: TAGS=aaa:bbb

(cherry picked from commit 6f3ac0d51766b0b9101676cefe5c4ba81feba436)

4 years agoset: introduce set_strjoin()
Yu Watanabe [Sun, 6 Dec 2020 11:10:48 +0000 (20:10 +0900)]
set: introduce set_strjoin()

(cherry picked from commit 4dbce717873000cff7b56f89266d1d2fe53f9284)

4 years agotools: make update-dbus-docs compatible with Python 3.6
Anita Zhang [Mon, 1 Feb 2021 03:04:34 +0000 (19:04 -0800)]
tools: make update-dbus-docs compatible with Python 3.6

668b3a42fe9e250912bd3efa4460ed691452d9bf allowed update-dbus-docs.py to start
running on Cent OS 8 (instead of skipping). But subprocess.check_output()'s
text argument didn't exist until Python 3.7 and C8 is still running
Python 3.6. Use universal_newlines instead for backwards compatibility.

(cherry picked from commit 934d0d023e33aa38c56e1e12118be8ddbd839284)

4 years agoman: fix small issue in AllowedMemoryNodes description
Pavel Hrdina [Sat, 30 Jan 2021 17:03:40 +0000 (18:03 +0100)]
man: fix small issue in AllowedMemoryNodes description

It should not mention "CPU" but "NUMA nodes".

(cherry picked from commit 16455ee2b1853238cf0e936735ff92e690a20253)

4 years agoman: make it clear how systemd calculate the DefaultTasksMax.
Einsler Lee [Sat, 30 Jan 2021 03:14:35 +0000 (11:14 +0800)]
man: make it clear how systemd calculate the DefaultTasksMax.

Actually, systemd takes the minimum of
* a) the maximum tasks value the kernel allows on this architecture
* b) the cgroups pids_max attribute for the system
* c) the kernel's configured maximum PID value
to calculate the DefaultTasksMax. Here, kernel.thread-max should also be methioned.

(cherry picked from commit 9c587d66187976de49e2d2028cebe1aef5b77b9c)

4 years agoresolved: use reference counting for DnsQueryCandidate objects
Zbigniew Jędrzejewski-Szmek [Fri, 29 Jan 2021 15:21:08 +0000 (16:21 +0100)]
resolved: use reference counting for DnsQueryCandidate objects

Follow-up for 4ea8b443de. The logic that manages DnsQueryCandidate is rather
complicated: a calls to dns_query_complete() that wants to destroy a
DnsQueryCandidate can be nested inside a deep chain of calls. Using reference
counts seems like the simplest approach.

DnsSearchDomain already uses reference counting.

This patch effectively brings dns_query_candidate_go() to the state before
4ea8b443de, but wraps the iteration over DnsQueryCandidate.transactions in
dns_query_candidate_ref+dns_query_candidate_unref.

(cherry picked from commit 0e0fd08fc832b8f42e567d722d388eba086da5ff)

4 years agoresolved: minor cleanups
Zbigniew Jędrzejewski-Szmek [Fri, 29 Jan 2021 15:18:12 +0000 (16:18 +0100)]
resolved: minor cleanups

(cherry picked from commit c805014a350da7c32eb2bdb408a9fa643c191dee)

4 years agotools: make update-dbus-docs compatible with Python 3.7
Luca Boccassi [Tue, 19 Jan 2021 11:57:46 +0000 (11:57 +0000)]
tools: make update-dbus-docs compatible with Python 3.7

Debian Stable uses Python 3.7, but there are a couple of 3.8 features used
in the script. Add fallbacks.

(cherry picked from commit 668b3a42fe9e250912bd3efa4460ed691452d9bf)

4 years agonetwork: drop wrong flag for neighbor entry
Yu Watanabe [Tue, 26 Jan 2021 16:19:24 +0000 (01:19 +0900)]
network: drop wrong flag for neighbor entry

NLM_F_REQUEST is a nlmsg flag, not a neighbor flag.

(cherry picked from commit 4816e7bb75cc573d188f325f14eb59a90357eec2)

4 years agosysusers: flush nscd's caches whenever /etc/{passwd,group} are modified
Franck Bui [Mon, 25 Jan 2021 15:32:44 +0000 (16:32 +0100)]
sysusers: flush nscd's caches whenever /etc/{passwd,group} are modified

(cherry picked from commit d481b8305280cc7780fcd1ce2c391f12ff31786f)

4 years agotree-wide: ignore messages with too long control data
Lennart Poettering [Tue, 19 Jan 2021 20:34:20 +0000 (21:34 +0100)]
tree-wide: ignore messages with too long control data

Apparently SELinux inserts control data into AF_UNIX datagrams where we
don't expect it, thus miscalculating the control data. This looks like
something to fix in SELinux, but we still should handle this gracefully
and just drop the offending datagram and continue.

recvmsg_safe() actually already drops the datagram, it's just a matter
of actually ignoring EXFULL (which it generates if control data is too
large) in the right places.

This does this wherever an AF_UNIX/SOCK_DGRAM socket is used with
recvmsg_safe() that is not just internal communication.

Fixes: #17795
Follow-up for: 3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1

(cherry picked from commit 741bfd7f4e60fdc07ecaadbd93f1196dbee657ca)

4 years agosystemctl: warn when importing environment variables with control characters
Zbigniew Jędrzejewski-Szmek [Tue, 19 Jan 2021 13:20:16 +0000 (14:20 +0100)]
systemctl: warn when importing environment variables with control characters

I don't think it is useful to warn about about environemnt variables where the user
explicitly configured some value. If they went through the effort of escaping the cc
to include it in the setting (e.g. Environment="VAR=\efoo"), and we pass this through,
there isn't anything to warn about. This also applies to 'systemctl set-environment',
where the variable name and value are passed as arguments.

The only case where the warning *might* be useful is where the user might be
surprised by the value. This occurs when importing variables from the inherited
environment, i.e. in 'systemctl import-environment'. In not convinced that this is
useful, since the user better control their shell environment anyway.

$ systemctl import-environment
Calling import-environment without a list of variable names is deprecated.
Environment variable $LESS_TERMCAP_mb contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_md contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_me contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_se contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_so contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_ue contains control characters, importing anyway.
Environment variable $LESS_TERMCAP_us contains control characters, importing anyway.
Environment variable $ZZZ contains control characters, importing anyway.

(cherry picked from commit e9155cd0778499a7e20edd2af8429247bbb1daa9)

4 years agoAllow control characters in environment variable values
Zbigniew Jędrzejewski-Szmek [Sun, 3 Jan 2021 21:26:52 +0000 (22:26 +0100)]
Allow control characters in environment variable values

So far, we would allow certain control characters (NL since
b4346b9a77bc6129dd3e, TAB since 6294aa76d818e831de45), but not others. Having
other control characters in environment variable *value* is expected and widely
used, for various prompts like $LESS, $LESS_TERMCAP_*, and other similar
variables. The typical environment exported by bash already contains a dozen or
so such variables, so programs need to handle them.

We handle then correctly too, for example in 'systemctl show-environment',
since 804ee07c1370d49aa9a. But we would still disallow setting such variables
by the user, in unit file Environment= and in set-environment/import-environment
operations. This is unexpected and confusing and doesn't help with anything
because such variables are present in the environment through other means.

When printing such variables, 'show-environment' escapes all special
characters, so variables with control characters are plainly visible.
In other uses, e.g. 'cat -v' can be used in similar fashion. This would already
need to be done to suppress color codes starting with \[.

Note that we still forbid invalid utf-8 with this patch. (Control characters
are valid, since they are valid 7-bit ascii.) I'm not sure if we should do
that, but since people haven't been actually asking for invalid utf-8, and only
for control characters, and invalid utf-8 causes other issues, I think it's OK
to leave this unchanged.

Fixes #4446, https://gitlab.gnome.org/GNOME/gnome-session/-/issues/45.

(cherry picked from commit 30927a24848c4d727f7619cc74b878f098cdd724)

4 years agosystemctl: print a warning when trying to import a nonexistent variable
Zbigniew Jędrzejewski-Szmek [Sun, 3 Jan 2021 20:53:38 +0000 (21:53 +0100)]
systemctl: print a warning when trying to import a nonexistent variable

I was quite confused what is happening:
$ XXX=xxx
$ systemctl --user import-environment XXX
$ systemctl --user show-environment | grep XXX
(nothing)

Obviously, 'export XXX' was missing. Without any indication why the
export is not happening, this can be hard to figure out.

Another option would be to error out. But so far we didn't, and doing
that could break some script which optimistically tries to export some
variables, if present.

(cherry picked from commit c4899ea427fe93b5b2beac8ab10bfee7dfbf2021)

4 years agoresolved: fix use-after-free with queries hitting the cache
Zbigniew Jędrzejewski-Szmek [Sun, 17 Jan 2021 18:51:28 +0000 (19:51 +0100)]
resolved: fix use-after-free with queries hitting the cache

When dns_transaction_complete() manages to resolve a query, it invalidates the
query candidate object. It shall not be accessed afterwards.

We have the following chain of calls:
dns_query_candidate_go → dns_transaction_go → dns_transaction_prepare → dns_cache_lookup (success: 1)
                                                                      → dns_transaction_complete
After returning back to dns_query_candidate_go(), we'd attempt to continue
iteration over the list of transactions attached to the query candidate,
accessing already freed (and overwritten) memory:

(gdb) bt
0  0x00007f637297cf47 in hashmap_iterate_entry (i=0x7ffe7e15cc90, h=0x706f746b73656465) at ../src/basic/hashmap.c:703
1  _hashmap_iterate (h=0x706f746b73656465, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88,
    key=key@entry=0x0) at ../src/basic/hashmap.c:712
2  0x00007f637297d01b in set_iterate (s=<optimized out>, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88)
    at ../src/basic/hashmap.c:733
hence we crash

3  0x0000557bc99eb80f in dns_query_candidate_go (c=c@entry=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:139
...but c is not valid here in the second iteration of the loop

4  0x0000557bc99eb720 in dns_query_candidate_notify (c=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:271
c was valid here at entry...

5  0x0000557bc99efe28 in dns_transaction_complete (t=0x557bcac072f0, state=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:350
t is a valid transaction (11481 in the backtrace below)

6  0x0000557bc99f1efb in dns_transaction_process_reply (t=0x557bcac072f0, p=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:1171
7  0x0000557bc99f2d41 in on_dns_packet (s=<optimized out>, fd=<optimized out>, revents=<optimized out>,
    userdata=0x557bcac072f0) at ../src/resolve/resolved-dns-transaction.c:1223
8  0x00007f6372a25217 in source_dispatch (s=s@entry=0x557bcb162c50) at ../src/libsystemd/sd-event/sd-event.c:3181
9  0x00007f6372a254fd in sd_event_dispatch (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3620
10 0x00007f6372a267c8 in sd_event_run (e=e@entry=0x557bcb15b050, timeout=timeout@entry=18446744073709551615)
    at ../src/libsystemd/sd-event/sd-event.c:3678
11 0x00007f6372a269ef in sd_event_loop (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3700
12 0x0000557bc99ddc14 in run (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:92
13 0x0000557bc99d260a in main (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:99

xxx.name.net systemd-resolved[31705]: Got message type=method_call sender=:1.3644 destination=org.freedesktop.resolve1 path=/org/freedesktop/resolve1 interface=org.freedesktop.resolve1.Manager member=ResolveHostname cookie=2 reply_cookie=0 signature=isit error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: idn2_lookup_u8: xxx → xxx
xxx.name.net systemd-resolved[31705]: Looking up RR for xxx IN A.
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=1102 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetNameOwner cookie=1103 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1103 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Cache miss for xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> scope dns on enp42s0/*.
xxx.name.net systemd-resolved[31705]: Using feature level UDP for transaction 11481.
xxx.name.net systemd-resolved[31705]: Using DNS server 192.168.1.1 for transaction 11481.
xxx.name.net systemd-resolved[31705]: Sending query packet with id 11481 of size 35.
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1102 signature= error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Match type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0=':1.3644' successfully installed.
xxx.name.net systemd-resolved[31705]: Processing incoming packet on transaction 11481 (rcode=NXDOMAIN).
xxx.name.net systemd-resolved[31705]: Not caching negative entry without a SOA record: xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> on scope dns on enp42s0/* now complete with <rcode-failure> from network (unsigned).
xxx.name.net systemd-resolved[31705]: Positive cache hit for xxx.lan IN A
xxx.name.net systemd-resolved[31705]: Transaction 64364 for <xxx.lan IN A> on scope dns on enp42s0/* now complete with <success> from cache (unsigned).
xxx.name.net systemd-resolved[31705]: Sent message type=method_return sender=n/a destination=:1.3644 path=n/a interface=n/a member=n/a cookie=1104 reply_cookie=2 signature=a(iiay)st error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=1105 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Freeing transaction 64364.
xxx.name.net systemd[1]: systemd-resolved.service: Main process exited, code=dumped, status=11/SEGV
xxx.name.net systemd[1]: systemd-resolved.service: Failed with result 'core-dump'.

Fixes #16168, https://bugzilla.redhat.com/show_bug.cgi?id=1895937.

(cherry picked from commit 4ea8b443de8be0f7a932f325dfafa1ee2a843795)

4 years agoman: clarify what network scopes are
Adam Nielsen [Sun, 17 Jan 2021 01:10:57 +0000 (11:10 +1000)]
man: clarify what network scopes are

(cherry picked from commit e64652f70c1cb1a2fd86915a8d806491cf73b162)

4 years agorpm: expose $systemd_util_dir also as rpm macro
Zbigniew Jędrzejewski-Szmek [Fri, 15 Jan 2021 09:31:00 +0000 (10:31 +0100)]
rpm: expose $systemd_util_dir also as rpm macro

This variable (a.k.a. rootlibexecdir), was exposed through the .pc file, but
not as rpm macro.

The .pc file must be located in the package that provides libraries, which
pulls in a lot of dependencies. In Fedora, the macros are split out to a
separate package so that other packages which need to refer to some systemd
path but don't otherwise require it, can only pull in the (much smaller and
dependency-less) macros package. zram-generator uses the path to specify the
location of systemd-makefs, so by using the rpm macro we'll be able to use
a much smaller buildroot.

(cherry picked from commit 3bc66bfa0136e370a8f7b06c3b69a52f5636ef82)

4 years agosystemctl-edit: Add missing ret_dropin_paths argument in retry path
Anita Zhang [Thu, 14 Jan 2021 08:17:41 +0000 (00:17 -0800)]
systemctl-edit: Add missing ret_dropin_paths argument in retry path

find_paths_to_edit() makes 2 calls to unit_find_paths(), one of which is
a retry client-side. ret_dropin_paths should be passed the same in
both cases.

(cherry picked from commit e4d22a9f321e3d7c4a3e3bc1783c5204d79d80e3)

4 years agosystemctl-edit: fix abort in find_paths_to_edit()
Anita Zhang [Thu, 14 Jan 2021 08:02:09 +0000 (00:02 -0800)]
systemctl-edit: fix abort in find_paths_to_edit()

After 85c5d313b5c92115f5c77663e736bcf21e99f02f, if you, for example,
create a drop-in for -.slice without a corresponding -.slice file, you will
get the following:

  # put some valid stuff in /etc/systemd/system/-.slice.d/override.conf

  [root@image ~]# systemctl daemon-reload
  [root@image ~]# systemctl edit -- -.slice
  Assertion 'path' failed at src/systemctl/systemctl-edit.c:425, function
  find_paths_to_edit(). Aborting.
  Aborted

The aforementioned commit sets the ret_dropin_paths argument for
unit_find_paths(). Thus, unit_find_paths() returns 1 in the example above
because it finds a relevant drop-in. However find_paths_to_edit() was written
to expect 1 only if the unit file itself exists (it does not in this example).

To make this behave more like the version of `systemctl edit` prior to
this commit, add an additional check so the code enters the
"unit file not found" code branch.

(cherry picked from commit 98199724cb9fdad910e8f4b222d39d9d1e77f1c4)

4 years agoimport: mangle untarred OS images after pull-tar, too
Lennart Poettering [Tue, 12 Jan 2021 17:49:11 +0000 (18:49 +0100)]
import: mangle untarred OS images after pull-tar, too

We do this for import-tar and import-fs, we should do it for pull-tar,
too.

Fixes: #17563
(cherry picked from commit c33e405f20631ab5bbb9d3b326e805c57dc4fac5)

4 years agodhcp6: refuse zero length vendor class
Yu Watanabe [Tue, 12 Jan 2021 13:38:29 +0000 (22:38 +0900)]
dhcp6: refuse zero length vendor class

Also, fixes the maximum length of the vendor class to UINT16_MAX.
Moreover, a memory leak in sd_dhcp6_client_set_request_vendor_class().

(cherry picked from commit 019951ec97a98775063271e5f36096ac3ba0b510)

4 years agodhcp6: refuse zero length dhcp user class
Yu Watanabe [Tue, 12 Jan 2021 13:03:43 +0000 (22:03 +0900)]
dhcp6: refuse zero length dhcp user class

This also fixes a memory leak when
sd_dhcp6_client_set_request_user_class() is called multiple times.

(cherry picked from commit 5a99444e4fe80c2ed416ca402b437e780a9de4b8)

4 years agonetwork: refuse zero length dhcp user class
Yu Watanabe [Tue, 12 Jan 2021 12:55:15 +0000 (21:55 +0900)]
network: refuse zero length dhcp user class

(cherry picked from commit b79951fa328f60577082a5710852e1d020d60b65)

4 years agodhcp: length of each user class field must be positive
Yu Watanabe [Tue, 12 Jan 2021 12:47:23 +0000 (21:47 +0900)]
dhcp: length of each user class field must be positive

This also fixes an memory leak when sd_dhcp_client_set_user_class()
is called multiple times.

(cherry picked from commit e4336c0a5df42f4c88ed31c4bad743b93b69718f)

4 years agojournal: send journald logs to kmsg again
Franck Bui [Fri, 4 Dec 2020 08:48:52 +0000 (09:48 +0100)]
journal: send journald logs to kmsg again

This was broken by commit bc694c06e60505efeb09e5278a7b22cdfa23975e.

(cherry picked from commit b3d6eb01653f249cd8df898525c4565dcaf082bf)

4 years agotimedate: actually reset system time with new timezone
Yu Watanabe [Tue, 12 Jan 2021 12:00:27 +0000 (21:00 +0900)]
timedate: actually reset system time with new timezone

Fix a bug introduced by 56b0ef2fc283425df6ae6f1dc198e0c408f70471.

Closes CID#1436943.

(cherry picked from commit df49792e01c2f6e49f21271e4d0abe0723b854b3)

4 years agowifi-util: do not ignore wifi iftype when SSID is not set
Yu Watanabe [Mon, 11 Jan 2021 14:36:42 +0000 (23:36 +0900)]
wifi-util: do not ignore wifi iftype when SSID is not set

Previously, if an interface does not have SSID, e.g. run in mesh-point
type, then the wifi iftype obtained by the netlink call was ignored.

Fixes #18059.

(cherry picked from commit a66a402da471f6230ab8674fd2c1df6d918773b5)

4 years agowifi-util: cleanup header inclusion
Yu Watanabe [Mon, 11 Jan 2021 14:26:54 +0000 (23:26 +0900)]
wifi-util: cleanup header inclusion

(cherry picked from commit a5330078158cbd5070e42fd3f91ecb570e210359)

4 years agodocs: `mesonconf` is not a valid command, `meson configure` is
igo95862 [Mon, 11 Jan 2021 13:04:33 +0000 (16:04 +0300)]
docs: `mesonconf` is not a valid command, `meson configure` is

Meson documentation for `meson configure`
https://mesonbuild.com/Commands.html#configure

(cherry picked from commit 5adfb06d5582adf09421d189b5e2fc6b93fa23e8)

4 years agobpf: do not use structured initialization for bpf_attr
Luca Boccassi [Sun, 10 Jan 2021 15:36:31 +0000 (15:36 +0000)]
bpf: do not use structured initialization for bpf_attr

It looks like zero'ing the struct is not enough, and with some level
of optimizations there is still non-zero padding left over.
Switch to member-by-member initialization. Also convert all remaining
bpf_attr variables in other files.

(cherry picked from commit 9ca600e2bfacc52a65c89f3485723b2c27394e55)

4 years agotest-xattr-util: don't insist that /usr supports xattrs
Lennart Poettering [Sat, 9 Jan 2021 15:32:55 +0000 (16:32 +0100)]
test-xattr-util: don't insist that /usr supports xattrs

(apparently overlayfs has issues with xattrs, hence don't require that
/usr supports xattrs)

(cherry picked from commit 84319c5c07e7283f31930c799dfd948d251d9b73)

4 years agobpf: zero bpf_attr before initialization
Luca Boccassi [Fri, 8 Jan 2021 23:47:03 +0000 (23:47 +0000)]
bpf: zero bpf_attr before initialization

When building with Clang and using structured initialization, the
bpf_attr union is not zero-padded, so the kernel misdetects it as
an unsupported extension.
zero it until Clang's behaviour matches GCC. Do not skip the test
on Github Actions anymore.

(cherry picked from commit 28abf5ad3483a417d3d4de561533d282493a7f2a)

4 years agoshell-completion: fix systemctl set/unset/import-environment
Zbigniew Jędrzejewski-Szmek [Tue, 5 Jan 2021 11:34:28 +0000 (12:34 +0100)]
shell-completion: fix systemctl set/unset/import-environment

unset-environment is completed with variable names in the environment block.
set-environment the same, but suffixed with "=".
import-environment is completed with variable names in the client environment.

(cherry picked from commit 341992081b6ece1adba270e239f96c9840884885)

4 years agoman: improve description of environment block creation
Zbigniew Jędrzejewski-Szmek [Tue, 5 Jan 2021 10:17:14 +0000 (11:17 +0100)]
man: improve description of environment block creation

This adds a general description of "philosphy" of keeping the environemnt
block small and hints about systemd-run -P env.

The list of generated variables is split out to a subsection. Viewing
the patch with ignoring whitespace changes is recommended.

We don't ignore invalid assignments (except in import-environment to some
extent), previous description was wrong.

For https://bugzilla.redhat.com/show_bug.cgi?id=1912046#c17.

(cherry picked from commit 82651d5b6b20ef959252e0a6845b906788235c70)

4 years agostat-util: don't try to open path on path_is_temporary_fs()
Lennart Poettering [Wed, 6 Jan 2021 17:05:56 +0000 (18:05 +0100)]
stat-util: don't try to open path on path_is_temporary_fs()

I mean, the old code at least used O_PATH, but still, we shouldn't
allocate/close an fd if we don't have to.

(cherry picked from commit 15308e5083391f6a1b9ce25c5b7323f37544eab8)

4 years agosystemctl: have is-enabled return success for aliases when calling into pid1 too
Luca Boccassi [Tue, 5 Jan 2021 13:44:26 +0000 (13:44 +0000)]
systemctl: have is-enabled return success for aliases when calling into pid1 too

commit 15d7ab87c4e5917f5788f1f8dce327a1e272bea3 introduced the
change to add an 'alias' state, but it was wired to systemctl
only when running in 'client-side' mode. Return success as
expected and documented also when running in 'server-mode'.

Fixes https://github.com/systemd/systemd/issues/18134

(cherry picked from commit bf3b428f73eb51f4abb64a80ea5be346b9eeb2fe)

4 years agoman: fix path reference to unit file
Gaël PORTAY [Thu, 5 Mar 2020 17:38:31 +0000 (12:38 -0500)]
man: fix path reference to unit file

The unit files are located at path /usr/lib/systemd/system.

This fixes the path reference to the unit file by adding the missing
path component system.

(cherry picked from commit 0215f04a7ebd1ab1da4b4279d5057953ae1ebcaa)

4 years agodocs: fix the link to boot loader specification
Gaël PORTAY [Wed, 30 Dec 2020 14:29:36 +0000 (09:29 -0500)]
docs: fix the link to boot loader specification

The boot loader specification link points to the boot loader interface
documentation.

This fixes the link to point to BOOT_LOADER_SPECIFICATION instead of
BOOTLOADER_INTERFACE which is itself.

(cherry picked from commit 7745379ea8c1d08ecde9ccd15af1a76cdac91cc5)

4 years agonetwork: fix possible memory leak
Yu Watanabe [Tue, 29 Dec 2020 17:11:32 +0000 (02:11 +0900)]
network: fix possible memory leak

When set_put() returns 0, then already stored rule will be unref()ed
from Manager.

(cherry picked from commit fdce9324c7132a9a6d3b2fe9f8449dcfc8309114)

4 years agoresolve: field size in dns resource record may be zero
Yu Watanabe [Tue, 29 Dec 2020 16:48:35 +0000 (01:48 +0900)]
resolve: field size in dns resource record may be zero

(cherry picked from commit b652cccab9ed4091ec347f6e924be131105279e9)

4 years agosiphash: introduce siphash24_compress_safe()
Yu Watanabe [Tue, 29 Dec 2020 16:44:04 +0000 (01:44 +0900)]
siphash: introduce siphash24_compress_safe()

(cherry picked from commit 0b71a7e01d8d04a3668c349e2320c42c786f2382)

4 years agofuzzers: set maximum length for several fuzzers
Yu Watanabe [Tue, 29 Dec 2020 08:26:43 +0000 (17:26 +0900)]
fuzzers: set maximum length for several fuzzers

Hopefully fixes oss-fuzz#19081, oss-fuzz#21731, oss-fuzz#21755.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19081
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21731
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21755

(cherry picked from commit 57dda0de3896e57f6d3f0625b2d5e13bbdb48d79)

4 years agoshared/dns: fix dlopen_idn return code check
Luca Boccassi [Mon, 28 Dec 2020 00:23:14 +0000 (00:23 +0000)]
shared/dns: fix dlopen_idn return code check

Fixes https://github.com/systemd/systemd/issues/18078

(cherry picked from commit 5def1f11f84fd4000a0f7c9ed1294b04f0cea703)

4 years agoman/systemd-nspawn: document hashing machine name for uid base
Dmitry Borodaenko [Wed, 23 Dec 2020 01:54:04 +0000 (17:54 -0800)]
man/systemd-nspawn: document hashing machine name for uid base

Explicitly document the behavior introduced in #7437: when picking a new
UID shift base with "-U", a hash of the machine name will be tried
before falling back to fully random UID base candidates.

(cherry picked from commit 68709a636c838e0754b49caa6ff2d4168e3c99c8)

4 years agoudev: fix memleak
Yu Watanabe [Mon, 21 Dec 2020 06:28:19 +0000 (15:28 +0900)]
udev: fix memleak

Fixes #18039.

(cherry picked from commit 9df1e11e31588c5df39aa7efed05414273f93f69)

4 years agojournal-importer: ignore invalid field at one more place
Yu Watanabe [Mon, 21 Dec 2020 07:33:20 +0000 (16:33 +0900)]
journal-importer: ignore invalid field at one more place

Fixes oss-fuzz#28817.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28817

(cherry picked from commit 8786d4bbe43b5f6493982bcb5211e010f99deb57)

4 years agoman/localtime: document default timezone
Luca BRUNO [Mon, 21 Dec 2020 09:55:04 +0000 (09:55 +0000)]
man/localtime: document default timezone

This explicitly documents the default `UTC` timezone which is used
by systemd and (other softwares) when `/etc/localtime` is not present.

Ref: https://github.com/systemd/systemd/blob/v247/src/basic/time-util.c#L1460-L1469
(cherry picked from commit 3d909037e3bb86bb14ceef98325b2759b938a4b3)

4 years agoman/systemd.netdev: clarify the wireguard AllowedIPs= setting
Florian Klink [Sun, 20 Dec 2020 17:24:05 +0000 (18:24 +0100)]
man/systemd.netdev: clarify the wireguard AllowedIPs= setting

`AllowedIPs=` only affects "routing inside the network interface
itself", as in, which wireguard peer packets with a specific destination
address are sent to, and what source addresses are accepted from which
peer.

To cause packets to be sent via wireguard in first place, a route via
that interface needs to be added - either in the `[Routes]` section on
the `.network` matching the wireguard interface, or outside of networkd.

This is a common cause of misunderstanding, because tools like wg-quick
also add routes to the interface. However, those tools are meant as a
"extremely simple script for easily bringing up a WireGuard interface,
suitable for a few common use cases (from their manpage).

Networkd also should support other usecases - like setting AllowedIPs to
0.0.0.0/0 and ::/0 and having a dynamic routing protocol setting more
specific routes (or the user manually setting them).

Reported-In: https://github.com/systemd/systemd/issues/14176
(cherry picked from commit c6b90e5c5e54e98b6aed38677f77d8491f2e49c8)