systemd/.git
4 years agolocaled: use PROJECT_FILE rather than __FILE__ for logging v249.5
Lennart Poettering [Mon, 11 Oct 2021 11:56:22 +0000 (13:56 +0200)]
localed: use PROJECT_FILE rather than __FILE__ for logging

All our log.h code uses PROJECT_FILE for this, let's hence use it here
too.

(cherry picked from commit 11c8b1f1031d368358286f4bb26abebd73cd2868)

4 years agoether-addr-util: make hw_addr_to_string() return valid string even if hardware addres...
Yu Watanabe [Wed, 15 Sep 2021 13:59:52 +0000 (22:59 +0900)]
ether-addr-util: make hw_addr_to_string() return valid string even if hardware address is null

Previously, when the length of the hardware address is zero, then the
buffer was not nul-terminated.

This also replaces sprintf() with hexchar().

(cherry picked from commit 914ac555cd40f9c09e655a737214bfb7de21b8d9)

4 years agocoredump: Don't log an error if D-Bus isn't running
Daan De Meyer [Wed, 6 Oct 2021 12:20:36 +0000 (13:20 +0100)]
coredump: Don't log an error if D-Bus isn't running

coredumpctl could be used in a chroot where D-Bus isn't running. If
that's the case, we shouldn't consider it an error if we can't connect
to the D-Bus daemon so let's reduce the severity of the error we log
when we can't connect to D-Bus because the socket doesn't exist.

(cherry picked from commit 414bd2e786f9912f51b82e5fe4a1126179a5652a)

4 years agocore/service: also check path in exec commands
Yu Watanabe [Tue, 5 Oct 2021 15:19:41 +0000 (00:19 +0900)]
core/service: also check path in exec commands

(cherry picked from commit 8688a389cabdff61efe187bb85cc1776de03c460)

4 years agocore: fix SIGABRT on empty exec command argv
Henri Chain [Tue, 5 Oct 2021 11:10:31 +0000 (13:10 +0200)]
core: fix SIGABRT on empty exec command argv

This verifies that the argv part of any exec_command parameters that
are sent through dbus is not empty at deserialization time.

There is an additional check in service.c service_verify() that again
checks if all exec_commands are correctly populated, after the service
has been loaded, whether through dbus or otherwise.

Fixes #20933.

(cherry picked from commit 29500cf8c47e6eb0518d171d62aa8213020c9152)

4 years agouser-record: disable two pbkdf fields that don't apply for pkbdf2
Lennart Poettering [Tue, 5 Oct 2021 16:24:05 +0000 (18:24 +0200)]
user-record: disable two pbkdf fields that don't apply for pkbdf2

Fixes: #20830
(cherry picked from commit 8b4f88d13681c6dec839de06c668d32374d44724)

4 years agobasic/env-util: correctly parse extended vars after non-extended vars (#20941)
Andrew Soutar [Wed, 6 Oct 2021 02:55:27 +0000 (22:55 -0400)]
basic/env-util: correctly parse extended vars after non-extended vars (#20941)

(cherry picked from commit 5ef97a712236f0ddddec52665c0aea7d4e6d3c13)

4 years agorepart: use right error variable
Lennart Poettering [Tue, 5 Oct 2021 12:10:27 +0000 (14:10 +0200)]
repart: use right error variable

(cherry picked from commit 8ac04a65477b59c9143b635c0c0daa5152d9b466)

4 years agosleep: don't skip resume device with low priority/available space
Egor [Sun, 3 Oct 2021 00:42:50 +0000 (03:42 +0300)]
sleep: don't skip resume device with low priority/available space

this fixes hibernation when there's a higher priority swap preceding
the resume swap in /proc/swaps.

fixes #19486

(cherry picked from commit 936a7cb66a0b423e75ceef87f02537067ad17002)

4 years agomount-util: fix fd_is_mount_point() when both the parent and directory are network fs
Franck Bui [Thu, 30 Sep 2021 12:05:36 +0000 (14:05 +0200)]
mount-util: fix fd_is_mount_point() when both the parent and directory are network fs

The second call to name_to_handle_at_loop() didn't check for the specific
errors that can happen when the parent dir is mounted by nfs and instead of
falling back like it's done for the child dir, fd_is_mount_point() failed in
this case.

(cherry picked from commit 964ccab8286a7e75d7e9107f574f5cb23752bd5d)

4 years agotest: Add failing/non-failing syscall filter test setting architecture
Benjamin Berg [Fri, 24 Sep 2021 11:35:34 +0000 (13:35 +0200)]
test: Add failing/non-failing syscall filter test setting architecture

This adds a high level test verifying that syscall filtering in
combination with a simple architecture filter for the "native"
architecture works fine.

(cherry picked from commit e975a94559900f47a3a5cc333682992616877a67)

4 years agotest: Check that "native" architecture is always filtered
Benjamin Berg [Fri, 17 Sep 2021 12:00:39 +0000 (14:00 +0200)]
test: Check that "native" architecture is always filtered

(cherry picked from commit 08bf703cc1511817cdf67543c3b166dc8831ba8c)

4 years agoseccomp: Always install filters for native architecture
Benjamin Berg [Fri, 17 Sep 2021 11:05:32 +0000 (13:05 +0200)]
seccomp: Always install filters for native architecture

The commit 6597686865ff ("seccomp: don't install filters for archs that
can't use syscalls") introduced a regression where filters may not be
installed for the "native" architecture. This means that setting
SystemCallArchitectures=native for a unit effectively disables the
SystemCallFilter= and SystemCallLog= options.

Conceptually, we have two filter stages:
 1. architecture used for syscall (SystemCallArchitectures=)
 2. syscall + architecture combination (SystemCallFilter=)

The above commit tried to optimize the filter generation by skipping the
second level filtering when it is not required.

However, systemd will never fully block the "native" architecture using
the first level filter. This makes the code a lot simpler, as systemd
can execve() the target binary using its own architecture. And, it
should be perfectly fine as the "native" architecture will always be the
one with the most restrictive seccomp filtering.

Said differently, the bug arises because (on x86_64):
 1. x86_64 is permitted by libseccomp already
 2. native != x86_64
 3. the loop wants to block x86_64 because the permitted set only
    contains "native" (i.e. "native" != "x86_64")
 4. x86_64 is marked as blocked in seccomp_local_archs

Thereby we have an inconsistency, where it is marked as blocked in the
seccomp_local_archs array but it is allowed by libseccomp. i.e. we will
skip generating filter stage 2 without having stage 1 in place.

The fix is simple, we just skip the native architecture when looping
seccomp_local_archs. This way the inconsistency cannot happen.

(cherry picked from commit f833df38488ea40fc3d601ccefd64cfa3fce8bb4)

4 years agonetworkd-test: fix resolved_domain_restricted_dns
Michael Biebl [Thu, 30 Sep 2021 23:00:28 +0000 (01:00 +0200)]
networkd-test: fix resolved_domain_restricted_dns

megasearch.net was meant to be a non-existing bogus domain, and had been
for a long time. But it seems some domain grabber recently registered
it, and it's an actual thing now:

  $ host megasearch.net
  megasearch.net has address 207.148.248.143

This causes the test to fail randomly.

Use search.example.com instead which yields

  $ host search.example.com
  Host search.example.com not found: 3(NXDOMAIN)

Fixes: #18357
(cherry picked from commit 528dd6a42389fcf4aa490c0fa0d858772e930d13)

4 years agocore/mount: add implicit unit dependencies even if when mount unit is generated from...
Yu Watanabe [Sun, 29 Aug 2021 12:20:43 +0000 (21:20 +0900)]
core/mount: add implicit unit dependencies even if when mount unit is generated from /proc/self/mountinfo

Hopefully fixes #20566.

(cherry picked from commit aebff2e7ce209fc2d75b894a3ae8b80f6f36ec11)

4 years agohwdb: sensors: Fix some modalias matches no longer working with newer kernels
Hans de Goede [Tue, 31 Aug 2021 13:49:33 +0000 (15:49 +0200)]
hwdb: sensors: Fix some modalias matches no longer working with newer kernels

Kernels >= 5.8 have added new fields to the dmi/id/modalias file in the
middle of the modalias (instead of adding them at the end).

Specifically new ":br<value>:" and (optional) ":efr<value>:" fields have
been added between the ":bd<value>:" and ":svn<value>:" fields.

Note the 5.13.0 and 5.14.0 kernels also added a new ":sku<value>:" field
between the ":pvr<value>:" and ":rvn<value>:" fields, this has been fixed
in later 5.13.y and 5.14.y releases, by moving the sku field to the end:
https://lore.kernel.org/lkml/20210831130508.14511-1-hdegoede@redhat.com/

Unfortunately the same cannot be done for the new br and efr fields since
those have been added more then a year ago and hwdb even already has some
newer entries relying on the new br field being there (and thus not working
with older kernels).

Fix the issue with the br and efr fields through the following changes:

1. Replace any matches on ":br<value>" from newer entries with an '*'
2. Replace "bd<value>:svn<value>" matches with: "bd<value>:*svn<value>"
   inserting an '*' where newer kernels will have the new br + efr fields

This makes these matches working with old as well as new kernels.

Link: https://github.com/systemd/systemd/issues/20550
Link: https://github.com/systemd/systemd/pull/20562
(cherry picked from commit f81351554285f1d4869fe842659b72797edfc899)

4 years agobasic/unit-file: don't filter out names starting with dot
Anita Zhang [Wed, 29 Sep 2021 06:52:39 +0000 (23:52 -0700)]
basic/unit-file: don't filter out names starting with dot

Fixes #20859
Reverts 3796bdc55d6ba499d1049f749072218879e619a7

(cherry picked from commit 14bb72953458caace048b55ead7ea06a592b864f)

4 years agocore: drop "const" from NeedsDaemonReload unit dbus property
Lennart Poettering [Wed, 29 Sep 2021 08:30:17 +0000 (10:30 +0200)]
core: drop "const" from NeedsDaemonReload unit dbus property

It's not "const", it can change any time if people change the fs, and we
don#t send out notifications for it. Hence don't claim it was const.
(Otherwise clients might cache it, but they should not)

Prompted-by: #20792
(cherry picked from commit e30a3ba16a5da4b46cd6c8bc363dbccb791fc45e)

4 years agoresolvconf-compat: make "-u" operation a NOP
Lennart Poettering [Wed, 29 Sep 2021 08:48:24 +0000 (10:48 +0200)]
resolvconf-compat: make "-u" operation a NOP

According to the various man pages of "resolvconf" the -u switch is for:

"-u Just run the update scripts (if updating is enabled)."

"-u Force resolvconf to update all its subscribers. resolvconf does not
    update the subscribers when adding a resolv.conf that matches what
    it already has for that interface."

We have no "subscribers", we ourselves are the only "subscriber" we
support. Hence it's probably better to ignore such a request and make it
a NOP, then to fail.

Fixes: #20748
(cherry picked from commit bee07a399572e0d60600c040a84099ecb418ed33)

4 years agoAdd remaining supported schemes as options for default-net-naming-scheme
dann frazier [Mon, 27 Sep 2021 17:00:53 +0000 (11:00 -0600)]
Add remaining supported schemes as options for default-net-naming-scheme

(cherry picked from commit aa0a23ec8629aa033a098ab55e9d97ccd9fbf39c)

4 years agoresolved: suppress writing DNS server info into /etc/resolv.conf for non-standard...
Lennart Poettering [Mon, 27 Sep 2021 12:28:16 +0000 (14:28 +0200)]
resolved: suppress writing DNS server info into /etc/resolv.conf for non-standard UDP ports

glibc doesn't support this, hence don#t generate it.

Fixes: #20836
(cherry picked from commit a50dadf2fd7413bbfc26af7e2ad2900b3e06af82)

4 years agoman: fix a reference in timedatectl man page
Anssi Hannula [Fri, 24 Sep 2021 12:26:21 +0000 (15:26 +0300)]
man: fix a reference in timedatectl man page

timedatectl(1) says the synchronization service list generation is
described "below", but in reality it is documented in
systemd-timedated.service(8).

Fix the sentence to reference the correct man page.

(cherry picked from commit 9376b2aab3692d26de60a93e396f84fa2799b80b)

4 years agolibsystemd-network: disable event sources before unref them
Yu Watanabe [Fri, 24 Sep 2021 08:26:35 +0000 (17:26 +0900)]
libsystemd-network: disable event sources before unref them

Fixes #20825.

(cherry picked from commit eb2f750242d6c4c0963887dbd561d8bafa318685)

4 years agonetwork: disable event sources before unref them
Yu Watanabe [Fri, 24 Sep 2021 08:26:10 +0000 (17:26 +0900)]
network: disable event sources before unref them

(cherry picked from commit d105befc976ad704d3b17b3a5ee1b659a5f624d4)

4 years agobootctl: Fix update not adding EFI entry if Boot IDs are non-consecutive
Anssi Hannula [Thu, 23 Sep 2021 09:08:05 +0000 (12:08 +0300)]
bootctl: Fix update not adding EFI entry if Boot IDs are non-consecutive

"bootctl update" tries to add sd-boot to the EFI boot loader list if it
is not already there. To do so, it uses find_slot() which finds the
proper BootXXXX slot ID to use and also returns 1 if an existing sd-boot
entry was found at this ID or 0 if it is a new unused ID. In "update"
case install_variables() only writes the entry in case 0 (no existing
entry).

However, find_slot() erroneously returns 1 if it finds a gap in the Boot
IDs (i.e. when not resorting to max(ids) + 1). This causes
"bootctl update" to not add a missing systemd-boot boot entry if the
existing BootXXXX entry IDs are not consecutive.

Fix that by returning 0 in find_slot() when an empty gap ID is selected
to make it match the behavior when selecting an empty non-gap ID.

(cherry picked from commit 26d54e1263dcb58daa6578595cc6ab1037315593)

4 years agotest-fileio: test read_virtual_file() with more files from /proc
Lennart Poettering [Thu, 16 Sep 2021 09:31:52 +0000 (11:31 +0200)]
test-fileio: test read_virtual_file() with more files from /proc

i.e. let's pick some files we know are too large, or where struct stat's
.st_size is zero even though non-empty, and test read_virtual_file()
with that, to ensure things are handled sensibly. Goal is to ensure all
three major codepaths in read_virtual_file() are tested.

Prompted-by: #20743
(cherry picked from commit f3b751220bb842ce22a4f607d817f481f0961d40)

4 years agofileio: fix truncated read handling in read_virtual_file()
Lennart Poettering [Thu, 16 Sep 2021 10:20:09 +0000 (12:20 +0200)]
fileio: fix truncated read handling in read_virtual_file()

We mishandled the case where the size we read from the file actually
matched the maximum size fully. In that case we cannot really make a
determination whether the file was fully read or only partially. In that
case let's do another loop, so that we operate with a buffer, and
we can detect the EOF (which will be signalled to us via a short read).

(cherry picked from commit 00bd9a4a82ed57bc0c7f158da4564fc1eab808b4)

4 years agofileio: start with 4k buffer for procfs
Anita Zhang [Tue, 14 Sep 2021 23:33:10 +0000 (16:33 -0700)]
fileio: start with 4k buffer for procfs

There's a very gradual increase of anonymous memory in systemd-journald that
blames to 2ac67221bb6270f0fbe7cbd0076653832cd49de2.

systemd-journald makes many calls to read /proc/PID/cmdline and
/proc/PID/status, both of which tend to be well under 4K. However the
combination of allocating 4M read buffers, then using `realloc()` to
shrink the buffer in `read_virtual_file()` appears to be creating
fragmentation in the heap (when combined with the other allocations
systemd-journald is doing).

To help mitigate this, try reading /proc with a 4K buffer as
`read_virtual_file()` did before 2ac67221bb6270f0fbe7cbd0076653832cd49de2.
If it isn't big enough then try again with the larger buffers.

(cherry picked from commit 5aaa55d841249f057fd69e50cf12a52e9781a6ce)

4 years agofileio: set O_NOCTTY when reading virtual files
Lennart Poettering [Tue, 14 Sep 2021 21:11:55 +0000 (23:11 +0200)]
fileio: set O_NOCTTY when reading virtual files

Better be safe than sorry, maybe someone points this call to a TTY one
day, and we'd rather not make it our controlling TTY in that case.

(cherry picked from commit be991d7678c35aa037ef79672c0c70781eebed9c)

4 years agofileio: lower maximum virtual file buffer size by one byte
Lennart Poettering [Tue, 14 Sep 2021 21:03:37 +0000 (23:03 +0200)]
fileio: lower maximum virtual file buffer size by one byte

When reading virtual files (i.e. procfs, sysfs, …) we currently put a
limit of 4M-1 on that. We have to pick something, and we have to read
these files in a single read() (since the kernel generally doesn't
support continuation read()s for them). 4M-1 is actually the maximum
size the kernel allows for reads from files in /proc/sys/, all larger
reads will result in an ENOMEM error (which is really weird, but the
kernel does what the kernel does). Hence 4M-1 sounds like a smart
choice.

However, we made one mistake here: in order to be able to detect EOFs
properly we actually read one byte more than we actually intend to
return: if that extra byte can be read, then we know the file is
actually larger than our limit and we can generate an EFBIG error from
that. However, if it cannot be read then we know EOF was hit, and we are
good. So ultimately after all we issued a single 4M read, which the
kernel then responds with ENOMEM to.  And that means read_virtual_file()
actually doesn't work properly right now on /proc/sys/. Let's fix that.

The fix is simple, lower the limit of the the buffer we intend to return
by one, i.e. 4M-2. That way, the read() we'll issue is exactly as large
as the limit the kernel allows, and we still get safely detect EOF from
it.

(cherry picked from commit 7ab7547a40d456d34120b2f44b26385ac1338ebd)

4 years agowatchdog: pass right error code to log function so that %m works
Lennart Poettering [Wed, 15 Sep 2021 13:43:42 +0000 (15:43 +0200)]
watchdog: pass right error code to log function so that %m works

(cherry picked from commit a4588af942af976c55f72869340c24d5017db278)

4 years agosd-journal: Ignore data threshold if set to zero in sd_journal_enumerate_fields()
Daan De Meyer [Wed, 15 Sep 2021 12:05:46 +0000 (13:05 +0100)]
sd-journal: Ignore data threshold if set to zero in sd_journal_enumerate_fields()

According to the documentation, Setting the data threshold to zero disables the
data threshold alltogether. Let's make sure we actually implement this behaviour
in sd_journal_enumerate_fields() by only applying the data threshold if it exceeds
zero.

(cherry picked from commit adbd80f51088058d55e703abe0ac11476cfe0ba4)

4 years agojournalctl: never fail at flushing when the flushed flag is set
Franck Bui [Wed, 4 Aug 2021 09:20:07 +0000 (11:20 +0200)]
journalctl: never fail at flushing when the flushed flag is set

Even if journald was not running, flushing the volatile journal used to work if
the journal was already flushed (ie the flushed flag
/run/systemd/journald/flushed was created).

However since commit 4f413af2a0a, this behavior changed and now '--flush' fails
because it tries to contact journald without checking the presence of the
flushed flag anymore.

This patch restores the previous behavior since there's no reason to fail when
journalctl can figure out that the flush is not necessary.

(cherry picked from commit f6fca35e642a112e80cc9bddb9a2b4805ad40df2)

4 years agomeson: add missing include directory when using xkbcommon
Antonio Alvarez Feijoo [Wed, 15 Sep 2021 06:46:40 +0000 (08:46 +0200)]
meson: add missing include directory when using xkbcommon

Otherwise the build fails:

FAILED: systemd-localed.p/src_locale_localed.c.o
cc -Isystemd-localed.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=overflow -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Werror=unused-function -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -ffast-math -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -Werror=shadow -include config.h -MD -MQ systemd-localed.p/src_locale_localed.c.o -MF systemd-localed.p/src_locale_localed.c.o.d -o systemd-localed.p/src_locale_localed.c.o -c ../src/locale/localed.c
../src/locale/localed.c:9:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory
    9 | #include <xkbcommon/xkbcommon.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

(cherry picked from commit aff870ef61bda152ea6241f684dcab26a9265e78)

4 years agoRespect install_sysconfdir
Kai Wohlfahrt [Mon, 13 Sep 2021 23:32:52 +0000 (00:32 +0100)]
Respect install_sysconfdir

This was lost e11a25cadbe and c900d89faa0 while adding jinja2
templating. Breaks builds on NixOS.

(cherry picked from commit 679de141122ca30388bba6d132f8c0dddcdddd15)

4 years agosd-journal: Don't compare hashes from different journal files
Daan De Meyer [Tue, 14 Sep 2021 14:08:46 +0000 (15:08 +0100)]
sd-journal: Don't compare hashes from different journal files

In sd_journal_enumerate_fields(), we check if we've already handled
a field by checking if we can find it in any of the already processed
journal files. We do this by calling
journal_file_find_field_object_with_hash(), which compares the size,
payload and hash of the given field against all fields in a journal file,
trying to find a match. However, since we now use per file hash functions,
hashes for the same fields will differ between different journal files,
meaning we'll never find an actual match.

To fix the issue(), let's use journal_file_find_field_object() when one
or more of the files we're comparing is using per file keyed hashes.
journal_file_find_field_object() only takes the field payload and size
as arguments and calculates the hash itself using the hash function from
the journal file we're searching in.

(cherry picked from commit 27bf0ab76e13611dce10210f2a22fb5fba05adbb)

4 years agoFix error building repart with no libcryptsetup (#20739)
Marcus Harrison [Wed, 15 Sep 2021 01:55:07 +0000 (03:55 +0200)]
Fix error building repart with no libcryptsetup (#20739)

(cherry picked from commit 2709d02906dd3ab5ecc2b3e19e2846b1714a7e5a)

4 years agotest-network: kernel treats the lowest IP address as unicast since 5.14
Yu Watanabe [Mon, 13 Sep 2021 17:50:37 +0000 (02:50 +0900)]
test-network: kernel treats the lowest IP address as unicast since 5.14

See kernel's 94c821c74bf5fe0c25e09df5334a16f98608db90.

(cherry picked from commit 8be102f8b8019a9bd7e445532cad632cbc6986d3)

4 years agovirt: Improve detection of EC2 metal instances
Benjamin Herrenschmidt [Fri, 3 Sep 2021 01:36:46 +0000 (11:36 +1000)]
virt: Improve detection of EC2 metal instances

The current detection code relies on /sys/firmware/dmi/entries/0-0/raw
to disambiguate Amazon EC2 virtualized from metal instances.

Unfortunately this file is root only. Thus on a c6g.metal instance
(aarch64), we observe something like this:

$ systemd-detect-virt
amazon
$ sudo systemd-detect-virt
none

Only the latter is correct.

The right long term fix is to extend the kernel to expose the SMBIOS BIOS
Characteristics properly via /sys/class/dmi, but until this happens (and
for backwards compatibility when it does), we need a plan B.

This change implements such a workaround by falling back to using the
instance type from DMI and looking at the ".metal" string present on
metal instances.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
(cherry picked from commit f90eea7d18d9ebe88e6a66cd7a86b618def8945d)

4 years agounit: systemd-oomd.service requires cgroup memory controller
Yu Watanabe [Sat, 11 Sep 2021 11:56:15 +0000 (20:56 +0900)]
unit: systemd-oomd.service requires cgroup memory controller

(cherry picked from commit ca589b1b4139c85e2ae55b62be0a2a6d3eb4db90)

4 years agonetwork: fix handling of network interface renaming
Yu Watanabe [Thu, 9 Sep 2021 23:09:56 +0000 (08:09 +0900)]
network: fix handling of network interface renaming

Fixes #20657.

(cherry picked from commit 160203e974945ce520fe8f569458634ef898c61c)

4 years agocore: Parse log environment settings again after applying manager environment
Daan De Meyer [Tue, 7 Sep 2021 15:13:56 +0000 (16:13 +0100)]
core: Parse log environment settings again after applying manager environment

Currently, SYSTEMD_LOG_LEVEL set in the ManagerEnvironment property in system.conf
or user.conf doesn't affect the manager's logging level. Parsing the logging environment
variables again after pushing the manager environment into the process environment
block makes sure any new environment changes also get taken into account for logging.

(cherry picked from commit a4303b4096d9a75acd09c5b897ed3d20c9bca6de)

4 years agonss-systemd: ensure returned strings point into provided buffer
Michael Catanzaro [Wed, 8 Sep 2021 21:51:16 +0000 (16:51 -0500)]
nss-systemd: ensure returned strings point into provided buffer

Jamie Bainbridge found an issue where glib's g_get_user_database_entry()
may crash after doing:

```
error = getpwnam_r (logname, &pwd, buffer, bufsize, &pw);
// ...
pw->pw_name[0] = g_ascii_toupper (pw->pw_name[0]);
```

in order to uppercase the first letter of the user's real name. This is
a glib bug, because there is a different codepath that gets the pwd from
vanilla getpwnam instead of getpwnam_r as shown here. When the pwd
struct is returned by getpwnam, its fields point to static data owned by
glibc/NSS, and so it must not be modified by the caller. After much
debugging, Jamie Bainbridge has fixed this in https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2244
by making a copy of the data before modifying it, and that resolves all
problems for glib. Yay!

However, glib is crashing even when getpwnam_r is used instead of
getpwnam! According to getpwnam_r(3), the strings in the pwd struct are
supposed to be pointers into the buffer passed by the caller, so glib
should be able to safely edit it directly in this case, so long as it
doesn't try to increase the size of any of the strings.

Problem is various functions throughout nss-systemd.c return synthesized
records declared at the top of the file. These records are returned
directly and so contain pointers to static strings owned by
libsystemd-nss. systemd must instead copy all the strings into the
provided buffer.

This crash is reproducible if nss-systemd is listed first on the passwd
line in /etc/nsswitch.conf, and the application looks up one of the
synthesized user accounts "root" or "nobody", and finally the
application attempts to edit one of the strings in the returned struct.
All our synthesized records for the other struct types have the same
problem, so this commit fixes them all at once.

Fixes #20679

(cherry picked from commit 47fd7fa6c650d7a0ac41bc89747e3b866ffb9534)

4 years agonss-systemd: pack pw_passwd result into supplied buffer
Michael Catanzaro [Wed, 8 Sep 2021 18:42:16 +0000 (13:42 -0500)]
nss-systemd: pack pw_passwd result into supplied buffer

getpwnam_r() guarantees that the strings in the struct passwd that it
returns are pointers into the buffer allocated by the application and
passed to getpwnam_r(). This means applications may choose to modify the
strings in place, as long as the length of the strings is not increased.
So it's wrong for us to return a static string here, we really do have
to copy it into the application-provided buffer like we do for all the
other strings.

This is only a theoretical problem since it would be very weird for an
application to modify the pw_passwd field, but I spotted this when
investigating a similar crash caused by glib editing a different field.
See also:

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2244
(cherry picked from commit 92b264676ccd79c89da270aabc1ec466fa18cd0d)

4 years agosd-event: take ref on event loop object before dispatching event sources
Michal Sekletar [Wed, 8 Sep 2021 13:42:11 +0000 (15:42 +0200)]
sd-event: take ref on event loop object before dispatching event sources

Idea is that all public APIs should take reference on objects that get
exposed to user-provided callbacks. We take the reference as a
protection from callbacks dropping it. We used to do this also here in
sd_event_loop(). However, in cleanup portion of f814c871e6 this was
accidentally dropped.

(cherry picked from commit 9f6ef467818f902fe5369c8e37a39a3901bdcf4f)

4 years agocore: fix free undefined pointer when strdup failed in the first loop
xujing [Wed, 8 Sep 2021 06:26:20 +0000 (14:26 +0800)]
core: fix free undefined pointer when strdup failed in the first loop

(cherry picked from commit 1509274359979079e3e61899ce12fc8b0f0958d9)

4 years agodocs: portablectl is in bin/
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 16:43:58 +0000 (18:43 +0200)]
docs: portablectl is in bin/

Follow-up for 80f39b81f3876ed3816061f1093db991f72269ec.

(cherry picked from commit a00ff6717b98580136d46cde0e8f9543e60c8f76)

4 years agohome: 'secret' argument of handle_generic_user_record_error may be null
Yu Watanabe [Sun, 5 Sep 2021 02:16:26 +0000 (11:16 +0900)]
home: 'secret' argument of handle_generic_user_record_error may be null

When RefHome() bus method is called in acquire_home(), secret is NULL.

Fixes #20639.

(cherry picked from commit 6a09dbb89507449d158af6c7097d2c51ce83205f)

4 years agomeson.build: change operator combining bools from + to and
Dan Streetman [Fri, 3 Sep 2021 16:43:33 +0000 (12:43 -0400)]
meson.build: change operator combining bools from + to and

upstream meson stopped allowing combining boolean with the plus
operator, and now requires using the logical and operator

reference:
https://github.com/mesonbuild/meson/commit/43302d3296baff6aeaf8e03f5d701b0402e37a6c

Fixes: #20632
(cherry picked from commit c29537f39e4f413a6cbfe9669fa121bdd6d8b36f)

4 years agonspawn: fix type to pass to connect()
Lennart Poettering [Wed, 1 Sep 2021 12:41:37 +0000 (14:41 +0200)]
nspawn: fix type to pass to connect()

It expects a generic "struct sockaddr", not a "struct sockaddr_un".
Pass the right member of the union.

Not sure why gcc/llvm never complained about this...

(cherry picked from commit 32b9736a230d47b73babcc5cfa27d672bb721bd0)

4 years agoudev: fix potential memleak
Yu Watanabe [Fri, 27 Aug 2021 08:27:26 +0000 (17:27 +0900)]
udev: fix potential memleak

(cherry picked from commit 4154524d47d24bcee3ebfed939912a847ebeb1b3)

4 years agonetwork: print Ethernet Link-Layer DHCP client ID with leading 0's
Alvin Šipraga [Tue, 31 Aug 2021 12:17:33 +0000 (14:17 +0200)]
network: print Ethernet Link-Layer DHCP client ID with leading 0's

This is a small cosmetic change.

Before:

   Offered DHCP leases: 192.168.0.183 (to 0:9:a7:36:bc:89)

After:

   Offered DHCP leases: 192.168.0.183 (to 00:09:a7:36:bc:89)

(cherry picked from commit 8e664ab6ecc9c420d2151f14b36824aecc76d8ac)

4 years agohomed: remove misplaced assert()
Lennart Poettering [Tue, 31 Aug 2021 08:47:40 +0000 (10:47 +0200)]
homed: remove misplaced assert()

(cherry picked from commit 67f9bf897c762ecb61872a5e8e0707a97c8ccd3d)

4 years agohomed: add missing SYNTHETIC_ERRNO()
Lennart Poettering [Tue, 31 Aug 2021 08:47:29 +0000 (10:47 +0200)]
homed: add missing SYNTHETIC_ERRNO()

(cherry picked from commit 9191142ddfb3ccd2007245c01197d3f42943815c)

4 years agohomed: fix log message referring to fsck, when we actually mean mount
Lennart Poettering [Tue, 31 Aug 2021 08:47:02 +0000 (10:47 +0200)]
homed: fix log message referring to fsck, when we actually mean mount

(cherry picked from commit e070b9eac92993422db25c72ebdbdcc1cf424a0f)

4 years agohomed: make sure to use right asssesors for GID + access mode
Lennart Poettering [Tue, 31 Aug 2021 08:46:06 +0000 (10:46 +0200)]
homed: make sure to use right asssesors for GID + access mode

Don't reach directly into the UserRecord struct, but use the right
assessors, so that the "unspecified" case is covered.

(cherry picked from commit 279e060e2549183101ebf94e9739b70ed499c4c1)

4 years agohomed: add missing capabilities for SMB/CIFS backend
Lennart Poettering [Tue, 31 Aug 2021 08:04:06 +0000 (10:04 +0200)]
homed: add missing capabilities for SMB/CIFS backend

In 2020 mount.cifs started to require a bunch for caps to work. let's
add them to the capability bounding set.

Also, SMB support obviously needs network access, hence open that up.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1962920
(cherry picked from commit 169764332af0a85e52e01f7b9cb28cc05cee038f)

4 years agorun/mount/systemctl: don't fork off PolicyKit/ask-pw agent when in --user mode
Lennart Poettering [Mon, 30 Aug 2021 11:21:55 +0000 (13:21 +0200)]
run/mount/systemctl: don't fork off PolicyKit/ask-pw agent when in --user mode

When we are in --user mode there's no point in doing PolicyKit/ask-pw
because both of these systems are only used by system-level services.
Let's disable the two agents for that automaticlly hence.

Prompted by: #20576

(cherry picked from commit 966f3a246c8c804d8a9c9d393f03c5c3fe0dd393)

4 years agoman: Don't leak memory in path-documents example
Thomas Mühlbacher [Mon, 30 Aug 2021 14:16:30 +0000 (16:16 +0200)]
man: Don't leak memory in path-documents example

The `sd_path_lookup(3)` man page states that the returned string shall be
`free(3)`'d but then doesn't do so in the example code.

Also add basic error handling as well.

(cherry picked from commit fee1863c83d04aa06d50a90ff42f5d4f4f2b9178)

4 years agohwdb: remove double empty line in --help text
Lennart Poettering [Mon, 30 Aug 2021 11:20:59 +0000 (13:20 +0200)]
hwdb: remove double empty line in --help text

(cherry picked from commit aecc04f1800c87e0479e74e0225e288a403ba77e)

4 years agoFix another crash due to missing NHDR
Kevin Orr [Thu, 26 Aug 2021 21:04:53 +0000 (17:04 -0400)]
Fix another crash due to missing NHDR

(cherry picked from commit a3a5446b7675696f43c2d8a2a0b898d72228a53d)

4 years agopath-util: make find_executable() work without /proc mounted
Yu Watanabe [Sun, 22 Aug 2021 21:16:48 +0000 (06:16 +0900)]
path-util: make find_executable() work without /proc mounted

Follow-up for 888f65ace6296ed61285d31db846babf1c11885e.

Hopefully fixes #20514.

(cherry picked from commit 93413acd3ef3a637a0f31a1d133b103e1dc81fd6)

4 years agocore: Check unit start rate limiting earlier
Daan De Meyer [Tue, 24 Aug 2021 15:46:47 +0000 (16:46 +0100)]
core: Check unit start rate limiting earlier

Fixes #17433. Currently, if any of the validations we do before we
check start rate limiting fail, we can still enter a busy loop as
no rate limiting gets applied. A common occurence of this scenario
is path units triggering a service that fails a condition check.

To fix the issue, we simply move up start rate limiting checks to
be the first thing we do when starting a unit. To achieve this,
we add a new method to the unit vtable and implement it for the
relevant unit types so that we can do the start rate limit checks
earlier on.

(cherry picked from commit 9727f2427ff6b2e1f4ab927cc57ad8e888f04e95)

4 years agocore: Remove circular include
Daan De Meyer [Tue, 24 Aug 2021 15:19:03 +0000 (16:19 +0100)]
core: Remove circular include

service.h includes socket.h and socket.h includes service.h. Move
service.h include from socket.h to socket.c to remove the circular
dependency.

(cherry picked from commit a243128d1fcfc378df9fce1b4997148a17ef23a5)

4 years agoNEWS: net.ipv4.tcp_ecn = 1 was reverted at v240
Sho Iizuka [Wed, 25 Aug 2021 04:00:03 +0000 (13:00 +0900)]
NEWS: net.ipv4.tcp_ecn = 1 was reverted at v240

Turning on ECN was reverted by 1e190df.

(cherry picked from commit e447ffe4daca1d0beb57242f079125669e4e1c3c)

4 years agologin: respect install_sysconfdir_samples in meson file
Andreas Rammhold [Mon, 26 Jul 2021 15:20:34 +0000 (17:20 +0200)]
login: respect install_sysconfdir_samples in meson file

The refactoring done in c900d89faa0 caused the configuration files to be
installed into the pkgsysconfdir regardless of the state of the
install_sysconfdir_samples boolean that indicates whether or not the
sample files should be installed.

(cherry picked from commit 72964d047a7a8f79ae12ab41168feb0080eef6c3)

4 years agocore: respect install_sysconfdir_samples in meson file
Andreas Rammhold [Mon, 26 Jul 2021 14:57:43 +0000 (16:57 +0200)]
core: respect install_sysconfdir_samples in meson file

The refactoring done in e11a25cadbe caused the configuration files to be
installed into the pkgsysconfdir regardless of the state of the
install_sysconfdir_samples boolean that indicates whether or not the
sample files should be installed.

(cherry picked from commit cfd760b6a77808d0b9451ed618a23b6259fe525f)

4 years agoexplicitly close FIDO2 devices
pedro martelletto [Wed, 8 Sep 2021 08:42:56 +0000 (10:42 +0200)]
explicitly close FIDO2 devices

FIDO2 device access is serialised by libfido2 using flock().
Therefore, make sure to close a FIDO2 device once we are done
with it, or we risk opening it again at a later point and
deadlocking. Fixes #20664.

(cherry picked from commit b6aa89b0a399992c8ea762e6ec4f30cff90618f2)

4 years agoDrop bundled copy of linux/if_arp.h
Zbigniew Jędrzejewski-Szmek [Wed, 15 Sep 2021 14:33:05 +0000 (16:33 +0200)]
Drop bundled copy of linux/if_arp.h

As far as I can see, we use this to get a list of ARPHRD_* defines (used in
particular for Type= in .link files). If we drop our copy, and build against
old kernel headers, the user will have a shorter list of types available.  This
seems OK, and I don't think it's worth carrying our own version of this file
just to have newest possible entries.

7c5b9952c4f6e2b72f90edbe439982528b7cf223 recently updated this file, but we'd
have to update it every time the kernel adds new entries. But if we look at
the failure carefully:

src/basic/arphrd-from-name.gperf:65:16: error: ‘ARPHRD_MCTP’ undeclared (first use in this function); did you mean ‘ARPHRD_FCPP’?
   65 | MCTP, ARPHRD_MCTP
      |                ^~
      |                ARPHRD_FCPP

we see that the list we were generating was from the system headers, so it was
only as good as the system headers anyway, without the newer entries in our
bundled copy, if there were any. So let's make things simpler by always using
system headers.

And if somebody wants to fix things so that we always have the newest list,
then we should just generate and store the converted list, not the full header.

(cherry picked from commit e7f46ee3ae1cc66a94b293957721d68dc09d7449)

4 years agobasic/linux: Sync if_arp.h with Linux 5.14
Chris Packham [Thu, 9 Sep 2021 21:51:36 +0000 (09:51 +1200)]
basic/linux: Sync if_arp.h with Linux 5.14

ARPHRD_MCTP was added in 5.14. Sync if_arp.h to pick up the definition

Fixes #20694

(cherry picked from commit 7c5b9952c4f6e2b72f90edbe439982528b7cf223)

4 years agotpm-util: fix TPM parameter handling
Anatol Pomozov [Fri, 10 Sep 2021 18:52:55 +0000 (11:52 -0700)]
tpm-util: fix TPM parameter handling

cryptenroll allows to specify a custom TPM driver separated from
parameters with colon e.g. `systemd-cryptenroll --tpm2-device=swtpm:`
tells to load swtpm tss driver and use it as a device.

Unfortunately it does not work, swtpm driver init() fails with

```
debug:tcti:src/tss2-tcti/tcti-swtpm.c:570:Tss2_Tcti_Swtpm_Init() Dup'd conf string to: 0x562f91cbc000
debug:tcti:src/util/key-value-parse.c:85:parse_key_value_string() parsing key/value: swtpm:
WARNING:tcti:src/util/key-value-parse.c:50:parse_key_value() key / value string is invalid
Failed to initialize TCTI context: tcti:A parameter has a bad value
```

It turns out that cryptenroll suppose to use the driver name internally
and strip it before passing the rest of parameters to init() function.
Without doing it swtpm receives incorrect key-value property and gets
confused.

Fix it by passing the correct parameter (without driver name) to the
init() function.

Fixes #20708

(cherry picked from commit 8889564a8da574e4b956e2b6ced34354dee54cd7)

4 years agojournal,network,timesync: fix segfault on 32bit timeval/timespec systems
Yu Watanabe [Wed, 15 Sep 2021 14:29:11 +0000 (23:29 +0900)]
journal,network,timesync: fix segfault on 32bit timeval/timespec systems

Fixes #20741.

(cherry picked from commit f782eee68aea996c68b8cfeba5f288dae7fc876f)

4 years agotimesync: check cmsg length
Yu Watanabe [Sun, 29 Aug 2021 11:55:44 +0000 (20:55 +0900)]
timesync: check cmsg length

(cherry picked from commit 37df6d9b8d3a8b34bec5346766ab8093c0f0fc26)

4 years agosocket-util: introduce CMSG_SPACE_TIMEVAL/TIMESPEC macro to support additional 64bit...
Yu Watanabe [Sun, 29 Aug 2021 11:50:49 +0000 (20:50 +0900)]
socket-util: introduce CMSG_SPACE_TIMEVAL/TIMESPEC macro to support additional 64bit timeval or timespec

Fixes #20482 and #20564.

(cherry picked from commit 9365e296fe281da45797af89a97627e872fc019d)

4 years agoicmp6: drop unnecessary assertion
Yu Watanabe [Thu, 19 Aug 2021 23:44:27 +0000 (08:44 +0900)]
icmp6: drop unnecessary assertion

Follow-up for 3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1.

(cherry picked from commit 6da22a2fa592cc908d26c732b537d8b4fc004280)

4 years agonetwork: fix wrong flag: manage_foreign_routes -> manage_foreign_rules
Yu Watanabe [Tue, 7 Sep 2021 12:46:50 +0000 (21:46 +0900)]
network: fix wrong flag: manage_foreign_routes -> manage_foreign_rules

Fixes a bug in d94dfe7053d49fa62c4bfc07b7f3fc2227c10aff.

(cherry picked from commit 771a36439e955906290afc16a6fb3b10401892cf)

4 years agoimport: turn off weird protocols in curl v249.4
Lennart Poettering [Thu, 19 Aug 2021 16:12:56 +0000 (18:12 +0200)]
import: turn off weird protocols in curl

Let's lock things down a bit and now allow curl's weirder protocols to
be used with our use. i.e. stick to http:// + https:// + file:// and
turn everything else off. (Gopher!)

This is cde that interfaces with the network after all, and we better
shouldn't support protocols needlessly that are much less tested.

(Given that HTTP redirects (and other redirects) exist, this should give
us a security benefit, since we will then be sure that noone can forward
us to a weird protocol, which we never tested, and other people test
neither)

(cherry picked from commit 55b90ee00b78a449c8f187a5e8141f8ccb100bf4)

4 years agolink: Stop prefixing features with "the"
Daan De Meyer [Thu, 19 Aug 2021 12:37:41 +0000 (13:37 +0100)]
link: Stop prefixing features with "the"

(cherry picked from commit f20710c74c08bf69472f62c886e5bdd5e38c87a5)

4 years agotimesync: fix wrong type for receiving timestamp in nanoseconds
Yu Watanabe [Thu, 19 Aug 2021 23:40:11 +0000 (08:40 +0900)]
timesync: fix wrong type for receiving timestamp in nanoseconds

Fixes #20482.

(cherry picked from commit 6f96bdc58746b1698bf8b3430a6c638f8949daec)

4 years agosrc/boot/efi/linux: fix linux_exec prototype
Alfonso Sánchez-Beato [Thu, 19 Aug 2021 10:21:12 +0000 (12:21 +0200)]
src/boot/efi/linux: fix linux_exec prototype

Callers to linux_exec() are actually passing an EFI_HANDLE, not a pointer to
it. linux_efi_handover(), which is called by linux_exec(), also expects an
EFI_HANDLE.

(cherry picked from commit d48f9174cf211a235193963a06b3d28537fc6529)

4 years agodiscover-image: pass the right fd to fd_getcrtime()
Lennart Poettering [Wed, 18 Aug 2021 20:41:08 +0000 (22:41 +0200)]
discover-image: pass the right fd to fd_getcrtime()

(cherry picked from commit 12a7f04a2b9135a4751dba71e2f688525d7c93e7)

4 years agofstab-generator: Respect nofail when ordering
Vladimir Panteleev [Tue, 17 Aug 2021 18:30:29 +0000 (18:30 +0000)]
fstab-generator: Respect nofail when ordering

(cherry picked from commit e9aee932409754c9f709a8ea3ad13caf39fce7d2)

4 years agoFix typo in dbus property name ("OnSuccesJobMode")
Vladimir Panteleev [Tue, 17 Aug 2021 17:56:41 +0000 (17:56 +0000)]
Fix typo in dbus property name ("OnSuccesJobMode")

(cherry picked from commit ecfcf0244ae6a5f89411761ac4a86e0e9e10e31b)

4 years agoshell-completion: add missing uevent actions for udevadm
Yu Watanabe [Tue, 17 Aug 2021 14:13:07 +0000 (23:13 +0900)]
shell-completion: add missing uevent actions for udevadm

(cherry picked from commit 74614801f6bd33dfb2c051fa6b6d7c899c695cf6)

4 years agonetwork: do not assume the highest priority when Priority= is unspecified
Yu Watanabe [Tue, 17 Aug 2021 05:03:19 +0000 (14:03 +0900)]
network: do not assume the highest priority when Priority= is unspecified

Previously, when Priority= is unspecified, networkd configured the rule with
the highest (=0) priority. This commit makes networkd distinguish the case
the setting is unspecified and one explicitly specified as Priority=0.

Note.
1) If the priority is unspecified on configure, then kernel dynamically picks
   a priority for the rule.
2) The new behavior is consistent with 'ip rule' command.

Replaces #15606.

(cherry picked from commit c4f7a347566b8926382029593b4d9957fef2564c)

4 years agounit: coldplug both job and nop_job if possible
Geass-LL [Fri, 2 Apr 2021 03:27:59 +0000 (11:27 +0800)]
unit: coldplug both job and nop_job if possible

Sometimes, both job and nop_job are deserialized. In this case,
if we only cold plug the job, the nop_job will also stuck in the
job list.

(cherry picked from commit 7dbd330c7ef28852db0fb044503ed6f072477d50)

4 years agonetwork: allow users to forbid passthru MACVLAN from putting its link into promiscuou...
Tom Yan [Mon, 16 Aug 2021 10:00:42 +0000 (18:00 +0800)]
network: allow users to forbid passthru MACVLAN from putting its link into promiscuous mode

While we haven't implemented a key for users to set MACVLAN/MACVTAP flags,
we can at least allow them to make use of the Promiscuous= key of
the corresponding link to set the nopromisc flag.

(cherry picked from commit 17a6a4ae2e7104a1105a0cef0ba049799f3ef6bc)

4 years agoDon't open /var journals in volatile mode when runtime_journal==NULL
Milo Turner [Fri, 13 Aug 2021 14:28:58 +0000 (10:28 -0400)]
Don't open /var journals in volatile mode when runtime_journal==NULL

(cherry picked from commit d64441b669932ab97fbbfc71cb143045f690039e)

4 years agoresolved: retry on SERVFAIL before downgrading feature level
Steven Siloti [Sun, 11 Jul 2021 18:05:26 +0000 (11:05 -0700)]
resolved: retry on SERVFAIL before downgrading feature level

The SERVFAIL RCODE can be generated for many reasons which may not be related
to lack of feature support. For example, the Stubby resolver generates
SERVFAIL when a request times out. Such transient failures can cause
unnecessary downgrades to both the transaction and the server's feature level.
The consequences of this are especially severe if the server is in DNSSEC
strict mode. In this case repeated downgrades eventually cause the server to
stop resolving entirely with the error "incompatible-server".

To avoid unnecessary downgrades the request should be retried once with the
current level before the transaction's feature level is downgraded.

(cherry picked from commit 8a33aa199dc1cea14494469ac9d7d08dc6721df1)

4 years agosd-boot: Fix possible null pointer dereference
Jan Janssen [Wed, 11 Aug 2021 12:59:46 +0000 (14:59 +0200)]
sd-boot: Fix possible null pointer dereference

Auto entries are showing garbage for the version in print_status()
because StrDuplicate does not expect null pointers.

(cherry picked from commit b52fafb26d90b77cfc259fcbdab3c95a571bacb1)

4 years agocore: Make sure cgroup_oom_queue is flushed on manager exit
Michal Koutný [Wed, 4 Aug 2021 16:59:35 +0000 (18:59 +0200)]
core: Make sure cgroup_oom_queue is flushed on manager exit

The unit queues are not serialized/deserialized (they are recreated
after reexec/reload instead). The destroyed units are not removed from
the cgroup_oom_queue. That means the queue may contain possibly invalid
pointers to released units.

Fix this by removing the units from cgroup_oom_queue as we do for
others. When at it, sync assert checks with currently existing queues
and put them in order in the manager cleanup code.

(cherry picked from commit 13e721036bf4ba15eb255d8f0a14800f969ac0d7)

4 years agocgroup: do 'catchup' for unit cgroup inotify watch files
Dan Streetman [Sun, 11 Jul 2021 20:59:27 +0000 (16:59 -0400)]
cgroup: do 'catchup' for unit cgroup inotify watch files

While reexec/reload, we drop the inotify watch on cgroup file(s), so
we need to re-check them in case they changed and we missed the event.

Fixes: #20198
(cherry picked from commit 869f52f21831b611160c4937bef822ca94c802ba)

4 years agosystemd-analyze: parse ip_filters_custom_egress correctly
Maanya Goenka [Tue, 10 Aug 2021 21:30:46 +0000 (14:30 -0700)]
systemd-analyze: parse ip_filters_custom_egress correctly

Fixed bug in original assignment of security_info variable: ip_filters_custom_egress.

(cherry picked from commit 3da57008e743643d45d3dc05eacac1a4623539a4)

4 years agohostname: fix off-by-one issue in gethostname()
Yu Watanabe [Tue, 10 Aug 2021 15:12:40 +0000 (00:12 +0900)]
hostname: fix off-by-one issue in gethostname()

gethostname() returns null-terminated hostname.

Fixes #20309 and #20417.

(cherry picked from commit ccdf235464297c2ca4c1dea8733a6bad423084d5)

4 years agosd-dhcp-server: fix possible double-free or use-after-free
Yu Watanabe [Wed, 11 Aug 2021 07:20:35 +0000 (16:20 +0900)]
sd-dhcp-server: fix possible double-free or use-after-free

(cherry picked from commit 3dc8fb0eb8dd4b7dd802aa69cfe5b2c8f760f561)

4 years agoGet rid of dangling setutxent()
MertsA [Wed, 11 Aug 2021 03:54:50 +0000 (20:54 -0700)]
Get rid of dangling setutxent()

utmp_wall() and utmp_put_dead_process() called setutxent() directly instead of the stub in utmp-wtmp.h and never called endutxent(). This would leave /run/utmp left open by PID 1 or journald. This can be reproduced by e.g. lsof /run/utmp and systemd-cat -p 0 echo test. For utmp_put_dead_process() it would only leave it open if it returned early before calling write_utmp_wtmp()

(cherry picked from commit bbd239f67a683fe63ee3698896fa503ff25031ed)

4 years agosd-dhcp6-client: cirtainly adjust T1 and T2
Yu Watanabe [Tue, 10 Aug 2021 12:39:27 +0000 (21:39 +0900)]
sd-dhcp6-client: cirtainly adjust T1 and T2

This fixes a bug introduced by 99f1d3fc5043b33dea5faa88f7015a487965333f.
Note that in the information requesting mode, the lease has neither
addresses nor PD prefixes.

(cherry picked from commit de949e911ee15d1c9daaf5ba5a3cff806fb2b514)

4 years agosd-dhcp6-client: fix copy-and-paste mistake
Yu Watanabe [Tue, 10 Aug 2021 12:36:04 +0000 (21:36 +0900)]
sd-dhcp6-client: fix copy-and-paste mistake

Fix bug introduced by b47fb949b338a8e77be789542fffb8c86da79284.

(cherry picked from commit 0c42b613485978eb82d7aff7ed426b8a8bb327af)

4 years agoresolved: Don't omit AD bit in reply if DO is set in the query
Jack Dähn [Tue, 3 Aug 2021 06:07:05 +0000 (08:07 +0200)]
resolved: Don't omit AD bit in reply if DO is set in the query

Set the AD bit in the response if the data is authenticated and AD or DO is set in the query, as suggested by section 5.8 of RFC6840.

Fixes #20332

(cherry picked from commit b553abd8aed0f6fbff9973882fb08c3aec1d9400)

4 years agotest: use a correct kernel binary on ppc64le machines
Frantisek Sumsal [Mon, 9 Aug 2021 12:32:43 +0000 (14:32 +0200)]
test: use a correct kernel binary on ppc64le machines

Ubuntu calls the kernel binary as `vmlinux-*`, but RHEL/CentOS uses
the "standard" `vmlinuz-` prefix.

Follow-up to eaa602cb14217f2623c9c8c44b6f3012dc4d0b24.

(cherry picked from commit 46db176f8c34adc47f535904e834d18c8ad53f5f)