systemd/.git
4 years agoshared/calendarspec: when mktime() moves us backwards, jump forward
Zbigniew Jędrzejewski-Szmek [Mon, 22 Mar 2021 11:51:47 +0000 (12:51 +0100)]
shared/calendarspec: when mktime() moves us backwards, jump forward

When trying to calculate the next firing of 'Sun *-*-* 01:00:00', we'd fall
into an infinite loop, because mktime() moves us "backwards":

Before this patch:
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
...

We rely on mktime() normalizing the time. The man page does not say that it'll
move the time forward, but our algorithm relies on this. So let's catch this
case explicitly.

With this patch:
$ TZ=Europe/Dublin faketime 2021-03-21 build/systemd-analyze calendar --iterations=5 'Sun *-*-* 01:00:00'
Normalized form: Sun *-*-* 01:00:00
    Next elapse: Sun 2021-03-21 01:00:00 GMT
       (in UTC): Sun 2021-03-21 01:00:00 UTC
       From now: 59min left
       Iter. #2: Sun 2021-04-04 01:00:00 IST
       (in UTC): Sun 2021-04-04 00:00:00 UTC
       From now: 1 weeks 6 days left           <---- note the 2 week jump here
       Iter. #3: Sun 2021-04-11 01:00:00 IST
       (in UTC): Sun 2021-04-11 00:00:00 UTC
       From now: 2 weeks 6 days left
       Iter. #4: Sun 2021-04-18 01:00:00 IST
       (in UTC): Sun 2021-04-18 00:00:00 UTC
       From now: 3 weeks 6 days left
       Iter. #5: Sun 2021-04-25 01:00:00 IST
       (in UTC): Sun 2021-04-25 00:00:00 UTC
       From now: 1 months 4 days left

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1941335.

(cherry picked from commit 129cb6e249bef30dc33e08f98f0b27a6de976f6f)

4 years agoshared/calendarspec: abort calculation after 1000 iterations
Zbigniew Jędrzejewski-Szmek [Sun, 21 Mar 2021 19:59:32 +0000 (20:59 +0100)]
shared/calendarspec: abort calculation after 1000 iterations

We have a bug where we seem to enter an infinite loop when running in the
Europe/Dublin timezone. The timezone is "special" because it has negative SAVE
values. The handling of this should obviously be fixed, but let's use a
belt-and-suspenders approach, and gracefully fail if we fail to find an answer
within a specific number of attempts. The code in this function is rather
complex, and it's hard to rule out another bug in the future.

(cherry picked from commit 169615c9a8cdc54d748d4dfc8279be9b3c2bec44)

4 years agoresolved: propagate correct error variable
Lennart Poettering [Mon, 22 Mar 2021 17:27:36 +0000 (18:27 +0100)]
resolved: propagate correct error variable

(cherry picked from commit 4cba52cc7a2191d0b38e605801c60d8648bc67e2)

4 years agolog: protect errno in log_open()
Sergey Bugaev [Mon, 22 Mar 2021 15:31:12 +0000 (18:31 +0300)]
log: protect errno in log_open()

Commit 0b1f3c768ce1bd1490a5e53f539976dcef8ca765 has introduced log_open()
calls after exec fails post-fork. However, the log_open() call itself could
change the value of errno, which, for me, manifested in:

$ coredumpctl gdb
...
Failed to invoke gdb: Success

Fix this by using PROTECT_ERRNO in log_open().

(cherry picked from commit 0e557eef37c9ebcc8f5c19fc6fc44b6fd617cc5d)

4 years agoshell-completion: systemd-run: add missing options
Yu Watanabe [Fri, 19 Mar 2021 13:16:22 +0000 (22:16 +0900)]
shell-completion: systemd-run: add missing options

Closes #19044.

(cherry picked from commit c23bb96b388f371e44c4f1756801dec2b4e72307)

4 years agologs-show: add missing newline in warning message
Antonio Terceiro [Sun, 21 Mar 2021 14:37:51 +0000 (11:37 -0300)]
logs-show: add missing newline in warning message

(cherry picked from commit 17e90001643d07a7353ba88417e12be2ff0fa042)

4 years agoblockdev-util: fix access to possibly invalidated dirent struct
Lennart Poettering [Fri, 19 Mar 2021 10:14:52 +0000 (11:14 +0100)]
blockdev-util: fix access to possibly invalidated dirent struct

Let's copy out the string we need from the dirent, there's no reason to
believe the dirent struct might live for longer than one loop iteration.

(cherry picked from commit c68fc3514ddd53abd7ecfd22afb07aa0ad785c5c)

4 years agorepart: make sure to grow partition table after growing backing loopback file
Lennart Poettering [Fri, 19 Mar 2021 09:36:48 +0000 (10:36 +0100)]
repart: make sure to grow partition table after growing backing loopback file

This fixes the --size= switch, i.e. where we grow a disk image: after
growing it we need to expand the partition table so that its idea of the
the medium size matches the new reality. Otherwise our disk size
calculations in the subsequent steps might still use the original
ungrown size.

(This used to work, I guess this was borked when libfdisk learnt the
concept of "minimized" partition tables)

(cherry picked from commit f9b3afae96c72564cd4cd766555845f17e3c12a9)

4 years agoWrong index in error message
Sam Lunt [Thu, 18 Mar 2021 19:50:30 +0000 (14:50 -0500)]
Wrong index in error message

(cherry picked from commit 6f50c94dfda7c5bd31b364a40038c3d68d1e56ab)

4 years agoudev: do not try to assign invalid ifname
Yu Watanabe [Thu, 18 Mar 2021 21:26:53 +0000 (06:26 +0900)]
udev: do not try to assign invalid ifname

Fixes #19038.

(cherry picked from commit 5cdb3f70ebe035323f4f079028a262669a2bbbf6)

4 years agocg_unified_cached: return ENOMEDIUM if we cannot find a known hierarchy
Mike Gilbert [Tue, 9 Mar 2021 22:57:37 +0000 (17:57 -0500)]
cg_unified_cached: return ENOMEDIUM if we cannot find a known hierarchy

When the test suite is being run in a foreign environment,
/sys/fs/cgroup might not be set up in a way that we recognize.
Returning ENOMEDIUM causes the tests to be skipped in this case.

Bug: https://bugs.gentoo.org/771819
(cherry picked from commit 2156061fb33811aedb160d1b476793a5b845b143)

4 years agodhcp6: fix wrong length for IA_PD dhcp6 option
Yu Watanabe [Tue, 16 Mar 2021 15:23:51 +0000 (00:23 +0900)]
dhcp6: fix wrong length for IA_PD dhcp6 option

Fixes an issue introduced by 73b49d433c2c8e6304c8b82538bd4231d070fce4.

When PrefixDelegationHint= is not set, dhcp6_option_append_pd() sets
wrong length for IA_PD option, as `r` is `-EINVAL`.

Fixes #19021.

(cherry picked from commit fa92d38428cdac260e72e280bf1d43539f4ea805)

4 years agojournald: restore syslog priority *with* facility bits for stream connections when...
Lennart Poettering [Tue, 16 Mar 2021 15:09:47 +0000 (16:09 +0100)]
journald: restore syslog priority *with* facility bits for stream connections when restarting journald

Fixes: #19019
(cherry picked from commit d977ef2542accd3e10a7540b3a8b6d1278cc0041)

4 years agoman: specify that ProtectProc= does not work with root/cap_sys_ptrace
Luca Boccassi [Sun, 14 Mar 2021 12:36:15 +0000 (12:36 +0000)]
man: specify that ProtectProc= does not work with root/cap_sys_ptrace

When using hidepid=invisible on procfs, the kernel will check if the
gid of the process trying to access /proc is the same as the gid of
the process that mounted the /proc instance, or if it has the ptrace
capability:

https://github.com/torvalds/linux/blob/v5.10/fs/proc/base.c#L723
https://github.com/torvalds/linux/blob/v5.10/fs/proc/root.c#L155

Given we set up the /proc instance as root for system services,
The same restriction applies to CAP_SYS_PTRACE, if a process runs with
it then hidepid=invisible has no effect.

ProtectProc effectively can only be used with User= or DynamicUser=yes,
without CAP_SYS_PTRACE.
Update the documentation to explicitly state these limitations.

Fixes #18997

(cherry picked from commit 301e7cd047c8d07715d5dc37f713e8aa031581b4)

4 years agoman: DNS/NTP servers received from DHCP server are concatenated with the statically...
Yu Watanabe [Sat, 13 Mar 2021 10:56:30 +0000 (19:56 +0900)]
man: DNS/NTP servers received from DHCP server are concatenated with the statically configured ones

Prompted by #9473.

(cherry picked from commit b63dae3168209a06cefe2b9916667b7754b7de34)

4 years agoask-password-api: fix error handling on invalid unicode character v247.4
Kevin Backhouse [Fri, 12 Mar 2021 17:00:56 +0000 (18:00 +0100)]
ask-password-api: fix error handling on invalid unicode character

The integer overflow happens when utf8_encoded_valid_unichar() returns an error
code. The error code is a negative number: -22. This overflows when it is
assigned to `z` (type `size_t`). This can cause an infinite loop if the value
of `q` is 22 or larger.

To reproduce the bug, you need to run `systemd-ask-password` and enter an
invalid unicode character, followed by a backspace character.

GHSL-2021-052

(cherry picked from commit 37ca78a35cd1b9f13e584ccf3d332413c7875e40)

4 years agoresolved: disable event sources before unreffing them
Zbigniew Jędrzejewski-Szmek [Mon, 1 Mar 2021 22:10:06 +0000 (23:10 +0100)]
resolved: disable event sources before unreffing them

We generally operate on the assumption that a source is "gone" as soon
as we unref it. This is generally true because we have the only reference.
But if something else holds the reference, our unref doesn't really stop
the source and it could fire again.

In particular, on_query_timeout() is called with DnsQuery* as userdata, and
it calls dns_query_stop() which invalidates that pointer. If it was ever
called again, we'd be accessing already-freed memory.

I don't see what would hold the reference. sd-event takes a temporary reference,
but on the sd_event object, not on the individual sources. And our sources
are non-floating, so there is no reference from the sd_event object to the
sources.

For #18427.

(cherry picked from commit 97935302283729c9206b84f5e00b1aff0f78ad19)

4 years agotree-wide: fix the string concatenation warning with clang-12
Frantisek Sumsal [Mon, 8 Feb 2021 10:26:26 +0000 (11:26 +0100)]
tree-wide: fix the string concatenation warning with clang-12

e.g.:
./src/shared/dissect-image.c:2218:39: error: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Werror,-Wstring-concatenation]
                                      "/usr/lib/os-release\0",
                                      ^
../src/shared/dissect-image.c:2217:39: note: place parentheses around the string literal to silence warning
                [META_OS_RELEASE]   = "/etc/os-release\0"
                                      ^
1 error generated.

See: https://reviews.llvm.org/D85545
(cherry picked from commit 8762049792024df1be9f0b219438220bb9ee547d)

4 years agonetwork: Delay addition of IPv6 Proxy NDP addresses
Kevin P. Fleming [Sat, 6 Feb 2021 15:58:43 +0000 (10:58 -0500)]
network: Delay addition of IPv6 Proxy NDP addresses

Setting of IPv6 Proxy NDP addresses must be done at the same
time as static addresses, static routes, and other link attributes
that must be configured when the link is up. Doing this ensures
that they are reconfigured on the link if the link goes down
and returns to service.

(cherry picked from commit 12f7469bbe0142d7f360a29ca2b407ce7f5ff096)

Fixes https://github.com/systemd/systemd-stable/issues/89

4 years agopkg-config: make prefix overridable again
Jan Tojnar [Sat, 2 Jan 2021 01:46:33 +0000 (02:46 +0100)]
pkg-config: make prefix overridable again

While we don't support prefix being != /usr, and this is hardcoded
all over the place, variables in pkg-config file are expected
to have overridable base directory.

This is important for at least the following two use cases:

- Installing projects to non-FHS package-specific prefixes for Nix-style
  package managers. Of course, it is then their responsibility
  to ensure systemd can find the service files.
- Installing to local path for development purposes.
  This is a compromise between running a program from a build directory,
  and running it fully installed to system prefix.

You will not want to write to system prefix in either case.

For more information, see also
https://www.bassi.io/articles/2018/03/15/pkg-config-and-paths/

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

Partially reverts 6e65df89c348242dbd10036abc7dd5e8181cf733

(cherry picked from commit 60bce7c6d9606185114df1bdcd5ea100407688b8)

Fixes https://github.com/systemd/systemd-stable/issues/88

4 years agoUpdate resolvectl.xml
ulf-f [Thu, 11 Mar 2021 18:18:14 +0000 (19:18 +0100)]
Update resolvectl.xml

fixed typo of filename

(cherry picked from commit 2d8ce4c70114d9163be9ff45bdece1551a7036cc)

4 years agooomd: "downgrade" level of message
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 08:21:25 +0000 (09:21 +0100)]
oomd: "downgrade" level of message

PID1 already logs about the service being started, so this line isn't necessary
in normal use. Also, by the time it is emitted, the service has already
signalled readiness, so let's not say "starting" but "started".

(cherry picked from commit a19c1a4baaa1dadc80885e3ad41f19a6c6c450fd)

4 years agovarlink: avoid using dangling ref in varlink_close_unref()
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 15:42:35 +0000 (16:42 +0100)]
varlink: avoid using dangling ref in varlink_close_unref()

Fixes #18025, https://bugzilla.redhat.com/show_bug.cgi?id=1931034.

We drop the reference stored in Manager.managed_oom_varlink_request in two code paths:
vl_disconnect() which is installed as a disconnect callback, and in manager_varlink_done().
But we also make a disconnect from manager_varlink_done(). So we end up with the following
call stack:

(gdb) bt
 0  vl_disconnect (s=0x112c7b0, link=0xea0070, userdata=0xe9bcc0) at ../src/core/core-varlink.c:414
 1  0x00007f1366e9d5ac in varlink_detach_server (v=0xea0070) at ../src/shared/varlink.c:1210
 2  0x00007f1366e9d664 in varlink_close (v=0xea0070) at ../src/shared/varlink.c:1228
 3  0x00007f1366e9d6b5 in varlink_close_unref (v=0xea0070) at ../src/shared/varlink.c:1240
 4  0x0000000000524629 in manager_varlink_done (m=0xe9bcc0) at ../src/core/core-varlink.c:479
 5  0x000000000048ef7b in manager_free (m=0xe9bcc0) at ../src/core/manager.c:1357
 6  0x000000000042602c in main (argc=5, argv=0x7fff439c43d8) at ../src/core/main.c:2909

When we enter vl_disconnect(), m->managed_oom_varlink_request.n_ref==1.
When we exit from vl_discconect(), m->managed_oom_varlink_request==NULL. But
varlink_close_unref() has a copy of the pointer in *v. When we continue executing
varlink_close_unref(), this pointer is dangling, and the call to varlink_unref()
is done with an invalid pointer.

(cherry picked from commit 39ad3f1c092b5dffcbb4b1d12eb9ca407f010a3c)

4 years agopid1: return varlink error on the right connection
Zbigniew Jędrzejewski-Szmek [Sat, 6 Mar 2021 18:06:08 +0000 (19:06 +0100)]
pid1: return varlink error on the right connection

(cherry picked from commit 8b0f54c9290564e8c27c9c8ac464cdcc2c659ad5)

4 years agorepart: fix the loop dev support check
Frantisek Sumsal [Thu, 11 Mar 2021 11:49:00 +0000 (12:49 +0100)]
repart: fix the loop dev support check

Since f17bdf8264e231fa31c769bff2475ef698487d0b the test-repart was
effectively disabled, since `/dev/loop-control` is a character special
file, whereas `-f` works only on regular files. Even though we could use
`-c` to check specifically for character special files, let's use `-e`
just in case.

(cherry picked from commit 3a1bc3fcc02e61683e815091d129b03ad10771ef)

4 years agodissect-image: fix volatile images
Lennart Poettering [Thu, 11 Mar 2021 10:44:03 +0000 (11:44 +0100)]
dissect-image: fix volatile images

This makes sure nspawn's --volatile=yes switch works again: there we
have a read-only image that is overmounted by a tmpfs (with the
exception of /usr). This we need to mkdir all mount points even though
the image is read-only.

Hence, let's drop the optimizatio of avoiding mkdir() on images that are
read-only, it's wrong and misleading here, since the image itself might
be read-only but our mounts are not.

(cherry picked from commit 334eb5b0999d51efbc38b775fca92a2556c85830)

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