systemd/.git
3 years agotree-wide: mark set-but-not-used variables as unused to make LLVM happy
Frantisek Sumsal [Wed, 15 Sep 2021 08:56:21 +0000 (10:56 +0200)]
tree-wide: mark set-but-not-used variables as unused to make LLVM happy

LLVM 13 introduced `-Wunused-but-set-variable` diagnostic flag, which
trips over some intentionally set-but-not-used variables or variables
attached to cleanup handlers with side effects (`_cleanup_umask_`,
`_cleanup_(notify_on_cleanup)`, `_cleanup_(restore_sigsetp)`, etc.):

```
../src/basic/process-util.c:1257:46: error: variable 'saved_ssp' set but not used [-Werror,-Wunused-but-set-variable]
        _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL;
                                                     ^
                                                     1 error generated.
```

(cherry picked from commit d7ac09520be8f0d3d94df3dd4fd8a6e7404c0174)

3 years agoci: fix clang-13 installation
Frantisek Sumsal [Tue, 22 Feb 2022 13:43:40 +0000 (14:43 +0100)]
ci: fix clang-13 installation

For some reason Ubuntu Focal repositories now have `llvm-13` virtual
package which can't be installed, but successfully fools our check,
resulting in no clang/llvm being installed...

```
$ apt show llvm-13
Package: llvm-13
State: not a real package (virtual)
N: Can't select candidate version from package llvm-13 as it has no candidate
N: Can't select versions from package 'llvm-13' as it is purely virtual
N: No packages found

$ apt install --dry-run llvm-13
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package llvm-13 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'llvm-13' has no installation candidate
```

(cherry picked from commit b491d74064f9d5e17a71b38b014434237169a077)
(cherry picked from commit fa6e263273905cfc9e4528e8175ace3d19d881e3)

3 years agoci: replace apt-key with signed-by
Evgeny Vereshchagin [Sun, 26 Dec 2021 01:11:00 +0000 (01:11 +0000)]
ci: replace apt-key with signed-by

to limit the scope of the key to apt.llvm.org only.

This is mostly inspired by https://blog.cloudflare.com/dont-use-apt-key/

(cherry picked from commit bfa6bd1be098adc4710e1819b9cd34d65b3855da)
(cherry picked from commit c92297a20c13b7e15b0026b1f36ebe99d86cfce8)

3 years agoresolve: add reference of the original bus message to the aux queries
Yu Watanabe [Fri, 11 Feb 2022 00:43:16 +0000 (09:43 +0900)]
resolve: add reference of the original bus message to the aux queries

Otherwise, the error in aux queries cannot be replied.

Fixes #22477.

(cherry picked from commit 08275791d85a1852e79951212f6cbbc727db789a)
(cherry picked from commit 919d398668d2baa1873e61f7f502fac910a9d606)

3 years agoresolve: refuse AF_UNSPEC when resolving address
Yu Watanabe [Fri, 11 Feb 2022 00:49:13 +0000 (09:49 +0900)]
resolve: refuse AF_UNSPEC when resolving address

Fixes #22480.

(cherry picked from commit 0234f0c0531682e7f28a4ef51852c102c6e97267)
(cherry picked from commit 084c88983eaecbf23e113db5a7ee11f94b60472b)

3 years agoci: use the system llvm-11 package on Focal
Frantisek Sumsal [Mon, 11 Oct 2021 19:12:42 +0000 (21:12 +0200)]
ci: use the system llvm-11 package on Focal

ATTOW llvm-11 got into focal-updates, which conflicts with llvm-11
provided by the apt.llvm.org repositories. Let's use the system
llvm package if available in such cases to avoid that.

(cherry picked from commit 1c71302f70c7d0712d49b5214f5f29b4d6a2c73e)

3 years agopackit: build on and use Fedora 35 spec file v249.10
Luca Boccassi [Tue, 15 Feb 2022 01:21:01 +0000 (01:21 +0000)]
packit: build on and use Fedora 35 spec file

It's targeted to the v249 branch, while the rawhide one follows
the newest upstream release, and the command line options are not
compatible

3 years agoPartially revert "sd-dhcp-server: refuse too large packet to send"
Luca Boccassi [Tue, 15 Feb 2022 10:21:49 +0000 (10:21 +0000)]
Partially revert "sd-dhcp-server: refuse too large packet to send"

This test fails on this branch:

 949/1228 fuzz-dhcp-server-relay-message_clusterfuzz-testcase-minimized-fuzz-dhcp-server-relay-message-4972399731277824_address,undefined FAIL           0.00s (exit status 127)12:43
--- command ---12:43
01:47:36 UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1' /usr/bin/env /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-server-relay-message:address,undefined /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/test/fuzz/fuzz-dhcp-server-relay-message/clusterfuzz-testcase-minimized-fuzz-dhcp-server-relay-message-497239973127782412:43
--- stderr ---12:43
/usr/bin/env: ‘/tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-server-relay-message:address,undefined’: No such file or directory

This partially reverts commit 76bcd1d6d26ebe0424e2c5edc7f5a31a82ae3a7c.

(cherry picked from commit e69b2a3a69d472e887633162111ed2a45f317eb9)

3 years agoRevert "tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains"
Luca Boccassi [Tue, 15 Feb 2022 10:20:34 +0000 (10:20 +0000)]
Revert "tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains"

The test fails on this branch:

 948/1228 fuzz-dhcp-client_minimized-from-555a2b073b8d208655b68c294f8dfd592a11e50a_address,undefined                                      FAIL           0.00s (exit status 127)12:43
--- command ---12:43
01:47:36 UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1' /usr/bin/env /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-client:address,undefined /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/test/fuzz/fuzz-dhcp-client/minimized-from-555a2b073b8d208655b68c294f8dfd592a11e50a12:43
--- stderr ---12:43
/usr/bin/env: ‘/tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-client:address,undefined’: No such file or directory

This reverts commit 87728a590ad82391e76a275024c9039625ff2b67.

(cherry picked from commit 2614461383b344041b397870fb3662c79f2a7b75)

3 years agosd-device: silence gcc warning with newest gcc
Zbigniew Jędrzejewski-Szmek [Sat, 15 Jan 2022 12:38:30 +0000 (13:38 +0100)]
sd-device: silence gcc warning with newest gcc

(cherry picked from commit 376ee2c312b87951028a0adff96b1052f32475fa)
(cherry picked from commit 18aff8c85720606e05826045b6799d19a7dcf08a)

3 years agopackit: remove unsupported -Dcryptolib=openssl option
Luca Boccassi [Tue, 15 Feb 2022 01:21:01 +0000 (01:21 +0000)]
packit: remove unsupported -Dcryptolib=openssl option

Introduced later, so it breaks the build on v249-stable

3 years agosd-bus: allow numerical uids in -M user@.host
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jul 2021 16:02:50 +0000 (18:02 +0200)]
sd-bus: allow numerical uids in -M user@.host

UIDs don't work well over ssh, but locally or with containers they are OK.
In particular, user@.service uses UIDs as identifiers, and it's nice to be
able to copy&paste that UID for interaction with the user's managers.

(cherry picked from commit 2da7d0bc92e2423a5c7225c5d24b99d5d52a0bc6)

3 years agosd-bus: print debugging information if bus_container_connect_socket() fails
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jul 2021 16:01:03 +0000 (18:01 +0200)]
sd-bus: print debugging information if bus_container_connect_socket() fails

We would return the errno, but there are many steps, and without some
debugging info it's hard to figure out what exactly failed.

(cherry picked from commit 0c201ca945c64e97ba4961ded13ce38a63200468)

3 years agosd-bus: print quoted commandline when in bus_socket_exec()
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jul 2021 14:36:49 +0000 (16:36 +0200)]
sd-bus: print quoted commandline when in bus_socket_exec()

The arguments are where the interesting part is:
src/libsystemd/sd-bus/bus-socket.c:965: sd-bus: starting bus with systemd-run...

src/libsystemd/sd-bus/bus-socket.c:972: sd-bus: starting bus with systemd-run -M.host -PGq --wait -pUser=1000 -pPAMName=login systemd-stdio-bridge "-punix:path=\${XDG_RUNTIME_DIR}/bus"

(cherry picked from commit 87fa2e21dd7a30d25ccda2df6b8446a82637b059)

3 years agocore: use the new quoting helper
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jul 2021 14:28:19 +0000 (16:28 +0200)]
core: use the new quoting helper

(cherry picked from commit 8a62620ebe23945021075df7e1b0759102c286ae)

3 years agobasic/escape: add helper for quoting command lines
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jul 2021 14:27:51 +0000 (16:27 +0200)]
basic/escape: add helper for quoting command lines

(cherry picked from commit eeb91d29b0279d6bf8a3f1c4da54c9e9c0881a19)

3 years agotest-network: add missing tests for bridge properties
Yu Watanabe [Thu, 10 Feb 2022 09:04:34 +0000 (18:04 +0900)]
test-network: add missing tests for bridge properties

(cherry picked from commit b6d5dab7bbb8ecf4ce1229840085daa15ab4cf57)
(cherry picked from commit ab30fe12edf4b859d38f4c5726b3eaa71aa5b3f7)

3 years agonetwork: bridge: fix endian of vlan protocol
Yu Watanabe [Thu, 10 Feb 2022 08:47:14 +0000 (17:47 +0900)]
network: bridge: fix endian of vlan protocol

Fixes #22469.

(cherry picked from commit 6eb35be8e0fa5f1f00dddd558cf4dc3642d9e53e)
(cherry picked from commit 514a4c051ce6cceaa5417a2044e708bd5105131d)

3 years agoresolve: use _cleanup_ attribute for freeing DnsQuery
Yu Watanabe [Sat, 5 Feb 2022 13:04:42 +0000 (22:04 +0900)]
resolve: use _cleanup_ attribute for freeing DnsQuery

(cherry picked from commit c704288c473fa08820566fdb16c38726d24db026)
(cherry picked from commit 0533d1aab61b6a797d07c4c861acf5e87f8191e8)

3 years agoresolve: fix possible memleak
Yu Watanabe [Sat, 5 Feb 2022 13:03:19 +0000 (22:03 +0900)]
resolve: fix possible memleak

Fortunately, unlike the issue fixed in the previous commit, the memleak
should be superficial and not become apparent, as the queries handled
here are managed by the stub stream, and will be freed when the stream
is closed.

Just for safety, and slightly reducing the runtime memory usage by the
stub stream.

(cherry picked from commit fe8c5ce615ee2123f17b1f0b3728c439e19e4b5b)
(cherry picked from commit 4dbc210124b4303ecadb6cdb28a4a4c821e1150b)

3 years agoresolve: fix potential memleak and use-after-free
Yu Watanabe [Sat, 5 Feb 2022 12:37:01 +0000 (21:37 +0900)]
resolve: fix potential memleak and use-after-free

When stub stream is closed early, then queries associated to the stream
are freed. Previously, the timer event source for queries may not be
disabled, hence may be triggered with already freed query.
See also dns_stub_stream_complete().

Note that we usually not set NULL or zero when freeing simple objects.
But, here DnsQuery is large and complicated object, and the element may
be referenced in subsequent freeing process in the future. Hence, for
safety, let's set NULL to the pointer.

(cherry picked from commit 73bfd7be042cc63e7649242b377ad494bf74ea4b)
(cherry picked from commit d82bd80cf4e7659906a502735b20a45964b55a88)

3 years agoutil: another set of CVE-2021-4034 assert()s
Lennart Poettering [Tue, 1 Feb 2022 11:06:21 +0000 (12:06 +0100)]
util: another set of CVE-2021-4034 assert()s

It's a good idea that we validate argc/argv when we are supposed to
store them away.

(cherry picked from commit 007e03b284e8ffc0b92edb2122cd9d2d16f049ef)
(cherry picked from commit dcba78244e5dc3a4b57fb978a2d21640164c89a2)

3 years agotest: use mksquashfs -noappend
Luca Boccassi [Thu, 27 Jan 2022 14:08:05 +0000 (14:08 +0000)]
test: use mksquashfs -noappend

Makes the setup idempotent, as mksquashfs by default attempts to
append to an existing image

(cherry picked from commit 392d46d7a8f78169ff6b0d2740f82924e6fdc878)
(cherry picked from commit 44c4116557389ad86d5d204e290f8f2c57b7f009)

3 years agocore/mount: fail early if directory cannot be created
Yu Watanabe [Wed, 2 Feb 2022 05:05:45 +0000 (14:05 +0900)]
core/mount: fail early if directory cannot be created

Prompted by #22334.

(cherry picked from commit e4de58c8231e47509ffeb3aa47620ca42f22d7f6)
(cherry picked from commit 1d7e0b68048ba0760f8fdf6a26c7a5017ac38569)

3 years agounits: we need systemd-journald.service from systemd-journal-flush.service
Lennart Poettering [Tue, 1 Feb 2022 17:11:04 +0000 (18:11 +0100)]
units: we need systemd-journald.service from systemd-journal-flush.service

This is a follow-up for d5ee050ffc9d413253932d9340ade8c8fb111092, and
reintroduces a requirement dep from systemd-journal-flush.service onto
systemd-journald.service, but a weaker one than originally: a Wants= one
instead of a Requires= one.

Why? Simply because the service issues an IPC call to the journald,
hence it should pull it in. (Note that socket activation doesn't happen
for the Varlink socket it uses, hence we should pull in the service
itself.)

(cherry picked from commit 23b1e8d087c9e8c5a2cdcc6a91510a4e7ca8f72f)
(cherry picked from commit 9793254248a51bd2d19399bacb314e541cf2a4a0)

3 years agosd-dhcp-lease: fix memleak
Yu Watanabe [Sun, 30 Jan 2022 20:19:09 +0000 (05:19 +0900)]
sd-dhcp-lease: fix memleak

Fixes https://github.com/systemd/systemd/pull/22294#issuecomment-1024840811.

(cherry picked from commit 06cf04dff4dd6c69e527913ad137616c23861270)
(cherry picked from commit ae95ca27bee2bef5bf53002873a254f1a0fe8b81)

3 years agotest-network: set xfrm interface ID
Yu Watanabe [Tue, 1 Feb 2022 04:26:40 +0000 (13:26 +0900)]
test-network: set xfrm interface ID

This also unifies two tests for xfrm, and checks the output of
'ip link' command.

Fixes #22329.

(cherry picked from commit 020483b248b45b15eb93d2ae322d7f211c61e44d)
(cherry picked from commit a5fc827b3a775f8553c95381ed49649beb86c5ea)

3 years agonetwork: xfrm: refuse zero interface ID
Yu Watanabe [Tue, 1 Feb 2022 04:00:51 +0000 (13:00 +0900)]
network: xfrm: refuse zero interface ID

Since kernel 5.17-rc1, 5.16.3, and 5.15.17 (more specifically,
https://github.com/torvalds/linux/commit/8dce43919566f06e865f7e8949f5c10d8c2493f5)
the kernel refuses to create an xfrm interface with zero ID.

(cherry picked from commit fd11005951920a0cee96f0c56f36d9ff8bc66a41)
(cherry picked from commit 1ef56ad928df3a8fb45b9dcdf3950035a6f699b7)

Conflicts:
src/network/netdev/xfrm.c

3 years agoexecute: document that the 'env' param is input *and* output
Lennart Poettering [Tue, 1 Feb 2022 12:50:28 +0000 (13:50 +0100)]
execute: document that the 'env' param is input *and* output

(cherry picked from commit 421bb42d1b366c00392ef5bbab6a67412295b6dc)
(cherry picked from commit c4357f31da66b1917d3612d02c28adb300d4b0c6)

3 years agoexecute: line break comments a bit less aggressively
Lennart Poettering [Tue, 1 Feb 2022 12:50:13 +0000 (13:50 +0100)]
execute: line break comments a bit less aggressively

(cherry picked from commit cafc5ca147cb05b90bd731661d8594c299601f79)
(cherry picked from commit 14567dc93d5c498bfaadd28478f59952f6da320c)

3 years agoexecute: use _cleanup_ logic where appropriate
Lennart Poettering [Tue, 1 Feb 2022 12:49:56 +0000 (13:49 +0100)]
execute: use _cleanup_ logic where appropriate

(cherry picked from commit 46e5bbab5895b7137b03453dee08bd1c89c710e9)
(cherry picked from commit 9b2954b79435eaf54be208acdce8026b83bdc249)

3 years agopid1: pass PAM_DATA_SILENT to pam_end() in child
Lennart Poettering [Tue, 1 Feb 2022 11:37:51 +0000 (12:37 +0100)]
pid1: pass PAM_DATA_SILENT to pam_end() in child

Fixes: #22318
(cherry picked from commit 7feb2b5737ad110eb3985e8e9d8189f18d1c5147)
(cherry picked from commit 9c560d201527ee064ae11784d6538ae544926181)

3 years agologin: use bus_error_message() at one more place
Yu Watanabe [Sat, 29 Jan 2022 20:38:35 +0000 (05:38 +0900)]
login: use bus_error_message() at one more place

(cherry picked from commit 80c8c786a314bceba180fac5506e72aa48c0764a)
(cherry picked from commit 048487c094a149e99b4067c8cd2d3974a8f17397)

3 years agocore/unit: use bus_error_message() at one more place
Yu Watanabe [Sat, 29 Jan 2022 20:38:01 +0000 (05:38 +0900)]
core/unit: use bus_error_message() at one more place

(cherry picked from commit 33322185554799b08e94aca036dd109aaee52408)
(cherry picked from commit 81e59411161078f4f90d80e2e111755adc16db33)

3 years agobus-util: retrieve bus error from message
Yu Watanabe [Sat, 29 Jan 2022 20:36:56 +0000 (05:36 +0900)]
bus-util: retrieve bus error from message

The error in argument is not input, but used for output.

(cherry picked from commit 853b94863cf26d084454edd63ce987cc7ab0505a)
(cherry picked from commit b9e144629bdb7c3d4535fb0a0ad8639140a25034)

3 years agocore: don't fail on EEXIST when creating mount point
Luca Boccassi [Fri, 28 Jan 2022 22:56:10 +0000 (22:56 +0000)]
core: don't fail on EEXIST when creating mount point

systemd[1016]: Failed to mount /tmp/app1 (type n/a) on /run/systemd/unit-extensions/1 (MS_BIND ): No such file or directory
systemd[1016]: Failed to create destination mount point node '/run/systemd/unit-extensions/1': File exists

(cherry picked from commit 9d6d4c305ab8d65aab7f546450d7331f760b7259)
(cherry picked from commit ae8bc570a81e1286eb5b59a77ef179a500b95f9d)

3 years agosd-dhcp-lease: fix a memory leak in dhcp_lease_parse_search_domains
Evgeny Vereshchagin [Sat, 29 Jan 2022 03:16:40 +0000 (03:16 +0000)]
sd-dhcp-lease: fix a memory leak in dhcp_lease_parse_search_domains

=================================================================
==81071==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x51245c in __interceptor_reallocarray (/home/vagrant/systemd/build/fuzz-dhcp-client+0x51245c)
    #1 0x7f01440c67e6 in strv_push /home/vagrant/systemd/build/../src/basic/strv.c:435:13
    #2 0x7f01440ca9e1 in strv_consume /home/vagrant/systemd/build/../src/basic/strv.c:506:13
    #3 0x7f01440ca9e1 in strv_extend /home/vagrant/systemd/build/../src/basic/strv.c:558:16
    #4 0x5806e3 in dhcp_lease_parse_search_domains /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:900:21
    #5 0x57c1be in dhcp_lease_parse_options /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:727:21
    #6 0x572450 in parse_options /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:348:33
    #7 0x571c6a in dhcp_option_parse /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:376:13
    #8 0x559a01 in client_handle_offer /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-client.c:1543:13
    #9 0x5592bd in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/libsystemd-network/fuzz-dhcp-client.c:74:16
    #10 0x44a379 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a379)
    #11 0x42ae1f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x42ae1f)
    #12 0x432ade in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x432ade)
    #13 0x421f86 in main (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421f86)
    #14 0x7f0142fff55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)

(cherry picked from commit 9591c0a8b3496d0e5cbbfe7c75161ba80089c143)
(cherry picked from commit 7dc0f80588f371a62a56a75bf27eab2c515becf3)

3 years agotests: add a file triggering a memory leak in dhcp_lease_parse_search_domains
Evgeny Vereshchagin [Sat, 29 Jan 2022 03:18:31 +0000 (03:18 +0000)]
tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains

(cherry picked from commit 998ec39b1d20a40453a3b47f7eb68feacefd65d9)
(cherry picked from commit ba335f6f40b58ea4050471a5051ceacfbff71f08)

3 years agosd-dhcp-lease: fix an infinite loop found by the fuzzer
Evgeny Vereshchagin [Sat, 29 Jan 2022 02:08:39 +0000 (02:08 +0000)]
sd-dhcp-lease: fix an infinite loop found by the fuzzer

(cherry picked from commit 86b06c666be8b7afb45541d35aa4d0ecb38056d1)
(cherry picked from commit 426807c54b9500b806eaaf50d32c7c936510706c)

3 years agobasic: mac_[selinux,smack]_apply_fd does not work when applying labels
Donald Chan [Fri, 28 Jan 2022 22:53:46 +0000 (22:53 +0000)]
basic: mac_[selinux,smack]_apply_fd does not work when applying labels

Commit a7fdc6c introduced a regression where file descriptors are opened
using O_PATH option. mac_smack_apply_fd() calls fsetxattr() and would fail
with a -EBADF (Bad file descriptor) error.

Use FORMAT_PROC_FD_PATH(fd) to convert the fd back into a full path and
call setxattr() or setfilecon() instead.

Signed-off-by: Donald Chan <hoiho@amazon.com>
(cherry picked from commit a718364e9d9242cc2111c9860f2ab5bb9bb26db9)
(cherry picked from commit 9f596964f6e403b089450dc083724b48fb4b4bb1)

3 years agosd-dhcp-server: refuse too large packet to send
Yu Watanabe [Fri, 28 Jan 2022 02:53:49 +0000 (11:53 +0900)]
sd-dhcp-server: refuse too large packet to send

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

(cherry picked from commit 71df50a9734f7006bc1ac8be59ca81c797b39c35)
(cherry picked from commit 530a18d49361ade6d3f09abb78f8f901753a4cda)

3 years agologind.conf: Fix name of option: RuntimeDirectoryInodes -> RuntimeDirectoryInodesMax
Arfrever Frehtes Taifersar Arahesis [Thu, 27 Jan 2022 00:00:00 +0000 (00:00 +0000)]
logind.conf: Fix name of option: RuntimeDirectoryInodes -> RuntimeDirectoryInodesMax

(cherry picked from commit a42a93830fcc18da073a5ac06f93c386efc9109d)
(cherry picked from commit 5b20a2b19c847b8ad8b354f1b735fbbaf88d2f8f)

3 years agocore/namespace: s/normalize_mounts()/drop_unused_mounts()
Christian Brauner [Mon, 24 Jan 2022 09:12:57 +0000 (10:12 +0100)]
core/namespace: s/normalize_mounts()/drop_unused_mounts()

Rename the normalize_mounts() helper to drop_unused_mounts. All the
helpers called in there get rid of mounts that are unused for a variety
of reasons. And whereas the helpers are aptly prefixed with "drop" the
overall helper isn't and instead uses "normalize".

Make it more obvious what the helper actually does by renaming it from
normalize_mounts() to drop_unused_mounts(). Readers of code calling this
helper will immediately see that it will get rid of unused mounts.

Link: https://github.com/systemd/systemd/issues/22206
(cherry picked from commit fbf90c0d5cadc5d1e95485f770f45a7d4cd39daa)
(cherry picked from commit 09936a7ec92c859b3c4c9520ecd49c2909a8b35c)

3 years agocore/namespace: allow using ProtectSubset=pid and ProtectHostname=true together
Christian Brauner [Fri, 21 Jan 2022 12:08:19 +0000 (13:08 +0100)]
core/namespace: allow using ProtectSubset=pid and ProtectHostname=true together

If a service requests both ProtectSubset=pid and ProtectHostname=true
then it will currently fail to start. The ProcSubset=pid option
instructs systemd to mount procfs for the service with subset=pid which
hides all entries other than /proc/<pid>. Consequently trying to
interact with the two files /proc/sys/kernel/{hostname,domainname}
covered by ProtectHostname=true will fail.

Fix this by only performing this check when ProtectSubset=pid is not
requested. Essentially ProtectSubset=pid implies/provides
ProtectHostname=true.

(cherry picked from commit 1361f015773e3b4d74e382edf1565f3315a3396b)
(cherry picked from commit a727941affa7821592d503c8a5033c92d615f64c)

3 years agoudevadm: cleanup-db: don't delete information for kept db entries
Martin Wilck [Thu, 20 Jan 2022 13:31:45 +0000 (14:31 +0100)]
udevadm: cleanup-db: don't delete information for kept db entries

devices with the db_persist property won't be deleted during database
cleanup. This applies to dm and md devices in particular.
For such devices, we should also keep the files under /run/udev/links,
/run/udev/tags, and /run/udev/watch, to make sure that after restart,
udevd has the same information about the devices as it did before
the cleanup.

If we don't do this, a lower-priority device that is discovered in
the coldplug phase may take over symlinks from a device that persisted.
Not removing the watches also enables udevd to resume watching a device
after restart.

Signed-off-by: Martin Wilck <mwilck@suse.com>
(cherry picked from commit 7ec624147a41d80f8e492c9fe19a24e2cda58c25)
(cherry picked from commit ef7ceef26adb714ef44b2fbc07a219c05a012b42)

3 years agoudevadm: cleanup_dir: use dot_or_dot_dot()
Martin Wilck [Fri, 21 Jan 2022 09:44:26 +0000 (10:44 +0100)]
udevadm: cleanup_dir: use dot_or_dot_dot()

which is safer than just checking dent[0].
Also, fix two style issues.

(cherry picked from commit 28d6e8545151d413f8614db9fa790f9f9edbb045)
(cherry picked from commit 494e3c0def197abd4ec88f7b0c3ba331a708d81e)

3 years agooomd: handle situations when no cgroups are killed
Anita Zhang [Wed, 19 Jan 2022 21:26:01 +0000 (13:26 -0800)]
oomd: handle situations when no cgroups are killed

Currently if systemd-oomd doesn't kill anything in a selected cgroup, it
selects a new candidate immediately. But if a selected cgroup wasn't killed,
it is likely due to it disappearing or getting cleaned up between the time
it was selected as a candidate and getting sent SIGKILL(s). We should handle
it as though systemd-oomd did perform a kill so that it will check
swap/pressure again before it tries to select a new candidate.

(cherry picked from commit 914d4e99f43761f1ce77b520850cf096aa5196cd)
(cherry picked from commit c4d89cd602b94ab3baac746395c797ec4da43679)

3 years agooomd: fix race with path unavailability when killing cgroups
Anita Zhang [Wed, 19 Jan 2022 18:40:46 +0000 (10:40 -0800)]
oomd: fix race with path unavailability when killing cgroups

There can be a situation where systemd-oomd would kill all of the processes
in a cgroup, pid1 would clean up that cgroup, and systemd-oomd would get
ENODEV trying to iterate the cgroup a final time to ensure it was empty.
systemd-oomd sees this as an error and immediately picks a new candidate even
though pressure may have recovered. To counter this, check and handle
path unavailability errnos specially.

Fixes: #22030
(cherry picked from commit 2ee209466bb51f39ae9df7fec4d5594ce8cfa3f0)
(cherry picked from commit 0456e3aaaae7c21a037f4d3c758463c3ba4d167c)

3 years agoresolve: fix assertion triggered when r == 0
Yu Watanabe [Wed, 19 Jan 2022 20:24:31 +0000 (05:24 +0900)]
resolve: fix assertion triggered when r == 0

Fixes #22178.

(cherry picked from commit 98b1eb711cfc70776fefd3d4ec437a6a4f9aeff2)
(cherry picked from commit 740dd39e070b3b827cbac37df2a40d61bd9cdb89)

3 years agocore: refuse to mount ExtensionImages if the base layer doesn't at least have ID...
Luca Boccassi [Wed, 19 Jan 2022 00:08:57 +0000 (00:08 +0000)]
core: refuse to mount ExtensionImages if the base layer doesn't at least have ID in os-release

We can't match an extension if we don't at least have an ID,
so refuse to continue

(cherry picked from commit 78ab2b5064a0f87579ce5430f9cb83bba0db069a)
(cherry picked from commit 179bd47f04c538ed1f2c1de2cf2c18f17b027a51)

3 years agodissect-image: validate extension-release even if the host has only ID in os-release
Luca Boccassi [Wed, 19 Jan 2022 00:01:48 +0000 (00:01 +0000)]
dissect-image: validate extension-release even if the host has only ID in os-release

A rolling distro won't set VERSION_ID or SYSEXT_LEVEL in os-release,
which means we skip validation of ExtensionImages.
Validate even with just an ID, the lower level helper already
recognizes and accepts this use case.

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

(cherry picked from commit 37361f46d571ad0b71ef99dec6a9b76edbab38bb)
(cherry picked from commit 0dab9e5f057380322755e90ee4d35716d5bf6232)

3 years agosysext: use LO_FLAGS_PARTSCAN when opening image
Luca Boccassi [Wed, 19 Jan 2022 00:27:45 +0000 (00:27 +0000)]
sysext: use LO_FLAGS_PARTSCAN when opening image

Jan 17 12:34:59 myguest1 (sd-sysext)[486]: Device '/var/lib/extensions/myext.raw' is loopback block device with partition scanning turned off, please turn it on.

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

(cherry picked from commit 70a5c6dce0872b3bb0a39be250adde86a0c8f35c)
(cherry picked from commit 4ef7122f3c3328aa01e1ed187a793e7b1595ee87)

3 years agonamespace: allow ProcSubset=pid with some ProtectKernel options
Topi Miettinen [Sat, 27 Nov 2021 10:51:39 +0000 (12:51 +0200)]
namespace: allow ProcSubset=pid with some ProtectKernel options

In case `/proc` is successfully mounted with pid tree subset only due to
`ProcSubset=pid`, the protective mounts for `ProtectKernelTunables=yes` and
`ProtectKernelLogs=yes` to non-pid `/proc` paths are failing because the paths
don't exist. But the pid only option may have failed gracefully (for example
because of ancient kernel), so let's try the mounts but it's not fatal if they
don't succeed.

(cherry picked from commit 788e720181aead8c85ba30fc7ec9a1455a865cbe)

3 years agomeson: fix cross compiling
Yu Watanabe [Tue, 21 Dec 2021 11:10:09 +0000 (20:10 +0900)]
meson: fix cross compiling

(cherry picked from commit 3112d756a36993900b70fbff98e69a2a43b970a8)

3 years agojournal: Skip data objects with invalid offsets v249.9
Daan De Meyer [Wed, 12 Jan 2022 14:44:50 +0000 (14:44 +0000)]
journal: Skip data objects with invalid offsets

We already skip invalid objects, but don't yet skip invalid offsets.
Let's skip these as well to improve robustness when we're dealing with
corrupted journals.

Before:

```
➜  systemd git:(main) build/journalctl -r -n 5 --file ~/Downloads/system@0005d2b275abaaf8-f243a2818cb39b98.journal_
Failed to get journal fields: Cannot assign requested address
-- No entries --
```

After:

```
➜  systemd git:(main) ✗ build/journalctl -r -n 5 --file ~/Downloads/system@0005d2b275abaaf8-f243a2818cb39b98.journal_
Dec 09 08:32:38 snowball3 NetworkManager[911]: <info>  [1639038758.1464] device (wlp1s0): supplicant interface state: scanning -> authenticating
Dec 09 08:32:38 snowball3 kernel: wlp1s0: send auth to ec:a9:40:79:fb:ad (try 1/3)
Dec 09 08:32:38 snowball3 kernel: wlp1s0: authenticate with ec:a9:40:79:fb:ad
Dec 09 08:32:38 snowball3 wpa_supplicant[1003]: wlp1s0: SME: Trying to authenticate with ec:a9:40:79:fb:ad (SSID='UPC949397B' freq=5500 MHz)
```

(cherry picked from commit df207ccb7be02b1ca6bdd0a2066a898e5b24ee86)
(cherry picked from commit 556f46aa3b17f4ed6768521137405297c8a99d35)

3 years agoxdg-autostart-service: Ignore missing desktop-sepcific condition binary
Benjamin Berg [Mon, 10 Jan 2022 11:35:46 +0000 (12:35 +0100)]
xdg-autostart-service: Ignore missing desktop-sepcific condition binary

If a desktop specific ExecCondition= binary does not exist, this just
means that the desktop environment is not available. As such, it is not
an error condition that should prevent the service from being installed
in the .wants target.

Fix this by simply returning zero.

(cherry picked from commit 6d0aef1dd15088e7379681b3bd93c3cb450f3c55)
(cherry picked from commit 19fbd7764da2e23a89e27b4d95afd77b99f4be87)

3 years agoman+docs: adjust links to the new page
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 10:32:53 +0000 (11:32 +0100)]
man+docs: adjust links to the new page

(cherry picked from commit 717e92ceb96471251f8242ad4f4c45cc2c68ecc9)
(cherry picked from commit 704d859eeb20fea27cec10c7c6cdb47c59413138)

3 years agopolicy files: adjust landing page link
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 09:42:22 +0000 (10:42 +0100)]
policy files: adjust landing page link

(cherry picked from commit d6e2c1ab7158d52425d3cb72459c5624db12368c)
(cherry picked from commit 944d8d9050b96e690054224e796254dfc18e6681)

3 years agodocs: use https:// for fd.o links
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 09:39:00 +0000 (10:39 +0100)]
docs: use https:// for fd.o links

(cherry picked from commit 931bc1957b13817fcb0ffe69958dd562202c8e4c)
(cherry picked from commit e7ed0ba895e53109c1d6f225d7d53605cad8bd8c)

3 years agoREADME: link to the new page
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 09:33:57 +0000 (10:33 +0100)]
README: link to the new page

Lennart's blog is now mostly of historical interest, and the wiki
landing page has been replaced by systemd.io.

(cherry picked from commit 2777a4a3bfe153cb675d3d66b383a26043c187b8)
(cherry picked from commit 26271c128ae2b519ecf25ad6cc07e9cf4051c92b)

3 years agoNEWS: adjust links to moved pages
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 09:33:10 +0000 (10:33 +0100)]
NEWS: adjust links to moved pages

All those pages contain a redirect at the top of the page, so it doesn't
make much sense to tell people to take the detour. Linking directly will
also increase the search rankings of the new pages.

(cherry picked from commit a794a4d87219367e8b24469fcafce83a9f224080)
(cherry picked from commit 2b075f74cb23ba838a29c4b5b898437c8294ddf9)

3 years agofix test-string-util failed when locale is not utf8
yangmingtai [Tue, 11 Jan 2022 12:22:11 +0000 (20:22 +0800)]
fix test-string-util failed when locale is not utf8

(cherry picked from commit 647082cf7f07a87c65601626e86c3ed9f78fb387)
(cherry picked from commit 32f33c9474ab89061d799a92a1273b106468e8c6)

3 years agoRevert "core: Add trigger limit for path units"
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 21:22:21 +0000 (22:22 +0100)]
Revert "core: Add trigger limit for path units"

This reverts commit 4c63c3b00aac56390a44e4c0a9d056426d6ff81d.

3 years agoRevert "core: Check unit start rate limiting earlier"
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 21:21:14 +0000 (22:21 +0100)]
Revert "core: Check unit start rate limiting earlier"

This reverts commit a82b93092bdd3901a22375a820bfa09db8a39978.

This previous commit.

3 years agoRevert "Reintroduce ExitType"
Zbigniew Jędrzejewski-Szmek [Wed, 12 Jan 2022 21:19:37 +0000 (22:19 +0100)]
Revert "Reintroduce ExitType"

This reverts commit 31b7eefb6c3c8e3da74ef18d864e64d72f542e16.

I included this patch because it is important to fix starting of user units
under KDE [1], but I got lost in all the attempts and reverts, and the backport
is broken [2]. I'll try to do a better backport later.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1956022
[2] https://bugzilla.redhat.com/show_bug.cgi?id=2039888

3 years agoReintroduce ExitType v249.8
Zbigniew Jędrzejewski-Szmek [Tue, 11 Jan 2022 19:45:42 +0000 (20:45 +0100)]
Reintroduce ExitType

This introduces `ExitType=main|cgroup` for services.
Similar to how `Type` specifies the launch of a service, `ExitType` is
concerned with how systemd determines that a service exited.

- If set to `main` (the current behavior), the service manager will consider
  the unit stopped when the main process exits.

- The `cgroup` exit type is meant for applications whose forking model is not
  known ahead of time and which might not have a specific main process.
  The service will stay running as long as at least one process in the cgroup
  is running. This is intended for transient or automatically generated
  services, such as graphical applications inside of a desktop environment.

Motivation for this is #16805. The original PR (#18782) was reverted (#20073)
after realizing that the exit status of "the last process in the cgroup" can't
reliably be known (#19385)

This version instead uses the main process exit status if there is one and just
listens to the cgroup empty event otherwise.

The advantages of a service with `ExitType=cgroup` over scopes are:
- Integrated logging / stdout redirection
- Avoids the race / synchronisation issue between launch and scope creation
- More extensive use of drop-ins and thus distro-level configuration:
  by moving from scopes to services we can have drop ins that will affect
  properties that can only be set during service creation,
  like `OOMPolicy` and security-related properties
- It makes systemd-xdg-autostart-generator usable by fixing [1], as obviously
  only services can be used in the generator, not scopes.

[1] https://bugs.kde.org/show_bug.cgi?id=433299

(cherry picked from commit 596e447076b27d103a30c26a68626e9820ac705b)

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

3 years agonss: only read logging config from environment variables
Zbigniew Jędrzejewski-Szmek [Tue, 11 Jan 2022 12:36:39 +0000 (13:36 +0100)]
nss: only read logging config from environment variables

log_parse_environment() uses should_parse_proc_cmdline() to determine whether
it should parse settings from the kernel command line. But the checks that
should_parse_proc_cmdline() apply to the whole process, and we could get a positive
answer also when log_parse_environment() was called from one of the nss modules.
In case of nss-modules, we don't want to look at the kernel command line.

log_parse_environment_variables() that only looks at the environment variables
is split out and used in the nss modules.

Fixes #22020.

(cherry picked from commit a7d15a24659770b0fa9f4cd26fc7bbb17765cbb7)

3 years agonss: drop dummy setup_logging() helpers
Zbigniew Jędrzejewski-Szmek [Tue, 11 Jan 2022 12:23:27 +0000 (13:23 +0100)]
nss: drop dummy setup_logging() helpers

log_parse_environment() stopped being a macro in 9fdee66f2d9.
As reported by @bauen1 in https://github.com/systemd/systemd/issues/22020,
the comment was out of date.

(cherry picked from commit 56a5f4969b96529c82ec8cc08db4fa8e9c61e7b9)

3 years agocore: Add trigger limit for path units
Daan De Meyer [Fri, 17 Dec 2021 19:01:31 +0000 (20:01 +0100)]
core: Add trigger limit for path units

When conditions fail on a service unit, a path unit can cause
PID 1 to busy loop as it keeps trying to activate the service unit.
To avoid this from happening, add a trigger limit to the path unit,
identical to the trigger limit we have for socket units.

Initially, let's start with a high limit and not make it configurable.
If needed, we can add properties to configure the rate limit similar
to the ones we have for socket units.

(cherry picked from commit aaae822b37aa3ca39aebb516fdc6bef36d730c25)

3 years agoshared/rm-rf: loop over nested directories instead of instead of recursing
Zbigniew Jędrzejewski-Szmek [Tue, 30 Nov 2021 21:29:05 +0000 (22:29 +0100)]
shared/rm-rf: loop over nested directories instead of instead of recursing

To remove directory structures, we need to remove the innermost items first,
and then recursively remove higher-level directories. We would recursively
descend into directories and invoke rm_rf_children and rm_rm_children_inner.
This is problematic when too many directories are nested.

Instead, let's create a "TODO" queue. In the the queue, for each level we
hold the DIR* object we were working on, and the name of the directory. This
allows us to leave a partially-processed directory, and restart the removal
loop one level down. When done with the inner directory, we use the name to
unlinkat() it from the parent, and proceed with the removal of other items.

Because the nesting is increased by one level, it is best to view this patch
with -b/--ignore-space-change.

This fixes CVE-2021-3997, https://bugzilla.redhat.com/show_bug.cgi?id=2024639.
The issue was reported and patches reviewed by Qualys Team.
Mauro Matteo Cascella and Riccardo Schirone from Red Hat handled the disclosure.

(cherry picked from commit 5b1cf7a9be37e20133c0208005274ce4a5b5c6a1)
(cherry picked from commit 911516e1614e435755814ada5fc6064fa107a105)

3 years agoshared/rm_rf: refactor rm_rf() to shorten code a bit
Zbigniew Jędrzejewski-Szmek [Tue, 23 Nov 2021 15:56:42 +0000 (16:56 +0100)]
shared/rm_rf: refactor rm_rf() to shorten code a bit

(cherry picked from commit 84ced330020c0bae57bd4628f1f44eec91304e69)
(cherry picked from commit 664529efa9431edc043126013ea54e6c399ae2d3)

3 years agoshared/rm_rf: refactor rm_rf_children_inner() to shorten code a bit
Zbigniew Jędrzejewski-Szmek [Tue, 23 Nov 2021 14:55:45 +0000 (15:55 +0100)]
shared/rm_rf: refactor rm_rf_children_inner() to shorten code a bit

(cherry picked from commit 3bac86abfa1b1720180840ffb9d06b3d54841c11)
(cherry picked from commit 47741ff9eae6311a03e4d3d837128191826a4a3a)

3 years agotmpfiles: 'st' may have been used uninitialized
Zbigniew Jędrzejewski-Szmek [Tue, 23 Nov 2021 14:05:58 +0000 (15:05 +0100)]
tmpfiles: 'st' may have been used uninitialized

(cherry picked from commit 160dadc0350c77d612aa9d5569f57d9bc84c3dca)

3 years agorm-rf: optionally fsync() after removing directory tree
Lennart Poettering [Tue, 5 Oct 2021 08:32:56 +0000 (10:32 +0200)]
rm-rf: optionally fsync() after removing directory tree

(cherry picked from commit bdfe7ada0d4d66e6d6e65f2822acbb1ec230f9c2)

3 years agorm-rf: refactor rm_rf_children(), split out body of directory iteration loop
Lennart Poettering [Tue, 26 Jan 2021 15:30:06 +0000 (16:30 +0100)]
rm-rf: refactor rm_rf_children(), split out body of directory iteration loop

This splits out rm_rf_children_inner() as body of the loop. We can use
that to implement rm_rf_child() for deleting one specific entry in a
directory.

(cherry picked from commit 1f0fb7d544711248cba34615e43c5a76bc902d74)

3 years agoboot-timestamps: Discard firmware init time when running in a VM
Jan Janssen [Sun, 9 Jan 2022 13:22:15 +0000 (14:22 +0100)]
boot-timestamps: Discard firmware init time when running in a VM

Fixes: #22060
(cherry picked from commit f699bd81e8e18da2d2fc11e7fb7dce95f8bb3f9e)
(cherry picked from commit 3c5c13f82c760c7067bb189484e1f672ff6713f6)

3 years agoman: add missing example title in systemd.network(5)
Zbigniew Jędrzejewski-Szmek [Fri, 7 Jan 2022 08:52:19 +0000 (09:52 +0100)]
man: add missing example title in systemd.network(5)

Also rename the file to match the example being extended.

(cherry picked from commit 55ac274ef4c1661f3053ae3a709202c918365f3b)
(cherry picked from commit d1612a7163b2c2fa2499738040da39ab24ef1b63)

3 years agoseccomp: move arch_prctl to @default
Zbigniew Jędrzejewski-Szmek [Fri, 7 Jan 2022 14:23:55 +0000 (15:23 +0100)]
seccomp: move arch_prctl to @default

It was reported as used by the linker:

> [It is] called in the setup of ld-linux-x86-64.so.2 from _dl_sysdep_start.
> My local call stack (with LTO):
>
> #0 init_cpu_features.constprop.0 (/usr/lib64/ld-linux-x86-64.so.2)
> #1 _dl_sysdep_start (/usr/lib64/ld-linux-x86-64.so.2)
> #2 _dl_start (/usr/lib64/ld-linux-x86-64.so.2)
> #3 _start (/usr/lib64/ld-linux-x86-64.so.2)
>
> Looking through the source, I think it's this (links for glibc 2.34):
> - First dl_platform_init calls _dl_x86_init_cpu_features, a wrapper for init_cpu_features.
> - Then init_cpu_features calls get_cet_status.
> - At last, get_cet_status invokes arch_prctl.

Fixes #22033.

(cherry picked from commit 5f02870a74aa3a758115cc9bd6d68f239caf8453)
(cherry picked from commit d08f6ff204c8525f7533875128468afb8be60ae0)

3 years agofstab-generator: also skip other network filesystems and live image
Yu Watanabe [Wed, 5 Jan 2022 13:06:03 +0000 (22:06 +0900)]
fstab-generator: also skip other network filesystems and live image

(cherry picked from commit 155e1bb4e7cf87191007488cf6a68a558a16eca1)
(cherry picked from commit 41134e766aa2a0f6f013d46689215c5ec86a7e5d)

3 years agofstab-generator: skip root directory handling when nfsroot is requested
Yu Watanabe [Wed, 5 Jan 2022 10:24:46 +0000 (19:24 +0900)]
fstab-generator: skip root directory handling when nfsroot is requested

Fixes RHBZ#2037233 (https://bugzilla.redhat.com/show_bug.cgi?id=2037233).

(cherry picked from commit 77b8e92de8264c0b656a7d2fb437dd8d598ab597)
(cherry picked from commit 7ca41c509e6549abbfc753e560c822b5e32a63cc)

3 years agohomed: stop before stopping dbus
Markus Weippert [Tue, 4 Jan 2022 12:56:11 +0000 (13:56 +0100)]
homed: stop before stopping dbus

Otherwise, systemd-homed-active.service will fail to deactivate all
homes because homectl can no longer talk to homed if dbus stops first.
As a result, /home cannot be umounted.

Doing this on systemd-homed-active.service instead works as well, but
systemd-homed will exit 1 if dbus is already shut down.

(cherry picked from commit e00a25a7b41bd45ab73b47cbd94b3af909b8f8a1)
(cherry picked from commit 11f3040d0a1eee663acedda1bdb9aa450c22f2a4)

3 years agotest-watchdog: mark as unsafe
Mike Gilbert [Wed, 5 Jan 2022 04:43:10 +0000 (23:43 -0500)]
test-watchdog: mark as unsafe

If something goes wrong with this test it may result in an unsafe
system restart. Let's avoid running it automatically.

See https://github.com/systemd/systemd/issues/22001.

(cherry picked from commit 70652c2a6fa9c06c7faac62f41c72e2e4eaa9340)
(cherry picked from commit 4c0ed19c520a8944f68f613edc3acbd0471dcc81)

3 years agologind: do not propagate error in delayed action
Zbigniew Jędrzejewski-Szmek [Wed, 5 Jan 2022 14:10:33 +0000 (15:10 +0100)]
logind: do not propagate error in delayed action

If the action failed, we should log about the issue, and continue.
Exiting would bring the graphical session down, which of course is not
appreciated by users.

As documented in previous commits, a non-negative return from the callback
doesn't matter, so the callback is simplified a bit.

Fixes #21991.

(cherry picked from commit 8207b8321bbbcbd19a345deb77d455d98e6ffb84)
(cherry picked from commit fb9bbbee6a3c09b75817f9f343176fa2170fdb31)

3 years agobacklight: ignore error if the backlight device is already removed
Yu Watanabe [Wed, 5 Jan 2022 09:26:46 +0000 (18:26 +0900)]
backlight: ignore error if the backlight device is already removed

Fixes #21997.

(cherry picked from commit f0f65087834198d4dabf8b389ddc34223400aab7)
(cherry picked from commit b4c57e1b1c249f28f13a86637d8854c920bcf26d)

3 years agohwdb: fix check for uppercasedness of match patterns
Zbigniew Jędrzejewski-Szmek [Tue, 4 Jan 2022 09:39:53 +0000 (10:39 +0100)]
hwdb: fix check for uppercasedness of match patterns

The check was added in 77547d5313ea916d2fb64ca5a8812734e9b50f92, but
it doesn't work as expected. Because the second part is wrapped in Optional(),
it would silently "succeed" when the lowercase digits were in the second part:

>>> from parse_hwdb import *
>>> g = 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4))
>>> g.parseString('v04D8pE11C*')
(['v', '04D8', 'p', 'E11C'], {})
>>> g.parseString('v04D8pe11c*')
(['v', '04D8'], {})

The following matches are OK:
usb:v0627p0001:*QEMU USB Keyboard*
usb:v0627p0001:*
usb:v0627p0001*
usb:v0627*

(cherry picked from commit 1a37237e2ffe6dfe142224a9d9e8b24135e93244)
(cherry picked from commit 697ec43fc5b0dcefbad92e5616eaa5f3407d407f)

3 years agobasic/log: allow errno values higher than 255
Zbigniew Jędrzejewski-Szmek [Mon, 3 Jan 2022 16:53:29 +0000 (17:53 +0100)]
basic/log: allow errno values higher than 255

When the support for "synthetic errno" was added, we started truncating
the errno value to just the least significant byte. This is generally OK,
because errno values are defined up to ~130.

The docs don't really say what the maximum value is. But at least in principle
higher values could be added in the future. So let's stop truncating
the values needlessly.

The kernel (or libbpf?) have an error where they return 524 as an errno
value (https://bugzilla.redhat.com/show_bug.cgi?id=2036145). We would
confusingly truncate this to 12 (ENOMEM). It seems much nicer to let
strerror() give us "Unknown error 524" rather than to print the bogus
message about ENOMEM.

(cherry picked from commit 5f74fcd41cb1a1b26c23e0f2ab405ae9cf6bcc93)
(cherry picked from commit cd686fe4c719bfb894bd24d673c51f19cea64643)

3 years agomissing-syscall: add __NR_openat2
Yu Watanabe [Sun, 2 Jan 2022 18:44:50 +0000 (03:44 +0900)]
missing-syscall: add __NR_openat2

(cherry picked from commit d96ad9e8cb9fc8a9adfeebf69a645b809705daa0)
(cherry picked from commit cd88d010e862d26ce816eb3bd6735a80999ac41e)

3 years agosyscalls: update syscall definitions
Yu Watanabe [Sun, 2 Jan 2022 18:48:10 +0000 (03:48 +0900)]
syscalls: update syscall definitions

(cherry picked from commit 0c718b1a67cd0d3512eafeb4659458694bf3865b)
(cherry picked from commit 7e338876577cb328632ce3e7753c0130b54dd7a2)

3 years agonss-myhostname: do not apply non-zero offset to null pointer
Yu Watanabe [Fri, 31 Dec 2021 00:13:00 +0000 (09:13 +0900)]
nss-myhostname: do not apply non-zero offset to null pointer

Fixes https://github.com/systemd/systemd/issues/21935#issuecomment-1003216503.

(cherry picked from commit 92e9df9ca031b9b04487a46afd986ab3122183fd)
(cherry picked from commit a473bfb4332ad6b0a0894135c4de0f8cc324d378)

3 years agonss-systemd: fix alignment of gr_mem
Yu Watanabe [Thu, 30 Dec 2021 21:59:42 +0000 (06:59 +0900)]
nss-systemd: fix alignment of gr_mem

Follow-up for 1e65eb8f9b7d567462030b2e625998d77677e636.

Fixes #21935.

(cherry picked from commit 420a35c1fadfb4d67be6316436233d98b5688de5)
(cherry picked from commit 9c8bc0451ab2393f3b9b689e46e1b05e9f6dad35)

3 years agonss-systemd: fix required buffer size calculation
Yu Watanabe [Thu, 30 Dec 2021 15:31:51 +0000 (00:31 +0900)]
nss-systemd: fix required buffer size calculation

This also fixes the pointer assigned to the gr_mem element of struct group.

Fixes a bug introduced by 47fd7fa6c650d7a0ac41bc89747e3b866ffb9534.

Fixes #21935.

(cherry picked from commit 1e65eb8f9b7d567462030b2e625998d77677e636)
(cherry picked from commit 17227e81ab8a9bdfac679d450ed35434435a6ff8)

3 years agosysusers: use filename if /proc is not mounted
Yu Watanabe [Thu, 30 Dec 2021 15:11:01 +0000 (00:11 +0900)]
sysusers: use filename if /proc is not mounted

During system install, /proc may not be mounted yet.

Fixes RHBZ#2036217 (https://bugzilla.redhat.com/show_bug.cgi?id=2036217).

(cherry picked from commit b78d7f246899687a1697cdcebe93d8512c5e7c4b)
(cherry picked from commit 747b4f1ff8aac3a1b800b0a7ac0edef4af34da70)

3 years agonetwork: complete example for xfrm setup
Noel Kuntze [Thu, 30 Dec 2021 11:49:23 +0000 (12:49 +0100)]
network: complete example for xfrm setup

(cherry picked from commit 0d03e672a97c6ee85f563648e1ff40c88ce81d85)
(cherry picked from commit 19bb2b8443598e80a4da391e70211d6576b2a144)

3 years agosystemd-run: ensure error logs suggest to use '--user' when appropriate
Luca Boccassi [Thu, 30 Dec 2021 00:54:32 +0000 (00:54 +0000)]
systemd-run: ensure error logs suggest to use '--user' when appropriate

Before:

$ systemd-run --service-type=notify --user false
Job for run-rc3fe52ee6ddd4a6eaaf1a20e0a949cdf.service failed because the control process exited with error code.
See "systemctl status run-rc3fe52ee6ddd4a6eaaf1a20e0a949cdf.service" and "journalctl -xeu run-rc3fe52ee6ddd4a6eaaf1a20e0a949cdf.service" for details.

After:

$ systemd-run --service-type=notify --user false
Job for run-r7791e380a7b6400ea01d6a0e5a458b23.service failed because the control process exited with error code.
See "systemctl --user status run-r7791e380a7b6400ea01d6a0e5a458b23.service" and "journalctl --user -xeu run-r7791e380a7b6400ea01d6a0e5a458b23.service" for details.

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

(cherry picked from commit 466f2351bbb5c0fdc9f153e35506570e59b14c5f)
(cherry picked from commit b59615dc76cf82bd1fca301220ee0b7961cbcacd)

3 years agodbus-wait-for-jobs: add extra_args to bus_wait_for_jobs_one()
Luca Boccassi [Thu, 30 Dec 2021 00:53:29 +0000 (00:53 +0000)]
dbus-wait-for-jobs: add extra_args to bus_wait_for_jobs_one()

And pass it through to bus_wait_for_jobs()

(cherry picked from commit 86980de64bf8c03505eec729808f52f3b3042998)
(cherry picked from commit 0c4fe2e3dcde8225006a36cff643c112bd6c6523)

3 years agorandom-util: use ssize_t for getrandom return value
Mike Gilbert [Sat, 25 Dec 2021 00:20:36 +0000 (19:20 -0500)]
random-util: use ssize_t for getrandom return value

This matches the prototype provided by glibc.

(cherry picked from commit 289b41aae7356b7a6c72ff4a3476193a084ff33f)
(cherry picked from commit 4d889024ef5ba1edc5d967a010a2551e0826e5d7)

3 years agosd-journal: fix segfault when match_new() fails
Yu Watanabe [Thu, 23 Dec 2021 12:45:29 +0000 (21:45 +0900)]
sd-journal: fix segfault when match_new() fails

Fixes #21867.

(cherry picked from commit 39dfc0de05238410e2cd4d7c0176a3f3994cc563)

3 years agosd-journal: free incomplete match on failure
Yu Watanabe [Thu, 23 Dec 2021 12:35:29 +0000 (21:35 +0900)]
sd-journal: free incomplete match on failure

(cherry picked from commit 418cce628cf28d4feaeda60241cf9781f8afbf1c)

3 years agomachined: set TTYPath for container shell
Ludwig Nussel [Tue, 21 Dec 2021 10:38:49 +0000 (11:38 +0100)]
machined: set TTYPath for container shell

TTYPath is needed for proper utmp registration of the shell to
receive wall messages.

(cherry picked from commit a9c97bbbfb271d68b2ca4f3aa346fdf5e9c70c27)