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)
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)
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)
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)
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)
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)
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)
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)
наб [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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Balint Reczey [Tue, 5 May 2020 19:24:53 +0000 (21:24 +0200)]
test: Skip test-boot-timestamps on permission denied
In containers even root can be denied to access the needed files.
(cherry picked from commit
e48471b94885b7e9861d468974cfc00e1455a7fd)
Lennart Poettering [Tue, 5 May 2020 19:46:56 +0000 (21:46 +0200)]
sysusers: be extra careful when locking accounts
Let's use "!*" instead of "!!" as invalid password string.
Generally, any invalid password string can be used to for locking an
account, according to shadow(5). To temporarily lock a password of an
account it is commonly implemented to prefix the original password with
a single "!", so that it can later on be unlocked again by removing the
"!", restoring the original password. Thus, the "!" marker is an
indicator for a locked password; the act of prefixing "!" to a
password string is the locking operation; and the removal of a "!"
prefix is the unlock operation. (This is also suggested in shadow(5)).
If we want to entirely lock an account we previously used "!!" as
password string. This is nice since it indicates the password is locked.
However, it is less than ideal, since applying the password unlock
operation once will change the string to "!", which is still a locked
password. Unlocking the password a second time will result in "", i.e.
the empty password, which will in many cases allow logging in without
password. And that's a problem. Hopefully, tools do not allow such
duplicate unlocking, but it's still not a nice property.
By changing our password string to "!*" we get different behaviour: the
password will appear locked. When it is unlocked the password is "*"
which is an invalid password. In that case the password is hence
unlocked but invalid, which is a much better state to be in than the
above.
This is paranoia hardening. Not more. There's no report that anyone
every unlocked an account twice and people could log in.
(cherry picked from commit
fc58c0c7bf7e4f525b916e3e5be0de2307fef04e)
Zbigniew Jędrzejewski-Szmek [Mon, 4 May 2020 17:45:19 +0000 (19:45 +0200)]
shared/install: print name of offending file in error
"Unit type slice cannot be templated."
↓
"/etc/systemd/system.control/user@.slice: unit type slice cannot be templated."
(cherry picked from commit
bce84e10f8e38982306b07596584287c1d27d79d)
Zbigniew Jędrzejewski-Szmek [Thu, 30 Apr 2020 16:45:08 +0000 (18:45 +0200)]
systemctl: fix --root support in querying presets
We would always look on the host, ignoring --root.
(cherry picked from commit
c39b7821f6d24d0b096ee347c6e1e2708391438f)
Zbigniew Jędrzejewski-Szmek [Thu, 30 Apr 2020 10:38:36 +0000 (12:38 +0200)]
systemctl: fix hint when 'systemctl help' is given
Not all verbs require unit names, but that is beside the point. We need a verb
here, and help is not a valid verb.
(cherry picked from commit
77102db288e533050397128da182b081a98211f7)
Zbigniew Jędrzejewski-Szmek [Thu, 30 Apr 2020 10:02:44 +0000 (12:02 +0200)]
shared/unit-file: fix resolution of absoulute symlinks with --root
$ systemctl --no-pager --root /tmp/root2/ cat ctrl-alt-del.target
Failed to resolve symlink /tmp/root2/etc/systemd/system/ctrl-alt-del.target pointing to /usr/lib/systemd/system/reboot.target, ignoring: Channel number out of range
...
(cherry picked from commit
b8239b9c501f6d08e918e74f0af301b2cc472b89)
Zbigniew Jędrzejewski-Szmek [Wed, 29 Apr 2020 16:22:46 +0000 (18:22 +0200)]
man: mention that ProtectSystem= also takes care of /efi
(cherry picked from commit
26b8190841fa6e00a66a4a46b343bde117b855fc)
Chris Down [Tue, 5 May 2020 19:16:10 +0000 (20:16 +0100)]
man: systemd.service: systemd-analyze exit-codes -> exit-status
5238d9a83a52 renames this to exit-status, but systemd.service was not
updated.
The rest of the doc seems a bit inconsistent in its use of the terms
"exit code" and "exit status", but it's not that confusing, so leave
those alone for now.
(cherry picked from commit
87afd40b5a926e303c188855a167ee21c3124528)
Lennart Poettering [Thu, 30 Apr 2020 11:42:59 +0000 (13:42 +0200)]
man: expand on the star…end/repetition time expressions
And attempt to explain what is requested in #15030, but still be
concise.
Fixes: #15030
(cherry picked from commit
2edc7aea7a95dc0dc0fb3e9ef5ffbe413a477593)
Lennart Poettering [Thu, 30 Apr 2020 11:24:31 +0000 (13:24 +0200)]
calendarspec: be more graceful with two kinds of calendar expressions
This changes the calendarspec parser to allow expressions such as
"00:05..05", i.e. a range where start and end is the same. It also
allows expressions such as "00:1-2/3", i.e. where the repetition value
does not fit even once in the specified range. With this patch both
cases will now be optimized away, i.e. the range is removed and a fixed
value is used, which is functionally equivalent.
See #15030 for an issue where the inability to parse such expressions
caused confusion.
I think it's probably better to accept these gracefully and optimizing
them away instead of refusing them with a plain EINVAL. With a tool such
as "systemd-analyze" calendar it should be easy to figure out the
normalized form with the redundant bits optimized away.
(cherry picked from commit
c9c9f6f450f678a0d5e5b929ba238d4a5254bded)
Lennart Poettering [Thu, 30 Apr 2020 11:20:23 +0000 (13:20 +0200)]
calendarspec: minor simplification
(cherry picked from commit
05851cb9df1305d53b99f1a0ee9d2acb7e1ffb52)
Lennart Poettering [Tue, 5 May 2020 06:19:30 +0000 (08:19 +0200)]
shutdown: fix spacing in shutdown error message
(cherry picked from commit
5fe4d1b51416c2fde35fc5ca0d3edf08844173a5)
Motiejus Jakštys [Mon, 4 May 2020 16:57:40 +0000 (19:57 +0300)]
nspawn: mount custom paths before writing to /etc
Consider such configuration:
$ systemd-nspawn --read-only --timezone=copy --resolv-conf=copy-host \
--overlay="+/etc::/etc" <...>
Assuming one wants `/` to be read-only, DNS and `/etc/localtime` to
work. One way to do it is to create an overlay filesystem in `/etc/`.
However, systemd-nspawn tries to create `/etc/resolv.conf` and
`/etc/localtime` before mounting the custom paths, while `/` (and, by
extension, `/etc`) is read-only. Thus it fails to create those files.
Mounting custom paths before modifying anything in `/etc/` makes this
possible.
Full example:
```
$ debootstrap buster /var/lib/machines/t1 http://deb.debian.org/debian
$ systemd-nspawn --private-users=false --timezone=copy --resolv-conf=copy-host --read-only --tmpfs=/var --tmpfs=/run --overlay="+/etc::/etc" -D /var/lib/machines/t1 ping -c 1 example.com
Spawning container t1 on /var/lib/machines/t1.
Press ^] three times within 1s to kill container.
ping: example.com: Temporary failure in name resolution
Container t1 failed with error code 130.
```
With the patch:
```
$ sudo ./build/systemd-nspawn --private-users=false --timezone=copy --resolv-conf=copy-host --read-only --tmpfs=/var --tmpfs=/run --overlay="+/etc::/etc" -D /var/lib/machines/t1 ping -qc 1 example.com
Spawning container t1 on /var/lib/machines/t1.
Press ^] three times within 1s to kill container.
PING example.com (93.184.216.34) 56(84) bytes of data.
--- example.org ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 110.912/110.912/110.912/0.000 ms
Container t1 exited successfully.
```
(cherry picked from commit
5c4deb9a5c29cf7b4f53009a1fb439b816cb3a34)
Emmanuel Garette [Thu, 30 Apr 2020 07:51:29 +0000 (09:51 +0200)]
repart: fix partition maximum size segfault
Discovered, tracked down and fix proposed by Emmanuel Garette.
See: https://lists.freedesktop.org/archives/systemd-devel/2020-April/044435.html
(Lennart turned this into a PR)
Fixes: #15608
(cherry picked from commit
db1442260a56963a8aa507787e71b97e5f08f17c)
nabijaczleweli [Wed, 29 Apr 2020 16:38:56 +0000 (18:38 +0200)]
link: Add units and fix typo in (Rx|Tx)BufferSize= manpage. Clean up the implementation slightly
(cherry picked from commit
80af9bdabe2aa6421568d5d20f4c513cf49a3e43)
Lennart Poettering [Wed, 22 Apr 2020 20:49:02 +0000 (22:49 +0200)]
main: bump RLIMIT_MEMLOCK by physical RAM size
Let's allow more memory to be locked on beefy machines than on small
ones. The previous limit of 64M is the lower bound still. This
effectively means on a 4GB machine we can lock 512M, which should be
more than enough, but still not lock up the machine entirely under
pressure.
Fixes: #15053
(cherry picked from commit
04d1ee0f7ec7a280136ddf5f3f34d6282a50846d)
Lennart Poettering [Wed, 22 Apr 2020 14:35:32 +0000 (16:35 +0200)]
nspawn: be more careful with creating/chowning directories to overmount
We should never re-chown selinuxfs.
Fixes: #15475
(cherry picked from commit
dcff2fa5d16f01edd774cd9dbc21fa4385af65bb)
Zbigniew Jędrzejewski-Szmek [Tue, 28 Apr 2020 07:09:26 +0000 (09:09 +0200)]
homectl: say "home area" in more places
Follow-up for
b5947b5b100f694c93857a82018fb0656d08be34.
(cherry picked from commit
c11428adf9a789ff2b13a4095450f47af2b49c30)
Zbigniew Jędrzejewski-Szmek [Tue, 28 Apr 2020 07:13:47 +0000 (09:13 +0200)]
userdbctl: make --help fit in 80 columns
(cherry picked from commit
7009610ff580f1238c71e50c71029bef0b2d00a7)
Ronan Pigott [Mon, 27 Apr 2020 06:16:55 +0000 (23:16 -0700)]
shell-completion/zsh: update systemd-analyze completions
(cherry picked from commit
4b6d94a1e59b75c8623a0eaea49cc7ff26c8b820)
Haochen Tong [Sun, 26 Apr 2020 22:30:49 +0000 (00:30 +0200)]
zsh: fix disable/enable completion
The "preset" column introduced in
b01c1f305c044a381ad110709a62507d74bf6d86 breaks zsh completion for
systemctl disable/enable. Fix by ignoring everything after the last
space in a line.
(cherry picked from commit
f5b3be308d1c72c34b1204702a21233b6585b533)
Dan Streetman [Sat, 21 Mar 2020 15:19:44 +0000 (11:19 -0400)]
cgroup-util: check for SYSFS_MAGIC when detecting cgroup format
When nothing at all is mounted at /sys/fs/cgroup, the fs.f_type is
SYSFS_MAGIC (0x62656572) which results in the confusing debug log:
"Unknown filesystem type
62656572 mounted on /sys/fs/cgroup."
Instead, if the f_type is SYSFS_MAGIC, a more accurate message is:
"No filesystem is currently mounted on /sys/fs/cgroup."
(cherry picked from commit
0bc5f001dbf25ea264a9b61aafd3d7362f53b7be)
Lennart Poettering [Thu, 23 Apr 2020 12:50:53 +0000 (14:50 +0200)]
stat-util: no need to open a file to check fs type
(cherry picked from commit
6d965610bde404f60c43accb12f570ab75d4195e)
Lennart Poettering [Thu, 23 Apr 2020 12:50:07 +0000 (14:50 +0200)]
sysusers,tmpfiles: always mention error when failing to replace specifiers
(cherry picked from commit
0f7e4b2888840e7e6a702aa8ce5d3e3b2bc077ef)
Lennart Poettering [Thu, 23 Apr 2020 12:49:14 +0000 (14:49 +0200)]
sysusers: add accidentally forgotten 'return'
(cherry picked from commit
2230e8f29ddb018697b9c3d13c1f522c62976e70)
Lennart Poettering [Thu, 23 Apr 2020 14:51:37 +0000 (16:51 +0200)]
man: document binfmt's new --unregister switch
(cherry picked from commit
cd9aa8f0f91b113acb079e79750c146c0529c2d7)
Lennart Poettering [Thu, 23 Apr 2020 14:36:45 +0000 (16:36 +0200)]
binfmt: also unregister binfmt entries from unit
We unregister binfmt_misc twice during shutdown with this change:
1. A previous commit added support for doing that in the final shutdown
phase, i.e. when we do the aggressive umount loop. This is the robust
thing to do, in case the earlier ("clean") shutdown phase didn't work
for some reason.
2. This commit adds support for doing that when systemd-binfmt.service
is stopped. This is a good idea so that people can order mounts
before the service if they want to register binaries from such
mounts, as in that case we'll undo the registration on shutdown
again, before unmounting those mounts.
And all that, just because of that weird "F" flag the kernel introduced
that can pin files...
Fixes: #14981
(cherry picked from commit
846acb6798a63f35162f58e1146d1a1f40849e86)
Lennart Poettering [Thu, 23 Apr 2020 14:27:46 +0000 (16:27 +0200)]
binfmt: modernize code a bit
Let's just copy out the bit of the string we need, and let's make sure
we refuse rules called "status" and "register", since those are special
files in binfmt_misc's file system.
(cherry picked from commit
f3670df13e144c2f81bf6f9a0bea581e6d555bdd)
Lennart Poettering [Thu, 23 Apr 2020 14:25:53 +0000 (16:25 +0200)]
shutdown: unregister all binfmt_misc entries before entering shutdown loop
Apparently if the new "F" flag is used they might pin files, which
blocks us from unmounting things. Let's hence clear this up explicitly.
Before entering our umount loop.
Fixes: #14981
(cherry picked from commit
0282c0285a3e3c2e409305ce28555a6ad0489539)
Lennart Poettering [Thu, 23 Apr 2020 14:36:06 +0000 (16:36 +0200)]
shared: add common helper for unregistering all binfmt entries
(cherry picked from commit
965cc99416a3b5a2a71127e9e6d2e4a95ab3c432)
Lennart Poettering [Thu, 23 Apr 2020 11:46:10 +0000 (13:46 +0200)]
home: fix strv NUL termination
Fixes: #15559
(cherry picked from commit
113a51d22139ecb8d60163ec1a5bf05016cfeb77)
Lennart Poettering [Thu, 23 Apr 2020 13:18:18 +0000 (15:18 +0200)]
networkd: don't do lldp rx nor tx on bond devices
Fixes: #15146
(cherry picked from commit
b2cdefad3a437a756f99f93344422f665f59ef45)
Daan De Meyer [Wed, 22 Apr 2020 20:02:17 +0000 (22:02 +0200)]
sd-bus: Fix typo in sd_bus_message_append_array docs
(cherry picked from commit
31e4abd1a6afd18ad049a589d44ec0b58cc6c22f)
Zbigniew Jędrzejewski-Szmek [Thu, 23 Apr 2020 12:53:54 +0000 (14:53 +0200)]
shared: add NULL callback check in one more place
Follow-up for
9f65637308.
(cherry picked from commit
d3d53e5cd143bf96d1eb0e254f16fa8d458d38ce)
Zbigniew Jędrzejewski-Szmek [Wed, 22 Apr 2020 21:27:51 +0000 (23:27 +0200)]
core: fix unused variable warning when !HAVE_SECCOMP
(cherry picked from commit
8f3e342fa9d14ad68143f364231069e8c4074f02)
Lennart Poettering [Thu, 23 Apr 2020 11:36:00 +0000 (13:36 +0200)]
udev: prepare memory for extra NUL termination for NULSTR
Fixes: #15162
(cherry picked from commit
cd3c8a117ccf3505e49d34324473e2175ef0a9ce)
Lennart Poettering [Thu, 23 Apr 2020 07:40:03 +0000 (09:40 +0200)]
tree-wide: use recvmsg_safe() at various places
Let's be extra careful whenever we return from recvmsg() and see
MSG_CTRUNC set. This generally means we ran into a programming error, as
we didn't size the control buffer large enough. It's an error condition
we should at least log about, or propagate up. Hence do that.
This is particularly important when receiving fds, since for those the
control data can be of any size. In particular on stream sockets that's
nasty, because if we miss an fd because of control data truncation we
cannot recover, we might not even realize that we are one off.
(Also, when failing early, if there's any chance the socket might be
AF_UNIX let's close all received fds, all the time. We got this right
most of the time, but there were a few cases missing. God, UNIX is hard
to use)
(cherry picked from commit
3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1)
Lennart Poettering [Fri, 17 Apr 2020 20:26:14 +0000 (22:26 +0200)]
socket-util: add recvmsg_safe() wrapper that handles MSG_CTRUNC
(cherry picked from commit
47eae6ce0c28b1984f8f5ec4c2f7bc428cf3b6ad)
Lennart Poettering [Wed, 22 Apr 2020 17:32:09 +0000 (19:32 +0200)]
sd-bus: work around ubsan warning
ubsan complains that we add an offset to a NULL ptr here in some cases.
Which isn't really a bug though, since we only use it as the end
condition for a for loop, but we can still fix it...
Fixes: #15522
(cherry picked from commit
0cd41757d061c4b0a85532499f29f23651279234)
Balint Reczey [Wed, 22 Apr 2020 07:51:53 +0000 (09:51 +0200)]
shared: Don't try calling NULL callback in bus_wait_for_units_clear
BugLink: https://bugs.launchpad.net/bugs/1870930
(cherry picked from commit
9f656373082cb13542b877b4f5cb917ef5ff329c)
Lennart Poettering [Wed, 22 Apr 2020 18:08:34 +0000 (20:08 +0200)]
run: don't wait for start job to complete when running interactively anyway
Otherwise we'd not read the services input while waiting for the job to
wait, and there's no point in waiting for the job anyway if we wait for
the unit to stop ultimately.
Fixes: #15395
(cherry picked from commit
a7c71d214c37797d82de2f66cfe0a0a79c3a5c92)
Niklas Hambüchen [Thu, 23 Apr 2020 00:26:32 +0000 (02:26 +0200)]
man: Fix typo "multiplied with" -> "multiplied by"
(cherry picked from commit
69123c218c5783ddc9e0e36ce8a48fc0726274fe)
Lennart Poettering [Wed, 22 Apr 2020 19:52:22 +0000 (21:52 +0200)]
core: make sure we don't get confused when setting TERM for a tty fd
Fixes: #15344
(cherry picked from commit
e8cf09b2a2ad0d48e5493050d54251d5f512d9b6)
Lennart Poettering [Wed, 22 Apr 2020 14:42:38 +0000 (16:42 +0200)]
man: document that VirtualEthernetExtra= has nothing to do with Bridge=
Fixes: #15402
(cherry picked from commit
60e16d20a3eab0d3a4e0c839c76ae974bea1b8d9)
Luca Boccassi [Tue, 21 Apr 2020 16:28:01 +0000 (17:28 +0100)]
core: add debug log when a job in the activation queue is not runnable
When a job is skipped due its dependencies not being ready, log
a debug message saying what is holding it back.
This was very useful with transient units timing out to figure
out where the problem was.
(cherry picked from commit
c03fbd37d662a1cb8b63f505b1dd29389eba1d2e)
Luca Boccassi [Tue, 21 Apr 2020 16:23:21 +0000 (17:23 +0100)]
core: add log_get_max_level check optimization in log_unit_full
Just as log_full already does, check if the log level would result in
logging immediately in the macro in order to avoid doing
unnecessary work that adds up in hot spots.
(cherry picked from commit
c5bc2c01eef4d3defb58245960065a063f5f75cf)
Balaji Punnuru [Thu, 9 Apr 2020 16:21:49 +0000 (12:21 -0400)]
util: return the correct correct wd from inotify helpers
We need to propagate the acquired watch descriptors because our callers
are counting on them.
[Lennart: this is split out of #15381 and simplified]
(cherry picked from commit
f6f4f5fe5395a57f10dd446c7266c53f0673eaac)
Lennart Poettering [Tue, 21 Apr 2020 15:21:38 +0000 (17:21 +0200)]
core: minor error code handling fixes
(cherry picked from commit
df3d3bdfe8a1c8c63a4ef1ead35d24788fefe05b)
Lennart Poettering [Tue, 21 Apr 2020 09:18:56 +0000 (11:18 +0200)]
man: document how to get the boot menu with zero time-out
Fixes: #15125
(cherry picked from commit
e14a0c21e9c0caa1cf63844d3b1629756f2d2953)
Zbigniew Jędrzejewski-Szmek [Mon, 20 Apr 2020 11:52:35 +0000 (13:52 +0200)]
resolved: return org.freedesktop.resolve1.DnsError.NXDOMAIN on LLMNR resolution failure
Fixes #14922.
(cherry picked from commit
e53b8cc5216742f919dff35d9c86397b06d5f33d)
Zbigniew Jędrzejewski-Szmek [Mon, 20 Apr 2020 07:20:01 +0000 (09:20 +0200)]
man: use manpages.ubuntu.com for resolvconf(8) link
Add manpages.debian.org as a man citeref "project", so we can refer to man
pages hosted there. resolvconf(8) doesn't seem to appear on any of the ones we
currently have defined.
We are doing a trick, where our man page is installed as resolvconf(1), and
we refer the reader to resolvconf(8). This can be pretty confusing, so the
least we can do is to provide a non-broken symlink ;)
v2:
- link to manpages.d.o instead of manpages.ubuntu.com, because debian is the
upstream here, and because with debian we can use /unstable/ as the version,
and ubuntu doesn't seem to have any such shortcut, so the version would need
to be periodically updated.
(cherry picked from commit
42ecca2e6839aa4a36e335564461731ceee9180a)
Zbigniew Jędrzejewski-Szmek [Sun, 19 Apr 2020 20:01:21 +0000 (22:01 +0200)]
man: add a note that resolvconf updates /etc/resolv.conf in specific circumstances
When someone knows how the whole ecosystem works, this is understandable.
But for someone coming from a system where resolvconf updates /etc/resolv.conf
directly, this can be rather surprising.
For https://bugzilla.redhat.com/show_bug.cgi?id=
1815605.
(cherry picked from commit
924ccc35f95cabbcb475a659f4a2e2f4cd9ff7c6)
Zbigniew Jędrzejewski-Szmek [Fri, 17 Apr 2020 16:29:23 +0000 (18:29 +0200)]
resolvectl: fix indentation of hexdump'ed packets
ebf963c551e1077abaa5e0fa0f330e6d1c23565e changed the 'sep' argument to always
be either " " or "\n", which broke the indentation logic for the first line
in base64_append_width(). Since it now always is one character, and never NULL,
let's change the type to char and simplify the logic a bit.
$ COLUMNS=30 build/test-dns-packet test/test-resolve/org~
20200417.pkts
============== test/test-resolve/org~
20200417.pkts ==============
org IN DNSKEY 256 3 RSASHA1-NSEC3-SHA1
AwEAAcLPVEcg0hFBheXQf
QOqqLiRgckk69o2KTAsq3
lNRY0c9mnEjzZDGsGmXNy
2EQ6yelkIYYus7KLor2Fz
x59hEqcM82zqkdHV6hXvZ
yjxxSHG3nl8xQS6gF8mdI
YouDTWWhTInfjSKoIeDok
Hq3S67EjSngV7/wVCMTbI
amS0NF4H
-- Flags: ZONE_KEY
-- Key tag: 37022
...
$ COLUMNS=120 build/test-dns-packet test/test-resolve/org~
20200417.pkts
============== test/test-resolve/org~
20200417.pkts ==============
org IN DNSKEY 256 3 RSASHA1-NSEC3-SHA1 AwEAAcLPVEcg0hFBheXQfQOqqLiRgckk69o2KTAsq3lNRY0c9mnEjzZDGsGmXNy2EQ6yelkIYYus7KLor
2Fzx59hEqcM82zqkdHV6hXvZyjxxSHG3nl8xQS6gF8mdIYouDTWWhTInfjSKoIeDokHq3S67EjSngV7/w
VCMTbIamS0NF4H
-- Flags: ZONE_KEY
-- Key tag: 37022
...
(cherry picked from commit
0136b1d1e091809065cfa5c9824664cacfdb5655)
Lennart Poettering [Thu, 16 Apr 2020 10:04:03 +0000 (12:04 +0200)]
journald: add configuration option for enabling/disabling audit during journald startup
Let's make it optional whether auditing is enabled at journald start-up
or not.
Note that this only controls whether audit is enabled/disabled in the
kernel. Either way we'll still collect the audit data if it is
generated, i.e. if some other tool enables it, we'll collect it.
Fixes: #959
(cherry picked from commit
511e03a3eedb7613beb0ba59f98fdc1dd753aced)
Luca BRUNO [Thu, 16 Apr 2020 13:28:18 +0000 (13:28 +0000)]
man/systemd-service: clarify env variable expansion
This clarifies some more aspects of `${FOO}` expansions in service
units, mostly trying to answer my own doubts about what happens when
the matching variable is not defined.
(cherry picked from commit
3db1c62d22b8659ad0cdbbae561e07f63abf0162)
Zbigniew Jędrzejewski-Szmek [Thu, 16 Apr 2020 15:55:48 +0000 (17:55 +0200)]
resolved: fix typo in an unused function and add comment
Follow-up for
2615691003b9d73a92590b8250a54ad135e3a33b.
(cherry picked from commit
a942084057c212d6a7306b60ed3f9bbe3bf3d719)
Zbigniew Jędrzejewski-Szmek [Thu, 16 Apr 2020 15:23:41 +0000 (17:23 +0200)]
network: use "FooOverUDP" as one word
The whole thing is one name, and I think it's confusing to break it
up into separate words.
(cherry picked from commit
fac216635916eee9aa2b08b978bf60d97ac95179)
Zbigniew Jędrzejewski-Szmek [Thu, 16 Apr 2020 14:49:30 +0000 (16:49 +0200)]
network: fix static assertion on IPPROTO_MAX range
Builds with recent glibc would fail with:
../src/network/netdev/fou-tunnel.c: In function ‘config_parse_ip_protocol’:
../src/basic/macro.h:380:9: error: static assertion failed: "IPPROTO_MAX-1 <= UINT8_MAX"
380 | static_assert(expr, #expr)
| ^~~~~~~~~~~~~
../src/network/netdev/fou-tunnel.c:161:9: note: in expansion of macro ‘assert_cc’
161 | assert_cc(IPPROTO_MAX-1 <= UINT8_MAX);
| ^~~~~~~~~
This is because
f9ac84f92f151e07586c55e14ed628d493a5929d (present in
glibc-2.31.9000-9.fc33.x86_64) added IPPROTO_MPTCP=262, following
v5.5-rc5-1002-gfaf391c382 in the kernel.
(cherry picked from commit
3d58d7328a6ecbc61d3494803d705edd8a108d72)
Lennart Poettering [Thu, 16 Apr 2020 13:06:58 +0000 (15:06 +0200)]
resolved: tone down comment in /run/systemd/{stub-,}resolve.conf
There are legitimate reasons to access the file directly, as currently
discussed on fedora-devel. Hence tone things down from "must" to "should
typically not".
Also, let's use fputs() instead of fputs_unlocked() here,
fopen_temporary_label() turns off stdio locking anyway for the whole
FILE*, hence no need to do this manually each time.
(cherry picked from commit
ce416f425c509bac429b8c9971f5f4edf726a54f)
Zbigniew Jędrzejewski-Szmek [Thu, 16 Apr 2020 11:46:37 +0000 (13:46 +0200)]
logind: skip polkit query with --no-wall
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=
1800875.
(cherry picked from commit
5644d47b7c288c4126aab60d2d6a65923f7df4cc)
Giedrius Statkevičius [Tue, 7 Apr 2020 21:38:16 +0000 (00:38 +0300)]
verify: ignore nonexistent executables if required
We provide a way via the '-' symbol to ignore errors when nonexistent
executable files are passed to Exec* parameters & so on. In such a case,
the flag `EXEC_COMMAND_IGNORE_FAILURE` is set and we go on happily with
our life if that happens. However, `systemd-analyze verify` complained
about missing executables even in such a case. In such a case it is not
an error for this to happen so check if the flag is set before checking
if the file is accessible and executable.
Add some small tests to check this condition.
Closes #15218.
(cherry picked from commit
c90c597ee3b6b9d30ee86410e46939ba875e467a)
Lennart Poettering [Mon, 13 Apr 2020 09:26:15 +0000 (11:26 +0200)]
hwdb: optimize isatty()-per-line away
Fixes: #15407
(cherry picked from commit
648ba0ee8178105777502cfcd869d7c04511db96)
Lennart Poettering [Mon, 13 Apr 2020 09:25:43 +0000 (11:25 +0200)]
fileio: extend comment a bit
(cherry picked from commit
451fcbfc58d3ccb9855095666aa9ba4ae1327224)
Lennart Poettering [Mon, 13 Apr 2020 09:20:59 +0000 (11:20 +0200)]
fileio: optionally allow telling read_line_full() whether we are processing a tty or not
(cherry picked from commit
609ae0f59619619efe6db07e34f73a237e7f332b)
Lennart Poettering [Mon, 13 Apr 2020 08:09:44 +0000 (10:09 +0200)]
fileio: fileno() can realistically return -1
An stdio FILE* stream usually refers to something with a file
descriptor, but that's just "usually". It doesn't have to, when taking
fmemopen() and similar into account. Most of our calls to fileno()
assumed the call couldn't fail. In most cases this was correct, but in
some cases where we didn't know whether we work on files or memory we'd
use the returned fd as if it was unconditionally valid while it wasn't,
and passed it to a multitude of kernel syscalls. Let's fix that, and do
something reasonably smart when encountering this case.
(Running test-fileio with this patch applied will remove tons of ioctl()
calls on -1).
(cherry picked from commit
14f594b995bbaea85456a4c26e5c07446a4c446e)
Frantisek Sumsal [Sun, 12 Apr 2020 18:39:09 +0000 (20:39 +0200)]
coredumpctl: support --file=PATH
Let's match journalctl's functionality by throwing --file for
coredumpctl into the mix, so we can work on a single journal file
as well.
(cherry picked from commit
aeb56450820f824785d1d2718064598293e3bd6c)
Joel Shapiro [Sun, 12 Apr 2020 05:40:17 +0000 (00:40 -0500)]
Fix pam_systemd_home's debug parameter to match man page description
(cherry picked from commit
332f38d084c68c3d524c086f4d7843a2fd048ba8)
Lennart Poettering [Mon, 13 Apr 2020 09:38:34 +0000 (11:38 +0200)]
core: make sure ProtectHostname= is handled gracefully in containers lacking seccomp
Fixes: #15408
(cherry picked from commit
daf8f72b4eba3702a5bdf109c82dc71d1483f1c6)
Frantisek Sumsal [Wed, 8 Apr 2020 10:12:46 +0000 (12:12 +0200)]
test: wait a bit after stopping the test service
Give systemd a chance to process the stop event before checking if the
PID has indeed leaked. This should fix the intermittent test fails in CI
even with a fixed systemd version, like this one:
```
Apr 08 10:22:09 testsuite-47.sh[345]: ++ cat /leakedtestpid
Apr 08 10:22:09 testsuite-47.sh[334]: + leaked_pid=342
Apr 08 10:22:09 testsuite-47.sh[334]: + systemctl stop testsuite-47-repro
Apr 08 10:22:10 testsuite-47.sh[334]: + ps -p 342
Apr 08 10:22:10 testsuite-47.sh[348]: PID TTY TIME CMD
Apr 08 10:22:10 testsuite-47.sh[348]: 342 ? 00:00:00 sleep
Apr 08 10:22:10 testsuite-47.sh[334]: + exit 42
```
Followup to
197298ff9fc930de450330095cc5b67d165d0801
(cherry picked from commit
e00e2e0b50bbd120290572c8d1242703fb98b34e)
Lennart Poettering [Tue, 7 Apr 2020 09:15:49 +0000 (11:15 +0200)]
catalog: add entry for SD_MESSAGE_UNSAFE_USER_NAME
(cherry picked from commit
ad313ec33bb367624c25c9264994d6e43b8a7e2e)
Lennart Poettering [Tue, 7 Apr 2020 09:04:59 +0000 (11:04 +0200)]
docs: hook up the new USER_NAMES document everywhere
(Also correct the set of names we accept in User=, which was forgotten
to be updated in
ae480f0b09aec815b64579bb1828ea935d8ee236.
(cherry picked from commit
887a8fa341d9b24a7c9cd3f1fce328f8e43a1b4f)
Lennart Poettering [Sat, 4 Apr 2020 10:23:02 +0000 (12:23 +0200)]
user-util: rework how we validate user names
This reworks the user validation infrastructure. There are now two
modes. In regular mode we are strict and test against a strict set of
valid chars. And in "relaxed" mode we just filter out some really
obvious, dangerous stuff. i.e. strict is whitelisting what is OK, but
"relaxed" is blacklisting what is really not OK.
The idea is that we use strict mode whenver we allocate a new user
(i.e. in sysusers.d or homed), while "relaxed" mode is when we process
users registered elsewhere, (i.e. userdb, logind, …)
The requirements on user name validity vary wildly. SSSD thinks its fine
to embedd "@" for example, while the suggested NAME_REGEX field on
Debian does not even allow uppercase chars…
This effectively liberaralizes a lot what we expect from usernames.
The code that warns about questionnable user names is now optional and
only used at places such as unit file parsing, so that it doesn't show
up on every userdb query, but only when processing configuration files
that know better.
Fixes: #15149 #15090
(cherry picked from commit
7a8867abfab10e5bbca10590ec2aa40c5b27d8fb)
Lennart Poettering [Fri, 3 Apr 2020 20:27:09 +0000 (22:27 +0200)]
userdbctl: drop redundant user name validity check
The userdb_by_name() invocation immediately following does the same check
anyway, no need to do this twice.
(Also, make sure we exit the function early on failure)
(cherry picked from commit
2aea5883f1d016ec7304acdb59516c30cae92452)
Luca Boccassi [Wed, 8 Apr 2020 14:39:20 +0000 (15:39 +0100)]
man: explicitly note that ExecSt*Post does count for After/Before ordering
(cherry picked from commit
fe78538cab13fd8b6180dfdfab87d86bfdd1ac58)
Lennart Poettering [Wed, 8 Apr 2020 17:54:44 +0000 (19:54 +0200)]
sleep: improve log msg slightly
Let's make the log msgs a bit longer, to make clearer what is going on
here...
Prompted bymy attempts to debug #15354
(cherry picked from commit
0ed4b54e05e8436685cab79177c64a5fe8a2d15c)
Lennart Poettering [Wed, 8 Apr 2020 16:45:31 +0000 (18:45 +0200)]
man: correct the default slice for systemd-run units
As suggested in #15362
(cherry picked from commit
ba45534917d5ac56bf621ab6e6f4ccb11d0eb269)
Marcel Holtmann [Sun, 5 Apr 2020 08:01:14 +0000 (10:01 +0200)]
hwdb: Update database of Bluetooth company identifiers
(cherry picked from commit
9fac14980df8dcce922e1fe8856a88b09590d2c3)
Zbigniew Jędrzejewski-Szmek [Fri, 3 Apr 2020 17:38:50 +0000 (19:38 +0200)]
detect-virt: also detect "microsoft" as WSL
From https://github.com/microsoft/WSL/issues/423#issuecomment-
221627364:
> it's unlikely we'll change it to something that doesn't contain "Microsoft"
> or "WSL".
... but well, it happened. If they change it incompatibly w/o adding an stable
detection mechanism, I think we should not add yet another detection method.
But adding a different casing of "microsoft" is not a very big step, so let's
do that.
Follow-up for #11932.
(cherry picked from commit
a2f838d59075a49b012f9b7056664f7ffeed44d2)
Topi Miettinen [Fri, 3 Apr 2020 13:32:10 +0000 (16:32 +0300)]
dbus-execute: show also ProtectClock
Show also `ProtectClock=` setting. This also lets `systemd-analyze security`
get the correct state for it.
(cherry picked from commit
b8b7b838fd6e1ab36962a592838a59de30c32b98)
Zbigniew Jędrzejewski-Szmek [Tue, 31 Mar 2020 20:26:59 +0000 (22:26 +0200)]
man: add note that --no-hostname has limited effect
Clearly there is some confusion about the intent of this option, let's add
a short note.
https://bugzilla.redhat.com/show_bug.cgi?id=
1819313
(cherry picked from commit
e6a4e25a829470c055a1195a8e97834408138c32)
Zbigniew Jędrzejewski-Szmek [Mon, 30 Mar 2020 20:02:13 +0000 (22:02 +0200)]
journal-remote: fix description of option
We use whatever compression is configured, most often not XZ.
(cherry picked from commit
82b2281dd54b2b83c53ccbaf73b6ca9b687e0b94)
Lennart Poettering [Thu, 2 Apr 2020 15:20:47 +0000 (17:20 +0200)]
capability: don't skip ambient caps setup if we actually have something to set
Follow-up for
7ea4392f1e444388caa706d6bd64fb7b30dc2903
Let's not hide errors needlessly aggressively.
(cherry picked from commit
c4b23712634d020184393ba83451bd200a1e785f)