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)
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)
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)
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)
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)
Franck Bui [Thu, 2 Apr 2020 06:58:31 +0000 (08:58 +0200)]
mount: introduce mount_is_nofail() helper
(cherry picked from commit
5a7c4f4f3b3bc8f01fc2fa6ab55ed0b6665508e5)
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)
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)
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)
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)
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)
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)
Franck Bui [Mon, 30 Mar 2020 08:39:21 +0000 (10:39 +0200)]
fstab-util: introduce fstab_is_extrinsic()
(cherry picked from commit
bc9e5a4c67f5fff536d122118e16a53dfb592acd)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)