systemd/.git
4 years agosd-event: always reshuffle time prioq on changing online/offline state v248.6
Yu Watanabe [Mon, 14 Jun 2021 17:13:59 +0000 (02:13 +0900)]
sd-event: always reshuffle time prioq on changing online/offline state

Before 81107b8419c39f726fd2805517a5b9faab204e59, the compare functions
for the latest or earliest prioq did not handle ratelimited flag.
So, it was ok to not reshuffle the time prioq when changing the flag.

But now, those two compare functions also compare the source is
ratelimited or not. So, it is necessary to reshuffle the time prioq
after changing the ratelimited flag.

Hopefully fixes #19903.

(cherry picked from commit 2115b9b6629eeba7bc9f42f757f38205febb1cb7)

Hopefully fixes #20285 and
https://bugzilla.redhat.com/show_bug.cgi?id=1984651.

4 years agosd-event: make event_source_time_prioq_reshuffle() accept all event source type
Yu Watanabe [Mon, 14 Jun 2021 17:03:02 +0000 (02:03 +0900)]
sd-event: make event_source_time_prioq_reshuffle() accept all event source type

But it does nothing for an event source which is neither a timer nor
ratelimited.

(cherry picked from commit 5c08c7ab23dbf02aaf4e4bbae8e08a195da230a4)

4 years agosd-event: use usec_add()
Yu Watanabe [Mon, 14 Jun 2021 16:01:48 +0000 (01:01 +0900)]
sd-event: use usec_add()

(cherry picked from commit a595fb5ca9c69c589e758e9ebe3b70ac90450ba3)

4 years agosd-event: drop unnecessary "else"
Yu Watanabe [Mon, 14 Jun 2021 15:44:04 +0000 (00:44 +0900)]
sd-event: drop unnecessary "else"

(cherry picked from commit 7e2bf71ca3638e36ee33215ceee386ba8013da6d)

4 years agoman: document nss-{resolve,myhostname} resolving in the other direction, too
Florian Klink [Sat, 17 Jul 2021 17:49:42 +0000 (19:49 +0200)]
man: document nss-{resolve,myhostname} resolving in the other direction, too

(cherry picked from commit 946f7ce32cef44d9bfcf2dc594bb193341434f57)
(cherry picked from commit f869a39bceb35406d3193058d6ab5308c2e28f17)

4 years agoman: stop recommending putting myhostname after dns
Florian Klink [Thu, 1 Jul 2021 20:11:27 +0000 (22:11 +0200)]
man: stop recommending putting myhostname after dns

nss-resolve also looks in /etc/hosts, and has the same local hostname
resolving logic as nss-myhostname. We shouldn't recommend another order
than nss-resolve uses internally.

When nss-resolve is used, there's no possibility to override
nss-myhostname hosts via DNS *anyway*.

On top of that, it's not a good idea to allow DNS to override local
hostnames as all - at least not something we should advertise in the
docs.

Followup of f918c67d38ba6ccd4eb0dc657f3f3155e5010cae /
https://github.com/systemd/systemd/pull/16754.

(cherry picked from commit ce266330fc3bd6767451ac3400336cd9acebe9c1)
(cherry picked from commit 21423efc5852194ba3bf2bbc8067258e35c1558d)

4 years agopid1: propagate the original command line when reexecuting
Zbigniew Jędrzejewski-Szmek [Thu, 22 Jul 2021 06:21:46 +0000 (08:21 +0200)]
pid1: propagate the original command line when reexecuting

When we reexec the manager in a container, we lose configuration settings on
the kernel command line:

  $ systemd-nspawn -M rawhide -b systemd.status-unit-format=name systemd.show-status=yes
  ...
  # tr '\0' ' ' </proc/1/cmdline
  /usr/lib/systemd/systemd systemd.status_unit_format=combined systemd.show-status=yes
  # sudo systemctl daemon-reexec
  # tr '\0' ' ' </proc/1/cmdline
  /usr/lib/systemd/systemd --system --deserialize 20

  This means that after daemon-reexec, the settings that we gain from the
  commandline are reset to defaults.

So let's reeexecute with the original arguments copied over, modulo some
filtering.

(cherry picked from commit 846f1da465beda990c1c01346311393f485df467)
(cherry picked from commit f3af6ba86c1128ccf6d6f896f70c22f9645a51c5)

4 years agosd-bus: fix missing initializer in SD_BUS_VTABLE_END (#20253)
Matthijs van Duin [Wed, 21 Jul 2021 09:10:36 +0000 (11:10 +0200)]
sd-bus: fix missing initializer in SD_BUS_VTABLE_END (#20253)

When two fields were added to the vtable.x.start struct, no initializers
for these were added to SD_BUS_VTABLE_END which also (ab)used that
struct (albeit sneakily by using non-designated initialization).

While C tolerates this, C++ prohibits these missing initializers, and
both g++ and clang++ will complain when using -Wextra.

This patch gives SD_BUS_VTABLE_END its own case in the union and
clarifies its initialization.

I tested the behaviour of g++ 10.2 and clang 11 in various cases. Both will warn
(-Wmissing-field-initializers, implied by -Wextra) if you provide initializers for some
but not all fields of a struct. Declaring x.end as empty struct or using an empty initializer
{} to initialize the union or one of its members is valid C++ but not C, although both gcc
and clang accept it without warning (even at -Wall -Wextra -std=c90/c++11) unless you
use -pedantic (which requires -std=c99/c++2a to support designated initializers).

Interestingly, .x = { .start = { 0, 0, NULL } } is the only initializer I found for the union
(among candidates for SD_BUS_VTABLE_END) where gcc doesn't zero-fill it entirely
when allocated on stack, it looked like it did in all other cases (I only examined this on
32-bit arm). clang always seems to initialize all bytes of the union.

[zjs: test case:
$ cat vtable-test.cc
#include "sd-bus.h"

const sd_bus_vtable vtable[] = {
   SD_BUS_VTABLE_END
};

$ g++ -I src/systemd/ -Wall -Wmissing-field-initializers -c vtable-test.cc
vtable-test.cc:5:1: warning: missing initializer for member ‘sd_bus_vtable::<unnamed union>::<unnamed struct>::features’ [-Wmissing-field-initializers]
    5 | };
      | ^
vtable-test.cc:5:1: warning: missing initializer for member ‘sd_bus_vtable::<unnamed union>::<unnamed struct>::vtable_format_reference’ [-Wmissing-field-initializers]

$ clang++ -I src/systemd/ -Wmissing-field-initializers -c vtable-test.cc
vtable-test.cc:4:4: warning: missing field 'features' initializer [-Wmissing-field-initializers]
   SD_BUS_VTABLE_END
   ^
src/systemd/sd-bus-vtable.h:188:28: note: expanded from macro 'SD_BUS_VTABLE_END'
                .x = { { 0 } },                                         \
                           ^
1 warning generated.

Both warnings are gone with the patch.]

(cherry picked from commit 654eaa403070d3c897454a5190603fda4071c3ff)
(cherry picked from commit cdaf655f73bb3be10d47ab6f00d71a8d0b1a81e3)

4 years agohwdb: 60-keyboard::remove hardcoded definition for KEYBOARD_KEY_56 for MSI Prestige...
Aakash Singh [Mon, 19 Jul 2021 18:57:48 +0000 (00:27 +0530)]
hwdb: 60-keyboard::remove hardcoded definition for  KEYBOARD_KEY_56 for MSI Prestige And  Modern

(cherry picked from commit 30c9faff0d74ceb0cbafb8ecdd8573bc479984dc)
(cherry picked from commit 95c3ad53f3febdaa1f175b85fb8b08ffc2bc96be)

This fixes a regression which was introduced into v248-stable with
976b4254a336a5bda52e7a38df48564d08f4cbff.

4 years agoalloc-util: introduce MALLOC_SIZEOF_SAFE() helper
Lennart Poettering [Tue, 18 May 2021 20:27:24 +0000 (22:27 +0200)]
alloc-util: introduce MALLOC_SIZEOF_SAFE() helper

It's a wrapper around malloc_usable_size() that is supposed to be
compatible with _FORTIFY_SOURCES=1, by taking the
__builtin_object_size() data into account, the same way as the
_FORTIFY_SOURCES=1 logic does.

Fixes: #19203
(cherry picked from commit 6df28e1f847d68ad37ffe3f4ff47745b55233861)

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

4 years agofileio: bump limit for read_full_file() and friends to 64M
Lennart Poettering [Thu, 10 Jun 2021 08:19:11 +0000 (10:19 +0200)]
fileio: bump limit for read_full_file() and friends to 64M

Apparently people use such large key files. Specifically, people used 4M
key files, and we lowered the limit from 4M to 4M-1 back in 248.

This raises the limit to 64M for read_full_file() to avoid these
specific issues and give some non-trivial room beyond the 4M files seen
IRL.

Note that that a 64M allocation in glibc is always immediately done via
mmap(), and is thus a lot slower than shorter allocations. This means
read_virtual_file() becomes ridiculously slow if we'd use the large
limit, since we use it all the time for reading /proc and /sys metadata,
and read_virtual_file() typically allocates the full size with malloc()
in advance.  In fact it becomes so slow, that test-process-util kept
timing out on me all the time, once I blindly raised the limit.

This patch hence introduces two distinct limits for read_full_file() and
read_virtual_file(): the former is much larger than the latter and the
latter remains where it is. This is safe since the former uses an
exponentially growing realloc() loop while the latter uses the
aforementioend ahead-of-time full limit allocation.

Fixes: #19193

(cherry picked from commit f6dd48fae807f93e4295c27bff79f4707cc96662)

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

4 years agobasic/unit-name: do not use strdupa() on a path v248.5
Zbigniew Jędrzejewski-Szmek [Wed, 23 Jun 2021 09:46:41 +0000 (11:46 +0200)]
basic/unit-name: do not use strdupa() on a path

The path may have unbounded length, for example through a fuse mount.

CVE-2021-33910: attacked controlled alloca() leads to crash in systemd and
ultimately a kernel panic. Systemd parses the content of /proc/self/mountinfo
and each mountpoint is passed to mount_setup_unit(), which calls
unit_name_path_escape() underneath. A local attacker who is able to mount a
filesystem with a very long path can crash systemd and the whole system.

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

The resulting string length is bounded by UNIT_NAME_MAX, which is 256. But we
can't easily check the length after simplification before doing the
simplification, which in turns uses a copy of the string we can write to.
So we can't reject paths that are too long before doing the duplication.
Hence the most obvious solution is to switch back to strdup(), as before
7410616cd9dbbec97cf98d75324da5cda2b2f7a2.

(cherry picked from commit 441e0115646d54f080e5c3bb0ba477c892861ab9)
(cherry picked from commit 764b74113e36ac5219a4b82a05f311b5a92136ce)

4 years agoMinor typo (#20254)
rene [Tue, 20 Jul 2021 05:45:04 +0000 (15:45 +1000)]
Minor typo (#20254)

Correct resoulution with resolution.

(cherry picked from commit b838bc11268ea461e8c58ce69e2f781be1821aa1)
(cherry picked from commit 5ea3ec8e18a2883c2ea89af9de48fc0fb0e3f283)

4 years agoshell-completion/zsh/_systemd-run: Fix completion of command names and arguments
duament [Sat, 17 Jul 2021 17:17:41 +0000 (01:17 +0800)]
shell-completion/zsh/_systemd-run: Fix completion of command names and arguments

(cherry picked from commit 3f49d1faf59acaa85aa5ad502c39b1a601d58d26)
(cherry picked from commit b511a441f3277750e68a14d8d7e6649c4f182b86)

4 years agoman/systemd.network: Fix duplicate Xfrm description
Raul Tambre [Wed, 14 Jul 2021 11:58:31 +0000 (14:58 +0300)]
man/systemd.network: Fix duplicate Xfrm description

It's already listed along with others (Tunnel, VLAN, etc.) and its description matches those. The duplication was introduced by commit c3006a485c9c35c0ab947479ff1dd7149fda9750.

(cherry picked from commit 534b5abce12847abc896fba24cafb99c101a2987)
(cherry picked from commit d4ce78bfa3d90cc4601d1cbb0b51af32fe8f4b2a)

4 years agoshared/format-table: allocate buffer of sufficient size
Zbigniew Jędrzejewski-Szmek [Mon, 5 Jul 2021 19:29:11 +0000 (21:29 +0200)]
shared/format-table: allocate buffer of sufficient size

(cherry picked from commit 6dc57047ff0f1f9e98938ffb172dae06e6868b94)
(cherry picked from commit e6407ca25852dadec355df2e6fdc92d1f189bceb)

4 years agohomed: allow systemd-homed access to FIDO2 devices
Gibeom Gwon [Mon, 12 Jul 2021 17:57:43 +0000 (02:57 +0900)]
homed: allow systemd-homed access to FIDO2 devices

Add DeviceAllow= option for FIDO2 devices in systemd-homed.service.

(cherry picked from commit 85e424c0c852fcb92d108494a6efa9dd0ce943b2)
(cherry picked from commit 727a03e4826efe1392b8a1899b220e7df7976990)

4 years agosystemctl: show error when help for unknown unit is requested
Zbigniew Jędrzejewski-Szmek [Mon, 12 Jul 2021 10:32:39 +0000 (12:32 +0200)]
systemctl: show error when help for unknown unit is requested

Fixes #20189. We would only log at debug level and return failure, which looks
like a noop for the user.

('help' accepts multiple arguments and will show multiple concatenated man
pages in that case. Actually, it will also show multiple concatenated man pages
if the Documentation= setting lists multiple pages. I don't think it's very
terribly useful, but, meh, I don't think we can do much better. If a user
requests a help for a two services, one known and one unknown, there'll now be
a line in the output. It's not very user friendly, but not exactly wrong too.)

(cherry picked from commit 75312ada5324d8adae3f3a0ed97f0acfc8b8bde5)
(cherry picked from commit 486412ad3bba4f1306597302cf66cc4858126243)

4 years agoUpdated manpage for sd_bus_set_property
Ben Stockett [Fri, 9 Jul 2021 20:29:36 +0000 (20:29 +0000)]
Updated manpage for sd_bus_set_property

Updated manpage for sd_bus_set_property and sd_bus_set_propertyv. In the old manpage, these functions included the parameter sd_bus_message **reply when the actual function had no such argument.

(cherry picked from commit 4226dfafbac2167e1441a7a65d00c29c5016d4fb)
(cherry picked from commit 70a318d012d5900ad16685038a1e9a30e9a2a41d)

4 years agoFixed typo (#20187)
nassir90 [Fri, 9 Jul 2021 20:16:02 +0000 (21:16 +0100)]
Fixed typo (#20187)

* Fixed typo

Before, the file claimed that some systemd units are created "from other
configuration". It should have read "from other configuration files".

Co-authored-by: Nozz <nozolo90@gmail.com>
(cherry picked from commit a814eae728a5e238e39d4a9d952ce8e309fa38fd)
(cherry picked from commit 5263490368b3f2c94935300bb5faa09cc04cb4cd)

4 years agotest: strip binaries by default
Frantisek Sumsal [Fri, 9 Jul 2021 12:59:11 +0000 (14:59 +0200)]
test: strip binaries by default

Since 23f8e01 we always kept binaries unstripped, since $STRIP_BINARIES
is unset by default.

(cherry picked from commit e68e473ba2d6383155c49337c3c5f2c0d3fb0b5f)
(cherry picked from commit b149c2c64a1093fd509a94d7a25f01b726798098)

4 years agotest: bump the test timeout to give ldconfig.service enough time to finish
Frantisek Sumsal [Fri, 9 Jul 2021 12:44:38 +0000 (14:44 +0200)]
test: bump the test timeout to give ldconfig.service enough time to finish

Sometimes the ldconfig.service might take a bit longer to finish,
causing spurious test timeouts:

```
[ 1025.858923] systemd[24]: ldconfig.service: Executing: /sbin/ldconfig -X
...
[ 1043.883620] systemd[1]: ldconfig.service: Main process exited, code=exited, status=0/SUCCESS (success)
...
Trying to halt container. Send SIGTERM again to trigger immediate
termination.
Container TEST-52-HONORFIRSTSHUTDOWN terminated by signal KILL.
E: Test timed out after 20s
```

(cherry picked from commit 7fb4ee7aa5b6ffdf2e1e8e50a18630aa30f16505)
(cherry picked from commit 610406767b8ddf23a27c919fe52922d35457e0d3)

4 years agodocs: improve wording when mentioning the acronym "ESP"
nl6720 [Fri, 9 Jul 2021 09:56:54 +0000 (12:56 +0300)]
docs: improve wording when mentioning the acronym "ESP"

"ESP" is "EFI system partition", so "ESP partition" is redundant.

(cherry picked from commit 250db1bf02b9fd73f2e0604acddbc20937c67d19)
(cherry picked from commit 6822cfa5f066fcbf79ded85419d59a97decc67b9)

4 years agohwdb: update to state from v249 v248.4
Zbigniew Jędrzejewski-Szmek [Mon, 12 Jul 2021 11:38:53 +0000 (13:38 +0200)]
hwdb: update to state from v249

This updates various "upstream" hwdb entries. The two new files that
were added in v249, and the associated udev rules, are not included in
this.

4 years agohwdb: allow parser to expect usage of slash sign in value of property
Takashi Sakamoto [Wed, 7 Apr 2021 02:49:22 +0000 (11:49 +0900)]
hwdb: allow parser to expect usage of slash sign in value of property

Although in IEEE 1394 unit function list I have a plan to use slash sign
in name of property, current implementation of parser doesn't allow it.
When parsing current entries in database excluded from parser testing, we
can find usage of slash sign in name of property.

This commit adds slash sign in allow list of the parser for my
convenience.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
(cherry picked from commit 5e939304f513ba57ce6595f36b7da641c62c60db)

4 years agohostnamed: correct variable with errno in fallback_chassis
Jan Palus [Wed, 7 Jul 2021 22:23:21 +0000 (00:23 +0200)]
hostnamed: correct variable with errno in fallback_chassis

fixes assertion failure on arm:

systemd-hostnamed[642]: Assertion '(_error) != 0' failed at src/hostname/hostnamed.c:207, function fallback_chassis(). Aborting.

(cherry picked from commit 105a4245ff13d588e1e848e8ee3cffd6185bd0ae)

4 years agomeson: install the right README file in modprobe.d
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jul 2021 10:39:33 +0000 (12:39 +0200)]
meson: install the right README file in modprobe.d

We put the "global" README file there. Introduced
in d83e90c73cf25a839f5e60f355baa0d38364ff41.

(cherry picked from commit 378e9d2b6d701a1385c4bf72dfc0697c2c37bd57)

4 years agoClarify the behaviour of suspend-then-sleep mode in the manual pages.
Hamish Moffatt [Mon, 5 Jul 2021 09:06:15 +0000 (19:06 +1000)]
Clarify the behaviour of suspend-then-sleep mode in the manual pages.

Fixes #20125.

(cherry picked from commit 33f899bd479534b0a920ce427cdf06739028f5ab)

4 years agoNEWS: add old entry about Type=ether
Zbigniew Jędrzejewski-Szmek [Wed, 7 Jul 2021 07:26:12 +0000 (09:26 +0200)]
NEWS: add old entry about Type=ether

Apparently it's an important feature for some folks:
https://utcc.utoronto.ca/\~cks/space/blog/linux/NetworkdMACMatchesWidely.
I think we considered this more of a bugfix, but it's somewhere on the border.
Let's add this it's easier to discover.

(cherry picked from commit 88b2a95064675c5f86648053cf124265f5289095)

4 years agooomd: don't collect candidate stats on every interval
Anita Zhang [Tue, 6 Jul 2021 09:46:13 +0000 (02:46 -0700)]
oomd: don't collect candidate stats on every interval

cb13961ada52c1b27f6d6c2c6e37a2901f01ed30 updated the oomd logic to
collect candidate data when a kill was about to happen. However there
was still a call left over in the main loop to collect candidate data on
every interval. Remove this since it's unneeded.

Fixes #20122

(cherry picked from commit d61ee727f037ab4e07af720ab34055e9cafe9cec)

4 years agotmpfiles: fix borked assert
Zbigniew Jędrzejewski-Szmek [Tue, 6 Jul 2021 14:41:28 +0000 (16:41 +0200)]
tmpfiles: fix borked assert

It seems that fd_set_perms() is always called after checking that
fd >= 0 (also when called as action() in glob_item_recursively()),
so it seems that the assertion really came from fd==0.

Fixes #20140.

Also three other similar cases are updated.

(cherry picked from commit b4b0f87c6275dde32769c2e75231caa1d4c21f9b)

4 years agoman: correct return value of sd_bus_open_with_description
Luca Boccassi [Tue, 6 Jul 2021 11:55:30 +0000 (12:55 +0100)]
man: correct return value of sd_bus_open_with_description

Since https://github.com/systemd/systemd/commit/f4b2933ee7890e5d414ab266d8586f19027a2bd9
if a description is not set, sd_bus_open_with_description returns -ENXIO, but the
documnetation stated that it returned successfully with a NULL string.

(cherry picked from commit 48e5ef14af5ade97b0f7491c63443778c7602c43)

4 years agounits: correct description of final.target
qhill [Fri, 2 Jul 2021 13:13:13 +0000 (14:13 +0100)]
units: correct description of final.target

This was updated incorrectly in https://github.com/systemd/systemd/pull/20058/commits/4fd3fc66396026f81fd5b27746f2faf8a9a7b9ee.  As https://github.com/systemd/systemd/blob/main/man/systemd.special.xml decribes, this unit is about shutdown rather than boot.

(cherry picked from commit f127fed75d3bae3a1eb0be6feea334bb8d1c3a43)

4 years agocoredumpctl: show --help text if "coredumpctl help" is called
Lennart Poettering [Fri, 2 Jul 2021 13:30:43 +0000 (15:30 +0200)]
coredumpctl: show --help text if "coredumpctl help" is called

Most of our programs that take "verbs" make the "help" verb either
equivalent to passing the --help switch (or at least print a message
redirecting the user to that switch). Do so in coredumpctl too, in order
to minimize surprises.

(cherry picked from commit 6d8be376e1682a79f0aecceb2136884c5b4327e2)

4 years agoudev: Fix by-uuid symlink for ubifs volumes
Trent Piepho [Thu, 1 Jul 2021 19:19:57 +0000 (12:19 -0700)]
udev: Fix by-uuid symlink for ubifs volumes

ubifs volumes have a UUID and the built-in blkid is able to determine
it.  The disk/by-uuid symlink isn't created because ubifs volumes are
not on block devices but on SUBSYSTEM="ubi" devices.  See #20071.

Allow ubi subsystem devices to be processed by the persistent storage
rules too.  The kernel device name matching already allows ubi* to pass.
The existing rules are sufficient to create the link.

The links look like other by-uuid symlinks, for example:
/dev/disk/by-uuid/9a136158-585b-4ba4-9b70-cbaf2cf78a1c -> ../../ubi0_1

(cherry picked from commit 21ac7884e9c1684d091d893254bcbe4b83740e9f)

4 years agooomd: review follow ups to #20020
Anita Zhang [Fri, 2 Jul 2021 00:07:32 +0000 (17:07 -0700)]
oomd: review follow ups to #20020

(cherry picked from commit e82acab4db6f5f212f6c9c9b3ec2df9010a83925)

4 years agoRevert "rules: ubi mtd - add link to named partitions"
Lennart Poettering [Thu, 1 Jul 2021 13:03:16 +0000 (15:03 +0200)]
Revert "rules: ubi mtd - add link to named partitions"

This reverts commit 7f1e9c806b6915e8020cf3706dc87e1cd37bc2fa, PR #6750

Apparently the rule change never worked, see #20071.

Fixes #20071

(cherry picked from commit 4b6bc397b454f79006481c1e8507d85c5bfd2e9a)

4 years agocore: add comment explaining event source deallocation
Zbigniew Jędrzejewski-Szmek [Thu, 1 Jul 2021 09:06:45 +0000 (11:06 +0200)]
core: add comment explaining event source deallocation

Followup for bc989831e6. The original reproducer still works w/o the unref,
and doesn't work with this change.

(cherry picked from commit 13bb1ffb912cacea4041910e38674e0984ac5772)

4 years agounits: adjust description of systemd-update-utmp.service
Zbigniew Jędrzejewski-Szmek [Wed, 30 Jun 2021 11:20:27 +0000 (13:20 +0200)]
units: adjust description of systemd-update-utmp.service

"Update about" is not gramatically correct. I also think saying "Record" makes
this easier to understand for people who don't necessarilly know what UTMP is.

(cherry picked from commit 2e32d390b0cb49a7fd074c50fab43c097c38d4f3)

4 years agounits: shorten description of kmod-static-nodes.service
Zbigniew Jędrzejewski-Szmek [Wed, 30 Jun 2021 10:54:31 +0000 (12:54 +0200)]
units: shorten description of kmod-static-nodes.service

As suggested in
https://github.com/systemd/systemd/pull/20058#pullrequestreview-695023490.

(cherry picked from commit 8ea257852998ee4b2ee7af18313a7af4e172535d)

4 years agounits: adjust Descriptions of various units
Zbigniew Jędrzejewski-Szmek [Tue, 29 Jun 2021 07:47:53 +0000 (09:47 +0200)]
units: adjust Descriptions of various units

In general, it's not very usuful to repeat the unit name as the description.
Especially when the word is a common name and if somebody doesn't understand
the meaning immediately, they are not going to gain anything from the
repeat either, e.g. "halt", "swap".

In the status-unit-format=combined output parentheses are used around
Description, so avoid using parenthesis in the Description itself.

(cherry picked from commit 4fd3fc66396026f81fd5b27746f2faf8a9a7b9ee)

4 years agologind, units: unit Descriptions should be capitalized
Zbigniew Jędrzejewski-Szmek [Tue, 29 Jun 2021 07:29:57 +0000 (09:29 +0200)]
logind, units: unit Descriptions should be capitalized

(cherry picked from commit 0a59216caebdf0488d1200cd818cb46361d1f17b)

4 years agocore: add default descriptions for slices
Zbigniew Jędrzejewski-Szmek [Tue, 29 Jun 2021 07:10:42 +0000 (09:10 +0200)]
core: add default descriptions for slices

[  OK  ] Created slice system-getty.slice (Slice /system/getty).
[  OK  ] Created slice system-modprobe.slice (Slice /system/modprobe).
[  OK  ] Created slice system-sshd\x2dkeygen.slice (Slice /system/sshd-keygen).
[  OK  ] Created slice user.slice (User and Session Slice).

Before, the first three slices were shown without any description which didn't
look nice.

(cherry picked from commit 4dd21726f852010aef17e9b952b4bb1646fdf496)

4 years agocore/service: rework management of exec_fd event source
Zbigniew Jędrzejewski-Szmek [Mon, 10 May 2021 11:12:53 +0000 (13:12 +0200)]
core/service: rework management of exec_fd event source

The code in service_spawn() was written as if exec_fd_event_source
was always unset. (We would either fail the assertion that is moved in the
patch, or leak the event source object if it was set.)

To make this work, let's always assert that exec_fd_event_source is unset,
and actually unset it service_sigchld_event(). I think this is the most
elegant approach. The problem is that we don't have the same information
about execution flags as in service_spawn(), so we need to conditionalize
on pid==main_pid to know if we should disable exec_fd_event_source.
I think this matches all cases where we may set exec_fd_event_source:
service_enter_start() and service_run_next_main().

service_enter_stop_post() calls service_set_state(), which will also destroy
the source. But that happens too late, because from service_enter_stop_post()
we call service_spawn() first, and then service_set_state() second.

(An alternative approach would be to deallocate the existing
exec_fd_event_source in service_spawn(). But this would mean that we would
temporarily have an event source attached to a process that we already know is
dead, which seems less than ideal.)

Original report from Dimitri John Ledkov <dimitri.ledkov@canonical.com>:
> Ubuntu private bug reference for this issue at the moment is
> https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1921145

> Michael's and Ian's team run into an issue when using systemd in the
> initrd, without dbus daemon running, and launching a unit in a
> particular way that appears to lock up systemd (pid 1) it self.

> michael vogt: "The attached script works for me to reproduce this on
> classic. I tested 20.04 (245) and 21.04 (247) in a qemu VM. Sometimes
> I need to run it multiple times but usually it crashes after at most 2
> runs. Use "journalctl | tail" to see the messages, it's the same that
> Ian reported. There is also a /var/crash/_usr_lib_systemd_systemd
> crash file created."

> I understand that the particular way to run a unit is very odd,
> however, it is currently possible to invoke, and it would be expected
> for pid1 to not lock up and crash.

> The Assertion that systemd hits is along the lines of:

> [ 10.182627] systemd[1]: Assertion 's' failed at
> src/core/service.c:3204, function service_dispatch_exec_io().
> Aborting.
> [ 10.195458] systemd[1]: Caught <ABRT>, dumped core as pid 449.
> [ 10.204446] systemd[1]: Freezing execution.

(cherry picked from commit bc989831e634123c2ff43bcbbeae19097ccc9ff9)

4 years agosd-event: add more asserts about event source integrity
Zbigniew Jędrzejewski-Szmek [Mon, 10 May 2021 08:23:08 +0000 (10:23 +0200)]
sd-event: add more asserts about event source integrity

Also "downgrade" assert_se() to assert(), this is not test code.

(cherry picked from commit 199475092d9a6f0482a7b934592784a54b82ffd0)

4 years agocore: disable event sources before unreffing them
Zbigniew Jędrzejewski-Szmek [Mon, 10 May 2021 08:22:07 +0000 (10:22 +0200)]
core: disable event sources before unreffing them

This mirrors the change done for systemd-resolved in
97935302283729c9206b84f5e00b1aff0f78ad19. Quoting that patch:

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

In particular, we take temporary references from sd-event code, and when called
from an sd-event callback, we could temporarily see this elevated reference
count. This patch doesn't seem to change anything, but I think it's nicer to do
the same change as in other places and not rely on _unref() immediately
disabling the source.

(cherry picked from commit 5dcadb4c8320f6a7b8a9353404874d43668e4648)

4 years agoRevert "core: do not set noexec on sysfs/procfs"
Lennart Poettering [Mon, 1 Mar 2021 17:02:24 +0000 (18:02 +0100)]
Revert "core: do not set noexec on sysfs/procfs"

This reverts commit b33cd6b3eec52fc50c6c34d6f07a41cc6254c27f.

(cherry picked from commit 988bcc7c21a07acc08f9343b52b492b98b08444a)

4 years agocore/cgroup: upgrade log level when we fail to rescope a pid
Zbigniew Jędrzejewski-Szmek [Wed, 30 Jun 2021 15:17:41 +0000 (17:17 +0200)]
core/cgroup: upgrade log level when we fail to rescope a pid

See https://bugzilla.redhat.com/show_bug.cgi?id=1973058 again:

systemd[1779]: Started Application launched by gnome-session-binary.
systemd[1779]: app-glib-liveinst\x2dsetup-1897.scope: Failed to add PIDs to scope's control group: No such process
systemd[1779]: app-glib-liveinst\x2dsetup-1897.scope: Failed with result 'resources'.
systemd[1779]: Failed to start Application launched by gnome-session-binary.
systemd[1779]: app-glib-xdg\x2duser\x2ddirs-1900.scope: Failed to add PIDs to scope's control group: No such process
systemd[1779]: app-glib-xdg\x2duser\x2ddirs-1900.scope: Failed with result 'resources'.
systemd[1779]: Failed to start Application launched by gnome-session-binary.
systemd[1779]: app-gnome-gsettings\x2ddata\x2dconvert-1902.scope: Failed to add PIDs to scope's control group: No such process
systemd[1779]: app-gnome-gsettings\x2ddata\x2dconvert-1902.scope: Failed with result 'resources'.
systemd[1779]: Failed to start Application launched by gnome-session-binary.

Since we don't show the PID anywhere, it can be quite hard to figure out what
is going on. There may be logs from the pid above or below in the log, but
we have no PID number to identify them. So let's upgrade the log from
unit_attach_pids_to_cgroup() to tell us precisely which PIDs and why couldn't
be handled.

(cherry picked from commit 7a2ba4078731a00fa105c38c283b2ce7789bb512)

4 years agocore: emit nicer log message for exiting ConditionExec processes
Zbigniew Jędrzejewski-Szmek [Wed, 30 Jun 2021 15:02:45 +0000 (17:02 +0200)]
core: emit nicer log message for exiting ConditionExec processes

See https://bugzilla.redhat.com/show_bug.cgi?id=1973058:

we would log something like:
systemd[244]: Starting willskip.service...
systemd[244]: willskip.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
systemd[244]: willskip.service: Skipped due to 'exec-condition'.
systemd[244]: Condition check resulted in willskip.service being skipped.

The line with 'Control process exited' would be at LOG_NOTICE level.

With the patch:
systemd[244]: Starting willskip.service...
systemd[244]: willskip.service: Skipped due to 'exec-condition'.
systemd[244]: Condition check resulted in willskip.service being skipped.

Debug logs:
systemd[244]: Starting willskip.service...
systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/willskip_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=8 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/willskip_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=9 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/job/46 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=10 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
systemd[11020]: Skipping PR_SET_MM, as we don't have privileges.
systemd[11020]: willskip.service: Executing: sh -c 'exit 2'
systemd[244]: Received SIGCHLD from PID 11020 (sh).
systemd[244]: Child 11020 (sh) died (code=exited, status=2/INVALIDARGUMENT)
systemd[244]: willskip.service: Child 11020 belongs to willskip.service.
systemd[244]: willskip.service: Condition check process exited, code=exited, status=2/INVALIDARGUMENT (success)
systemd[244]: willskip.service: Got final SIGCHLD for state condition.
systemd[244]: willskip.service: Skipped due to 'exec-condition'.
systemd[244]: willskip.service: Service will not restart (restart setting)
systemd[244]: willskip.service: Changed condition -> dead
systemd[244]: willskip.service: Job 46 willskip.service/start finished, result=done
systemd[244]: Condition check resulted in willskip.service being skipped.

(cherry picked from commit 58441bc177bb1bcdeceff74d3ae6b6d9f93a7fbe)

4 years agooomd: check mem free and swap free before doing a swap-based kill
Anita Zhang [Thu, 24 Jun 2021 21:58:40 +0000 (14:58 -0700)]
oomd: check mem free and swap free before doing a swap-based kill

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

4 years agooomd: get memory total and free as part of system context
Anita Zhang [Thu, 24 Jun 2021 10:11:07 +0000 (03:11 -0700)]
oomd: get memory total and free as part of system context

(cherry picked from commit eeeaa422845a045bded6c44732d5e9b025084011)

4 years agooomd: switch system context parsing to use /proc/meminfo
Anita Zhang [Thu, 24 Jun 2021 09:37:57 +0000 (02:37 -0700)]
oomd: switch system context parsing to use /proc/meminfo

Makes it easier in the next commits to unify on one way to read swap and
memory info.

(cherry picked from commit 47136b9d9a75fff5f9e2e777aaed736e6f66c7f7)

4 years agocore: when recursively bind-remounting nested mounts, use options from top one
Luca Boccassi [Wed, 30 Jun 2021 14:51:03 +0000 (15:51 +0100)]
core: when recursively bind-remounting nested mounts, use options from top one

When mount points are stacked, bind_remount_recursive_with_mountinfo()
uses the existing mount options of the "lower" level mount (ie: the
first one that was mounted on a mount point). But the actual mount
point in use is the "top" one (ie: the last one that was mounted on a
mount point), so in practice if the mount options are different between
the layers, the bottom options are used by mistake on the top mount,
which is not what we want. This is because libmount returns the "bottom"
one first.

If the hashmap returns EEXIST, which means the same key (path) with different
value (options) is already present, update the hashmap instead of discarding
the result. This way, the last/top mount options are always used when
mounts are stacked on a mount point.

This was found to cause problems as LXC version 4.x stacks two /sys mounts,
the bottom one read-write and the top one read-only. systemd accidentally
remounts the top-one read-write, breaking various expectations since a
read-only /sys is the way we decide whether we are running in a container
or not (in this particular case, networkd tests are broken as networkd
expects to be able to modify network settings with a writable /sys).

Future versions of LXC will no longer do this double-stacking, but we
need to support running inside older versions too.

This was triggered by https://github.com/systemd/systemd/commit/6720e356c137
as that causes a recursive remount of '/', which processes '/sys' as one
of the submounts, from make_nosuid(). But it's likely that other combinations
of options could trigger this as well.

Before:

root@systemd-debug:/# systemd-run -t --wait --property ProtectSystem=yes findmnt
Running as unit: run-u9.service
Press ^] three times within 1s to disconnect TTY.
TARGET                         SOURCE                           FSTYPE    OPTIONS
/                              /dev/sda2[/var/lib/lxc/systemd-debug/rootfs]
│                                                               ext4      ro,nosuid,relatime,errors=remount-ro,stripe=
├─/dev                         none                             tmpfs     rw,nosuid,relatime,size=492k,mode=755
│ ├─/dev/.lxc/proc             proc                             proc      rw,nosuid,relatime
│ ├─/dev/.lxc/sys              sys                              sysfs     rw,nosuid,relatime
│ ├─/dev/console               devpts[/2]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/pts                   devpts                           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/ptmx                  devpts[/ptmx]                    devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty1                  devpts[/0]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty2                  devpts[/1]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty3                  devpts[/2]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/tty4                  devpts[/3]                       devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptm
│ ├─/dev/shm                   tmpfs                            tmpfs     rw,nosuid,nodev
│ ├─/dev/hugepages             hugetlbfs                        hugetlbfs rw,nosuid,relatime,pagesize=2M
│ └─/dev/mqueue                mqueue                           mqueue    rw,nosuid,nodev,noexec,relatime
├─/proc                        proc                             proc      rw,nosuid,nodev,noexec,relatime
│ ├─/proc/sys                  proc[/sys]                       proc      ro,nosuid,nodev,noexec,relatime
│ │ ├─/proc/sys/net            proc[/sys/net]                   proc      rw,nosuid,nodev,noexec,relatime
│ │ └─/proc/sys/kernel/random/boot_id
│ │                            none[/.lxc-boot-id]              tmpfs     ro,nosuid,nodev,noexec,relatime,size=492k,mo
│ └─/proc/sysrq-trigger        proc[/sysrq-trigger]             proc      ro,nosuid,nodev,noexec,relatime
├─/sys                         sysfs                            sysfs     rw,nosuid,nodev,noexec,relatime
│ └─/sys                       sysfs                            sysfs     rw,nosuid,nodev,noexec,relatime
│   ├─/sys/devices/virtual/net sysfs                            sysfs     rw,relatime
│   │ └─/sys/devices/virtual/net
│   │                          sysfs[/devices/virtual/net]      sysfs     rw,nosuid,relatime
│   ├─/sys/fs/fuse/connections fusectl                          fusectl   rw,nosuid,nodev,noexec,relatime
│   └─/sys/fs/cgroup           cgroup                           cgroup2   rw,nosuid,nodev,noexec,relatime,nsdelegate,m
├─/run                         tmpfs                            tmpfs     ro,nosuid,nodev,size=4912348k,nr_inodes=8192
│ ├─/run/credentials           tmpfs[/systemd/inaccessible/dir] tmpfs     ro,nosuid,nodev,noexec,size=4912348k,nr_inod
│ └─/run/systemd/incoming      tmpfs[/systemd/propagate/run-u9.service]
│                                                               tmpfs     ro,nosuid,nodev,size=4912348k,nr_inodes=8192
├─/tmp                         tmpfs                            tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409
│ └─/tmp                       tmpfs[/systemd-private-b730df90da424397a3f246cb15dcdbb1-run-u9.service-K6EUwf/tmp]
│                                                               tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409
└─/var/tmp                     /dev/sda2[/var/lib/lxc/systemd-debug/rootfs/var/tmp/systemd-private-b730df90da424397a3f246cb15dcdbb1-run-u9.service-vEHyRi/tmp]
                                                                ext4      rw,nosuid,relatime,errors=remount-ro,stripe=
Finished with result: success
Main processes terminated with: code=exited/status=0
Service runtime: 14.249s
CPU time consumed: 37ms

After:

root@systemd-debug:/# systemd-run -t --wait --property ProtectSystem=yes findmnt
Running as unit: run-u3.service
Press ^] three times within 1s to disconnect TTY.
TARGET                         SOURCE                      FSTYPE    OPTIONS
/                              /dev/sda2[/var/lib/lxc/systemd-debug/rootfs]
│                                                          ext4      rw,relatime,errors=remount-ro,stripe=32699
├─/dev                         none                        tmpfs     rw,relatime,size=492k,mode=755
│ ├─/dev/.lxc/proc             proc                        proc      rw,relatime
│ ├─/dev/.lxc/sys              sys                         sysfs     rw,relatime
│ ├─/dev/console               devpts[/2]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/pts                   devpts                      devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/ptmx                  devpts[/ptmx]               devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty1                  devpts[/0]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty2                  devpts[/1]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty3                  devpts[/2]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/tty4                  devpts[/3]                  devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode
│ ├─/dev/shm                   tmpfs                       tmpfs     rw,nosuid,nodev
│ ├─/dev/hugepages             hugetlbfs                   hugetlbfs rw,relatime,pagesize=2M
│ └─/dev/mqueue                mqueue                      mqueue    rw,nosuid,nodev,noexec,relatime
├─/proc                        proc                        proc      rw,nosuid,nodev,noexec,relatime
│ ├─/proc/sys                  proc[/sys]                  proc      ro,nosuid,nodev,noexec,relatime
│ │ ├─/proc/sys/net            proc[/sys/net]              proc      rw,nosuid,nodev,noexec,relatime
│ │ └─/proc/sys/kernel/random/boot_id
│ │                            none[/.lxc-boot-id]         tmpfs     ro,nosuid,nodev,noexec,relatime,size=492k,mode=75
│ └─/proc/sysrq-trigger        proc[/sysrq-trigger]        proc      ro,nosuid,nodev,noexec,relatime
├─/sys                         sysfs                       sysfs     rw,nosuid,nodev,noexec,relatime
│ └─/sys                       sysfs                       sysfs     ro,nosuid,nodev,noexec,relatime
│   ├─/sys/devices/virtual/net sysfs                       sysfs     rw,relatime
│   │ └─/sys/devices/virtual/net
│   │                          sysfs[/devices/virtual/net] sysfs     rw,nosuid,nodev,noexec,relatime
│   ├─/sys/fs/fuse/connections fusectl                     fusectl   rw,nosuid,nodev,noexec,relatime
│   └─/sys/fs/cgroup           cgroup                      cgroup2   rw,nosuid,nodev,noexec,relatime,nsdelegate,memory
├─/run                         tmpfs                       tmpfs     rw,nosuid,nodev,size=4912348k,nr_inodes=819200,mo
│ ├─/run/credentials           tmpfs[/systemd/inaccessible/dir]
│ │                                                        tmpfs     ro,nosuid,nodev,noexec,size=4912348k,nr_inodes=81
│ └─/run/systemd/incoming      tmpfs[/systemd/propagate/run-u3.service]
│                                                          tmpfs     ro,nosuid,nodev,size=4912348k,nr_inodes=819200,mo
├─/tmp                         tmpfs                       tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409600
├─/boot                        /dev/sda2[/var/lib/lxc/systemd-debug/rootfs/boot]
│                                                          ext4      ro,relatime,errors=remount-ro,stripe=32699
└─/usr                         /dev/sda2[/var/lib/lxc/systemd-debug/rootfs/usr]
                                                           ext4      ro,relatime,errors=remount-ro,stripe=32699
Finished with result: success
Main processes terminated with: code=exited/status=0
Service runtime: 14ms
CPU time consumed: 5ms

Host (LXC):

root@systemd-debug:/# findmnt
TARGET                         SOURCE               FSTYPE    OPTIONS
/                              /dev/sda2[/var/lib/lxc/systemd-debug/rootfs]
│                                                   ext4      rw,relatime,errors=remount-ro,stripe=32699
├─/run                         tmpfs                tmpfs     rw,nosuid,nodev,size=4912348k,nr_inodes=819200,mode=755
├─/tmp                         tmpfs                tmpfs     rw,nosuid,nodev,size=12280872k,nr_inodes=409600
├─/dev                         none                 tmpfs     rw,relatime,size=492k,mode=755
│ ├─/dev/pts                   devpts               devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/ptmx                  devpts[/ptmx]        devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty1                  devpts[/0]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty2                  devpts[/1]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty3                  devpts[/2]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/tty4                  devpts[/3]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,ma
│ ├─/dev/shm                   tmpfs                tmpfs     rw,nosuid,nodev
│ ├─/dev/hugepages             hugetlbfs            hugetlbfs rw,relatime,pagesize=2M
│ ├─/dev/mqueue                mqueue               mqueue    rw,nosuid,nodev,noexec,relatime
│ ├─/dev/console               devpts[/2]           devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/.lxc/proc             proc                 proc      rw,relatime
│ └─/dev/.lxc/sys              sys                  sysfs     rw,relatime
├─/proc                        proc                 proc      rw,nosuid,nodev,noexec,relatime
│ ├─/proc/sys                  proc[/sys]           proc      ro,nosuid,nodev,noexec,relatime
│ │ ├─/proc/sys/kernel/random/boot_id
│ │ │                          none[/.lxc-boot-id]  tmpfs     ro,nosuid,nodev,noexec,relatime,size=492k,mode=755
│ │ └─/proc/sys/net            proc[/sys/net]       proc      rw,nosuid,nodev,noexec,relatime
│ └─/proc/sysrq-trigger        proc[/sysrq-trigger] proc      ro,nosuid,nodev,noexec,relatime
└─/sys                         sysfs                sysfs     rw,nosuid,nodev,noexec,relatime
  └─/sys                       sysfs                sysfs     ro,nosuid,nodev,noexec,relatime
    ├─/sys/devices/virtual/net sysfs                sysfs     rw,relatime
    │ └─/sys/devices/virtual/net
    │                          sysfs[/devices/virtual/net]
    │                                               sysfs     rw,nosuid,nodev,noexec,relatime
    ├─/sys/fs/fuse/connections fusectl              fusectl   rw,nosuid,nodev,noexec,relatime
    └─/sys/fs/cgroup           cgroup               cgroup2   rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recurs

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

(cherry picked from commit e01030633c73d3974390292bba381aca1224709b)

4 years agoImprove tmpfiles unsafe transition log message (#20048)
Albert Brox [Wed, 30 Jun 2021 09:54:15 +0000 (05:54 -0400)]
Improve tmpfiles unsafe transition log message (#20048)

(cherry picked from commit f1bda7ead20c210a28be5decad636e1d95d8c3ec)

4 years agoman/dnssec-trust-anchors: update comment syntax description
Zbigniew Jędrzejewski-Szmek [Sun, 27 Jun 2021 13:49:28 +0000 (15:49 +0200)]
man/dnssec-trust-anchors: update comment syntax description

Let's just use the same phrase as in systemd.syntax(7).
Fixes #20045.

(cherry picked from commit 0b497bc46f4599906e153c1613b32fbb4e4f129e)

4 years agoresolved: Fix link to resolv.conf manpage
Raul Tambre [Tue, 29 Jun 2021 08:49:56 +0000 (11:49 +0300)]
resolved: Fix link to resolv.conf manpage

Seems to typically located in volume 5 these days on Linux systems that systemd targets.

(cherry picked from commit 12c0bb31a7c20663bf10a2effe498332400de92c)

4 years agoresolved: do not try to copy empty NSEC types bitmaps
Alexander Tsoy [Mon, 28 Jun 2021 20:00:11 +0000 (23:00 +0300)]
resolved: do not try to copy empty NSEC types bitmaps

dns_resource_record_copy() assumes that NSEC types bitmap is non-empty
which results in a null pointer dereference inside bitmap_copy() in some
cases. Fix this by calling bitmap_copy() conditionally.

(cherry picked from commit 1f00a50c695fe3b55dee38fbd02a902a6c703c87)

4 years agosd-device: allow to read sysattr which contains embedded NUL
Yu Watanabe [Sat, 26 Jun 2021 01:40:07 +0000 (10:40 +0900)]
sd-device: allow to read sysattr which contains embedded NUL

This effectively reverts the commit 2a394d0bf2f0afd8b9ed5faeb33f23459e3c6504.

But drop trailing '\r' of the read value, as sd_device_set_sysattr_value() drops it.

Fixes #20025.

(cherry picked from commit 70160c6eeee07ac6aa817826d13e8eff9563ce1e)

4 years agoman: fix incorrect description regarding DynamicUser= and StateDirectory=
dgcampea [Sat, 26 Jun 2021 12:23:20 +0000 (13:23 +0100)]
man: fix incorrect description regarding DynamicUser= and StateDirectory=

(cherry picked from commit e8f4bf33d8a6123ad8ae3955c989e36972f4884d)

4 years agoudev-test: add a testcase for string_escape=replace
Yu Watanabe [Sat, 26 Jun 2021 15:02:24 +0000 (00:02 +0900)]
udev-test: add a testcase for string_escape=replace

(cherry picked from commit 33989b967e30acc3f29f9cf9af3eec1817fd508e)

4 years agoudev: fix use of invalid pointer
Yu Watanabe [Sat, 26 Jun 2021 14:34:59 +0000 (23:34 +0900)]
udev: fix use of invalid pointer

Fixes a bug introduced by ea0f4578a7e90f5227817058bfb11bb91dbb1431.

Fixes CID#1457766.

(cherry picked from commit 7db6b672752ec7335ade74c7a7c52e5fc684c97a)

4 years agodbus-socket: fix check of Listen* arguments
Zbigniew Jędrzejewski-Szmek [Wed, 23 Jun 2021 16:10:57 +0000 (18:10 +0200)]
dbus-socket: fix check of Listen* arguments

We checked the wrong field, which was always NULL here, so we would always
reject the assignment. We would also print the wrong string in the error
message:

$ sudo systemd-run --socket-property ListenFIFO=/tmp/fifo3 cat
Failed to start transient socket unit: Invalid socket path: FIFO

(cherry picked from commit aeecab3804aae973577f36880af4b7799e4eb7d5)

4 years agoremove a left-over break
David Tardon [Fri, 25 Jun 2021 08:42:53 +0000 (10:42 +0200)]
remove a left-over break

By the "same logic as above...", we want to continue to fallback here,
but the break prohibits that.

This is a follow-up for ee1aa61c4710ae567a2b844e0f0bb8cb0456ab8c .

(cherry picked from commit 99df1cb6f50875db513a5b45f18191460a150f3d)

4 years agoresolvectl: Only strip ifname suffixes when being resolvconf
Mike Crowe [Thu, 24 Jun 2021 14:25:58 +0000 (15:25 +0100)]
resolvectl: Only strip ifname suffixes when being resolvconf

Only treat interface names containing dots specially when resolvectl is
pretending to be resolvconf to fix
https://github.com/systemd/systemd/issues/20014 .

Move the special suffix-stripping behaviour of ifname_mangle out to the
new ifname_resolvconf_mangle to be called from resolvconf only.

(cherry picked from commit 7875170f01991a1d28cfe284cc7075630cd69055)

4 years agoudev: remove unsafe characters from ID_SERIAL for nvme
Yu Watanabe [Wed, 14 Apr 2021 06:50:36 +0000 (15:50 +0900)]
udev: remove unsafe characters from ID_SERIAL for nvme

Fixes #19309.

(cherry picked from commit 5118e8e71dda211d20e34ec8d3012186ba27d3d3)

4 years agoman: update description of "string_escape=" udev option
Yu Watanabe [Wed, 23 Jun 2021 07:58:20 +0000 (16:58 +0900)]
man: update description of "string_escape=" udev option

(cherry picked from commit 91c27ac686261fcca913ac6e3fe1520f38440dcb)

4 years agoudev: fix key name in debug log
Yu Watanabe [Wed, 23 Jun 2021 07:33:14 +0000 (16:33 +0900)]
udev: fix key name in debug log

(cherry picked from commit 51c2f543d1474c2615fb8282ea90b2954db33a7e)

4 years agoudev: replace unsafe characters on assigning ENV{key}="val" when OPTIONS="string_esca...
Yu Watanabe [Wed, 14 Apr 2021 06:13:54 +0000 (15:13 +0900)]
udev: replace unsafe characters on assigning ENV{key}="val" when OPTIONS="string_escape=replace" is set

Strictly speaking, this breaks backward compatibility, as previously
`ENV{key}="val"` ignored `string_escape=` option. But, introducing
a new option such as `string_escape=hoge` sounds overkill for me.
The default escape mode is `ESCAPE_UNSET`, so I hope this merely break
existing rules.

(cherry picked from commit ea0f4578a7e90f5227817058bfb11bb91dbb1431)

4 years agodocs: update autofs Kconfig name
Andrea Pappacoda [Thu, 24 Jun 2021 15:30:51 +0000 (17:30 +0200)]
docs: update autofs Kconfig name

(cherry picked from commit 0c651d32d49e66ea0152eea5e65dd19fe01e7a06)

4 years agoman/50-xdg-data-dirs: add quotes as suggested by shellcheck
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jun 2021 07:06:11 +0000 (09:06 +0200)]
man/50-xdg-data-dirs: add quotes as suggested by shellcheck

(cherry picked from commit aa45911b793255bec34fe8c128c80bda1482cc14)

4 years agosd-journal: add missing bracket in journal verify log message
Lennart Poettering [Thu, 24 Jun 2021 11:13:39 +0000 (13:13 +0200)]
sd-journal: add missing bracket in journal verify log message

(cherry picked from commit 6abd991c718dbc1480ab7e71103a8b3e886bd3a3)

4 years agosd-dhcp-client: tentatively ignore FORCERENEW command
Yu Watanabe [Wed, 23 Jun 2021 16:22:07 +0000 (01:22 +0900)]
sd-dhcp-client: tentatively ignore FORCERENEW command

This makes DHCP client ignore FORCERENEW requests, as unauthenticated
FORCERENEW requests causes a security issue (TALOS-2020-1142, CVE-2020-13529).

Let's re-enable this after RFC3118 (Authentication for DHCP Messages)
and/or RFC6704 (Forcerenew Nonce Authentication) are implemented.

Fixes #16774.

(cherry picked from commit 38e980a6a5a3442c2f48b1f827284388096d8ca5)

4 years agocompletion: fix 'unbound variables' errors
Luca Boccassi [Tue, 22 Jun 2021 13:56:19 +0000 (14:56 +0100)]
completion: fix 'unbound variables' errors

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

(cherry picked from commit 36ec026830c6978be8bd39f3c6d1d7822495e07f)

4 years agocompletion/systemd-delta,-resolve: autocomplete with parameters
Luca Boccassi [Tue, 22 Jun 2021 13:55:22 +0000 (14:55 +0100)]
completion/systemd-delta,-resolve: autocomplete with parameters

(cherry picked from commit 6a0667d2b6f05682c2ced1b53132274049b9ea5c)

4 years agonetworkd: Permit all-zero RoutingPolicyRule prefixes
Hristo Venev [Tue, 22 Jun 2021 09:29:03 +0000 (12:29 +0300)]
networkd: Permit all-zero RoutingPolicyRule prefixes

For example this `From` address range is no longer ignored:

    [RoutingPolicyRule]
    From=0.0.0.0/8

(cherry picked from commit 2e8a32afbc300e0fe6b624174cd3f3d03467fed8)

4 years agotime-util: don't use plural units indiscriminately
Anders Wenhaug [Sun, 20 Jun 2021 19:43:07 +0000 (21:43 +0200)]
time-util: don't use plural units indiscriminately

format_timestamp_relative currently returns the plural form of
years and months no matter the quantity, and in many cases (for
durations > 1 week) this is the same with days.

This patch changes this so that the function takes the quantity into account,
returning "1 month 1 week ago" instead of "1 months 1 weeks ago".

(cherry picked from commit 45eb4d2261ed0d943fd503a6d79ee3b7b7558c09)

4 years agoUpdate systemd-resolved.service.8 help
plattrap [Fri, 18 Jun 2021 00:32:02 +0000 (12:32 +1200)]
Update systemd-resolved.service.8 help

Text currently refers to `/etc/nsswitch.conf` where it should refer to `/etc/resolv.conf`.
This is in the context of defining a nameserver IP and search domains.

(cherry picked from commit e83580bfc6e74359ba242d5176d933ea1e723f89)

4 years agoshell-completion: revert c1072f6473bafa063cbf700c86524083d2857031
Eric Cook [Wed, 16 Jun 2021 19:35:12 +0000 (15:35 -0400)]
shell-completion: revert c1072f6473bafa063cbf700c86524083d2857031
fixing https://github.com/systemd/systemd/issues/19689

(cherry picked from commit 682e043c42fe3ac0fee4ce727458aaeb0e638589)

4 years agocore: Hide "Deactivated successfully" message
Jan Macku [Thu, 27 May 2021 10:25:51 +0000 (12:25 +0200)]
core: Hide "Deactivated successfully" message

Show message "Deactivated successfully" in debug mode (when manager is
user) rather than in info mode. This message has low information value
for regular users and it might be a bit overwhelming on a system with
a lot of devices.

(cherry picked from commit edf2ee22f54005d76b2fb8fdcc9c60974feb88bc)

4 years agoman: fix RFC number and its title
Yu Watanabe [Wed, 16 Jun 2021 01:32:28 +0000 (10:32 +0900)]
man: fix RFC number and its title

(cherry picked from commit f4c48492fe3dfa268b6d2457c9ae425b685ca4e0)

4 years agoseccomp: drop quotactl_path() again from filter sets
Lennart Poettering [Tue, 15 Jun 2021 07:17:12 +0000 (09:17 +0200)]
seccomp: drop quotactl_path() again from filter sets

In the light of https://lwn.net/Articles/859679/ let's drop
quotactl_path() again from the filter set list, as it got backed out
again in 5.13-rc3.

It's likely going to be replaced by quotactl_fd() eventually, but that
hasn't made its way into the tree yet, hence let's not replace the entry
for now.

This partially reverts 34254e599a28529bdb89f91571adeaf7c76d9f43.

(cherry picked from commit 8156422c8f0d94d3444043282f01551084271b22)

4 years agosyscalls: update tables
Yu Watanabe [Tue, 15 Jun 2021 10:07:11 +0000 (19:07 +0900)]
syscalls: update tables

(cherry picked from commit d34e3b76e515af99b97a2b96c799c6889ffe6f71)

4 years agosyscalls: run ninja update-syscall-*
Lennart Poettering [Wed, 9 Jun 2021 09:40:14 +0000 (11:40 +0200)]
syscalls: run ninja update-syscall-*

(cherry picked from commit 5156e6804db9deaf1abe641b0563ee1110b4187c)

4 years agocore/service: fix assertion when Type=dbus but BusName= is not specified
Yu Watanabe [Mon, 14 Jun 2021 18:04:06 +0000 (03:04 +0900)]
core/service: fix assertion when Type=dbus but BusName= is not specified

Fixes #19920.

(cherry picked from commit 0f97b7c338bb7440572c454558efb8fee395896a)

4 years agocore: Avoid spurious realization of unit cgroups
Michal Koutný [Thu, 10 Jun 2021 13:58:43 +0000 (15:58 +0200)]
core: Avoid spurious realization of unit cgroups

Cgroups may be unnecessarily realized when they are not needed. This
happens, e.g. for mount units parsed from /proc/$PID/mountinfo, check

        touch /run/ns_mount
        unshare -n sh -c "mount --bind /proc/self/ns/net /run/ns_mount"
        # no cgroup exists
        file /sys/fs/cgroup/system.slice/run-ns_mount.mount
        systemctl daemon-reload
        # the vain cgroup exists
        file /sys/fs/cgroup/system.slice/run-ns_mount.mount

. (Such cgroups can account to a large number with many similar mounts.)

The code already accounts for "lazy" realization (see various checks for
Unit.cgroup_realized) but the unit_deserialize() in the reload/reexec
path performs unconditional realization.

Invalidate (and queue) the units for realization only if we know that
they were already realized in the past. This is a safe thing to do even
in the case the reload brings some new cgroup setting (controllers, BPF)
because units that aren't realized will use the updated setting when the
time for their realization comes. (It's not even needed to add a code
comment because the current formulation suggests the changed behavior.)

(cherry picked from commit cc815b7fea0ade5331e8dd22ef6b5183edb77608)

4 years agoman: clarify that global search domains apply to global servers, not all interfaces
Zbigniew Jędrzejewski-Szmek [Fri, 11 Jun 2021 07:13:25 +0000 (09:13 +0200)]
man: clarify that global search domains apply to global servers, not all interfaces

Fixes #19257.

(cherry picked from commit dbb3b26f1b347f9d7b9fd56aa4ef4a92253e6f2e)

4 years agosd-event: change ordering of pending/ratelimited events
Lennart Poettering [Tue, 8 Jun 2021 07:07:51 +0000 (00:07 -0700)]
sd-event: change ordering of pending/ratelimited events

Instead of ordering non-pending before pending we should order
"non-pending OR ratelimited" before "pending AND not-ratelimited".
This fixes a bug where ratelimited events were ordered at the end of the
priority queue and could be stuck there for an indeterminate amount of
time.

(cherry picked from commit 81107b8419c39f726fd2805517a5b9faab204e59)

4 years agokbd-model-map: add Latvian keyboard layout mapping
nl6720 [Thu, 10 Jun 2021 06:40:04 +0000 (09:40 +0300)]
kbd-model-map: add Latvian keyboard layout mapping

(cherry picked from commit 9dfb429a44b0c7e4c50f35f888ac8ba3c677a994)

4 years agoman: add note about operation without swap in systemd-oomd
Anita Zhang [Thu, 10 Jun 2021 04:55:38 +0000 (21:55 -0700)]
man: add note about operation without swap in systemd-oomd

(cherry picked from commit c48bc311a57aff76b592cc1569ca758b84438ef5)

4 years agoClarify help information for --global
nerdopolis [Wed, 9 Jun 2021 13:00:02 +0000 (09:00 -0400)]
Clarify help information for --global

(cherry picked from commit 3c3335c7146a43137c46acfa18417cca101cb088)

4 years agoman: add missing settings
Yu Watanabe [Wed, 9 Jun 2021 19:45:54 +0000 (04:45 +0900)]
man: add missing settings

Fixes #19869.

(cherry picked from commit c3006a485c9c35c0ab947479ff1dd7149fda9750)

4 years agoman: merge several settings about netdev
Yu Watanabe [Wed, 9 Jun 2021 19:41:08 +0000 (04:41 +0900)]
man: merge several settings about netdev

(cherry picked from commit 85bc4c080d8264c7d7e233c9e0f304c8d650f126)

4 years agoman: fix missing markdown & minor errors
Peter Morrow [Wed, 9 Jun 2021 17:04:08 +0000 (18:04 +0100)]
man: fix missing markdown & minor errors

In #19771 there were a few missing markdown tags a few style issue.

Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
(cherry picked from commit dbb8b5bcf78a86020287f98a8d96780af0203672)

4 years agojournal: don't try to reuse already calculated hash between files with keyed hash...
Lennart Poettering [Tue, 8 Jun 2021 21:17:53 +0000 (23:17 +0200)]
journal: don't try to reuse already calculated hash between files with keyed hash feature

When suppressing duplicate fields between files we so far tried to reuse
the already known hash value of the data fields between files. This was
fine as long as we used the same hash function everywhere. However,
since addition of the keyed hash feature for journal files this doesn't
work anymore, since the hashes will be different for different files.

Fixes: #19172
(cherry picked from commit 2e1a8a5dab8b5519c079c9bed54fc682aa4095b0)

4 years agojournal: add some careful overflow checking
Lennart Poettering [Tue, 8 Jun 2021 20:14:40 +0000 (22:14 +0200)]
journal: add some careful overflow checking

(cherry picked from commit d8671b1c6f036ce270b9631973314e7de24e74b1)

4 years agoseccomp: add some recently added syscalls to filter groups
Lennart Poettering [Wed, 9 Jun 2021 09:56:00 +0000 (11:56 +0200)]
seccomp: add some recently added syscalls to filter groups

(cherry picked from commit 34254e599a28529bdb89f91571adeaf7c76d9f43)

4 years agojournald: when journald namespace instances log, they can do so safely to the main...
Lennart Poettering [Tue, 8 Jun 2021 17:43:47 +0000 (19:43 +0200)]
journald: when journald namespace instances log, they can do so safely to the main journald instance

Fixes: #18951
(cherry picked from commit e68778a3ac30932a5fa86d08605b423d711ddb7c)

4 years agotest-libcrypt-util: print out default for password settings, run make_salt() a few...
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jun 2021 11:48:10 +0000 (13:48 +0200)]
test-libcrypt-util: print out default for password settings, run make_salt() a few times

Inspired by
https://fedoraproject.org/wiki/Changes/yescrypt_as_default_hashing_method_for_shadow.

(cherry picked from commit 7ff9d99e9e8b75930aa05b45eb21889eac8af014)

4 years agoresolved: fix strange function recursion
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jun 2021 16:17:44 +0000 (18:17 +0200)]
resolved: fix strange function recursion

In dns_server_unlink_marked() and dns_server_mark_all() we done recursively.
People might have dozens of servers defined, and it's better to avoid recursion
when a simple loop suffices.

dns_server_unlink_marked() would only unmark the first marked server.

Fixes #19651.

(cherry picked from commit a77f9dfbaed2e49269b42222da0d1c8680057fa6)

4 years agocore/socket: do not assign another fd to SocketPort which already has a fd on deseria...
Yu Watanabe [Tue, 8 Jun 2021 01:23:47 +0000 (10:23 +0900)]
core/socket: do not assign another fd to SocketPort which already has a fd on deserialization

Otherwise, if a socket address is duplicated, then the previous fd is
closed.

Fixes #19843.

(cherry picked from commit 3da0caf5bbf3c8cab716c4d7adf0eb25907dc951)