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

4 years agocore: do not serialize mounts and automounts for switch-root
Zbigniew Jędrzejewski-Szmek [Thu, 3 Jun 2021 17:40:01 +0000 (19:40 +0200)]
core: do not serialize mounts and automounts for switch-root

When e.g. tmp.mount is present in the initrd, and we serialize it, switch root,
and deserialize, the new systemd is confused because it thinks /tmp is mounted.
In general, it doesn't make sense to serialize anything that refers to paths in
the old root file system.

This fixes two errors for me:

1. tmp.mount was not mounted properly before local-fs.target. It would be
mounted as some point (I guess when we re-read /proc/self/mountinfo for some
other reason). In effect systemd-tmpfiles-setup.service would see one fs, and
some other units started later a different one. In particular gdm.service would
fail because the pre-created /tmp/.X11-unix with proper permissions would not
exist at time it was started.

2. # systemd[1]: proc-sys-fs-binfmt_misc.automount: Got hangup/error on autofs pipe from kernel. Likely our automount point has been unmounted by someone or something else?
   # systemd[1]: proc-sys-fs-binfmt_misc.automount: Failed with result 'unmounted'.
   # systemd[1]: Mounting proc-sys-fs-binfmt_misc.mount...
   # systemd[1]: Mounted proc-sys-fs-binfmt_misc.mount.
   # systemd[1]: Starting systemd-binfmt.service...
   # systemd[1]: Finished systemd-binfmt.service.
   # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
   # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount.
   # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
   # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount.
   # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
   # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount.
   # systemd[1]: Stopping systemd-binfmt.service...
   # systemd[1]: systemd-binfmt.service: Deactivated successfully.
   # systemd[1]: Stopped systemd-binfmt.service.

I couldn't understand the error here, but in retrospect the first line is entirely
correct: "someone or something else" was the old systemd unmounting the old root.

(cherry picked from commit 755021d43448011ef169f20ec3a08d4e92c824af)

4 years agoman: add details on overriding top level drop-ins
Peter Morrow [Mon, 7 Jun 2021 12:05:06 +0000 (13:05 +0100)]
man: add details on overriding top level drop-ins

When using top level drop-ins it isn't immediately obvious that one can
make use of symlinking to disable a top-level drop in for a specific
unit.

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

4 years agoman: explain ConditionNeedsUpdate a bit more
Zbigniew Jędrzejewski-Szmek [Mon, 7 Jun 2021 10:55:55 +0000 (12:55 +0200)]
man: explain ConditionNeedsUpdate a bit more

We were effectively doing all post-upgrade scripts twice in Fedora. We got this
wrong, so it's likely other people will get it wrong too. So let's explain
what is actually needed to make this work, but also when it's not useful.

(cherry picked from commit f75420a43a4dc3c69210f887b38f5df23660ea16)

4 years agoman: update docs on systemd-system.conf logging (LogTime=) (#19846)
alexlzhu [Tue, 8 Jun 2021 06:54:07 +0000 (23:54 -0700)]
man: update docs on systemd-system.conf logging (LogTime=) (#19846)

Updating documentation for systemd to reflect that logging is done in the console.

(cherry picked from commit 9f40351f77963efc304473830a431c424fd976b1)

4 years agoinstall: allow adding plain templates to .wants/ or .requires/
Zbigniew Jędrzejewski-Szmek [Fri, 4 Jun 2021 13:26:37 +0000 (15:26 +0200)]
install: allow adding plain templates to .wants/ or .requires/

Fixes #19437.

As reported in the bug:

> # drkonqi-coredump-processor@.service
>  ...
> [Install]
> WantedBy=systemd-coredump@.service
>
> The plan here is to have a systemd-coredump@ instance start the same %i for
> drkonqi-coredump-processor@. Works perfectly when creating the symlink manually
> ln -sv /usr/lib/systemd/system/drkonqi-coredump-processor@.service
> /etc/systemd/system/systemd-coredump@.service.wants/.

When DefaultInstance is set, we replace template references with
template@default-inst. But in this case we want to create a symlink for the
template name, so that systemd will fill in the instance from the
wanting/requiring unit. This is only possible for those units that actually
have an instance set, so we create the symlink only from .requires/ or .wants
of an instantiated unit (then this specific instance will be used), or a
template (than some instance will be inherited later).

Specifically:
...
[Install]
WantedBy=other@.service, fixed.service
DefaultInstance=inst

→ enable foo@.service creates other@.service.wants/foo@inst.service, and
other@a.service will want foo@inst.service, and other@b.service will want foo@inst.service,
and fixed.service will want foo@inst.service.

Without DefaultInstance,
→ enable foo@.service creates other@.service.wants/foo@.service, and
other@a.service would want foo@a.service, and other@b.service would want foo@b.service,
but enablement fails because no dependency can be created for fixed.service:

  Failed to enable unit, unit fixed.service is a non-template unit.

(cherry picked from commit b0ec372a9665dab6bb00066bc0fed667940f343e)

4 years agoudevadm: fix --tag-match help + description
Lennart Poettering [Mon, 7 Jun 2021 14:08:45 +0000 (16:08 +0200)]
udevadm: fix --tag-match help + description

(cherry picked from commit d27e6aee5050da17bc9531fb62ac11aba4b15ceb)

4 years agocore: disable "update" units in the initramfs
Zbigniew Jędrzejewski-Szmek [Mon, 7 Jun 2021 11:29:19 +0000 (13:29 +0200)]
core: disable "update" units in the initramfs

Initially I wanted to add ConditionPathExists=!/etc/initrd-release in various
units (ldconfig.service, systemd-sysusers.service, systemd-hwdb-update.service,
systemd-journal-catalog-update, systemd-update-done.service), but I think it's
better to just disable the mechanism in the initrd altogether. Initrd images
are put together in a very particular way, and there is not need to do
post-update steps on them. If a unit from some other package winds up in the
initrd, we wouldn't want to invoke it either.

Also, any modifications are ephemeral, so any update would happen on every
use. And finally, initrd images are all about speed, and we shouldn't invoke
any unneeded services.

(cherry picked from commit 294eace024b0e6c34cb64e3bb4f8958bb98ee00b)

4 years agounits: stop automount unit when shutting down
Zbigniew Jędrzejewski-Szmek [Tue, 1 Jun 2021 06:05:03 +0000 (08:05 +0200)]
units: stop automount unit when shutting down

This is currently our only .automount unit. We wouldn't want to trigger it
accidentally during shutdown, so let's stop it too.

(cherry picked from commit dc16846c26287fd2081eb3c4a73487c9b186e2b7)

4 years agopid1: only add a Wants= type dependency on /tmp when PrivateTmp=yes
Franck Bui [Fri, 28 Aug 2020 14:03:06 +0000 (16:03 +0200)]
pid1: only add a Wants= type dependency on /tmp when PrivateTmp=yes

We support that tmp.mount being masked, and this should not be considered an
error.

(cherry picked from commit b2c7d1bbc2243a425d9b825859bbd0647eecd050)

4 years agotmpfiles: do not check if unresolved globs are autofs paths
Zbigniew Jędrzejewski-Szmek [Wed, 2 Jun 2021 13:44:29 +0000 (15:44 +0200)]
tmpfiles: do not check if unresolved globs are autofs paths

With the previous commit, we would not complain about the not-found path, but
the check is still not useful. We use a libc function to resolve the glob, and
it has no notion of treating autofs specially. So we can't avoid touching
autofs when resolving globs. But usually the glob is found in the last
component of the path, so if we strip the glob part, we can still do a useful
check in many cases. (E.g. if /var/tmp is on autofs, something like
"/var/tmp/<glob>" is much more likely than "/var/<glob-that-matches-tmp>/<something>".)

With the system config in F34, we check the following prefixes:

/var/tmp/abrt/* → /var/tmp/abrt/
/run/log/journal/08a5690a2eed47cf92ac0a5d2e3cf6b0/*.journal* → /run/log/journal/08a5690a2eed47cf92ac0a5d2e3cf6b0/
/var/lib/systemd/coredump/.#core*.21e5c6c28c5747e6a4c7c28af9560a3d* → /var/lib/systemd/coredump/
/tmp/podman-run-* → /tmp/
/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-*/tmp → /tmp/
/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-* → /tmp/
/tmp/containers-user-* → /tmp/
/var/tmp/beakerlib-* → /var/tmp/
/var/tmp/dnf*/locks/* → /var/tmp/
/var/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-*/tmp → /var/tmp/
/var/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-* → /var/tmp/
/var/tmp/abrt/* → /var/tmp/abrt/
/var/tmp/beakerlib-* → /var/tmp/
/var/tmp/dnf*/locks/* → /var/tmp/
/tmp/podman-run-* → /tmp/
/tmp/containers-user-* → /tmp/
/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-* → /tmp/
/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-*/tmp → /tmp/
/var/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-* → /var/tmp/
/var/tmp/systemd-private-21e5c6c28c5747e6a4c7c28af9560a3d-*/tmp → /var/tmp/
/var/lib/systemd/coredump/.#core*.21e5c6c28c5747e6a4c7c28af9560a3d* → /var/lib/systemd/coredump/
/run/log/journal/08a5690a2eed47cf92ac0a5d2e3cf6b0/*.journal* → /run/log/journal/08a5690a2eed47cf92ac0a5d2e3cf6b0/

(cherry picked from commit bd6d28f21ad212e141b5e74bd0b7ad517f64a711)

4 years agobasic/glob-util: add helper to strip the glob part from a glob
Zbigniew Jędrzejewski-Szmek [Wed, 2 Jun 2021 14:01:40 +0000 (16:01 +0200)]
basic/glob-util: add helper to strip the glob part from a glob

(cherry picked from commit 1e472a6ce4747a1f10954fb239df73580c8e7411)

4 years agotmpfiles: stop complaining about autofs on not-found paths
Zbigniew Jędrzejewski-Szmek [Wed, 2 Jun 2021 13:40:27 +0000 (15:40 +0200)]
tmpfiles: stop complaining about autofs on not-found paths

systemd-tmpfiles[328]: Failed to determine whether '/run/cryptsetup' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/etc/resolv.conf' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/lock/subsys' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/setrans' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/console' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/faillock' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/sepermit' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/motd.d' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/motd.d' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/motd' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/run/nologin' is below autofs, ignoring: No such file or directory
systemd-tmpfiles[328]: Failed to determine whether '/var/lib/systemd/pstore' is below autofs, ignoring: No such file or directory
... and so on and so on.

(cherry picked from commit 16eff8271b402f2705d4329fa4cf5a0435e65996)

4 years agotest: don't expect that clone() always makes it to the kernel
Lennart Poettering [Fri, 4 Jun 2021 08:35:43 +0000 (10:35 +0200)]
test: don't expect that clone() always makes it to the kernel

We might get EPERM on certain clone() flag combinations. Apparently in
Docker for example.

Prompted by: https://github.com/systemd/systemd/pull/19800#issuecomment-854196491

(cherry picked from commit d414f415358846717c2260a1d931fe75d6c5f0e3)

4 years agoman: fix typo
adrian5 [Thu, 3 Jun 2021 19:05:20 +0000 (21:05 +0200)]
man: fix typo

(cherry picked from commit d0fd114929d3c8d5781e10e408ec178722d2f672)

4 years agopid1: don't choke on overly long device paths
Lennart Poettering [Wed, 2 Jun 2021 13:49:10 +0000 (15:49 +0200)]
pid1: don't choke on overly long device paths

This mimics what we do for device units: if there's a device we cannot
synthesize a good swap unit name for, then proceed without failure.

(cherry picked from commit e82c6e8b6230b237c838f053d52baa3297668eaa)

4 years agopid1: downgrade if we can't make sense of the old device on MOVE uevent
Lennart Poettering [Wed, 2 Jun 2021 13:34:34 +0000 (15:34 +0200)]
pid1: downgrade if we can't make sense of the old device on MOVE uevent

If the name of the old device didn#t work for us, we don't have to clean
anything up, since we know for sure that there won't be a device unit
for it. hence downgrade log message about it.

(cherry picked from commit 4d94c74fae21f7ef02a5f14b8296a4522d6b51df)

4 years agopid1: reduce log noise generated by devices with overly long sysfs paths
Lennart Poettering [Wed, 2 Jun 2021 13:29:29 +0000 (15:29 +0200)]
pid1: reduce log noise generated by devices with overly long sysfs paths

This basically does what 2c905207db37c691d4abef868165ad5ea2dd0f4f did
for mount units

Fixes: #16161
(cherry picked from commit ad172d19d5ef8b5a3631a8484cc3d1a28dba26c2)

4 years agoefi: drop glibc header and use pre-defined macros
Yu Watanabe [Wed, 2 Jun 2021 20:55:05 +0000 (05:55 +0900)]
efi: drop glibc header and use pre-defined macros

This reverts 72dc626b3d6905b105ae61ca2c60f51a6f74070e and replace glibc
specific macros with compiler's pre-defined macros.

(cherry picked from commit ffc36c276c47a9b3f21e83947090f11039628676)

4 years agosd-device: do not use ::subsystem member directly
Yu Watanabe [Wed, 2 Jun 2021 07:29:59 +0000 (16:29 +0900)]
sd-device: do not use ::subsystem member directly

The value is set dynamically when sd_device_get_subsystem() is called
first time.

Fixes the following issue:
```
$ build/udevadm test /sys/class/block/dm-1
...
Assertion '_subsystem' failed at src/libsystemd/sd-device/sd-device.c:767, function device_set_subsystem(). Aborting.
Program received signal SIGABRT, Aborted.
```

(cherry picked from commit 2255e8adee37c490bf8cf2daab791b6f746bb0a0)

4 years agovarious: don't say that the timestamp 'changed' on initial load
Zbigniew Jędrzejewski-Szmek [Tue, 1 Jun 2021 15:40:51 +0000 (17:40 +0200)]
various: don't say that the timestamp 'changed' on initial load

I always found this a bit annoying.
With the patch:

$ SYSTEMD_LOG_LEVEL=debug build/udevadm test /sys/class/block/dm-1
...
Loaded timestamp for '/etc/systemd/network'.
Loaded timestamp for '/usr/lib/systemd/network'.
Parsed configuration file /usr/lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/10-eth0.link
Created link configuration context.
Loaded timestamp for '/etc/udev/rules.d'.
Loaded timestamp for '/usr/lib/udev/rules.d'.
...

(cherry picked from commit 0d5a24beaedb161d4f7fe07361d2a5abdbd6e736)

4 years agovarlink: remove duplicated "varlink:" prefix
Zbigniew Jędrzejewski-Szmek [Tue, 1 Jun 2021 08:00:01 +0000 (10:00 +0200)]
varlink: remove duplicated "varlink:" prefix

We had:

systemd[1]: varlink-36: New incoming message: {"method":"io.systemd.UserDatabase.GetMemberships","parameters":{"userName":"gdm","service":"io.systemd.DynamicUser"},"more":true}
systemd[1]: varlink-36: varlink: changing state idle-server → processing-method-more
systemd[1]: varlink-36: Sending message: {"error":"io.systemd.UserDatabase.NoRecordFound","parameters":{}}
systemd[1]: varlink-36: varlink: changing state processing-method-more → processed-method
systemd[1]: varlink-36: varlink: changing state processed-method → idle-server
systemd[1]: varlink-36: Got POLLHUP from socket.
systemd[1]: varlink-36: varlink: changing state idle-server → pending-disconnect
systemd[1]: varlink-36: varlink: changing state pending-disconnect → processing-disconnect
systemd[1]: varlink-36: varlink: changing state processing-disconnect → disconnected

So let's drop the "varlink:" prefix and use capitalized sentences like in other messages.

(cherry picked from commit 953394e3bb1f1ead3c1d80237b97b71835b0755a)