systemd/.git
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)

3 years agorepart: use real disk start/end for bar production
Tom Yan [Sun, 19 Dec 2021 17:30:38 +0000 (01:30 +0800)]
repart: use real disk start/end for bar production

Partitions are not always within our aligned scope. Bar printing
involves foreign partitions as well.

Fixes #21817.

(cherry picked from commit d8daed09f37bc9f8ecb9268a4e371f65aec8b24a)

3 years agojournal-remote: use MHD_HTTP_CONTENT_TOO_LARGE as MHD_HTTP_PAYLOAD_TOO_LARGE is depre...
Yu Watanabe [Mon, 20 Dec 2021 11:48:32 +0000 (20:48 +0900)]
journal-remote: use MHD_HTTP_CONTENT_TOO_LARGE as MHD_HTTP_PAYLOAD_TOO_LARGE is deprecated since 0.9.74

(cherry picked from commit 30df858f43b14a55c6650b43bea12cbf2cc0bc67)

3 years agoman: correctly document default for DNSSEC= and DNSoverTLS=
Zbigniew Jędrzejewski-Szmek [Sat, 18 Dec 2021 16:03:43 +0000 (17:03 +0100)]
man: correctly document default for DNSSEC= and DNSoverTLS=

https://bugzilla.redhat.com/show_bug.cgi?id=1926323
(cherry picked from commit e803cf21393c9e49cb47903365f436a07a6fa3ba)

3 years agoman: describe flags for record resolving
Zbigniew Jędrzejewski-Szmek [Tue, 14 Dec 2021 18:39:36 +0000 (19:39 +0100)]
man: describe flags for record resolving

(cherry picked from commit c6f20515ab600098b5c2871bae2e9ecab3b41555)

3 years agoman: describe $SYSTEMD_NSS_RESOLVE_VALIDATE
Zbigniew Jędrzejewski-Szmek [Tue, 14 Dec 2021 17:48:25 +0000 (18:48 +0100)]
man: describe $SYSTEMD_NSS_RESOLVE_VALIDATE

This variable has a pretty important effect, but we didn't mention it
anywhere in the docs. It was added in aee9d18c8d909eb7aca2838e4bce5da018b6a112.

(cherry picked from commit 1c4539afc08f2ce4af70d32e2dcd6a3fd414c0ef)

3 years agobasic: add a size check to format timex members properly
Mike Gilbert [Mon, 20 Dec 2021 00:39:37 +0000 (19:39 -0500)]
basic: add a size check to format timex members properly

As of glibc-2.34, the size of members in struct timex varies depending on
the _TIME_BITS macro.

Fixes: https://github.com/systemd/systemd/issues/21826
(cherry picked from commit 9a723ed6e80e3078969567f7cb551535d2fb00bd)

3 years agologind: add a comment with a reminder why we don't use ProtrectProc=
Luca Boccassi [Fri, 17 Dec 2021 12:19:25 +0000 (12:19 +0000)]
logind: add a comment with a reminder why we don't use ProtrectProc=

Follow-up for https://github.com/systemd/systemd/pull/21785

(cherry picked from commit ba679b8d567e2e5b347865800da421a1bb87df75)

3 years agologind: allow to read /proc
Ludwig Nussel [Tue, 14 Dec 2021 13:59:19 +0000 (14:59 +0100)]
logind: allow to read /proc

User name and tty are used for wall messages. For that to work logind
must be able to poke around in proc entries of other processes.

(cherry picked from commit 60c5878dd4c57ae1b24dfa355128477df712c661)

3 years agounits: enable systemd-network-generator by default
Zbigniew Jędrzejewski-Szmek [Thu, 16 Dec 2021 08:46:26 +0000 (09:46 +0100)]
units: enable systemd-network-generator by default

It is used by udevd and networkd. Since udevd is enabled statically, let's also
change the preset to "on". networkd is opt-in, so let's pull in the generator
when enabling networkd too.

(cherry picked from commit e053f49272e46c2ba941cbd3fd8bf07b089b2917)

3 years agomeson: build network-generator unconditionally
Yu Watanabe [Wed, 15 Dec 2021 16:51:22 +0000 (01:51 +0900)]
meson: build network-generator unconditionally

The service also generates .link files for udevd.

(cherry picked from commit 987dd89c775815831ae21736fe60aef59cb7a6fa)

3 years agounit: run network-generator before starting udevd
Yu Watanabe [Tue, 14 Dec 2021 04:12:41 +0000 (13:12 +0900)]
unit: run network-generator before starting udevd

Otherwise, .link files generated by the service may not be loaded by
udevd.

(cherry picked from commit 85e865082767c84ea689a74006947693f06b69af)

3 years agofstab-generator: do not remount /sys when running in a container
Yu Watanabe [Sun, 12 Dec 2021 02:43:21 +0000 (11:43 +0900)]
fstab-generator: do not remount /sys when running in a container

Closes #21744.

(cherry picked from commit 18f0eaafd7f180f5d0d2d65349835374146efdb3)

3 years agojournactl: show info about journal range only at debug level (#21775)
Zbigniew Jędrzejewski-Szmek [Tue, 14 Dec 2021 21:30:15 +0000 (22:30 +0100)]
journactl: show info about journal range only at debug level (#21775)

The message that the "journal begins … ends …" has been always confusing to
users. (Before b91ae210e62 it was "logs begin … end …" which was arguably even
more confusing, but really the change in b91ae210e62 didn't substantially change
this.)

When the range shown is limited (by -e, -f, --since, or other options), it
doesn't really matter to the user what the oldest entries are, since they are
purposefully limiting the range. In fact, if we are showing the last few
entries with -e or -f, knowing that many months the oldest entries have is
completely useless.

And when such options are *not* used, the first entry generally corresponds to
the beginning of the range shown, and the last entry corresponds to the end of
that range. So again, it's not particularly useful, except when debugging
journalctl or such. Let's just treat it as a debug message.

Fixes #21491.

(cherry picked from commit a2d7654f99eba250eddf988db262abef96ebbe7a)

3 years agohome: fix heap-use-after-free
Yu Watanabe [Tue, 14 Dec 2021 06:38:12 +0000 (15:38 +0900)]
home: fix heap-use-after-free

`bus_home_emit_remove()` may be called from manager_free() -> home_free().
In that case, manager->bus is already unref()ed.

Fixes #21767.

(cherry picked from commit 2ff457720bd3bc59985e807b748f6305bdf27826)

3 years agoman: how to unset CPUQuota=
Sho Iizuka [Mon, 13 Dec 2021 13:53:36 +0000 (22:53 +0900)]
man: how to unset CPUQuota=

This description will help users who are trying to reset the already configured
CPUQuota= by trying incorrect ways such as CPUQuota=0 or CPUQUota=infinity.

(cherry picked from commit 17cfd6f96f43ec012b80b417878d87df85b07977)

3 years agoman: bump Fedora version to 35
Zbigniew Jędrzejewski-Szmek [Thu, 9 Dec 2021 11:43:34 +0000 (12:43 +0100)]
man: bump Fedora version to 35

Fedora-Cloud-Base-35-1.2.x86_64.qcow2 is again the latest version.

(cherry picked from commit 3f532f9216d473d5e966c7e9ec26917bc183e41e)

3 years agomkosi: Build Fedora 35 images
Daan De Meyer [Thu, 9 Dec 2021 11:35:23 +0000 (12:35 +0100)]
mkosi: Build Fedora 35 images

(cherry picked from commit 808b23ecf681c12493cbb84958e75ea300ebbeab)

3 years agoBump the max number of inodes for /tmp to a million too
Zbigniew Jędrzejewski-Szmek [Thu, 9 Dec 2021 09:20:46 +0000 (10:20 +0100)]
Bump the max number of inodes for /tmp to a million too

Fixes #21626. (The bug report talks about /run, but the issue is actually with
/tmp.) People use /tmp for various things that fit in memory, e.g. unpacking
packages, and 400k is not much. Let's raise is a bit.

(cherry picked from commit cac372a80177fb622806270eb0d810e4c6ad0c84)

3 years agoresolve: remove server 'large' level
Dan Streetman [Fri, 20 Aug 2021 18:44:35 +0000 (14:44 -0400)]
resolve: remove server 'large' level

This removes the DNS_SERVER_FEATURE_LEVEL_LARGE, and sets the EDNS0
advertised max packet size as if always in 'large' mode.

Without this, we always send out EDNS0 opts that limit response sizes
to 512 bytes, thus the remote server will never send anything larger
and will always truncate responses larger than 512 bytes, forcing us
to drop from EDNS0 down to TCP, even though one of the primary benefits
of EDNS0 is larger packet sizes.

Fixes: #20993
(cherry picked from commit 526fce97afe130f71dba3bd4646196bbb1188b82)

3 years agocore/cgroup: use helper macro for bfq conversion
Zbigniew Jędrzejewski-Szmek [Wed, 10 Nov 2021 10:37:15 +0000 (11:37 +0100)]
core/cgroup: use helper macro for bfq conversion

As suggested in https://github.com/systemd/systemd/pull/20522#discussion_r696699984.

(cherry picked from commit 311822ac28c99e2fb0e25286bdb72c9188314a66)

3 years agocore/cgroup: set bfq.weight first, and fixes blkio.weight value
Yu Watanabe [Tue, 24 Aug 2021 16:28:47 +0000 (01:28 +0900)]
core/cgroup: set bfq.weight first, and fixes blkio.weight value

Fixes issues introduced by 29eb0eefd14afc9a2424781a28b376db47c3c570.

This also fixes the value sets to blkio.weight, that is, "default" is dropped.

Moreover, This also changes the logic for mapping weight -> bfq.weight,
to always matches the min, max, and default values.

Fixes #20519 and #21187.

(cherry picked from commit 17283ce7b6035775f125585d1b228226942daf4b)

3 years agounits/systemd-udevd: allow bpf() syscall
Maciek Borzecki [Tue, 30 Nov 2021 10:07:30 +0000 (11:07 +0100)]
units/systemd-udevd: allow bpf() syscall

Programs run by udev triggers may need to execute the bpf() syscall. Even more
so, since on a cgroup v2 system, the only way to set up device access filtering
is to install a BPF program on the cgroup in question and one way of passing
data to such program is through BPF maps, which can only be access using the
bpf() syscall. One such use case was identified in RHBZ#2025264 related to
snap-device-helper, and led to RHBZ#2027627 being filed.

Unfortunately there is no finer grained control over what gets passed in the
syscall, so just enable bpf() and leave fine grained mediation to other
security layers (eg. SELinux).

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

Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
(cherry picked from commit 0ddd608a6ddcd095d378510c7096ee979741046d)

3 years agocore: use correct level for CPU time log message
Christian Göttsche [Mon, 6 Dec 2021 15:57:42 +0000 (16:57 +0100)]
core: use correct level for CPU time log message

raise_level() takes the info condition as second argument and the notice
one as third. For the consumed CPU time these conditions are swapped.

Fixes: 37109b856aeb ("pid1: use LOG_DEBUG/INFO/NOTICE for unit resource consumption message")
(cherry picked from commit ef6bb4dd3e3bb9c210c310026b4d827a46acc762)

3 years agofix DirectoryNotEmpty when it comes to a Non-directory file
yangmingtai [Mon, 6 Dec 2021 09:06:13 +0000 (17:06 +0800)]
fix DirectoryNotEmpty when it comes to a Non-directory file

(cherry picked from commit 5896a9ebdbe4d38c01390d0a5e82f9fcb4971059)

3 years agoman: fix description of sd_uid_get_sessions
Pavel Březina [Thu, 2 Dec 2021 12:07:07 +0000 (13:07 +0100)]
man: fix description of sd_uid_get_sessions

(cherry picked from commit 2f121b6fa1f6aa4c9bd699fce52f0b087abefd01)

3 years agojournal: don't remove the flushed flag when journald is stopped
Franck Bui [Wed, 1 Dec 2021 07:51:48 +0000 (08:51 +0100)]
journal: don't remove the flushed flag when journald is stopped

Due to the fact that systemd-journal-flush.service has
"Requires=systemd-journald.service", this service is stopped too when journald
is requested to do so.

However stopping systemd-journal-flush.service implies that journald
relinquishes /var hence implicitly switching back to the volatile storage
mode and removing /run/systemd/journal/flushed.

If journald is started afterwards, it will run in volatile storage mode
regardless of the value of 'Storage=' as it believes now that /var is not yet
ready (because the flushed flag is missing).

Because this flag is mainly an indication for journald that the initialization
of /var/log/journal (during the boot process) has been done,
systemd-journal-flush.service shouldn't be tied to the state of journald itself
but to the state of /var/log/journal, hence to the state of the system.

(cherry picked from commit d5ee050ffc9d413253932d9340ade8c8fb111092)

3 years agosd_bus_get_timeout: fix timeout value doc
Urs Ritzmann [Fri, 3 Dec 2021 14:47:18 +0000 (15:47 +0100)]
sd_bus_get_timeout: fix timeout value doc

The documentation of sd_bus_get_timeout wrongfully states that the returned time-value is relative. In fact, it is an absolute value which is based of CLOCK_MONOTONIC. This change corrects that documentation.

(cherry picked from commit 25060a570c106cf5a14a3268bb0d38d9feb7fdab)

3 years agoBump the max number of inodes for /dev to 128k
Franck Bui [Fri, 3 Dec 2021 10:23:36 +0000 (11:23 +0100)]
Bump the max number of inodes for /dev to 128k

Follow-up for 7d85383edbab73274dc81cc888d884bb01070bc2.

Apparently the previous limit set on the max number of inodes for /dev was too
small as a system with 4096 LUNs attached can consume up to 95k inodes for
symlinks:

  # /bin/df -i
  Filesystem                 Inodes  IUsed    IFree IUse% Mounted on
  devtmpfs                 49274377  95075 49179302    1% /dev

Hence this patch bumps the limit from 64k to 128k although the new limit is
still pretty arbitrary (that said, not sure if it really makes sense to put
such absolute limit number).

(cherry picked from commit 4c733d3046942984c5f73b40c3af39cc218c103f)

3 years agocryptenroll: fix wrong error messages
Gibeom Gwon [Fri, 3 Dec 2021 06:10:50 +0000 (15:10 +0900)]
cryptenroll: fix wrong error messages

PKCS#11 -> FIDO2 in cryptenroll-fido2.c

(cherry picked from commit 4b9aa29bc9ded35147f9fa77f77e13c3c6fa7fcf)