systemd/.git
5 years agoparse-util: make return parameter optional in safe_atou16_full()
Lennart Poettering [Mon, 1 Jun 2020 15:10:27 +0000 (17:10 +0200)]
parse-util: make return parameter optional in safe_atou16_full()

All other safe_atoXYZ_full() functions have the parameter optional,
let's make it optoinal here, too.

(cherry picked from commit aa85e4d3cef8ca8436e480bce9fa4ce72876b636)

5 years agoparse-util: allow '-0' as alternative to '0' and '+0'
Lennart Poettering [Mon, 1 Jun 2020 15:08:38 +0000 (17:08 +0200)]
parse-util: allow '-0' as alternative to '0' and '+0'

Let's allow "-0" as alternative to "+0" and "0" when parsing integers,
unless the new SAFE_ATO_REFUSE_PLUS_MINUS flag is specified.

In cases where allowing the +/- syntax shall not be allowed
SAFE_ATO_REFUSE_PLUS_MINUS is the right flag to use, but this also means
that -0 as only negative integer that fits into an unsigned value should
be acceptable if the flag is not specified.

(cherry picked from commit c78eefc13562a8fc0c22c00a6d3001af89860258)

5 years agoparse-util: allow tweaking how to parse integers
Lennart Poettering [Mon, 1 Jun 2020 15:06:19 +0000 (17:06 +0200)]
parse-util: allow tweaking how to parse integers

This allows disabling a few alternative ways to decode integers
formatted as strings, for safety reasons.

See: #15991
(cherry picked from commit 707e93aff8f358f8a62117e54b857530d6594e4b)

5 years agobasic/parse-util: add safe_atoux64()
Zbigniew Jędrzejewski-Szmek [Thu, 9 Apr 2020 09:18:26 +0000 (11:18 +0200)]
basic/parse-util: add safe_atoux64()

(cherry picked from commit ce51632a357d347737bf40d3817df331cd8874cb)

5 years agoefi: Cache contents of EFI variable SystemdOptions
Filipe Brandenburger [Wed, 10 Jun 2020 22:11:32 +0000 (15:11 -0700)]
efi: Cache contents of EFI variable SystemdOptions

Cache it early in startup of the system manager, right after `/run/systemd` is
created, so that further access to it can be done without accessing the EFI
filesystem at all.

(cherry picked from commit 209b2592ed5883bdfc7a0f2e5b7277c5c4fe834e)

5 years agobasic/efivars: try re-reading efivars without delay first
Zbigniew Jędrzejewski-Szmek [Sun, 31 May 2020 10:16:57 +0000 (12:16 +0200)]
basic/efivars: try re-reading efivars without delay first

Quoting https://github.com/systemd/systemd/issues/14828#issuecomment-635212615:

> [kernel uses] msleep_interruptible() and that means when the process receives
> any kind of signal masked or not this will abort with EINTR.  systemd-logind
> gets signals from the TTY layer all the time though.

> Here's what might be happening: while logind reads the EFI stuff it gets a
> series of signals from the TTY layer, which causes the read() to be aborted
> with EINTR, which means logind will wait 50ms and retry. Which will be
> aborted again, and so on, until quite some time passed. If we'd not wait for
> the 50ms otoh we wouldn't wait so long, as then on each signal we'd
> immediately retry again.

(cherry picked from commit eee9b30af41d2b3a265ad303234ac62bb46b7cd3)

5 years agoefi: add more logging for all EFI variable reads
Lennart Poettering [Wed, 27 May 2020 15:30:29 +0000 (17:30 +0200)]
efi: add more logging for all EFI variable reads

(cherry picked from commit 84190644ff4acea3cac3227f3dd85eddc3f8c673)

5 years agoefi: explicitly update mtime of EFI variables when changing them
Lennart Poettering [Wed, 27 May 2020 15:22:46 +0000 (17:22 +0200)]
efi: explicitly update mtime of EFI variables when changing them

(cherry picked from commit d197c403b2b71b6ab9b8cc9f3a171064b615018c)

5 years agoefi: as extra paranoia NUL terminate UTF-16 strings with three NUL bytes
Lennart Poettering [Wed, 27 May 2020 14:22:07 +0000 (16:22 +0200)]
efi: as extra paranoia NUL terminate UTF-16 strings with three NUL bytes

This is a safey net anyway, let's make it fully safe: if the data ends
on an uneven byte, then we need to complete the UTF-16 codepoint first,
before adding the final NUL byte pair. Hence let's suffix with three
NULs, instead of just two.

(cherry picked from commit c75e7da0b53dd67363b724502e91901e89097886)

5 years agoefivars: log whenever an EFI variable read access is slow
Lennart Poettering [Mon, 25 May 2020 15:13:57 +0000 (17:13 +0200)]
efivars: log whenever an EFI variable read access is slow

This should allow us to detect slowdowns caused by EFI variable read
access a bit.

(cherry picked from commit 698564d147ce09c0fedc9de10fe8e0850b729677)

5 years agobasic/efivars: fix errno propagation
Zbigniew Jędrzejewski-Szmek [Wed, 20 May 2020 16:08:05 +0000 (18:08 +0200)]
basic/efivars: fix errno propagation

Fixup for 484f4e5b2d62e885998fa3c09ed4d58b6c38f987. Should fix #15730.

(cherry picked from commit a0fa2683373a3fd69d628f62240c8faca25b0361)

5 years agoefi: honour SYSTEMD_EFI_OPTIONS even if we wouldn't honour SystemdOptions EFI var...
Lennart Poettering [Thu, 30 Apr 2020 08:08:54 +0000 (10:08 +0200)]
efi: honour SYSTEMD_EFI_OPTIONS even if we wouldn't honour SystemdOptions EFI var due to SecureBoot

Fixes: #14864
(cherry picked from commit 484f4e5b2d62e885998fa3c09ed4d58b6c38f987)

5 years agoefivars: retry open and read operations
Zbigniew Jędrzejewski-Szmek [Fri, 24 Apr 2020 08:53:46 +0000 (10:53 +0200)]
efivars: retry open and read operations

On my laptop (Lenovo X1carbo 4th) I very occasionally see test-boot-timestamps
fail with this tb:

262/494 test-boot-timestamps                    FAIL    0.7348453998565674 s (killed by signal 6 SIGABRT)

08:12:48 SYSTEMD_LANGUAGE_FALLBACK_MAP='/home/zbyszek/src/systemd/src/locale/language-fallback-map' SYSTEMD_KBD_MODEL_MAP='/home/zbyszek/src/systemd/src/locale/kbd-model-map' PATH='/home/zbyszek/src/systemd/build:/home/zbyszek/.local/bin:/usr/lib64/qt-3.3/bin:/usr/share/Modules/bin:/usr/condabin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/zbyszek/bin:/var/lib/snapd/snap/bin' /home/zbyszek/src/systemd/build/test-boot-timestamps
--- stderr ---
Failed to read $container of PID 1, ignoring: Permission denied
Found container virtualization none.
Failed to get SystemdOptions EFI variable, ignoring: Interrupted system call
Failed to read ACPI FPDT: Permission denied
Failed to read LoaderTimeInitUSec: Interrupted system call
Failed to read EFI loader data: Interrupted system call
Assertion 'q >= 0' failed at src/test/test-boot-timestamps.c:84, function main(). Aborting.

Normally it takes ~0.02s, but here there's a slowdown to 0.73 and things fail with EINTR.
This happens only occasionally, and I haven't been able to capture a strace.

It would be to ignore that case in test-boot-timestamps or always translate
EINTR to -ENODATA. Nevertheless, I think it's better to retry, since this gives
as more resilient behaviour and avoids a transient failure.

See
https://github.com/torvalds/linux/blob/master/fs/efivarfs/file.c#L75
and
https://github.com/torvalds/linux/commit/bef3efbeb897b56867e271cdbc5f8adaacaeb9cd.

(cherry picked from commit 7229ec02ab3a7f498b93158b500e697838ccdd9b)

5 years agoresolve: enable RES_TRUSTAD towards the 127.0.0.53 stub resolver
YmrDtnJu [Fri, 5 Jun 2020 13:36:58 +0000 (15:36 +0200)]
resolve: enable RES_TRUSTAD towards the 127.0.0.53 stub resolver

glibc 2.31 strips the AD flag, unless either the application specifies
RES_TRUSTAD or the options in resolv.conf contain trust-ad.

See https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=NEWS;hb=HEAD

(cherry picked from commit a742f9828ea73d9c2c9bafe701c10fe60f058012)

5 years agolldp: fix assertion checking argument for sd_lldp_set_neighbors_max()
Thomas Haller [Fri, 5 Jun 2020 17:48:13 +0000 (19:48 +0200)]
lldp: fix assertion checking argument for sd_lldp_set_neighbors_max()

Fixes: 34437b4f9c9c ('sd-lldp: rework sd-lldp API')
(cherry picked from commit 9141594cae1dfd2a17057d3d1effbd2164b1c235)

5 years agonetwork: make link become configured state when at least one dynamic protocol provide...
Yu Watanabe [Wed, 3 Jun 2020 08:07:16 +0000 (17:07 +0900)]
network: make link become configured state when at least one dynamic protocol provide an address

Before this, to speed up the system boot with IPv4 only network,
we need to specify `IPv6AcceptRA=no`, as it is enabled by default.

Closes #15469.

(cherry picked from commit 3cd5924c850929b03bc8d4ba5db614d662edb49a)

5 years agochange fs/file-max to LONG_MAX instead of ULONG_MAX
Einsler Lee [Thu, 4 Jun 2020 07:28:51 +0000 (15:28 +0800)]
change fs/file-max to LONG_MAX instead of ULONG_MAX

Since this has been changed in: https://github.com/systemd/systemd/commit/6e2f78948403a4cce45b9e34311c9577c624f066, the change should be synchronized.

(cherry picked from commit 168561f2eb01bd76ff4b8d5b69e76dfb0a6edba9)

5 years agoman: add note that emergency.target inherits mount state
Zbigniew Jędrzejewski-Szmek [Tue, 2 Jun 2020 12:26:26 +0000 (14:26 +0200)]
man: add note that emergency.target inherits mount state

Based on an internal discussion whether emergency.target should remount disks
ro, or maybe remount them rw, or do nothing. In some cases people want to boot
ro, and always remounting rw would break that. In other cases, remounting disks
ro after they have already been mounted rw is mostly pointless and might even
not be possible. So let's just document that we don't change the state.

Also: any→other, since emergency.service *is* pulled in.

Also: just advertise "emergency" as the way to boot into the target.
We are not going to remove this option, and it's way easier to type than
"systemd.unit=emergency.target".

(cherry picked from commit 927b9b8f63c2c8b1e56ffd127bf5366c02b2aa0f)

5 years agonetwork: read driver name from ethtool
Yu Watanabe [Wed, 3 Jun 2020 07:19:29 +0000 (16:19 +0900)]
network: read driver name from ethtool

To make Driver= in [Match] section work in containers.

Note that ID_NET_DRIVER= property in udev database is set with the
result of the ethtool. So, this should not change anything for
non-container cases.

Closes #15678.

(cherry picked from commit c643bda5ec3afe57c071d96b517cf20ec9f3423e)

5 years agoconf-parse: fix pretty bad typo
Lennart Poettering [Tue, 2 Jun 2020 14:49:50 +0000 (16:49 +0200)]
conf-parse: fix pretty bad typo

(cherry picked from commit 5aca2e6733d35534f82359e5720b3dea1d1332e5)

5 years agocore: set source_mtime after load dropins
Zbigniew Jędrzejewski-Szmek [Sun, 31 May 2020 12:35:40 +0000 (14:35 +0200)]
core: set source_mtime after load dropins

Dropins may specify SourcePath= too, but we would do the stat only
after loading the main fragment, before loading of the drop-ins.

Fixes #13634.

(cherry picked from commit c9e06956754036177442e0e225f8c63b1f7eac5f)

5 years agonetwork: use uint32_t instead of unsigned for route priority
Yu Watanabe [Mon, 1 Jun 2020 04:01:09 +0000 (13:01 +0900)]
network: use uint32_t instead of unsigned for route priority

(cherry picked from commit 132be2b8685883da4ffe756f4be69db0281c7483)

5 years agofd-util: be more careful with fclose() errnos
Lennart Poettering [Tue, 2 Jun 2020 08:39:25 +0000 (10:39 +0200)]
fd-util: be more careful with fclose() errnos

This might fix #15859, a bug which I find very puzzling.

(cherry picked from commit 75f6d5d87e950f62baced48fe9b58828969e3811)

5 years agonetwork: also read mtime of drop-in configs
Yu Watanabe [Mon, 1 Jun 2020 05:53:06 +0000 (14:53 +0900)]
network: also read mtime of drop-in configs

Fixes #15521.

(cherry picked from commit 9f83091e3cceb646a66fa9df89de6d9a77c21d86)

5 years agonetwork: do not propagte error on stat()
Yu Watanabe [Mon, 1 Jun 2020 07:19:50 +0000 (16:19 +0900)]
network: do not propagte error on stat()

(cherry picked from commit c4473dec34cd49db0a49b24dfe418ad2aa239328)

5 years agonetwork: fix double free in macsec_receive_channel_free()
Yu Watanabe [Fri, 29 May 2020 07:56:09 +0000 (16:56 +0900)]
network: fix double free in macsec_receive_channel_free()

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

(cherry picked from commit 0e77fc66bceb9832da82a56a4c1040fe49f8d805)

5 years agonetwork: wireguard: set ListenPort= when no peers are configured
Yu Watanabe [Mon, 1 Jun 2020 05:22:06 +0000 (14:22 +0900)]
network: wireguard: set ListenPort= when no peers are configured

Closes #15786.

(cherry picked from commit 50254f55006b896639a14af1254536ce979a9810)

5 years agoshell-completions: update bootctl
Zbigniew Jędrzejewski-Szmek [Sat, 30 May 2020 14:04:00 +0000 (16:04 +0200)]
shell-completions: update bootctl

Entries in the completion lists are reordered to follow --help output:
this makes it much easier to see what is missing.

(cherry picked from commit 8f0a346a290d6f7bddca32a080d36c0a64ed77f6)

[zjs: drop "reboot-to-firmware"]

5 years agobasic/user-util: always use base 10 for user/group numbers
Zbigniew Jędrzejewski-Szmek [Sun, 31 May 2020 16:21:09 +0000 (18:21 +0200)]
basic/user-util: always use base 10 for user/group numbers

We would parse numbers with base prefixes as user identifiers. For example,
"0x2b3bfa0" would be interpreted as UID==45334432 and "01750" would be
interpreted as UID==1000. This parsing was used also in cases where either a
user/group name or number may be specified. This means that names like
0x2b3bfa0 would be ambiguous: they are a valid user name according to our
documented relaxed rules, but they would also be parsed as numeric uids.

This behaviour is definitely not expected by users, since tools generally only
accept decimal numbers (e.g. id, getent passwd), while other tools only accept
user names and thus will interpret such strings as user names without even
attempting to convert them to numbers (su, ssh). So let's follow suit and only
accept numbers in decimal notation. Effectively this means that we will reject
such strings as a username/uid/groupname/gid where strict mode is used, and try
to look up a user/group with such a name in relaxed mode.

Since the function changed is fairly low-level and fairly widely used, this
affects multiple tools: loginctl show-user/enable-linger/disable-linger foo',
the third argument in sysusers.d, fourth and fifth arguments in tmpfiles.d,
etc.

Fixes #15985.

(cherry picked from commit 156a5fd297b61bce31630d7a52c15614bf784843)

5 years agoparse-util: backport safe_atou32_full()
Yu Watanabe [Tue, 23 Jun 2020 07:10:25 +0000 (09:10 +0200)]
parse-util: backport safe_atou32_full()

We need this for a follow up security fix.

(cherry picked from commit b934ac3d6e7dcad114776ef30ee9098693e7ab7e)

5 years agoefi: cache test results of boolean EFI state functions
Lennart Poettering [Tue, 28 Apr 2020 21:33:46 +0000 (23:33 +0200)]
efi: cache test results of boolean EFI state functions

EFI variable access is nowadays subject to rate limiting by the kernel.
Thus, let's cache the results of checking them, in order to minimize how
often we access them.

Fixes: #14828
(cherry picked from commit f46ba93944aac3f05211e0d630cdf84955eba2d8)

5 years agosd-journal: don't check namespaces if we have no namespace to go by
Lennart Poettering [Wed, 22 Apr 2020 17:48:48 +0000 (19:48 +0200)]
sd-journal: don't check namespaces if we have no namespace to go by

Fixes: #15528
(cherry picked from commit 2b6df46d21abe8a8b7481e420588a9a129699cf9)

5 years agonetwork: L2TP fix crash v245.6
Susant Sahani [Sat, 30 May 2020 04:35:28 +0000 (06:35 +0200)]
network: L2TP fix crash

```
=220358== Invalid read of size 8
==220358==    at 0x452F05: l2tp_session_free (l2tp-tunnel.c:46)
==220358==    by 0x456926: l2tp_tunnel_done (l2tp-tunnel.c:725)
==220358==    by 0x43CF4D: netdev_free (netdev.c:205)
==220358==    by 0x43D045: netdev_unref (netdev.c:210)
==220358==    by 0x4198B7: manager_free (networkd-manager.c:1877)
==220358==    by 0x40D0B3: manager_freep (networkd-manager.h:105)
==220358==    by 0x40DE1C: run (networkd.c:21)
==220358==    by 0x40DE75: main (networkd.c:130)
==220358==  Address 0x5c035d0 is 0 bytes inside a block of size 40 free'd
==220358==    at 0x483A9F5: free (vg_replace_malloc.c:538)
==220358==    by 0x452F87: l2tp_session_free (l2tp-tunnel.c:57)
==220358==    by 0x456857: netdev_l2tp_tunnel_verify (l2tp-tunnel.c:710)
==220358==    by 0x440947: netdev_load_one (netdev.c:738)
==220358==    by 0x441222: netdev_load (netdev.c:851)
==220358==    by 0x419C50: manager_load_config (networkd-manager.c:1934)
==220358==    by 0x40D7BE: run (networkd.c:87)
==220358==    by 0x40DE75: main (networkd.c:130)
==220358==  Block was alloc'd at
==220358==    at 0x4839809: malloc (vg_replace_malloc.c:307)
==220358==    by 0x452A76: malloc_multiply (alloc-util.h:96)
==220358==    by 0x4531E6: l2tp_session_new_static (l2tp-tunnel.c:82)
==220358==    by 0x455C01: config_parse_l2tp_session_id (l2tp-tunnel.c:535)
==220358==    by 0x48E6D72: next_assignment (conf-parser.c:133)
==220358==    by 0x48E77A3: parse_line (conf-parser.c:271)
==220358==    by 0x48E7E4F: config_parse (conf-parser.c:396)
==220358==    by 0x48E80E5: config_parse_many_files (conf-parser.c:453)
==220358==    by 0x48E8490: config_parse_many (conf-parser.c:512)
==220358==    by 0x44089C: netdev_load_one (netdev.c:729)
==220358==    by 0x441222: netdev_load (netdev.c:851)
==220358==    by 0x419C50: manager_load_config (networkd-manager.c:1934)

```

(cherry picked from commit a1422af564e3b1128fc7754596b4c2f8b36a4620)

5 years agoFix typo.
Michael Gubbels [Fri, 29 May 2020 23:40:39 +0000 (16:40 -0700)]
Fix typo.

(cherry picked from commit bf1abf1a2cd7bf7277b02ca1117535b451dc4728)

5 years agostat-util: trivial empty_or_null() tweaks
Lennart Poettering [Fri, 29 May 2020 15:46:40 +0000 (17:46 +0200)]
stat-util: trivial empty_or_null() tweaks

To small tweaks: /dev/null is definitely a char device. And if we have
the path, to a string base comparison first.

(cherry picked from commit 29da419305e6cc3c660172e7edcd2f423dc1108b)

5 years agoCheck ambient set against bounding set prior to applying ambient set
sterlinghughes [Thu, 28 May 2020 20:54:27 +0000 (13:54 -0700)]
Check ambient set against bounding set prior to applying ambient set

Fixes #15020

(cherry picked from commit 8acb11a6a337601a6f307fb50d77b13ffa0b3c5e)

5 years agoudev: when the BSD lock on a block device is taken, don't complain
Lennart Poettering [Tue, 26 May 2020 16:58:15 +0000 (18:58 +0200)]
udev: when the BSD lock on a block device is taken, don't complain

if someone implements https://systemd.io/BLOCK_DEVICE_LOCKING/ then we
shouldn't loudly complain about that.

This reverts back to the original behaviour from
3ebdb81ef088afd3b4c72b516beb5610f8c93a0d: when the lock is taken we
silently skip processing the device and sending out the messages for it.

(cherry picked from commit 5abee64ed40039404d68414f0189245988635e6c)

5 years agocore: add forgotten return in error path
Zbigniew Jędrzejewski-Szmek [Tue, 26 May 2020 14:07:30 +0000 (16:07 +0200)]
core: add forgotten return in error path

If we get an error here, this is most likely oom, and we should not continue.

(cherry picked from commit 1414090854829003c0d234042b218a3bd6f1cb0f)

5 years agoshared/efi-loader: remove check that uses absolute tick value
Zbigniew Jędrzejewski-Szmek [Tue, 26 May 2020 19:08:10 +0000 (21:08 +0200)]
shared/efi-loader: remove check that uses absolute tick value

sd-boot uses rdtsc to set those timestamps. There is no guarantee that the tsc
has any particular absolute value.

On my VM:
$ head /sys/firmware/efi/efivars/LoaderTime*
==> /sys/firmware/efi/efivars/LoaderTimeExecUSec-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f <==
4397904074
==> /sys/firmware/efi/efivars/LoaderTimeInitUSec-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f <==
4396386839
==> /sys/firmware/efi/efivars/LoaderTimeMenuUSec-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f <==
4396392521

$ build/test-boot-timestamps
...
LoaderTimeExecUSec=4396386839 too large, refusing.
Failed to read EFI loader data: Input/output error
Assertion 'q >= 0' failed at src/test/test-boot-timestamps.c:84, function main(). Aborting.

(with patch)
$ build/test-boot-timestamps
...
EFI Loader: start=1h 13min 16.386s exit=1h 13min 17.904s duration=1.517s
Firmware began 1h 13min 17.904074s before kernel.
Loader began 1.517235s before kernel.
Firmware began Tue 2020-05-26 11:04:13 CEST.
Loader began Tue 2020-05-26 12:17:30 CEST.
Kernel began Tue 2020-05-26 12:17:31 CEST.

(cherry picked from commit dde5c821bf33c085fcefb791bcb541510bb0e992)

5 years agogpt: include homed GPT partition type in well-known partition table
Lennart Poettering [Tue, 26 May 2020 16:52:15 +0000 (18:52 +0200)]
gpt: include homed GPT partition type in well-known partition table

(cherry picked from commit 7b11770bae0653eb7c9c81f90ebc7324c25bf697)

5 years agounits: don't set PrivateNetwork= in systemd-homed.service
Lennart Poettering [Tue, 26 May 2020 17:20:33 +0000 (19:20 +0200)]
units: don't set PrivateNetwork= in systemd-homed.service

We want to watch USB sticks being plugged in, and that requires
AF_NETLINK to work correctly and get the host's events. But if we live
in a network namespace AF_NETLINK is disconnected too and we'll not get
the host udev events.

Fixes: #15287
(cherry picked from commit 48432791accdcf775995781ddefd6027283f8a97)

5 years agoresolved-dns-query: remove dns_query_candidate_is_routable
Florian Klink [Sat, 23 Nov 2019 10:45:34 +0000 (11:45 +0100)]
resolved-dns-query: remove dns_query_candidate_is_routable

Resolved can't reliably determine on whether "it makes sense" to query
AAAA records when not explicitly specifying it in the request, so we
shouldn't remove them.

After having done the resolving, applications can use RFC6724 to
determine whether that address is reachable.

We can't know whether an address is reachable before having resolved it
and inspecting the routing table, and not resolving AAAA just because
there's no IPv6 default route on the main interface link them breaks
various setups, including IPv6-providing wireguard tunnels on a
non-dualstacked environment.

Fixes #5782
Fixes #5915
Fixes #8017

(cherry picked from commit 90bdc8be66765df09bbc355783cee7204a5ebb31)

5 years agosd-network: fix inverted error message
Zbigniew Jędrzejewski-Szmek [Sun, 24 May 2020 17:06:12 +0000 (19:06 +0200)]
sd-network: fix inverted error message

We get -ENOMSG when there is no lease.

(cherry picked from commit 2206aa5c35a20f923b6b80294725085833b86ce3)

5 years agonetwork: allow empty assignment to PreferredLifetime=
Zbigniew Jędrzejewski-Szmek [Thu, 21 May 2020 06:36:01 +0000 (08:36 +0200)]
network: allow empty assignment to PreferredLifetime=

Users might want to use that to unset a previous setting. The docs seem OK as
they are: we don't need to explictly mention the empty value, since it is
almost always allowed.

(cherry picked from commit 10b20e5a936e28de47b8c42fab8d73bce528fa8e)

5 years agoUpdate resolvectl zsh completion
codicodi [Thu, 21 May 2020 10:37:43 +0000 (12:37 +0200)]
Update resolvectl zsh completion

(cherry picked from commit d0192e93f8fa80df7e7a09a7466066db6fce851b)

5 years agoshared: treat generator units as vendor units
Jeremy Cline [Fri, 15 May 2020 20:28:35 +0000 (16:28 -0400)]
shared: treat generator units as vendor units

Units created with "systemctl edit --full" from generator units aren't
removed with "systemctl revert" because units in the generator,
generator_early, and generator_late paths aren't considered vendor
units.

Alter path_is_vendor() to return true if the given path is a
generator unit, which in turn causes "systemctl revert" to remove units
created with "systemctl edit --full" as they now have vendor versions.

Fixes #10053

(cherry picked from commit efdbf5fe9c4222725899d0e1093a09c5d649ab68)

5 years agotree-wide: fix bad errno checks
Zbigniew Jędrzejewski-Szmek [Wed, 20 May 2020 16:10:58 +0000 (18:10 +0200)]
tree-wide: fix bad errno checks

(cherry picked from commit 6b8664cb5b2577521e2d364153eb66649e558efb)

5 years agobus-message: immediately reject messages with invalid type
Zbigniew Jędrzejewski-Szmek [Wed, 20 May 2020 07:25:11 +0000 (09:25 +0200)]
bus-message: immediately reject messages with invalid type

For whatever reason, we were very permissive with accepting messages
of unknown type. Let's just reject any unknown types as early as
possible.

(cherry picked from commit a2dd991d0fde59dc0574bd4d0c1438f01dc0b8ff)

5 years agobus-message: fix negative offset with ~empty message
Zbigniew Jędrzejewski-Szmek [Wed, 20 May 2020 07:05:17 +0000 (09:05 +0200)]
bus-message: fix negative offset with ~empty message

In the linked reproducer, m->fields_size == 0, and we calculate ri == -1, which
of course doesn't end well. Skip the whole calculation if m->fields_size == 0,
and also check that we don't go negative even if it is non-zero.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19446 and #15583.

(cherry picked from commit e0c17a7d1bdd197dfb5e24ba527bd281f404f1a9)

5 years agoload-fragment: fix a typo
ExtinctFire [Wed, 20 May 2020 08:39:09 +0000 (16:39 +0800)]
load-fragment: fix a typo

Correct the typo of “priority” in log message

(cherry picked from commit 929fed02df3f6eda17c5e7d1f21c5490520d9b6a)

5 years agoNEWS: retroactively document Family=
Zbigniew Jędrzejewski-Szmek [Tue, 19 May 2020 14:21:52 +0000 (16:21 +0200)]
NEWS: retroactively document Family=

Requested in https://github.com/systemd/systemd/issues/13233#issuecomment-630800112.

(cherry picked from commit 70fcda8562b6a890e511fd39fa120a27471811bc)

5 years agoman: fix dir name in sysctl.d(5)
Zbigniew Jędrzejewski-Szmek [Mon, 18 May 2020 19:14:42 +0000 (21:14 +0200)]
man: fix dir name in sysctl.d(5)

Pointed out by Коренберг Марк in
https://github.com/systemd/systemd/commit/e0f424790d3dbde136a29a7fa4c2777c2e3fd695#commitcomment-39259499.

(cherry picked from commit 7b9289b1a0f0fe0a836fddc18b96d963673fad85)

5 years agojournalctl,elsewhere: make sure --file=foo fails with sane error msg if foo is not...
Lennart Poettering [Tue, 12 May 2020 21:36:27 +0000 (23:36 +0200)]
journalctl,elsewhere: make sure --file=foo fails with sane error msg if foo is not readable

It annoyed me for quite a while that running "journalctl --file=…" on a
file that is not readable failed with a "File not found" error instead
of a permission error. Let's fix that.

We make this work by using the GLOB_NOCHECK flag for glob() which means
that files are not accessible will be returned in the array as they are
instead of being filtered away. This then means that our later attemps
to open the files will fail cleanly with a good error message.

(cherry picked from commit 544e146b0e2f6227e28476e36becd1019b14ef70)

5 years agomakefs: log about OOM condition
Lennart Poettering [Mon, 18 May 2020 16:30:18 +0000 (18:30 +0200)]
makefs: log about OOM condition

(cherry picked from commit 700e0d3d87705a6ba01793d7130bbb8e6edbee16)

5 years agoblockdev: propagate one more unexpected error
Lennart Poettering [Mon, 18 May 2020 16:29:57 +0000 (18:29 +0200)]
blockdev: propagate one more unexpected error

(cherry picked from commit 6cba41ab0dbe5eb817f37bd43caff4754d801d3b)

5 years agorepart: don't insist on coming up on partition label ourselves
Lennart Poettering [Tue, 19 May 2020 07:23:00 +0000 (09:23 +0200)]
repart: don't insist on coming up on partition label ourselves

If the user specified a label, use that.

Fixes: #15841
(cherry picked from commit feb13fca97532b0a411a633fd601b93aa6f9275f)

5 years agojournal: fix dropping first record during upload to remote journal
Vladyslav Tronko [Thu, 14 May 2020 02:26:23 +0000 (05:26 +0300)]
journal: fix dropping first record during upload to remote journal

(cherry picked from commit bc48b25afd2800b643424125b05b822293840c2e)

5 years agomeson: initialize time-epoch to reproducible builds compatible value
Dimitri John Ledkov [Fri, 15 May 2020 18:16:05 +0000 (19:16 +0100)]
meson: initialize time-epoch to reproducible builds compatible value

Debian Policy encourages to preserve timestamps whenever possible in the
tarballs, thus stable release updates of systemd usually do not bump NEWS file
timestamp. And thus time-epoch remains the same for the lifetime of a release.

It would be better, if each new stable release rebuild of systemd would bump
the time epoch a bit. But at the same time remain
reproducible. SOURCE_DATE_EPOCH is an environmnet variable defined for this
purpose. Thus if available, prefer that, instead of the NEWS file modification
time.

For example, on Debian/Ubuntu under the reproducible builds the
SOURCE_DATE_EPOCH is set to the timestamp from the packaging metadata, thus it
is incremented on every new stable release update, whilst preserving
reproducible builds capability.

Reference: https://reproducible-builds.org/docs/timestamps/
(cherry picked from commit 6dbf352cfbbaf9c9b277af54da50da38296ae5c6)

5 years agolimit-util: quieten a very common debug message that is misleading
Lennart Poettering [Thu, 14 May 2020 17:11:18 +0000 (19:11 +0200)]
limit-util: quieten a very common debug message that is misleading

(cherry picked from commit 7cd9e4f8a087caa38acb5c7b0c41d38e82cf4d80)

5 years agoshared: fix integer overflow in calendarspec
Frantisek Sumsal [Fri, 15 May 2020 10:02:43 +0000 (12:02 +0200)]
shared: fix integer overflow in calendarspec

Fixes: oss-fuzz#22208

```
test/fuzz/fuzz-calendarspec/oss-fuzz-22208... ../src/shared/calendarspec.c:666:48: runtime error: signed integer overflow: 2147000000 + 1000000 cannot be represented in type 'int'
    #0 0x7f0b9f6cc56a in prepend_component ../src/shared/calendarspec.c:666
    #1 0x7f0b9f6cd03a in parse_chain ../src/shared/calendarspec.c:718
    #2 0x7f0b9f6cea1c in parse_calendar_time ../src/shared/calendarspec.c:845
    #3 0x7f0b9f6d1397 in calendar_spec_from_string ../src/shared/calendarspec.c:1084
    #4 0x401570 in LLVMFuzzerTestOneInput ../src/fuzz/fuzz-calendarspec.c:17
    #5 0x401ae0 in main ../src/fuzz/fuzz-main.c:39
    #6 0x7f0b9e31b1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #7 0x40122d in _start (/home/fsumsal/repos/systemd/build/fuzz-calendarspec+0x40122d)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/shared/calendarspec.c:666:48 in
```

(cherry picked from commit c07f18ffd458a224e1784f128df26b340c1c39c8)

5 years agorepart: suppress complaints about lack of BLKRRPART when operating on regular file
Lennart Poettering [Tue, 12 May 2020 15:08:39 +0000 (17:08 +0200)]
repart: suppress complaints about lack of BLKRRPART when operating on regular file

(cherry picked from commit 9a1deb8578268911f752129838e0f3c9a5cb89ea)

5 years agorepart: explain when we exit early and don't do a thing
Lennart Poettering [Tue, 12 May 2020 09:20:39 +0000 (11:20 +0200)]
repart: explain when we exit early and don't do a thing

(cherry picked from commit e2d65cd299355aba9afbaec24f04ed75ee3f0f1d)

5 years agomount: introduce mount_is_nofail() helper
Franck Bui [Thu, 2 Apr 2020 06:58:31 +0000 (08:58 +0200)]
mount: introduce mount_is_nofail() helper

(cherry picked from commit 5a7c4f4f3b3bc8f01fc2fa6ab55ed0b6665508e5)

5 years agomount: default startup dependencies and default network ones are orthogonal
Franck Bui [Thu, 2 Apr 2020 06:51:00 +0000 (08:51 +0200)]
mount: default startup dependencies and default network ones are orthogonal

Regardless of whether a mount is setup in initrd or int the main system,
the network default dependencies _netdev should still be honored.

IOW if a mount unit use the following options "x-initrd.mount,_netdev", it
should be ordered against initrd-fs.target, network.target,
network-online.target.

/dev/vdb1 /mnt ext4 x-initrd.mount,_netdev defaults 0 0

Before this patch:

Before=umount.target initrd-fs.target
After=system.slice sysroot.mount dev-vdb1.device -.mount systemd-journald.socket blockdev@dev-vdb1.target

After this patch:

Before=initrd-fs.target umount.target
After=network-online.target -.mount blockdev@dev-vdb1.target dev-vdb1.device sysroot.mount system.slice network.target systemd-journald.socket

(cherry picked from commit 2ec15c4f8a288d4f2e92ba2b8586736b2a07b9ea)

5 years agomount: introduce mount_add_default_ordering_dependencies()
Franck Bui [Thu, 9 Apr 2020 13:01:53 +0000 (15:01 +0200)]
mount: introduce mount_add_default_ordering_dependencies()

Move the handling of the usual startup/shutdown dependencies in a dedicated
funtion.

No functional change.

(cherry picked from commit 61154cf9533f0bbce674b2de22956f7086604c91)

5 years agoautomount: fix handling of default dependencies for automount units
Franck Bui [Thu, 2 Apr 2020 08:52:24 +0000 (10:52 +0200)]
automount: fix handling of default dependencies for automount units

First After=local-fs-pre.target wasn't described in the man page although it's
part of the default dependencies automatically set by pid1.

Secondly, Before=local-fs.target was only set if the automount unit was
generated from the fstab-generator because the dep was explicitly
generated. It was also not documented as a default dependency.

Fix it by managing the dep from pid1 instead.

(cherry picked from commit b3d7aef525dc1620a7948ffdbf3f36bfa3d5b5e8)

5 years agomount: let pid1 alone handle the default dependencies for mount units
Franck Bui [Thu, 2 Apr 2020 06:29:36 +0000 (08:29 +0200)]
mount: let pid1 alone handle the default dependencies for mount units

fstab-generator was also handling the default ordering dependencies for mount
units setup in initrd. To do that it was turning the defaults dependencies off
completely and ordered the mount unit against either local-fs.target or
initrd-fs.target or initrd-root-fs.target itself.

But it had the bad side effect to also remove all other default dependencies as
well. Thus if an initrd mount was using _netdev, the network dependencies were
missing.

In general fstab-generator shouldn't use DefaultDependecies=no because it can
handle only a small set of the default dependencies the rest are dealt by pid1.

So this patch makes pid1 handle all default dependencies.

(cherry picked from commit 83cdc870949823b5b9fa04dd76e952d42faab0b1)

5 years agomount: mount unit activated by automount unit should be only ordered against the...
Franck Bui [Wed, 1 Apr 2020 15:46:42 +0000 (17:46 +0200)]
mount: mount unit activated by automount unit should be only ordered against the automount unit

Both fstab-generator and pid1 are duplicating the handling of
"Before=local-fs.target" dependency for mount units.

fstab-generator is correctly skipping this dep if the mount unit is activated
by an automount unit.

However the condition used by pid1 was incorrect and missed the case when a mount
unit uses "x-systemd.automount" since in this case the mount unit should be
(only) ordered against its automount unit counterpart instead.

(cherry picked from commit 457d65932b3832cc8fd103d09ffb3e7ea924d07c)

5 years agogenerator: don't generate device dependencies for extrinsic mounts
Franck Bui [Mon, 30 Mar 2020 08:47:31 +0000 (10:47 +0200)]
generator: don't generate device dependencies for extrinsic mounts

Stop generating device dependencies for extrinsic mounts: we already exclude
extrinsic mounts from the usual start-up and shutdown dependencies but some
extra deps added by generator_write_device_deps() were remaining.

(cherry picked from commit ad8f1b0f3601b423b3bad5fe8de667de531ce7c4)

5 years agofstab-util: introduce fstab_is_extrinsic()
Franck Bui [Mon, 30 Mar 2020 08:39:21 +0000 (10:39 +0200)]
fstab-util: introduce fstab_is_extrinsic()

(cherry picked from commit bc9e5a4c67f5fff536d122118e16a53dfb592acd)

5 years agodevice: drop refuse_after
Franck Bui [Mon, 30 Mar 2020 08:49:29 +0000 (10:49 +0200)]
device: drop refuse_after

Scheduling devices after a given unit can be useful to start device *jobs* at a
specific time in the transaction, see commit 4195077ab4c823c.

This (hidden) change was introduced by commit eef85c4a3f8054d2.

(cherry picked from commit b862c25716520d9381d5a841dba0f0c14e9c970a)

5 years agoman: drop some left-over mentions of StandardOutput=syslog
Lennart Poettering [Thu, 14 May 2020 10:19:46 +0000 (12:19 +0200)]
man: drop some left-over mentions of StandardOutput=syslog

We dropped them from the StandardOuput= documentation long ago, but
elswhere some references where lurking.

(cherry picked from commit d2b843554add03b938416f33705e4896aee6995c)

5 years agosd-netlink: remove unused RTNL_WQUEUE_MAX define
Andreas Rammhold [Thu, 14 May 2020 17:23:33 +0000 (19:23 +0200)]
sd-netlink: remove unused RTNL_WQUEUE_MAX define

While investigating why some of my netlink calls would timeout I
stumbled upon the definition of the max write queue length. Finding this
constant made me believe we still had a write queue in the code - which
isn't true. The netlink write queue code was removed in #189.

(cherry picked from commit 32fcf399bfe7ff6e08ace48106567f8848a1b6e0)

5 years agotest: Add return 0 to main() function (even it is not strictly necessary)
Benjamin Robin [Sun, 10 May 2020 14:49:30 +0000 (16:49 +0200)]
test: Add return 0 to main() function (even it is not strictly necessary)

(cherry picked from commit 243945e95e8cfdef85b44e98a127496fcec8675d)

5 years agonetwork: 'cur' variable cannot be null, so simplify code
Benjamin Robin [Sat, 9 May 2020 19:19:12 +0000 (21:19 +0200)]
network: 'cur' variable cannot be null, so simplify code

(cherry picked from commit 81c5a5961fe655b0a735775e74be701f1a473ceb)

5 years agotree-wide: Initialize _cleanup_ variables if needed
Benjamin Robin [Sat, 9 May 2020 17:51:23 +0000 (19:51 +0200)]
tree-wide: Initialize _cleanup_ variables if needed

(cherry picked from commit b9c54c46652d74c4bd3a55a87abcb82d317cbb16)

5 years agonetlink: Fix assert condition on n_containers
Benjamin Robin [Sat, 9 May 2020 16:12:21 +0000 (18:12 +0200)]
netlink: Fix assert condition on n_containers

(cherry picked from commit 179b4db439ce4c41d44a6b5de22244c9ab54b252)

5 years agojournald: Increase stdout buffer size sooner, when almost full
Benjamin Robin [Sun, 3 May 2020 16:37:21 +0000 (18:37 +0200)]
journald: Increase stdout buffer size sooner, when almost full

If the previous received buffer length is almost equal to the allocated
buffer size, before this change the next read can only receive a couple
of bytes (in the worst case only 1 byte), which is not efficient.

(cherry picked from commit 034e9719ac1ba88a36b05da38c7aa98761d42c77)

5 years agocore: don't bind varlink socket if running in test mode
Lennart Poettering [Tue, 12 May 2020 15:28:27 +0000 (17:28 +0200)]
core: don't bind varlink socket if running in test mode

Fixes: #15748
(cherry picked from commit 08d50deaf813b44ebb8d64d2a2bd70344e9caedd)

5 years agopam_systemd: also print debug lines when ending a session
Lennart Poettering [Thu, 7 May 2020 08:35:48 +0000 (10:35 +0200)]
pam_systemd: also print debug lines when ending a session

(cherry picked from commit 45c5fa253a7241bfa7791fd39113aa0374b07b2e)

5 years agopam_systemd_home: use correct macro for converting ptr to fd
Lennart Poettering [Thu, 7 May 2020 08:49:52 +0000 (10:49 +0200)]
pam_systemd_home: use correct macro for converting ptr to fd

(cherry picked from commit da4340fd43abb9aed3a0fb29f632e9ac5f162f8a)

5 years agoFix misuse of PAM_PROMPT_ECHO_OFF in systemd-homed
Joel Shapiro [Sat, 9 May 2020 05:38:41 +0000 (00:38 -0500)]
Fix misuse of PAM_PROMPT_ECHO_OFF in systemd-homed

Previously pam_systemd_home.so was relying on `PAM_PROMPT_ECHO_OFF` to
display error messages to the user and also display the next prompt.
`PAM_PROMPT_ECHO_OFF` was never meant as a way to convey information to
the user, and following the example set in pam_unix.so you can see that
it's meant to _only_ display the prompt. Details about why the
authentication failed should be done in a `PAM_ERROR_MSG` before
displaying a short prompt as per usual using `PAM_PROMPT_ECHO_OFF`.

(cherry picked from commit d423294394a411a3fe98884993f9c1686edffb1b)

5 years agoshared/ethtool-util: hush gcc warnings about array bounds
Zbigniew Jędrzejewski-Szmek [Sat, 9 May 2020 07:09:11 +0000 (09:09 +0200)]
shared/ethtool-util: hush gcc warnings about array bounds

[127/1355] Compiling C object 'src/shared/5afaae1@@systemd-shared-245@sta/ethtool-util.c.o'
../src/shared/ethtool-util.c: In function ‘ethtool_get_permanent_macaddr’:
../src/shared/ethtool-util.c:260:60: warning: array subscript 5 is outside the bounds of an interior zero-length array ‘__u8[0]’ {aka ‘unsigned char[]’} [-Wzero-length-bounds]
  260 |                 ret->ether_addr_octet[i] = epaddr.addr.data[i];
      |                                            ~~~~~~~~~~~~~~~~^~~
In file included from ../src/shared/ethtool-util.c:5:
../src/shared/linux/ethtool.h:704:7: note: while referencing ‘data’
  704 |  __u8 data[0];
      |       ^~~~
../src/shared/ethtool-util.c: In function ‘ethtool_set_features’:
../src/shared/ethtool-util.c:488:31: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘__u32[0]’ {aka ‘unsigned int[]’} [-Wzero-length-bounds]
  488 |         len = buffer.info.data[0];
      |               ~~~~~~~~~~~~~~~~^~~
In file included from ../src/shared/ethtool-util.c:5:
../src/shared/linux/ethtool.h:631:8: note: while referencing ‘data’
  631 |  __u32 data[0];
      |        ^~~~

The kernel should not define the length of the array, but it does. We can't fix
that, so let's use a cast to avoid the warning.

For https://github.com/systemd/systemd/issues/6119#issuecomment-626073743.

v2:
- use #pragma instead of a cast. It seems the cast only works in some cases, and
  gcc is "smart" enough to see beyond the cast. Unfortunately clang does not support
  this warning, so we need to do a config check whether to try to suppress.

(cherry picked from commit 94c0c5b7eaa1529ff694318d3755181ba96ecefb)

5 years agocore: fix compilation with gcc -O3
Zbigniew Jędrzejewski-Szmek [Sat, 9 May 2020 06:53:27 +0000 (08:53 +0200)]
core: fix compilation with gcc -O3

../src/core/path.c: In function ‘path_serialize’:
../src/core/path.c:616:24: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  616 |                 (void) serialize_item_format(f, "path-spec", "%s %%i %%s",
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  617 |                                              path_type_to_string(s->type) //,
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  618 |                                              //                                             s->previous_exists,
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  619 |                                              //                                             s->path
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  620 |                 );
      |                 ~
In function ‘path_spec_dump’,
    inlined from ‘path_dump’ at ../src/core/path.c:392:17:
../src/core/path.c:226:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  226 |         fprintf(f,
      |         ^~~~~~~~~~
  227 |                 "%s%s: %s\n",
      |                 ~~~~~~~~~~~~~
  228 |                 prefix,
      |                 ~~~~~~~
  229 |                 path_type_to_string(s->type),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  230 |                 s->path);
      |                 ~~~~~~~~

s->type should be valid here, so let's just add an assert.

For https://github.com/systemd/systemd/issues/6119#issuecomment-626073743.

(cherry picked from commit 23450c897d11ccd8dfbe28cf3acca17f016e65be)

5 years agorandom-util: use ERRNO_IS_NOT_SUPPORTED() macro
Lennart Poettering [Sun, 10 May 2020 09:14:10 +0000 (11:14 +0200)]
random-util: use ERRNO_IS_NOT_SUPPORTED() macro

Some container mgr or sandbox solution might block it with an unexpected
error code, hence let's be tolerant here.

(cherry picked from commit e2b55464523adbb3732eb632ac2a21b685935642)

5 years agotmpfiles: clarify that "!" lines are filtered before collisions are checked
Lennart Poettering [Sun, 10 May 2020 09:45:52 +0000 (11:45 +0200)]
tmpfiles: clarify that "!" lines are filtered before collisions are checked

Fixes: #15675
(cherry picked from commit ead2a4a2310789a18615987ed293d8bb8a246a88)

5 years agoman: mention the exclamation mark and minus sign literally, to make things searchable
Lennart Poettering [Sun, 10 May 2020 09:44:53 +0000 (11:44 +0200)]
man: mention the exclamation mark and minus sign literally, to make things searchable

I was looking for the explanation for the exclamation mark in the text,
and couldn't find it, searching for "!". Let's make this easier, and
indicate the character meant.

(cherry picked from commit f742f9d317698c81ec58828814081d8d8a013762)

5 years agoman: clarify that exit status name mappings are unaffected by SuccessExitStatus=
Lennart Poettering [Mon, 11 May 2020 08:36:28 +0000 (10:36 +0200)]
man: clarify that exit status name mappings are unaffected by SuccessExitStatus=

Fixes: #15757

(Note there's quite some confusion regarding "exit status" vs. "exit
code" in the docs here. We should clean this up fully one day. This
change tries to fix some occasions of the wrong use, but not all.)

(cherry picked from commit 1e0d5eebf1da932a47c8e4c2728c2f008d09abca)

5 years agoseccomp-util: add new syscalls from kernel 5.6 to syscall filter table
Lennart Poettering [Sun, 10 May 2020 07:19:29 +0000 (09:19 +0200)]
seccomp-util: add new syscalls from kernel 5.6 to syscall filter table

(cherry picked from commit 8270e3d8ed320b41e14ec8578456228f578f0561)

5 years agotree-wide: Replace assert() by assert_se() when there is side effect
Benjamin Robin [Fri, 8 May 2020 11:32:11 +0000 (13:32 +0200)]
tree-wide: Replace assert() by assert_se() when there is side effect

(cherry picked from commit 20c3acfaad0b93990eafb6b994811db8c0617498)

5 years agonetworkctl: use uint64_t for link speed throughout
наб [Thu, 7 May 2020 19:34:39 +0000 (21:34 +0200)]
networkctl: use uint64_t for link speed throughout

format-table used size_t/uint64_t interchangeably for TABLE_BPS,
and ethtool-util used SIZE_MAX to indicate SPEED_UNKNOWN,
which worked only on ABIs with 64-bit pointers.

For example, the tg3 driver returns SPEED_UNKNOWN with no link (cf.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/broadcom/tg3.c?id=3eb2efbea193789397c36f52b17d8692ac79bf68#n12190)
which on x32 (and other 32-bit ABIs, presumably) caused
"networkctl status" to mark it with "Speed: 4Gbps":

nabijaczleweli@szarotka:~$ networkctl --version
systemd 245 (245.5-2)
nabijaczleweli@szarotka:~$ file $(which networkctl)
/bin/networkctl: ELF 32-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked, interpreter /libx32/ld-linux-x32.so.2,
BuildID[sha1]=36d684cb1fc8fb5060050d32b969e5aa172fa607, for GNU/Linux
3.4.0, stripped
nabijaczleweli@szarotka:~$ networkctl status onboard1
● 4: onboard1
                Driver: tg3
                 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express
                 Speed: 4Gbps

Whereas on 64-bit-pointer ABIs (here: amd64):

nabijaczleweli@szarotka:~$ networkctl --version
systemd 245 (245.5-2)
nabijaczleweli@szarotka:~$ file $(which networkctl)
/bin/networkctl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=7a3e406e54968d7774ad467fc3f6a9d35ff7aea2, for GNU/Linux
3.2.0, stripped
nabijaczleweli@szarotka:~$ networkctl status onboard1
● 4: onboard1
                Driver: tg3
                 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express
                 Speed: n/a

With this patch, networkctl returns, for x32:

nabijaczleweli@szarotka:~$ networkctl --version
systemd 245 (245.5-2.1~networkctl-4g-v2)
nabijaczleweli@szarotka:~$ file $(which networkctl)
/bin/networkctl: ELF 32-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked, interpreter /libx32/ld-linux-x32.so.2,
BuildID[sha1]=36d684cb1fc8fb5060050d32b969e5aa172fa607, for GNU/Linux
3.4.0, stripped
nabijaczleweli@szarotka:~$ networkctl status onboard1
● 4: onboard1
                Driver: tg3
                 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express
                 Speed: n/a

And for amd64:

nabijaczleweli@szarotka:~$ file $(which networkctl)
/bin/networkctl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=7a3e406e54968d7774ad467fc3f6a9d35ff7aea2, for GNU/Linux
3.2.0, stripped
nabijaczleweli@szarotka:~$ networkctl status onboard1
● 4: onboard1
                Driver: tg3
                 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express
                 Speed: n/a

(cherry picked from commit 2f665f24376c6fb0cceef69e50610e45132808bd)

5 years agotree-wide: use CMSG_SPACE() (and not CMSG_LEN()) to allocate control buffers
Lennart Poettering [Fri, 24 Apr 2020 21:36:03 +0000 (23:36 +0200)]
tree-wide: use CMSG_SPACE() (and not CMSG_LEN()) to allocate control buffers

We need to use the CMSG_SPACE() macro to size the control buffers, not
CMSG_LEN(). The former is rounded up to next alignment boundary, the
latter is not. The former should be used for allocations, the latter for
encoding how much of it is actually initialized. See cmsg(3) man page
for details about this.

Given how confusing this is, I guess we don't have to be too ashamed
here, in most cases we actually did get this right.

(cherry picked from commit a258f4915a2674d77e656755e5a4fa23059f778a)

5 years agoman: suffix pam options with "=" where arg is required too
Zbigniew Jędrzejewski-Szmek [Thu, 7 May 2020 11:28:39 +0000 (13:28 +0200)]
man: suffix pam options with "=" where arg is required too

(cherry picked from commit 1f63c72d2e6a527c1207ea01dc223fc711247ba0)

5 years agotest: Use assert_se() where variables are only checked by assert
Benjamin Robin [Wed, 6 May 2020 18:32:27 +0000 (20:32 +0200)]
test: Use assert_se() where variables are only checked by assert

Allow to build without any warning with NDEBUG defined

(cherry picked from commit 060d9c61b6ee80585082cf5a1e499195c4df8d42)

5 years agotree-wide: Fix, replace assert() by assert_se() when there is side effect
Benjamin Robin [Wed, 6 May 2020 18:30:43 +0000 (20:30 +0200)]
tree-wide: Fix, replace assert() by assert_se() when there is side effect

(cherry picked from commit f391597c6712ad90db37fe4a79047a45f4aca86a)

5 years agotree-wide: Mark as _unused_ variables that are only used in assert()
Benjamin Robin [Wed, 6 May 2020 18:29:31 +0000 (20:29 +0200)]
tree-wide: Mark as _unused_ variables that are only used in assert()

Allow to build without any warning with NDEBUG defined

(cherry picked from commit 0a0e594a26efe69afc3b05529dc0145a8d674e12)

5 years agotree-wide: Workaround -Wnonnull GCC bug
Benjamin Robin [Wed, 6 May 2020 19:24:05 +0000 (21:24 +0200)]
tree-wide: Workaround -Wnonnull GCC bug

See issue #6119

(cherry picked from commit 08f468567d9ebb56e04eb5585eda42add6cb4cb5)

5 years agoman: bring example PAM snippet of pam_systemd and pam_systemd_home back in sync
Lennart Poettering [Wed, 6 May 2020 20:28:37 +0000 (22:28 +0200)]
man: bring example PAM snippet of pam_systemd and pam_systemd_home back in sync

Let's make it the same snippet, just highlight different lines.

(cherry picked from commit 4ad5bf78655415b17550050bb7011420da7ff95b)

5 years agoman: highlight relevant lines in pam_systemd_home.so example PAM snippet
Lennart Poettering [Wed, 6 May 2020 20:26:54 +0000 (22:26 +0200)]
man: highlight relevant lines in pam_systemd_home.so example PAM snippet

let's do this like we do in the NSS module man pages.

(cherry picked from commit c6472bb019d57af5b9c4a95456885f097d7e87a5)

5 years agologin: include pam_systemd_home.so in the default PAM snippet we ship for user@.service
Lennart Poettering [Wed, 6 May 2020 20:25:34 +0000 (22:25 +0200)]
login: include pam_systemd_home.so in the default PAM snippet we ship for user@.service

Let's make sure systemd-homed works out-of-the box as well as possible.

(cherry picked from commit bd685faa1a3d08598322dc6e256ac585cffcdbac)