systemd/.git
4 years agodissect-image: clean up meaning of DISSECT_IMAGE_MKDIR
Lennart Poettering [Tue, 9 Mar 2021 21:03:00 +0000 (22:03 +0100)]
dissect-image: clean up meaning of DISSECT_IMAGE_MKDIR

Previously handling of DISSECT_IMAGE_MKDIR was pretty weird and broken:
it would control both if we create the top-level mount point when
mounting an image, and the inner mount points for images that consist of
multiple file systems. However, the latter is redundant, since
1f0f82f1311e4c52152b8e2b6f266258709c137d does this too, a few lines
further up – unconditionally!

Hence, let's make the meaning of DISSECT_IMAGE_MKDIR more strict: it
shall be only about the top-level mount point, not about the inner ones
(where we'll continue to create what is missing alwayway). Having a
separate flag for the top-level mount point is relevant, since the mount
point dir created by it will remain on the host fs – unlike the
directories we create inside the image, which will stay within the
image.

This slightly change of meaning is actually inline with what the flag is
actually used for and documented in systemd-dissect.

(cherry picked from commit 9842905ede9c7fdc541724ee5c6db7d46a47405d)

4 years agoinstall: refactor find_symlinks() and don't search for symlinks recursively
Michal Sekletar [Tue, 9 Mar 2021 16:22:32 +0000 (17:22 +0100)]
install: refactor find_symlinks() and don't search for symlinks recursively

After all we are only interested in symlinks either in top-level config
directory or in .wants and .requires sub-directories.

As a bonus this should speed up ListUnitFiles() roughly 3-4x on systems
with a lot of units that use drop-ins (e.g. SSH jump hosts with a lot of
user session scopes).

(cherry picked from commit 43b4e3058c106e663bbd5413e7bd106e55d6fd79)

4 years agocoredumpctl: fflush() stdout before invoking gdb
Lennart Poettering [Wed, 10 Mar 2021 20:54:59 +0000 (21:54 +0100)]
coredumpctl: fflush() stdout before invoking gdb

Fixes: #18936
(cherry picked from commit 48f813c4aab307695b853cbd3ea3c85f22486898)

4 years agocoredump: omit coredump info when -q is used with the `debug` verb
Frantisek Sumsal [Wed, 10 Mar 2021 15:41:35 +0000 (16:41 +0100)]
coredump: omit coredump info when -q is used with the `debug` verb

Skip printing the coredump info table when using the `debug` verb in
combination with the `-q/--quiet` option. Useful when trying to gather
coredump info non-interactively via scripted gdb commands.

Fixes: systemd/systemd#18935
(cherry picked from commit a174da59c299f6197425707f23757dc9149e5fba)

4 years agoRevert "udev: do not execute hwdb builtin import twice or thrice"
Zbigniew Jędrzejewski-Szmek [Wed, 10 Mar 2021 09:17:23 +0000 (10:17 +0100)]
Revert "udev: do not execute hwdb builtin import twice or thrice"

This reverts commit 876c75fe870846b09b54423a6b719d80bc879b27.

The patch seems to cause usb devices to get some attributes set from the parent
PCI device. 'hwdb' builtin has support for breaking iteration upwards on usb
devices. But when '--subsystem=foo' is specified, iteration is continued. I'm
sure it *could* be figured out, but it seems hard to get all the combinations
correct. So let's revert to functional status quo ante, even if does the lookup
more than once unnecessarily.

Fixes #18125.

(cherry picked from commit 451ba55fecd8b494add2001b3ca3c1915c8fd655)

4 years agosocket-util: refuse ifnames with embedded '%' as invalid
Lennart Poettering [Tue, 9 Mar 2021 19:43:02 +0000 (20:43 +0100)]
socket-util: refuse ifnames with embedded '%' as invalid

So Linux has this (insane — in my opinion) "feature" that if you name a
network interface "foo%d" then it will automatically look for the
interface starting with "foo…" with the lowest number that is not used
yet and allocates that.

We should never clash with this "magic" handling of ifnames, hence
refuse this, since otherwise we never know what the name is we end up
with.

We should probably switch things from a deny list to an allow list
sooner or later and be much stricter. Since the kernel directly enforces
only very few rules on the names, we'd need to do some research what is
safe and what is not first, though.

(cherry picked from commit e5f8ce13bbaf0d8b9ff597692c67fba0e38b4200)

4 years agooomd: add unit test to repro #18926
Anita Zhang [Mon, 8 Mar 2021 18:51:12 +0000 (10:51 -0800)]
oomd: add unit test to repro #18926

(cherry picked from commit 399d80ba8c604d57e7df6c5118ea3258cce026d9)

4 years agooomd: wrap paths in oomd_insert_cgroup_context with empty_to_root
Anita Zhang [Mon, 8 Mar 2021 18:21:37 +0000 (10:21 -0800)]
oomd: wrap paths in oomd_insert_cgroup_context with empty_to_root

(cherry picked from commit 50c0578b619e7298375afdffec7a8b3a40a68c21)

4 years agooomd: move TAKE_PTR to end of oomd_insert_cgroup_context()
Anita Zhang [Mon, 8 Mar 2021 18:35:31 +0000 (10:35 -0800)]
oomd: move TAKE_PTR to end of oomd_insert_cgroup_context()

Fixes #18926

(cherry picked from commit 45da27fa053898c1b94c175070a0dd63128875c9)

4 years agotimedated: fix skipping of comments in config file
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 19:49:53 +0000 (20:49 +0100)]
timedated: fix skipping of comments in config file

Reading file '/usr/lib/systemd/ntp-units.d/80-systemd-timesync.list'
Failed to add NTP service "# This file is part of systemd.", ignoring: Invalid argument
Failed to add NTP service "# See systemd-timedated.service(8) for more information.", ignoring: Invalid argument

:(

(cherry picked from commit 03a81441b1a490f8fc2a19aeb9b23299657c380c)

4 years agohomed: disable event sources before unreffing them
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 10:37:17 +0000 (11:37 +0100)]
homed: disable event sources before unreffing them

C.f. 9793530228.

We'd crash when trying to access an already-deallocated object:

Thread no. 1 (7 frames)
 #2 log_assert_failed_realm at ../src/basic/log.c:844
 #3 event_inotify_data_drop at ../src/libsystemd/sd-event/sd-event.c:3035
 #4 source_dispatch at ../src/libsystemd/sd-event/sd-event.c:3250
 #5 sd_event_dispatch at ../src/libsystemd/sd-event/sd-event.c:3631
 #6 sd_event_run at ../src/libsystemd/sd-event/sd-event.c:3689
 #7 sd_event_loop at ../src/libsystemd/sd-event/sd-event.c:3711
 #8 run at ../src/home/homed.c:47

The source in question is an inotify source, and the messages are:

systemd-homed[1340]: /home/ moved or renamed, recreating watch and rescanning.
systemd-homed[1340]: Assertion '*_head == _item' failed at src/libsystemd/sd-event/sd-event.c:3035, function event_inotify_data_drop(). Aborting.

on_home_inotify() got called, then manager_watch_home(), which unrefs the
existing inotify_event_source. I assume that the source gets dispatched again
because it was still in the pending queue.

I can't reproduce the issue (timing?), but this should
fix #17824, https://bugzilla.redhat.com/show_bug.cgi?id=1899264.

(cherry picked from commit cf5366387b24633284ee92285ea64a282270d591)

4 years agohomed: wrap some very long lines
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 10:28:19 +0000 (11:28 +0100)]
homed: wrap some very long lines

(cherry picked from commit 23d24b76f3df765fa6dbe7fe815bd4f8e76c9bb5)

4 years agodissect: fix memleak
Yu Watanabe [Sat, 6 Mar 2021 15:05:03 +0000 (00:05 +0900)]
dissect: fix memleak

Fixes #18903.

(cherry picked from commit f91861e49fea01c98ad0e1131b9141830c029f28)

4 years agosd-bus: fix memleak in failure path in bus_match_parse()
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 14:16:18 +0000 (15:16 +0100)]
sd-bus: fix memleak in failure path in bus_match_parse()

(cherry picked from commit 8df3f44c90a3e479b717e8cc4bb26c95ebbc5cb0)

4 years agosd-bus: fix memstream buffer extraction
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 20:19:02 +0000 (21:19 +0100)]
sd-bus: fix memstream buffer extraction

I'm getting the following error under valgrind:

==305970== Invalid free() / delete / delete[] / realloc()
==305970==    at 0x483E9F1: free (vg_replace_malloc.c:538)
==305970==    by 0x4012CD: mfree (alloc-util.h:48)
==305970==    by 0x4012EF: freep (alloc-util.h:83)
==305970==    by 0x4017F4: LLVMFuzzerTestOneInput (fuzz-bus-match.c:58)
==305970==    by 0x401A58: main (fuzz-main.c:39)
==305970==  Address 0x59972f0 is 0 bytes inside a block of size 8,192 free'd
==305970==    at 0x483FCE4: realloc (vg_replace_malloc.c:834)
==305970==    by 0x4C986F7: _IO_mem_finish (in /usr/lib64/libc-2.33.so)
==305970==    by 0x4C8F5E0: fclose@@GLIBC_2.2.5 (in /usr/lib64/libc-2.33.so)
==305970==    by 0x49D2CDB: fclose_nointr (fd-util.c:108)
==305970==    by 0x49D2D3D: safe_fclose (fd-util.c:124)
==305970==    by 0x4A4BCCC: fclosep (fd-util.h:41)
==305970==    by 0x4A4E00F: bus_match_to_string (bus-match.c:859)
==305970==    by 0x4016C2: LLVMFuzzerTestOneInput (fuzz-bus-match.c:58)
==305970==    by 0x401A58: main (fuzz-main.c:39)
==305970==  Block was alloc'd at
==305970==    at 0x483FAE5: calloc (vg_replace_malloc.c:760)
==305970==    by 0x4C98787: open_memstream (in /usr/lib64/libc-2.33.so)
==305970==    by 0x49D56D6: open_memstream_unlocked (fileio.c:97)
==305970==    by 0x4A4DEC5: bus_match_to_string (bus-match.c:859)
==305970==    by 0x4016C2: LLVMFuzzerTestOneInput (fuzz-bus-match.c:58)
==305970==    by 0x401A58: main (fuzz-main.c:39)
==305970==

So the fclose() which is called from _cleanup_fclose_ clearly reallocates the
buffer (maybe to save memory?). open_memstream(3) says:

  The locations referred to by these pointers are updated each time the
  stream is flushed (fflush(3)) and  when the stream is closed (fclose(3)).

This seems to mean that we should close the stream first before grabbing the
buffer pointer.

(cherry picked from commit 5963e6f43c4f33d5255ef0fb887cdf382bd51c9e)

4 years agorun: tweak algorithm for generating unit name from dbus unique name
Lennart Poettering [Thu, 4 Mar 2021 15:23:46 +0000 (16:23 +0100)]
run: tweak algorithm for generating unit name from dbus unique name

This reverts behaviour of systemd-run's unit name generation to the
status quo ante of #18871: we chop off the ":1." prefix if we can.
However, to address the issue that the unique name can overrun we then
do what #18871 did as fallback: only chop off the ":" prefix.

This way we should have pretty names that look like they always looked
in the common case, but in the case of a unique name overrun we still
will have names that work.

Follow-up for #18871

(cherry picked from commit e6283cbf48a3821d03ec73252620fc1b04bd4588)

4 years agotrans_time sec is int32,it will overflow if local system time is later than 2038.
caoxia [Thu, 28 Jan 2021 12:50:08 +0000 (20:50 +0800)]
trans_time sec is int32,it will overflow if local system time is later than 2038.

(cherry picked from commit 370d3c31b4637d1b2faeec555da3283e49a6744f)

4 years agorun: update dbus unique names check
Anita Zhang [Thu, 4 Mar 2021 01:25:40 +0000 (17:25 -0800)]
run: update dbus unique names check

Some code in systemd-run checks that a bus's unique name must start with
`:1.`. However the dbus specification on unique connection names only specifies
that it must begin with a colon. And the freedesktop/dbus implementation allows
allows unique names to go up to `:INT_MAX.INT_MAX`. So update the
current check to only look for a colon at the beginning.

(cherry picked from commit 01584bf9e43db1dfb7ea4ba628f533b3066e81cc)

4 years agocore: fix mtime calculation of dropin files
Zbigniew Jędrzejewski-Szmek [Wed, 3 Mar 2021 23:36:24 +0000 (00:36 +0100)]
core: fix mtime calculation of dropin files

Nominally, the bug was in unit_load_dropin(), which just took the last mtime
instead of calculating the maximum. But instead of adding code to wrap the
loop, this patch goes in the other direction.

All (correct) callers of config_parse() followed a very similar pattern to
calculate the maximum mtime. So let's simplify things by making config_parse()
assume that mtime is initialized and update it to the maximum. This makes all
the callers that care about mtime simpler and also fixes the issue in
unit_load_dropin().

config_parse_many_nulstr() and config_parse_many() are different, because it
makes sense to call them just once, and current ret_mtime behaviour make sense.

Fixes #17730, https://bugzilla.redhat.com/show_bug.cgi?id=1933137.

(cherry picked from commit da46a1bc3cd28ac36114002c216196dae004b05c)

4 years agoudev: add i2c to 60-persistent-input.rules for by-path (#18808)
Tom Shield [Tue, 2 Mar 2021 09:56:06 +0000 (03:56 -0600)]
udev: add i2c to 60-persistent-input.rules for by-path (#18808)

Add the i2c subsystem to those that create by-path links.
i2c devices may not have IDs so we can't rely on the by-id links
but they (or some of them) should at least have a path that we can use.

(cherry picked from commit e595edf1a3d7318811325cf97663c4b5a3859c6e)

4 years agosd-device: don't use BPF filtering for kernel monitors
Martin Wilck [Thu, 25 Feb 2021 16:09:03 +0000 (17:09 +0100)]
sd-device: don't use BPF filtering for kernel monitors

BPF filtering accesses fields in the netlink header that are
only filled in by libudev, never by the kernel. Therefore adding
BPF filters for kernel monitors is pointless. Even false filtering
of kernel events might be possible; at least it's hard to prove that
it can't occur.

(cherry picked from commit d8ce385fe3e5be91b6f414415e10f8897e41d942)

4 years agoFix path typo in systemd.unit
Lajos Veres [Sun, 28 Feb 2021 22:48:08 +0000 (22:48 +0000)]
Fix path typo in systemd.unit

/etc/systemd/systemd/ => /etc/systemd/system/

(cherry picked from commit 57733518817c1217b9f442ca790ff3f50705b1c8)

4 years agoudev: when btrfs.ko is not available consider btrfs filesystems not ready
Lennart Poettering [Thu, 25 Feb 2021 14:04:25 +0000 (15:04 +0100)]
udev: when btrfs.ko is not available consider btrfs filesystems not ready

Let's add a special tweak to the btrfs builtin: if /dev/btrfs-control is
not there, let's consider all btrfs file systems as SYSTEMD_READY=0.
This is useful in initrds, where btrfs.ko might be missing. After the
initrd → host transition we can then retigger the device and undo the
SYSTEMD_READY=0 marking.

(cherry picked from commit 97e535c7248cc0457395e2d62b6e7d6c342a0bd2)

4 years agoman: fix indentation of example
Lennart Poettering [Thu, 25 Feb 2021 13:36:18 +0000 (14:36 +0100)]
man: fix indentation of example

The man page otherwise looks very weirdly aligned.

(cherry picked from commit 8b596d51a9b347f6fe5d130cbb0d26693149ce25)

4 years agoman: advertise shared drop-ins more
Zbigniew Jędrzejewski-Szmek [Thu, 25 Feb 2021 13:54:54 +0000 (14:54 +0100)]
man: advertise shared drop-ins more

systemd.unit(5) is a wall of text. And this particular feature can be very useful
in the context of resource control. Let's avertise this cool feature a bit more.

Fixes #17900.

(cherry picked from commit a8136f1bc03d1bdf93b9071b4f82123b81a05c8e)

4 years agoman: fix two issues in udev(7)
Zbigniew Jędrzejewski-Szmek [Thu, 25 Feb 2021 13:30:34 +0000 (14:30 +0100)]
man: fix two issues in udev(7)

Fixed #18050.

(cherry picked from commit 4fc8a70d9f062b7b51c6c808a24ca3fd22df668f)

4 years agocgroup: don't generate BPF firewall unsupported warning on wrong unit
Lennart Poettering [Wed, 24 Feb 2021 16:49:32 +0000 (17:49 +0100)]
cgroup: don't generate BPF firewall unsupported warning on wrong unit

Let's generate the warning on a unit that actually needs the BPF
firewall, and not confusingly already for a sibling of one.

(cherry picked from commit a437c5e4da666d16f15649461ce45e0e6d735148)

4 years agoresolved: don't discard mDNS queries with bad flags
Sergey Bugaev [Fri, 19 Feb 2021 12:29:02 +0000 (15:29 +0300)]
resolved: don't discard mDNS queries with bad flags

Even though RFC 6762 specifies these bits MUST be zero, it also says they MUST
be ignored on reception.

(cherry picked from commit 2aaf3765974c9f340c0c3d705e9f0609073cf83c)

4 years agoresolved: don't discard mDNS packets with ip6.arpa RRs
Sergey Bugaev [Mon, 15 Feb 2021 16:03:27 +0000 (19:03 +0300)]
resolved: don't discard mDNS packets with ip6.arpa RRs

ip6.arpa is also a valid domain name to put in mDNS packets.

(cherry picked from commit 7675501540980eff80c0e055c219e5e1efde6b62)

4 years agotimedate: do not ignore fix_system argument in SetLocalRTC method
Yu Watanabe [Wed, 24 Feb 2021 04:16:15 +0000 (13:16 +0900)]
timedate: do not ignore fix_system argument in SetLocalRTC method

Fixes #18391.

(cherry picked from commit 2be6c4758e3c27a3f502735881a355e5bfae97b0)

4 years agodhcp6: do not set T1 and T2 by dhcp6_option_append_pd() in client
Yu Watanabe [Mon, 22 Feb 2021 13:39:31 +0000 (22:39 +0900)]
dhcp6: do not set T1 and T2 by dhcp6_option_append_pd() in client

Fixes #18090.

(cherry picked from commit 73b49d433c2c8e6304c8b82538bd4231d070fce4)

4 years agodhcp6: do not set T1 and T2 by dhcp6_option_append_ia() in client
Yu Watanabe [Mon, 22 Feb 2021 12:54:32 +0000 (21:54 +0900)]
dhcp6: do not set T1 and T2 by dhcp6_option_append_ia() in client

(cherry picked from commit e7613578b4747488bef9b558dc35e41d7075f18a)

4 years agodhcp6: make dhcp6_option_parse_{address,pdprefix}() return -EINVAL when received...
Yu Watanabe [Tue, 23 Feb 2021 10:25:17 +0000 (19:25 +0900)]
dhcp6: make dhcp6_option_parse_{address,pdprefix}() return -EINVAL when received address or prefix is refused

And then the caller ignores the error.
Otherwise, `ret_liftime_valid` is not set even if they succeeds.

(cherry picked from commit 1e84213a433f8a80c94dea34514744cc4937efd0)

4 years agodhcp6: do not use input value before checking
Yu Watanabe [Mon, 22 Feb 2021 12:59:24 +0000 (21:59 +0900)]
dhcp6: do not use input value before checking

(cherry picked from commit cf6c33bd6b6ca606f0756312bd73ae066c6aa9a8)

4 years agobootspec: assume that the root dir is at the top of its file system
Lennart Poettering [Tue, 23 Feb 2021 14:02:33 +0000 (15:02 +0100)]
bootspec: assume that the root dir is at the top of its file system

Fixes: #17746
(cherry picked from commit eceb61112c8ece03adfb4fcbc83e357875ca0ceb)

4 years agoman: add a description of how manager env block is set
Zbigniew Jędrzejewski-Szmek [Tue, 23 Feb 2021 16:18:05 +0000 (17:18 +0100)]
man: add a description of how manager env block is set

(cherry picked from commit d51586434677423e97decd0f8c02db0a266dd4e7)

4 years agoefi stub: accept it if our loaded image has no FilePath field set
Lennart Poettering [Tue, 23 Feb 2021 13:16:08 +0000 (14:16 +0100)]
efi stub: accept it if our loaded image has no FilePath field set

The firmware spec doesn't really say whether FilePath of the LoadedImage
protocol may be NULL or not. So far we assumed it to be non-NULL, but
apparently the FreeBSD UEFI chainloader sets it to NULL. Handle this
gracefully.

(Noticed and tracked down by Alexander Schreiber)

Fixes: #18733
(cherry picked from commit 685097b9cadf92d21dfa857c3a7ddc1ba115088e)

4 years agoman: various improvements to systemd.generator(7)
Lennart Poettering [Tue, 23 Feb 2021 13:07:46 +0000 (14:07 +0100)]
man: various improvements to systemd.generator(7)

In particular, make clear the .d/*.conf unit file drop-ins are OK to
generate from generators.

Inspired by: https://lists.freedesktop.org/archives/systemd-devel/2021-February/046148.html

(cherry picked from commit 3acf00a5a4ff656e2799f7f3e2544891b09bbc35)

4 years agoresolved: add another explanatory message to stub resolv.conf files
Zbigniew Jędrzejewski-Szmek [Tue, 23 Feb 2021 00:31:15 +0000 (01:31 +0100)]
resolved: add another explanatory message to stub resolv.conf files

Apparently people do "cat /etc/resolv.conf" and not realize that they
are looking at a file in /run.

(cherry picked from commit 2b767e9222809103cb756e368f0d71e906623bca)

4 years agocryptsetup: unescape ID_PART_ENTRY_NAME udev property before using it
Lennart Poettering [Mon, 22 Feb 2021 16:38:02 +0000 (17:38 +0100)]
cryptsetup: unescape ID_PART_ENTRY_NAME udev property before using it

Fixes: #18729
(cherry picked from commit fadd34dd5af9a26edf2906b237ac212169d39f0c)

4 years agoman: try to improve documentation of conditions/asserts
Lennart Poettering [Mon, 22 Feb 2021 17:12:34 +0000 (18:12 +0100)]
man: try to improve documentation of conditions/asserts

Fixes: #18725
(cherry picked from commit 0a6aa7a238e1130ebe1b797a62da06645fb73ad4)

4 years agoman: correct documentaiton of StandardInput='s defaults in regards to "data"
Lennart Poettering [Mon, 22 Feb 2021 16:52:20 +0000 (17:52 +0100)]
man: correct documentaiton of StandardInput='s defaults in regards to "data"

Fixes: #18710
(cherry picked from commit c6e33c293ecb1cad5f975fe3cd12ec5aff3df221)

4 years agoman: correct the unit file directory for attached images
Tyler Hicks [Sun, 21 Feb 2021 18:53:22 +0000 (12:53 -0600)]
man: correct the unit file directory for attached images

Commit 83f72cd65fb8 ("man,docs: document the new unit file directory for
attached images") updated the docs and man page with the new unit file
directory for attached images but included a system.attached ->
systemd.attached typo in the man page portion of the change. Fix the
typo to document the correct path.

(cherry picked from commit e4d54220a1ffa6629c0aad717a8b7601c0319657)

4 years agosysctl.d: silence warning if net.core.default_qdisc cannot be set
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 18:02:38 +0000 (19:02 +0100)]
sysctl.d: silence warning if net.core.default_qdisc cannot be set

Kernels can be compiled without the attribute. It's fine if this is not
set, so silence the warning.

(cherry picked from commit fa98c99ea7f7c5bec3962fa52f4d3496a9777024)

4 years agoxdg-autostart-generator: ignore DBusActivatable=true
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 08:50:09 +0000 (09:50 +0100)]
xdg-autostart-generator: ignore DBusActivatable=true

See https://wiki.gnome.org/HowDoI/DBusApplicationLaunching and
https://wiki.gnome.org/Initiatives/GnomeGoals/DBusActivatable for a description
of this key:
> Instead of the typical UNIX-style fork()/exec() approach to process creation,
> launching an application is done by sending a D-Bus message to the well-known
> name of that application, causing a D-Bus activation.
>
> Starting processes with D-Bus activation ensures that each application gets
> started in its own pristine environment, as a direct descendent of the
> session -- not in the environment of whatever its parent happened to be. This
> is important for ensuring the app ends up in the correct cgroup, for example.

So this motivation is not important for us: we launch stuff ourselves better.

This fixes warnings during boot:
systemd-xdg-autostart-generator[2274]: /etc/xdg/autostart/org.freedesktop.problems.applet.desktop:92: Unknown key name 'DBusActivatable' in section 'Desktop Entry', ignoring.

(cherry picked from commit 36290e0b97ba032cbd71723f2255917924eadc05)

4 years agoxdg-autostart-generator: reindent
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 08:47:32 +0000 (09:47 +0100)]
xdg-autostart-generator: reindent

(cherry picked from commit 9f11f565556410f9484db9e4991f6c04eeafffc7)

4 years agoRecommend drop-ins over modifications to the main config file
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 19:57:06 +0000 (20:57 +0100)]
Recommend drop-ins over modifications to the main config file

As discussed in https://github.com/systemd/systemd/pull/18347.

(cherry picked from commit 09db71a4a3fb9cee19f89cb75ad453caa46209b8)

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)