systemd/.git
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)
(cherry picked from commit 12600fdc423c0d06906204795230314d5dbfde82)

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)
(cherry picked from commit d804bcadcb448879f31c32363970d9b70b742b9a)

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)
(cherry picked from commit 84e1819ec104a168f7904134b6212669133c955f)

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)
(cherry picked from commit daaf9273294f133ab9c970b3172608686de6f86a)

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)
(cherry picked from commit 11acee8a00f1e04952f86088078041849d8f9819)

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)
(cherry picked from commit 98af14bf53e0aeebf9d88b8f1c202a31ae7bb753)

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)
(cherry picked from commit b1ce5653fac2766c4b4a070fec2126f211d49efa)

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)
(cherry picked from commit 6a3a8c70686ab6da80dd87d0bd816a8c18980b71)

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)
(cherry picked from commit 399a00be3536cb5fbf3f96058c2a88a2a634d466)

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)
(cherry picked from commit 82fcf663cf2cec519185330964c9fdee956047d8)

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)
(cherry picked from commit a2861e9b9c60bb697854a1aa317c0c365204aab1)

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)
(cherry picked from commit 5fbb002c65c5dbfb9e789caf3bea1dc6e63ee7ae)

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)
(cherry picked from commit 2ff9f3068341433b031ed8f42900bf1460b53ff6)

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)
(cherry picked from commit 7f035c549fdc0660431d48f1f7dcb7fc41bad22c)

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)
(cherry picked from commit cab22cae2addcbfaa42621440bd7cb4b1a56c84f)

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)
(cherry picked from commit 93cf1abc60b774eb5c19e327a2079f67e80011df)

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)
(cherry picked from commit 688b311f5c6c0b20a3811f6a135bf87e11f36502)

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)
(cherry picked from commit 780768328a755057f955f36bac56e1da01e090f0)

4 years agovarlink: say "varlink:" instead of "n/a:" when no description is available
Zbigniew Jędrzejewski-Szmek [Tue, 1 Jun 2021 07:55:09 +0000 (09:55 +0200)]
varlink: say "varlink:" instead of "n/a:" when no description is available

For new connections, we log something like this:

systemd[1]: n/a: New incoming connection.
systemd[1]: n/a: Connections of user 997: 0 (of 1024 max)
systemd[1]: varlink-22: varlink: setting state idle-server
systemd[1]: varlink-22: New incoming message: ...

This "n/a" is not very pretty, and without context it would be hard to even
figure out this is a varlink connection.

(cherry picked from commit f35e9b101d80c05d5a5eaece6e62e8eeb5743691)
(cherry picked from commit b5691dd6f83d99e0588532940c1c24e5647662f7)

4 years agoudev: ignore the case that the device is already removed
Yu Watanabe [Wed, 2 Jun 2021 10:10:49 +0000 (19:10 +0900)]
udev: ignore the case that the device is already removed

See #19788.

(cherry picked from commit 6be1feb1d7e30c0e7591121b74d4c3c7079de6b3)
(cherry picked from commit b4ad8b418f65e8fbe8719344415758e6e62602f6)

4 years agoefi: include endian.h to handle endian correctly
Yu Watanabe [Wed, 2 Jun 2021 06:38:29 +0000 (15:38 +0900)]
efi: include endian.h to handle endian correctly

The macro __BYTE_ORDER__ is defined in endian.h.

(cherry picked from commit 72dc626b3d6905b105ae61ca2c60f51a6f74070e)
(cherry picked from commit 326e3ae2af0254c0d489ee053610fbbdc60a1f8b)

4 years agoefi: do not use _STRING_ARCH_unaligned macro
Yu Watanabe [Wed, 2 Jun 2021 06:36:26 +0000 (15:36 +0900)]
efi: do not use _STRING_ARCH_unaligned macro

It is already removed from glibc. See,
https://sourceware.org/git/?p=glibc.git;a=commit;h=16396c41deab45f715ffd813280d9d685b3b281e
https://sourceware.org/git/?p=glibc.git;a=commit;h=09a596cc2cf4e0f9f8e9f3bba4b1a97efcb13bcb

(cherry picked from commit 959ab90bbc08855ad5824efecbc03d37b3f9c982)
(cherry picked from commit d31347080272128e9b5c5f922a3f098ba62b059e)

4 years agomount: be more descriptive when logging about overly long mount point paths
Lennart Poettering [Tue, 1 Jun 2021 20:26:49 +0000 (22:26 +0200)]
mount: be more descriptive when logging about overly long mount point paths

This is prompted by #17684: let's very explicitly say that the name is
too long for us, and that we'll ignore it.

(cherry picked from commit 3ebc9b9b30b04a3aeec55a11022b337ec5fdb5cf)
(cherry picked from commit 264f179b692843fbb5de2e111b85e6e8bb837e68)

4 years agocore: when looping over mount/swap names, continue if we find one which doesn't trans...
Lennart Poettering [Tue, 1 Jun 2021 20:20:55 +0000 (22:20 +0200)]
core: when looping over mount/swap names, continue if we find one which doesn't translate to a valid unit name

(cherry picked from commit 598a6a8491abd311d36b11caf262123fbbffb2c0)
(cherry picked from commit f564342089ab56e44bf7240d19b860f2ed003e58)

4 years agounit-name: generate a clear error code when converting an overly long fs path to...
Lennart Poettering [Tue, 1 Jun 2021 17:43:55 +0000 (19:43 +0200)]
unit-name: generate a clear error code when converting an overly long fs path to a unit name

(cherry picked from commit 9d5acfab20c5f1177d877d0bec18063c0a6c5929)
(cherry picked from commit 1579dce2c2a162bb09afb9a8a46fd4f7e8fbf1d5)

4 years agopam: do not require a non-expired password for user@.service
Zbigniew Jędrzejewski-Szmek [Tue, 1 Jun 2021 14:17:16 +0000 (16:17 +0200)]
pam: do not require a non-expired password for user@.service

Without this parameter, we would allow user@ to start if the user
has no password (i.e. the password is "locked"). But when the user does have a password,
and it is marked as expired, we would refuse to start the service.
There are other authentication mechanisms and we should not tie this service to
the password state.

The documented way to disable an *account* is to call 'chage -E0'. With a disabled
account, user@.service will still refuse to start:

systemd[16598]: PAM failed: User account has expired
systemd[16598]: PAM failed: User account has expired
systemd[16598]: user@1005.service: Failed to set up PAM session: Operation not permitted
systemd[16598]: user@1005.service: Failed at step PAM spawning /usr/lib/systemd/systemd: Operation not permitted
systemd[1]: user@1005.service: Main process exited, code=exited, status=224/PAM
systemd[1]: user@1005.service: Failed with result 'exit-code'.
systemd[1]: Failed to start user@1005.service.
systemd[1]: Stopping user-runtime-dir@1005.service...

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

(cherry picked from commit 71889176e4372b443018584c3520c1ff3efe2711)
(cherry picked from commit 0af5a8921f6019dc35057482711f0fbe347b0c06)

4 years agologind-dbus: correctly calculate when to create /etc/nologin file in all cases
Lennart Poettering [Tue, 1 Jun 2021 14:46:40 +0000 (16:46 +0200)]
logind-dbus: correctly calculate when to create /etc/nologin file in all cases

Fixes: #19258
(cherry picked from commit cbb6c000c7f08f97fca28db990cd6aeb7aad7f4a)
(cherry picked from commit e55a705af5bfe53c754727138455599798a573bf)

4 years agobasic/unit-file: fix use-after-free
Yu Watanabe [Fri, 28 May 2021 10:48:33 +0000 (19:48 +0900)]
basic/unit-file: fix use-after-free

This fixes a bug introduced by e8630e695232bdfcd16b55f3faafb4329c961104.

Fixes CID#1453292.

(cherry picked from commit 7f1238bd04000f3333e8e2fcb82c9c6e18ee3ffc)
(cherry picked from commit 218117da2a8b4f1eccfc61353fdbe01219696378)

4 years agocore/service: do not set zero error to log_unit_debug_errno()
Yu Watanabe [Tue, 25 May 2021 20:02:18 +0000 (05:02 +0900)]
core/service: do not set zero error to log_unit_debug_errno()

Fixes #19725.

(cherry picked from commit 95599cacd3944073f7d944a8b3973e1308d1d57f)
(cherry picked from commit 1af2dba1d3d2d6ffba6816d8ff59eb034074cc18)

4 years agoload-fragment: validate paths properly
Lennart Poettering [Tue, 25 May 2021 15:25:40 +0000 (17:25 +0200)]
load-fragment: validate paths properly

The comment suggests we validate paths here, but we actually didn't, we
only validated filenames. Let' fix that.

(Note this still lets any kind of paths through, including those with
".." and stuff, this is not a normalization check after all)

(cherry picked from commit 108144adea838b281fe1f60dfa75542fe4c82d4b)
(cherry picked from commit 740b24c3e0f81556576a16390d7a2d7e0dc2a7e2)

4 years agoREADME: point at IRC channel on the new network
Mantas Mikulėnas [Tue, 25 May 2021 10:09:05 +0000 (13:09 +0300)]
README: point at IRC channel on the new network

(cherry picked from commit fb906b00c68e34b8692e207a658bcfa3df62456c)
(cherry picked from commit 2aefb7beff0601c8785625784ace2f0d93214321)

4 years agonetwork: allow to set Group=0 in [Link] section
Yu Watanabe [Fri, 21 May 2021 05:11:36 +0000 (14:11 +0900)]
network: allow to set Group=0 in [Link] section

Previously, when a link has already in a numbered group, we cannot
remove the link from the group.

This also fixes the range mentioned in the man page.

(cherry picked from commit f0c09831bddb9f335af1b1ebfa6eb8424c2058f3)
(cherry picked from commit f59caa064e158fc0041938c3b0890c8704f84a65)

4 years agosystemctl: avoid crash when pattern expands to empty unit list
Zbigniew Jędrzejewski-Szmek [Mon, 24 May 2021 20:49:56 +0000 (22:49 +0200)]
systemctl: avoid crash when pattern expands to empty unit list

Fixes #19652.

(cherry picked from commit ffcd68385226d4b499dbff0123271e1d3fb8f516)
(cherry picked from commit 9a24f5edcc1c16f2afaa943dfd39f413322a5a0a)

4 years agokernel-install: don't erase previous errors if a hook returns 77
наб [Tue, 16 Mar 2021 15:59:07 +0000 (16:59 +0100)]
kernel-install: don't erase previous errors if a hook returns 77

The manpage says that exiting 77 is the same as exiting 0,
then skipping all other hooks, but the behaviour heretofor
was to exit 0, skip all, and behave as if all hooks exited 0

(cherry picked from commit 44230fa2b050d63fce49b4bfbbb93c42940754cc)
(cherry picked from commit 954f6ae49a6dc8a7994ff7ca3c86551a8748c2d1)

4 years agorules.d: Properly quote $env{MODALIAS}
Roshan Shariff [Mon, 24 May 2021 07:30:38 +0000 (01:30 -0600)]
rules.d: Properly quote $env{MODALIAS}

 Add quotes around use of $env{MODALIAS} in rules.d/80-drivers.rules. The
 modalias can contain whitespace, for example when it is dynamically generated
 using device or vendor IDs.

(cherry picked from commit 07c0e5eeaf3183963f4d680555d2289a33735d6e)
(cherry picked from commit 1151d6f55dd5cc4925a52e0faeca98963114df9b)

4 years agojournal: fix uninitialized variable use
Luca Boccassi [Thu, 20 May 2021 09:35:36 +0000 (10:35 +0100)]
journal: fix uninitialized variable use

If the journal file being processed is archivied, seqnum_id will not be
initialized before being passed on, and coverity complains.
Initialize it to zero.

CID #1453235

(cherry picked from commit 06a368e8198a9cbfad86ba17bba6a76a33f15492)
(cherry picked from commit b97c113704056c386574c047928e410c6c1e89ae)

4 years agonetwork: fix an infinite loop
Yu Watanabe [Thu, 20 May 2021 07:14:17 +0000 (16:14 +0900)]
network: fix an infinite loop

Fixes #19467.

(cherry picked from commit e8f99f4e249916e12c09ee5cc9a108cba6a2b5c0)
(cherry picked from commit b234ee7859de556c272c36fc691cee4cb08f7230)

4 years agoselinux: invoke selinux_set_callback(3) more type-safe
Christian Göttsche [Fri, 14 May 2021 12:14:25 +0000 (14:14 +0200)]
selinux: invoke selinux_set_callback(3) more type-safe

(cherry picked from commit 57e70396dfdc6835c4a9141d29043e4af407205d)
(cherry picked from commit c259b1b6da788964dd9a92f6ff0cfe02f62c0af8)

4 years agoselinux: reload label db on policy load with libselinux 3.2
Christian Göttsche [Fri, 14 May 2021 12:12:39 +0000 (14:12 +0200)]
selinux: reload label db on policy load with libselinux 3.2

Currently the label database is not reloaded with libselinux 3.2 on a
policy reload.

Since libselinux 3.2 avc_open(3) uses the SELinux status page instead of
a netlink socket to check for policy reloads.
The status page is also queried in mac_selinux_maybe_reload().
Thus calls to selinux_check_access(3) might consume an update, queried
by selinux_status_updated(3), leaving mac_selinux_maybe_reload() unable
to detect a policy reload.

Do not use selinux_status_updated(3), use selinux_status_policyload(3)
unconditionally.

Relevant libselinux commit: https://github.com/SELinuxProject/selinux/commit/05bdc03130d741e53e1fb45a958d0a2c184be503

Debian Bullseye is going to ship libselinux 3.1, so stay compatible for
backports.

(cherry picked from commit c46c76881144271b9a18842e086d1318febdb372)
(cherry picked from commit 82e9abf69ada90373efd7dc2db9934510562b853)

4 years agokbd-model-map: add mapping 'es-dvorak'
Franck Bui [Wed, 19 May 2021 08:18:21 +0000 (10:18 +0200)]
kbd-model-map: add mapping 'es-dvorak'

And update test-keymap-util accordingly.

While at it, make sure to use tabs everywhere.

(cherry picked from commit 0495728429096a405b1d2cf1fa283a90c30ebaa9)
(cherry picked from commit 644a8ca3e026d22e71cb1f37034e6713bb8ee982)

4 years agosystemctl: re-align colon in status output
Lennart Poettering [Fri, 14 May 2021 16:20:32 +0000 (18:20 +0200)]
systemctl: re-align colon in status output

(cherry picked from commit 1d406dceb769da2123417e6a06c85a99ebead7b1)
(cherry picked from commit 409c6a89e475e05776003cd43cb032050b6efa1e)

4 years agoFixed a typo
ei-ke [Sun, 16 May 2021 16:12:12 +0000 (18:12 +0200)]
Fixed a typo

(cherry picked from commit 410477a78f598e753996e3b7ee40176b219b8379)
(cherry picked from commit d6f6f9e578ed120222e84d2ebfda5e37d6827e58)

4 years agonetworkd: handle ignoring ll gateway being link ll
Devon Pringle [Mon, 14 Dec 2020 04:22:18 +0000 (14:22 +1000)]
networkd: handle ignoring ll gateway being link ll

In the event where network discovery gets a route with the gateway being
the interfaces local link address, networkd will fail the interface.

systemd-networkd[44319]: br_lan: Configuring route: dst: fdcd:41a4:5559:ec03::/64, src: n/a, gw: fe80::e4da:7eff:fe77:5c5e, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast
systemd-networkd[44319]: br_lan: Could not set NDisc route or address: Gateway can not be a local address. Invalid argument
systemd-networkd[44319]: br_lan: Failed
systemd-networkd[44319]: br_lan: State changed: configuring -> failed

This patch, instead of allowing the interface to fail, will instead log
the event and skip setting the route.

(cherry picked from commit 221019166f315252304b3459902ead613b905de5)

4 years agodns-query: export CNAME_MAX, so that we can use it in other files, too v247.7
Lennart Poettering [Fri, 5 Mar 2021 16:47:45 +0000 (17:47 +0100)]
dns-query: export CNAME_MAX, so that we can use it in other files, too

Let's rename it a bit, to be more explanatory while exporting it.

(And let's bump the CNAME limit to 16 — 8 just sounded so little)

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

(cherry picked from commit e0ae456a554d0fce250f9a009c561b97f20c41f8)

4 years agoresolved: fix braino with reference counting and linked lists
Zbigniew Jędrzejewski-Szmek [Fri, 14 May 2021 08:49:24 +0000 (10:49 +0200)]
resolved: fix braino with reference counting and linked lists

In 0e0fd08fc832b8f42e567d722d388eba086da5ff I added reference counts to keep
track of the DnsQueryCandidate objects. Unfortunately, dns_query_unref_candidates()
was written as

     while (q->candidates)
           dns_query_candidate_unref(q->candidates);

i.e. it would keep dropping the reference count as many times as needed for it
to hit 0, making the patch less than fully effective.

dns_query_unref_candidates() is renamed to dns_query_detach_candidates() and
changed to drop exactly one reference from each of the linked candidates.

Example failure:
==463== Invalid read of size 8
==463==    at 0x419C93: dns_query_candidate_go (resolved-dns-query.c:159)
==463==    by 0x41A143: dns_query_candidate_notify (resolved-dns-query.c:304)
==463==    by 0x434BD6: dns_transaction_complete (resolved-dns-transaction.c:437)
==463==    by 0x436A0F: dns_transaction_process_dnssec (resolved-dns-transaction.c:976)
==463==    by 0x4378C1: dns_transaction_process_reply (resolved-dns-transaction.c:1387)
==463==    by 0x437CE9: on_dns_packet (resolved-dns-transaction.c:1444)
==463==    by 0x4B2DC9B: source_dispatch (sd-event.c:3512)
==463==    by 0x4B2FB1F: sd_event_dispatch (sd-event.c:4077)
==463==    by 0x4B2FFFA: sd_event_run (sd-event.c:4138)
==463==    by 0x4B301D6: sd_event_loop (sd-event.c:4159)
==463==    by 0x464A24: run (resolved.c:92)
==463==    by 0x464B3C: main (resolved.c:99)
==463==  Address 0x5f409d0 is 32 bytes inside a block of size 72 free'd
==463==    at 0x48410E4: free (vg_replace_malloc.c:755)
==463==    by 0x418EDF: mfree (alloc-util.h:48)
==463==    by 0x4197E8: dns_query_candidate_free (resolved-dns-query.c:67)
==463==    by 0x4198B7: dns_query_candidate_unref (resolved-dns-query.c:70)
==463==    by 0x41A2E3: dns_query_unref_candidates (resolved-dns-query.c:337)
==463==    by 0x41C5FE: dns_query_cname_redirect (resolved-dns-query.c:1028)
==463==    by 0x41CA04: dns_query_process_cname_one (resolved-dns-query.c:1128)
==463==    by 0x41CA80: dns_query_process_cname_many (resolved-dns-query.c:1157)
==463==    by 0x40C0BD: bus_method_resolve_hostname_complete (resolved-bus.c:198)
==463==    by 0x41B312: dns_query_complete (resolved-dns-query.c:562)
==463==    by 0x41C1AC: dns_query_accept (resolved-dns-query.c:922)
==463==    by 0x41C2C4: dns_query_ready (resolved-dns-query.c:955)
==463==    by 0x41A162: dns_query_candidate_notify (resolved-dns-query.c:314)
==463==    by 0x434BD6: dns_transaction_complete (resolved-dns-transaction.c:437)
==463==    by 0x438995: dns_transaction_prepare (resolved-dns-transaction.c:1728)
==463==    by 0x43921D: dns_transaction_go (resolved-dns-transaction.c:1928)
==463==    by 0x419C7C: dns_query_candidate_go (resolved-dns-query.c:163)
==463==    by 0x41A143: dns_query_candidate_notify (resolved-dns-query.c:304)
==463==    by 0x434BD6: dns_transaction_complete (resolved-dns-transaction.c:437)
==463==    by 0x436A0F: dns_transaction_process_dnssec (resolved-dns-transaction.c:976)
==463==    by 0x4378C1: dns_transaction_process_reply (resolved-dns-transaction.c:1387)
==463==    by 0x437CE9: on_dns_packet (resolved-dns-transaction.c:1444)
==463==    by 0x4B2DC9B: source_dispatch (sd-event.c:3512)
==463==    by 0x4B2FB1F: sd_event_dispatch (sd-event.c:4077)
==463==    by 0x4B2FFFA: sd_event_run (sd-event.c:4138)
==463==    by 0x4B301D6: sd_event_loop (sd-event.c:4159)
==463==    by 0x464A24: run (resolved.c:92)
==463==    by 0x464B3C: main (resolved.c:99)
==463==  Block was alloc'd at
==463==    at 0x483E86F: malloc (vg_replace_malloc.c:380)
==463==    by 0x418F81: malloc_multiply (alloc-util.h:96)
==463==    by 0x419378: dns_query_candidate_new (resolved-dns-query.c:23)
==463==    by 0x41B42C: dns_query_add_candidate (resolved-dns-query.c:582)
==463==    by 0x41BB7A: dns_query_go (resolved-dns-query.c:762)
==463==    by 0x40CE3A: bus_method_resolve_hostname (resolved-bus.c:464)
==463==    by 0x4A84B86: method_callbacks_run (bus-objects.c:414)
==463==    by 0x4A87961: object_find_and_run (bus-objects.c:1323)
==463==    by 0x4A87FEE: bus_process_object (bus-objects.c:1443)
==463==    by 0x4AA3434: process_message (sd-bus.c:2964)
==463==    by 0x4AA3623: process_running (sd-bus.c:3006)
==463==    by 0x4AA4110: bus_process_internal (sd-bus.c:3226)
==463==    by 0x4AA41EF: sd_bus_process (sd-bus.c:3253)
==463==    by 0x4AA5343: io_callback (sd-bus.c:3604)
==463==    by 0x4B2DC9B: source_dispatch (sd-event.c:3512)
==463==    by 0x4B2FB1F: sd_event_dispatch (sd-event.c:4077)
==463==    by 0x4B2FFFA: sd_event_run (sd-event.c:4138)
==463==    by 0x4B301D6: sd_event_loop (sd-event.c:4159)
==463==    by 0x464A24: run (resolved.c:92)
==463==    by 0x464B3C: main (resolved.c:99)

Fixes #19376.

(cherry picked from commit c856ef0457c35e9edfdbf085b69ec81c126d48e5)
(cherry picked from commit 89324e233eef767334d9bfe5eed96956c973c2ad)

4 years agonetwork:dhcp4_server_configure returns if not able to get timezone
tramsay [Mon, 5 Apr 2021 22:12:49 +0000 (17:12 -0500)]
network:dhcp4_server_configure returns if not able to get timezone

When /etc/localtime is a symbolic link pointing to another symbolic
link, get_timezone will return -EINVAL instead of the timezone.
This issue can cause systemd-networkd DHCPServer to fail.

Instead of returning failure, log a warning indicating that that
the timezone will not be sent.

modified:   networkd-dhcp-server.c

(cherry picked from commit 7b5018ca9e6d3279887ec7113818f41d5b831c4d)
(cherry picked from commit 37c4cfde0ce613f0f00544d3f4e2e72bf93d9c76)

4 years agomeson: call find_program() once and reuse the variable everywhere
Zbigniew Jędrzejewski-Szmek [Fri, 14 May 2021 12:16:17 +0000 (14:16 +0200)]
meson: call find_program() once and reuse the variable everywhere

Meson 0.58 has gotten quite bad with emitting a message every time
a quoted command is used:
Program /home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh found: YES (/home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program xsltproc found: YES (/usr/bin/xsltproc)
Configuring custom-entities.ent using configuration
Message: Skipping bootctl.1 because ENABLE_EFI is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Message: Skipping journal-remote.conf.5 because HAVE_MICROHTTPD is false
Message: Skipping journal-upload.conf.5 because HAVE_MICROHTTPD is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Message: Skipping loader.conf.5 because ENABLE_EFI is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
...

Let's suffer one message only for each command. Hopefully we can silence
even this when https://github.com/mesonbuild/meson/issues/8642 is
resolved.

(cherry picked from commit 596f5101f29c10256208132bfa9c502bf898fd8b)

4 years agorun: update checks to allow running with a user's bus
Anita Zhang [Thu, 13 May 2021 08:17:51 +0000 (01:17 -0700)]
run: update checks to allow running with a user's bus

systemd-run is documented to as being able to connect and run on a
specific user bus with "--user --machine=lennart@.host" arguments.
This PR updates some logic that prevented this from working.

(cherry picked from commit cbdc29492097e24ef3320280bc2a8dedbce02d9a)
(cherry picked from commit cc589cce9815cabb0bed6d0695ec3ff77beebd06)

4 years agoresolved.conf.in: add missing Quad9 servers
Michael Catanzaro [Tue, 11 May 2021 13:24:55 +0000 (08:24 -0500)]
resolved.conf.in: add missing Quad9 servers

The example configuration is missing half of Quad9's addresses.

(cherry picked from commit aa2b370dddc7e37df33769a488d6c3dce89b4e17)
(cherry picked from commit 4b8d52f4f09fe7f514cc982ad945153565503127)

4 years agoresolved: be more careful with weird links with low MTUs
Lennart Poettering [Tue, 11 May 2021 20:21:52 +0000 (22:21 +0200)]
resolved: be more careful with weird links with low MTUs

Apparently CAN links will show up in rtnetlink with very low MTUs. We
shouldn't consider them relevant if no IP is spoken over them, since
these MTUs are irrelevant for us then.

Hence, let's check if there's an address assigned to the link before
considering its MTU.

As additional safety net filter out MTUs smaller than the minimum DNS
packet size, too.

Finally, in case we don't find any suitable interface MTU, let's default
to 1500 as the generic Ethernet MTU.

Fixes: #19396
(cherry picked from commit 5a0d0b8f9cdfcbb82c4a89b28f0ebce414c9ecfe)
(cherry picked from commit 3fd268d20979850a70453ed5f8891a0f03344bf2)

4 years agoresolved: add udp_header_size() helper
Lennart Poettering [Mon, 16 Nov 2020 20:00:24 +0000 (21:00 +0100)]
resolved: add udp_header_size() helper

(cherry picked from commit 4565863fff974e69d23a7c5a5237528bc5573a17)

4 years agocore: don't accidentally unref a varlink connection twice
Lennart Poettering [Fri, 12 Mar 2021 21:21:58 +0000 (22:21 +0100)]
core: don't accidentally unref a varlink connection twice

Let's make sure that our close handler unrefs a connection again that we
are already unreffing a few stack frames up by invalidating the pointer
first, and dropping the ref counter only after that.

Replaces: 39ad3f1c092b5dffcbb4b1d12eb9ca407f010a3c

Fixes: #18025
(cherry picked from commit d65e974e67e47222cdebd9d0b6becd6642547ce2)
(cherry picked from commit 68da6997a9323c127a45ca019d32fa97ff0d7cca)

4 years agoRevert "varlink: avoid using dangling ref in varlink_close_unref()"
Lennart Poettering [Fri, 12 Mar 2021 21:21:40 +0000 (22:21 +0100)]
Revert "varlink: avoid using dangling ref in varlink_close_unref()"

This reverts commit 39ad3f1c092b5dffcbb4b1d12eb9ca407f010a3c.

(cherry picked from commit cc6b0a18ff73325e2ecf0c5d857f4fdca75d97b4)
(cherry picked from commit 906b89a284308a64e599e7e4230763bb60a16895)

4 years agopam: fix typo try_authtok → use_authtok
Lennart Poettering [Wed, 12 May 2021 08:33:27 +0000 (10:33 +0200)]
pam: fix typo try_authtok → use_authtok

This was a copy/paste mistae apparently, there's not "try_authtok" and
this was supposed to copy what Fedora uses, which uses "use_authtok"
correctly. Hence adjust this.

Fixes: #19369
(cherry picked from commit 971c07fc6812315c2b27015dfcc652a747f919ed)
(cherry picked from commit ca276dcddc4def7348e2cb897fbf7a8b26bfc5ed)

4 years agobootctl: same entry path check case-insensitive
zsien [Mon, 10 May 2021 07:42:54 +0000 (15:42 +0800)]
bootctl: same entry path check case-insensitive

Some motherboards convert the path to uppercase under certain circumstances
(e.g. after booting into the Boot Menu in the ASUS ROG STRIX B350-F GAMING).

(cherry picked from commit 5c2e5957678462d871c5c2ea5261becec5f8f80f)
(cherry picked from commit 379679f807072b4d554711bc61b769d72ecc98d6)

4 years agoman: network: use `networkctl list` instead of `status` to list network interface...
Lucas Magasweran [Mon, 10 May 2021 08:11:28 +0000 (10:11 +0200)]
man: network: use `networkctl list` instead of `status` to list network interface type

To determine the network interface type for use in the `Type=` directive, it is more concise to use the `list` command. Whereas, the `status` command requires an interface parameter.

For example, on a RaspberryPi 4 the following shows that the `wlan0` interface type `wlan` is more coveniently listed by the `list` command.

```
root@raspberrypi4-64:~# networkctl list
IDX LINK  TYPE     OPERATIONAL SETUP
  1 lo    loopback carrier     unmanaged
  2 eth0  ether    routable    configured
  3 wlan0 wlan     off         unmanaged

3 links listed.
```

Whereas the `networkctl status` command doesn't include this information.

```
root@raspberrypi4-64:~# networkctl status
●   State: routable
  Address: 192.168.1.141 on eth0
           fd8b:8779:b7a4::f43 on eth0
           fd8b:8779:b7a4:0:dea6:32ff:febe:d1ce on eth0
           fe80::dea6:32ff:febe:d1ce on eth0
  Gateway: 192.168.1.1 (CZ.NIC, z.s.p.o.) on eth0
      DNS: 192.168.1.1

May 07 14:17:18 raspberrypi4-64 systemd-networkd[212]: eth0: Gained carrier
May 07 14:17:19 raspberrypi4-64 systemd-networkd[212]: eth0: Gained IPv6LL
May 07 14:17:19 raspberrypi4-64 systemd-networkd[212]: eth0: DHCPv6 address fd8b:8779:b7a4::f43/128 timeout preferred -1 valid -1
May 07 14:17:21 raspberrypi4-64 systemd-networkd[212]: eth0: DHCPv4 address 192.168.1.141/24 via 192.168.1.1
```

To get the interface type using the `status` command you need to specify an additional argument.

```
root@raspberrypi4-64:~# networkctl status wlan0
● 3: wlan0
                     Link File: /lib/systemd/network/99-default.link
                  Network File: n/a
                          Type: wlan
                         State: off (unmanaged)
                          Path: platform-fe300000.mmcnr
                        Driver: brcmfmac
                    HW Address: dc:a6:32:be:d1:cf (Raspberry Pi Trading Ltd)
                           MTU: 1500 (min: 68, max: 1500)
                         QDisc: noop
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 1/1
```

(cherry picked from commit 2480ca95bac0f1bed350ba8d5aef1ef92be0f8a4)
(cherry picked from commit 56ba53b17338f37c211a1c1ee0686ff4e5c09d28)

4 years agonetwork: examples: use wlan for Type instead of wifi
Lucas Magasweran [Mon, 10 May 2021 08:09:56 +0000 (10:09 +0200)]
network: examples: use wlan for Type instead of wifi

(cherry picked from commit b419e8776bc2dc1ca113c8332ed465724bff053a)
(cherry picked from commit bf3d671b379cc683375d62f109f133c1703dd828)

4 years agoresolve: remove RRs from zones before an update
Roman Beranek [Fri, 30 Apr 2021 13:51:44 +0000 (15:51 +0200)]
resolve: remove RRs from zones before an update

During an update of RRs, the records of each DNS-SD service are
replaced with new ones. However the old RRs can only be removed from
the mDNS scopes as long as they remain accessible from the DnssdService
structures, otherwise they remain stuck there.

Therefore the removal must take place before the update.

(cherry picked from commit ee3713b71ddf182852a399953968a2b39af22104)
(cherry picked from commit 46ee05ed1fca9c5637ec5cfbb4f71c84f94b3db6)

4 years agonss-systemd: properly handle empty membership lists
Lennart Poettering [Wed, 5 May 2021 16:57:30 +0000 (18:57 +0200)]
nss-systemd: properly handle empty membership lists

When we are queried for membership lists on a system that has exactly
zero, then we'll return ESRCH immediately instead of at EOF. Which is
OK, but we need to handle this in various places, and not get confused
by it.

(cherry picked from commit a1aa41e4e175c2712b97600d7e10e9d6c58e5543)
(cherry picked from commit d0f8a01a74e5a1bed4d687339abde774cb944579)

4 years agonss-systemd: reset the right field
Lennart Poettering [Wed, 5 May 2021 14:05:43 +0000 (16:05 +0200)]
nss-systemd: reset the right field

(cherry picked from commit 1fdfca4da739f47516513afc66d4c7008c9badfd)
(cherry picked from commit 18babc7b290de4c0108b2fe39400c3e9c471ef67)

4 years agosystem-conf: drop reference to ShutdownWatchdogUsec=
Franck Bui [Tue, 27 Apr 2021 08:59:24 +0000 (10:59 +0200)]
system-conf: drop reference to ShutdownWatchdogUsec=

Commit 65224c1d0e50667a87c2c4f840c49d4918718f80 renamed ShutdownWatchdogUsec
into RebootWatchdogUsec but left a reference of ShutdownWatchdogUsec in
system.conf.

(cherry picked from commit 45b1fc3a88b2f5102ecabfabdf0ee4f175aecd64)
(cherry picked from commit 54b5a1b21b69d674e55b69be79ef86e5b2215406)

4 years agosystemctl: hide some empty properties without --all
Frantisek Sumsal [Mon, 26 Apr 2021 20:03:19 +0000 (22:03 +0200)]
systemctl: hide some empty properties without --all

Fixes: #19423
(cherry picked from commit 1ceaad69378272c64da4ecaab0d59ebb7a92ca0a)
(cherry picked from commit af3a3dd2f1360973560d21d1aeec9531e953162a)

4 years agocore/service: also reject deserialized commands with no argv[0]
Zbigniew Jędrzejewski-Szmek [Fri, 23 Apr 2021 10:40:07 +0000 (12:40 +0200)]
core/service: also reject deserialized commands with no argv[0]

I'm pretty sure that bad things would happen later on.

(cherry picked from commit 90204792461030dbc8645d8511e7ac8d1b4f1ca2)
(cherry picked from commit d113fd4e0756b1b6f5543a47d0943af4564293ff)

4 years agocore/service: fix deserialization of non-absolute commands
Zbigniew Jędrzejewski-Szmek [Fri, 23 Apr 2021 10:39:03 +0000 (12:39 +0200)]
core/service: fix deserialization of non-absolute commands

We'd fail with:
Apr 23 10:58:26 systemd[1]: Deserializing state...
Apr 23 10:58:26 systemd[1]: testsuite-01.service: Failed to parse serialized command "ExecStart 0 sh "sh" "-e" "-x" "-c" "systemctl --state=failed --no-legend --no-pager >/failed ; systemctl daemon-reload ; echo OK >/testok"": Invalid argument
Apr 23 10:58:26 systemd[1]: testsuite-01.service: Reinstalled deserialized job testsuite-01.service/start as 209

This was missed in 5008da1ec1, and apparently nobody noticed until now :(

(cherry picked from commit 1a128a468ddd1070651478c36eae76e31f580b67)
(cherry picked from commit 27606d5448dcaef17d256ced7e89b963a13cfec4)

4 years agonetwork: update comment and log message
Yu Watanabe [Mon, 26 Apr 2021 00:03:33 +0000 (09:03 +0900)]
network: update comment and log message

After 4b30f2e135ee84041bb597edca7225858f4ef4fb, reading stable_secret
sysctl property fails with -ENOMEM, instead of -EIO.
This is due to read_full_virtual_file() uses read() as the backend while
read_one_line_file() uses fgetc(). And each functions return different
error on fails.

Anyway, the failure is harmless here. So, the log message and comment is
updated.

Closes one of the issues in #19410.

(cherry picked from commit 0e27527170aa0179f2a4b3b55b78ddc049f815b9)
(cherry picked from commit 2417e9b59aa654e4b3def3399576ebbc2cdd7c95)

4 years agocore: allow services stuck in reloading state to exit
Peter Morrow [Tue, 13 Apr 2021 16:20:42 +0000 (17:20 +0100)]
core: allow services stuck in reloading state to exit

If a service is in reloading state but has exited do not delay
the final exit until the service reload timer expires. Instead allow
the service to exit immediately since we can't expect the service to
ever transition out of reloading state.

For example if a service sent RELOADING=1 but crashed before it could
send READY=1 then it should be restarted if the service had
Restart= configured.

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

4 years agofix: point to the correct drop-ins subdirectory for confs
Jóhann B. Guðmundsson [Wed, 21 Apr 2021 21:09:29 +0000 (21:09 +0000)]
fix: point to the correct drop-ins subdirectory for confs

(cherry picked from commit eb34cce1787259de4cea1430fa017b6bd25bc4c1)
(cherry picked from commit 3d896e8b03b39c5bd68ef026536acb7496ae995f)

4 years agoman: dedent examples in sd-id128 to 2 columns
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 13:09:22 +0000 (15:09 +0200)]
man: dedent examples in sd-id128 to 2 columns

In man pages, horizontal space it at premium, and everything should
generally be indented with 2 spaces to make it more likely that the
examples fit on a user's screen.

C.f. 798d3a524ea57aaf40cb53858aaa45ec702f012d.

(cherry picked from commit e0a41aa4c6674f04723388c05b7cd81cc2ffd613)
(cherry picked from commit 80a7922d16c9f4b7964342dcd99d66f1ab006777)

4 years agojournald: enforce longer line length limit during "setup" phase of stream protocol
Yangyang Shen [Wed, 24 Mar 2021 13:23:01 +0000 (21:23 +0800)]
journald: enforce longer line length limit during "setup" phase of stream protocol

This PR made modification on Lennart Poettering's basis. Fix the LineMax's function failure problem.

Signed-off-by: Yangyang Shen <shenyangyang4@huawei.com>
(cherry picked from commit 80e9720616df0eeaba75874fd86fbfbe8b7a03a7)
(cherry picked from commit 9d5c5e4fab6e4816babbd4b74787b43fa5e4440a)

4 years agosd-device: use right clock when comparing initialization usec
Lennart Poettering [Tue, 20 Apr 2021 13:56:03 +0000 (15:56 +0200)]
sd-device: use right clock when comparing initialization usec

we actually use CLOCK_MONOTONIC for the timestamp, hence when
comparing/subtracting it from the current time, also use
CLOCK_MONOTONIC.

(cherry picked from commit 02ef01ade3b16c05dfc8698181d7f562f4934ef3)
(cherry picked from commit 873ad71291e942054dd96ca1a9000cc98f21487a)

4 years agosd-device: use right type for usec_initialized
Lennart Poettering [Tue, 20 Apr 2021 15:06:21 +0000 (17:06 +0200)]
sd-device: use right type for usec_initialized

(cherry picked from commit a156eb89c827206ee5b51d53016ba63be0c90449)
(cherry picked from commit d6b0efcdd83a937363267ed751fd9a1085505394)

4 years agodocument DefaultOOMPolicy
Miroslav Suchý [Tue, 20 Apr 2021 08:23:01 +0000 (10:23 +0200)]
document DefaultOOMPolicy

the `man systemd.service` say:
   Defaults to the setting DefaultOOMPolicy= in systemd-system.conf(5) is set to
but there is no such line in this config.
This is the default value I extracted from
   systemctl show --property=DefaultOOMPolicy

(cherry picked from commit 0084d4f6b58f70c9955fa2259c29d65d87e1e855)
(cherry picked from commit 48027216bdc1d77f208f3606c05489046ea30ace)

4 years agowifi-util: do not set zero errno to log_debug_errno()
Yu Watanabe [Tue, 20 Apr 2021 00:23:33 +0000 (09:23 +0900)]
wifi-util: do not set zero errno to log_debug_errno()

(cherry picked from commit 66205cb3f597e43c8446d122fa4cc849c4f101d7)
(cherry picked from commit 8eaf2da0f6c9fbea42d44343c30361dcf79702bf)

4 years agodissect: ext4 and loopback files are unimpressed by read-only access
Lennart Poettering [Mon, 19 Apr 2021 20:47:33 +0000 (22:47 +0200)]
dissect: ext4 and loopback files are unimpressed by read-only access

Even if we set up a loopback device read-only and mount it read-only
this means nothing, ext4 will still write through to the backing storage
file.

Yes, I lost 6h debugging time on this.

Apparently, we have to specify "norecovery" when mounting such file
systems, to force them into truly read-only mode. Let's do so.

(cherry picked from commit b620bf332f575ba9b8e4cd60c93446a0c35c23e8)
(cherry picked from commit 8c7bc71e772899a401b377711b63de32a67c951d)

4 years agorepart: deal with empty partition label sensibly
Lennart Poettering [Fri, 19 Mar 2021 21:45:15 +0000 (22:45 +0100)]
repart: deal with empty partition label sensibly

libfdisk appears to return NULL when encountering an empty partition
label, let's handle this sanely, and treat NULL and "" for the current
label as the same, but for the new label as distinct: there NULL means
nothing is set, and "" means an actual empty label.

(cherry picked from commit be9ce0188ebb414319f0c003f805ea02b5eb473e)
(cherry picked from commit b3b84982d0e72d3160ff7ecb6193c6439c1fc27e)

4 years agorepart: handle DISCARD failing with EBUSY gracefully
Lennart Poettering [Fri, 19 Mar 2021 21:25:09 +0000 (22:25 +0100)]
repart: handle DISCARD failing with EBUSY gracefully

(cherry picked from commit 22163eb51b682afe969f9381d56315dade874ec1)
(cherry picked from commit da72383bf769e83af7ba94d51dad8ac62b5754eb)

4 years agorepart: fix incorrect error code propagation
Lennart Poettering [Mon, 19 Apr 2021 15:35:54 +0000 (17:35 +0200)]
repart: fix incorrect error code propagation

(cherry picked from commit a0ff9971802b664aaa12481c46cec11eae77ea51)
(cherry picked from commit a9b9f49b089f297b8ba2acf2b71f7fbd71f65e21)

4 years agoshell-completion: use base.lst, not xorg.lst
Peter Hutterer [Tue, 20 Apr 2021 07:09:48 +0000 (17:09 +1000)]
shell-completion: use base.lst, not xorg.lst

Since 2005 xorg.lst has been the legacy symlink to the real file base.lst.

(cherry picked from commit 7a4afd3a15f201a2230dce1f640fc37d18bc39ac)
(cherry picked from commit 6b5621353981ee36280e6c4f08540fc24c19ca26)

4 years agosd-login: fix wrong constructor used in sd_login_monitor manpage example
Jason Francis [Mon, 19 Apr 2021 16:16:26 +0000 (12:16 -0400)]
sd-login: fix wrong constructor used in sd_login_monitor manpage example

(cherry picked from commit 941c5275eaaf8d22915eb876045d2173bdbb7d4c)
(cherry picked from commit 17cb088d6dd3ac940a299c6c7201085252f1367d)

4 years agosd-login: correct prototype of sd_peer_get_cgroup
Jason Francis [Mon, 19 Apr 2021 16:13:03 +0000 (12:13 -0400)]
sd-login: correct prototype of sd_peer_get_cgroup

(cherry picked from commit a8310e39e996b9b5f63d897879aecf8988261bdb)
(cherry picked from commit fa7f835f79d4da8ee6d7403be43a0ba4d24b9fb2)

4 years agofileio: use take_fdopen_unlocked()
Yu Watanabe [Fri, 16 Apr 2021 01:08:36 +0000 (10:08 +0900)]
fileio: use take_fdopen_unlocked()

This fixes maybe-uninitialized warning:
```
../src/basic/fileio.c: In function ‘chase_symlinks_and_fopen_unlocked’:
../src/basic/fileio.c:1026:19: warning: ‘f’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1026 |         *ret_file = f;
      |         ~~~~~~~~~~^~~

```

(cherry picked from commit 6604fb0207ee10e8dc05d67f6fe45de0b193b5c4)
(cherry picked from commit 277277cbf0386be082555f92b5fce0521fee17b3)

4 years agoman: correct requirements for systemd-oomd.service
Anita Zhang [Fri, 16 Apr 2021 07:42:44 +0000 (00:42 -0700)]
man: correct requirements for systemd-oomd.service

Fixes: #19331
(cherry picked from commit 169be51f94b7017fea1394dcb412d3afdfd7cea5)
(cherry picked from commit 7208e7465b6cb1563cad46f568c78c725790d237)

4 years agojournald: fix %m usage
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 20:06:02 +0000 (22:06 +0200)]
journald: fix %m usage

(cherry picked from commit cf5a2ee82517429a34d9f5bef853cabe055e3e59)
(cherry picked from commit 4186be9a05e162c04d1b72a9ba95224c0a9aa2c3)

4 years agoshared/module-util: fix errno value passed to log function
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 15:10:36 +0000 (17:10 +0200)]
shared/module-util: fix errno value passed to log function

If r == 0, no harm done. But if r > 0, this would be interpreted as an
errno value, wrongly.

(cherry picked from commit a2eb2267e44580446ecad37e7206e729cfd78155)
(cherry picked from commit e70a773f85ceb64435de3d47c12b07c08605f591)

4 years agopartition, random-seed, logind: fix log messages with %m
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 10:14:01 +0000 (06:14 -0400)]
partition, random-seed, logind: fix log messages with %m

We would print "...: Success", which is not too terrible, but not pretty
either.

(cherry picked from commit 111a3aae71fa019710216cc5b7aa95b7c8db0937)
(cherry picked from commit c032a26df67903e0c65150b5cc68ade35aa47c03)

4 years agosd-device: improve log message and tweak style
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 09:54:17 +0000 (05:54 -0400)]
sd-device: improve log message and tweak style

We shouldn't say the attribute is missing right after ruling out ENOENT.

(cherry picked from commit aca591ac55e5ee364905aec975388c5e30d0476c)
(cherry picked from commit e31914aa17df889ae10f0964a8bbc8c00e0f045b)

4 years agotest: use systemd-run --wait in TEST-44-LOG-NAMESPACE
Luca Boccassi [Wed, 14 Apr 2021 20:26:50 +0000 (21:26 +0100)]
test: use systemd-run --wait in TEST-44-LOG-NAMESPACE

The test appears to be occasionally failing. It uses systemd-run to echo
'hello world' into a namespaced journal and then uses journalctl to look for it,
but it doesn't wait.
In the failed runs it can't find it, but the automated journal dump shows
the message at the end.

Use --wait to avoid races.

(cherry picked from commit cf9844ffabd7fd51f22e729692b79d55cd7bdd76)
(cherry picked from commit 2c17e13ae48b94a0fd02c7746d723b26a0f3dc65)

4 years agolibsystemd-network: fix dhcp option buffer confusion
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 08:55:09 +0000 (04:55 -0400)]
libsystemd-network: fix dhcp option buffer confusion

We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a306fd2ba454d3ee333d63df71aa3873.

(cherry picked from commit 828b603a791edd04a5c3603456aa8caca44ce67e)
(cherry picked from commit cd1fc467f72e607bcd2464651b68f31bd2a8791a)

4 years agomeson.build: typo
Sevan Janiyan [Wed, 14 Apr 2021 23:01:53 +0000 (00:01 +0100)]
meson.build: typo

(cherry picked from commit d5b3e5104448ebfecd334c26dbdd3a8274440b1e)
(cherry picked from commit 812384ce37acd909d70f9295a3b0fce98c8cf840)

4 years agorfkill: add some casts to silence -Werror=sign-compare
Luca Boccassi [Tue, 13 Apr 2021 12:17:53 +0000 (13:17 +0100)]
rfkill: add some casts to silence -Werror=sign-compare

(cherry picked from commit ab1aa6368a883bce88e3162fee2bea14aacedf23)

Fixes https://github.com/systemd/systemd-stable/issues/101.

(cherry picked from commit 074475abc1d6187de88b77dcc4fe0c4d2ab804f5)

4 years agonetwork: add missing default setting in networkd.conf
Yu Watanabe [Sun, 11 Apr 2021 12:25:16 +0000 (21:25 +0900)]
network: add missing default setting in networkd.conf

(cherry picked from commit 6bfadad9bb6eaf614da92eba0a9b6243e8645018)
(cherry picked from commit ee24f9346630b6d59e88ef0989f943444e752569)

4 years agoudev: delete useless codes
gaoyi [Tue, 13 Apr 2021 10:59:46 +0000 (18:59 +0800)]
udev: delete useless codes

It seems no one will touch queue.bin

(cherry picked from commit 993eb00016a75cf085eed85cf626a6995e96ab3d)
(cherry picked from commit a511010f380397e8bb08816288e31b1666dc11b9)

4 years agoload-fragment: parse specifiers in CPUAffinity= (#19281)
Francois Gervais [Mon, 12 Apr 2021 22:25:29 +0000 (18:25 -0400)]
load-fragment: parse specifiers in CPUAffinity= (#19281)

(cherry picked from commit 54cfe9a75f0e84d0604d39b87b1d919542336809)
(cherry picked from commit bf3bd598136397b5371188bcdec0127e56a1db9a)

4 years agomeson: do not fail if rsync is not installed with meson 0.57.2
Zbigniew Jędrzejewski-Szmek [Mon, 12 Apr 2021 12:03:32 +0000 (14:03 +0200)]
meson: do not fail if rsync is not installed with meson 0.57.2

https://github.com/mesonbuild/meson/issues/8641

Our CI started to fail. Even if the change is reverted in meson,
we need a quick workaround here.

(cherry picked from commit 7c5fd25119a495009ea62f79e5daec34cc464628)
(cherry picked from commit f6435a07c1ca4b895573eba4a64dcf4bef3fb92b)

4 years agosd-device: header needs an include because it uses sd_device type
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:09:11 +0000 (10:09 +0200)]
sd-device: header needs an include because it uses sd_device type

(cherry picked from commit 023e75df4c2904e493c4c8ff62df9fa99709d408)
(cherry picked from commit 004ab84cf201af928aa5d795ef89aa815b7e1776)

4 years agobpf-firewall: attach with BPF_F_ALLOW_MULTI if kernel supports
Julia Kartseva [Thu, 4 Feb 2021 06:15:27 +0000 (22:15 -0800)]
bpf-firewall: attach with BPF_F_ALLOW_MULTI if kernel supports

Reduced version of [0].
Use BPF_F_ALLOW_MULTI attach flag for bpf-firewall if kernel supports
it.

Aside from addressing security issue in [0] attaching with 'multi'
allows further attaching of cgroup egress, ingress hooks specified by
BPFProgram=.

[0] https://github.com/systemd/systemd/pull/17495/commits/4e42210d40f96e185a55d43041dd6b962ea830dd

(cherry picked from commit a442ccb4ebdbc3a9ff9d4504eb9724092149fd42)
(cherry picked from commit 0af3810d4b1c8bb4f0683758f47e042e8cb76972)

4 years agoman: fix discriptions for --exec-delay
gaoyi [Mon, 12 Apr 2021 08:09:47 +0000 (16:09 +0800)]
man: fix discriptions for --exec-delay

There are two ambiguity in the original description:
1. It will delay all RUN instructions, include builtin.
2. It will delay before running RUN, not each of RUN{program} instructions.

(cherry picked from commit 45f5efdea7e5e94bd47fc24b9bd404c77b5771a0)
(cherry picked from commit cb92f5601ad169e8f86a61319b73a8fd9e19950b)

4 years agotest-repart: use cryptsetup and losetup autoclose
Luca Boccassi [Fri, 9 Apr 2021 09:56:13 +0000 (10:56 +0100)]
test-repart: use cryptsetup and losetup autoclose

The test occasionally fails as the umount is not yet completed when
cryptsetup close is invoked.
Both cryptsetup and losetup have supported deferred cleanup for some
time now, so use it instead to avoid races.

++ losetup -P --show --find /tmp/test-repart.dMOfYQ8UUF/zzz
+ LOOP=/dev/loop6
+ VOLUME=test-repart-11882
+ touch /tmp/test-repart.dMOfYQ8UUF/empty-password
+ cryptsetup open --type=luks2 --key-file=/tmp/test-repart.dMOfYQ8UUF/empty*** test-repart-11882
+ mkdir /tmp/test-repart.dMOfYQ8UUF/mount
+ mount -t ext4 /dev/mapper/test-repart-11882 /tmp/test-repart.dMOfYQ8UUF/mount
+ diff -r /tmp/test-repart.dMOfYQ8UUF/mount/def /tmp/test-repart.dMOfYQ8UUF/definitions
+ umount /tmp/test-repart.dMOfYQ8UUF/mount
+ cryptsetup close test-repart-11882
Device test-repart-11882 is still in use.
+ rm -rf /tmp/test-repart.dMOfYQ8UUF

(cherry picked from commit 0efcbecd8b266526bf4a8fd06b9b7e7c5c43566d)
(cherry picked from commit 059da06d666c9f3caa7f5ad9d663f6acc430095b)

4 years agoTEST-22-TMPFILES: add reproducer for bug with X
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 20:35:19 +0000 (22:35 +0200)]
TEST-22-TMPFILES: add reproducer for bug with X

(cherry picked from commit 1672be86021b5ae8e80d095409a4fffcba7cbb75)
(cherry picked from commit 280b157fca7b44b19ec0067ebb88d2c16df1b6e1)

4 years agoman: fix quickhelp listing in tmpfiles.d(5)
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 16:26:15 +0000 (18:26 +0200)]
man: fix quickhelp listing in tmpfiles.d(5)

Unlike many other small/big letter combos, this one has the recursive
version attached to the lowercase letter.

(cherry picked from commit 3dd61ee5be0291380d341571e138713d2f89125a)
(cherry picked from commit ba8032c414dcf7c627cee3e979654bc5e294def3)