Lennart Poettering [Fri, 11 Sep 2020 15:42:46 +0000 (17:42 +0200)]
test-fileio: use test strings that are actually valid in shell
(cherry picked from commit
6fe3196350fdb8715aabd315f8252c307da6661c)
Lennart Poettering [Thu, 10 Sep 2020 17:08:45 +0000 (19:08 +0200)]
man: document that RemainAfterElapse=no means that also the triggered unit needs to deactivate
Fixes: #16378
(cherry picked from commit
415f8a5bfed4604e4a1bc275682d51af3ad3b611)
Lennart Poettering [Thu, 10 Sep 2020 16:20:05 +0000 (18:20 +0200)]
sd-path: use ROOTPREFIX without suffixed slash
We already have rootprefix_noslash as meson variable, export it so that
we can also use it in C code.
Fixes: #16773
(cherry picked from commit
b612c26ceb9f56af0271fc9f07c1724d2d260a8a)
Lennart Poettering [Fri, 11 Sep 2020 22:09:07 +0000 (00:09 +0200)]
hashmap: make sure to initialize shared hash key atomically
if we allocate a bunch of hash tables all at the same time, with none
earlier than the other, there's a good chance we'll initialize the
shared hash key multiple times, so that some threads will see a
different shared hash key than others.
Let's fix that, and make sure really everyone sees the same hash key.
Fixes: #17007
(cherry picked from commit
ae0b700a856c0ae460d271bb50dccfaae84dbcab)
Lennart Poettering [Fri, 11 Sep 2020 17:58:54 +0000 (19:58 +0200)]
socket: downgrade log warnings about inability to set socket buffer sizes
In containers we might lack the privs to up the socket buffers. Let's
not complain so loudly about that. Let's hence downgrade this to debug
logging if it's a permission problem.
(This wasn't an issue before
b92f350789e33942be0cf85af22a580c1fd483d6
because back then the failures wouldn't be detected at all.)
(cherry picked from commit
35b4e3c1bc7d4001244ff3986c084152c8901d03)
Tobias Kaufmann [Mon, 31 Aug 2020 11:48:31 +0000 (13:48 +0200)]
core: fix securebits setting
Desired functionality:
Set securebits for services started as non-root user.
Failure:
The starting of the service fails if no ambient capability shall be
raised.
... systemd[217941]: ...: Failed to set process secure bits: Operation
not permitted
... systemd[217941]: ...: Failed at step SECUREBITS spawning
/usr/bin/abc.service: Operation not permitted
... systemd[1]: abc.service: Failed with result 'exit-code'.
Reason:
For setting securebits the capability CAP_SETPCAP is required. However
the securebits (if no ambient capability shall be raised) are set after
setresuid.
When setresuid is invoked all capabilities are dropped from the
permitted, effective and ambient capability set. If the securebit
SECBIT_KEEP_CAPS is set the permitted capability set is retained, but
the effective and the ambient set are cleared.
If ambient capabilities shall be set, the securebit SECBIT_KEEP_CAPS is
added to the securebits configured in the service file and set together
with the securebits from the service file before setresuid is executed
(in enforce_user).
Before setresuid is executed the capabilities are the same as for pid1.
This means that all capabilities in the effective, permitted and
bounding set are set. Thus the capability CAP_SETPCAP is in the
effective set and the prctl(PR_SET_SECUREBITS, ...) succeeds.
However, if the secure bits aren't set before setresuid is invoked they
shall be set shortly after the uid change in enforce_user.
This fails as SECBIT_KEEP_CAPS wasn't set before setresuid and in
consequence the effective and permitted set was cleared, hence
CAP_SETPCAP is not set in the effective set (and cannot be raised any
longer) and prctl(PR_SET_SECUREBITS, ...) failes with EPERM.
Proposed solution:
The proposed solution consists of three parts
1. Check in enforce_user, if securebits are configured in the service
file. If securebits are configured, set SECBIT_KEEP_CAPS
before invoking setresuid.
2. Don't set any other securebits than SECBIT_KEEP_CAPS in enforce_user,
but set all requested ones after enforce_user.
This has the advantage that securebits are set at the same place for
root and non-root services.
3. Raise CAP_SETPCAP to the effective set (if not already set) before
setting the securebits to avoid EPERM during the prctl syscall.
For gaining CAP_SETPCAP the function capability_bounding_set_drop is
splitted into two functions:
- The first one raises CAP_SETPCAP (required for dropping bounding
capabilities)
- The second drops the bounding capabilities
Why are ambient capabilities not affected by this change?
Ambient capabilities get cleared during setresuid, no matter if
SECBIT_KEEP_CAPS is set or not.
For raising ambient capabilities for a user different to root, the
requested capability has to be raised in the inheritable set first. Then
the SECBIT_KEEP_CAPS securebit needs to be set before setresuid is
invoked. Afterwards the ambient capability can be raised, because it is
in the inheritable and permitted set.
Security considerations:
Although the manpage is ambiguous SECBIT_KEEP_CAPS is cleared during
execve no matter if SECBIT_KEEP_CAPS_LOCKED is set or not. If both are
set only SECBIT_KEEP_CAPS_LOCKED is set after execve.
Setting SECBIT_KEEP_CAPS in enforce_user for being able to set
securebits is no security risk, as the effective and permitted set are
set to the value of the ambient set during execve (if the executed file
has no file capabilities. For details check man 7 capabilities).
Remark:
In capability-util.c is a comment complaining about the missing
capability CAP_SETPCAP in the effective set, after the kernel executed
/sbin/init. Thus it is checked there if this capability has to be raised
in the effective set before dropping capabilities from the bounding set.
If this were true all the time, ambient capabilities couldn't be set
without dropping at least one capability from the bounding set, as the
capability CAP_SETPCAP would miss and setting SECBIT_KEEP_CAPS would
fail with EPERM.
(cherry picked from commit
dbdc4098f6ebc6bf6e68f0c05a9b4e540d133e3b)
Tobias Kaufmann [Mon, 31 Aug 2020 10:50:25 +0000 (12:50 +0200)]
capability-util: add new function for raising setpcap
Up to now the capability CAP_SETPCAP was raised implicitly in the
function capability_bounding_set_drop.
This functionality is moved into a new function
(capability_gain_cap_setpcap).
The new function optionally provides the capability set as it was
before raisining CAP_SETPCAP.
(cherry picked from commit
57d4d284c95a3dfdb9a4e3f74978623cbb3f918a)
Yu Watanabe [Fri, 11 Sep 2020 09:39:16 +0000 (18:39 +0900)]
network: do not add prefix to RA if radv is not configured
Fixes #17017.
(cherry picked from commit
85b6a8110d21defb3d6cddace09ee21db4eb9766)
Nazar Vinnichuk [Fri, 11 Sep 2020 10:38:53 +0000 (13:38 +0300)]
man: document the random delay of persistent timers
The manual states that a persistent timer triggers it's service
immediately on activation to catch up with missed invocations, but since
PR #11608 it is no longer the case if RandomizedDelaySec= is set to a
non-zero value.
(cherry picked from commit
5501da15ba34284e50c10ccd6b3ffa8838bb431b)
Yu Watanabe [Fri, 11 Sep 2020 04:57:07 +0000 (13:57 +0900)]
test-network: add test for ENOBUFS issue #17012
The issue seems already fixed by PR #16982 and its follow-up commit
4934ba2121d76229659939e19ab7d70a89446629.
(cherry picked from commit
766f8f388fac18730bacd1a922f0619023244c89)
Yu Watanabe [Fri, 11 Sep 2020 08:44:20 +0000 (17:44 +0900)]
backlight: do not claim that ID_BACKLIGHT_CLAMP= property is not set
(cherry picked from commit
06d98bdc81b233584d4b225892d358f324b7030b)
Lennart Poettering [Wed, 9 Sep 2020 18:35:33 +0000 (20:35 +0200)]
fs-util,tmpfiles: fix error handling of fchmod_opath()
When
4dfaa528d45 was first commited its callers relied on `errno` instead of the
return value for error reporting. Which worked fine, since internally
under all conditions base were set — even if ugly and not inline with
our coding style. Things then got broken in
f8606626ed3c2582e06543550d58fe9886cdca5f where suddenly additional
syscalls might end up being done in the function, thus corrupting `errno`.
(cherry picked from commit
dee00c1939c6194404c15a80650d0c04bb01b0db)
Lennart Poettering [Wed, 9 Sep 2020 21:04:17 +0000 (23:04 +0200)]
bootctl: don't accidentally propagate errors in "bootctl status"
Fixes: #16989
(cherry picked from commit
c1b9708c109376578b08a97a64a34936b33463e1)
Lennart Poettering [Wed, 9 Sep 2020 21:41:49 +0000 (23:41 +0200)]
ethtool-util: don't pass error value that isn't used to log_syntax
(cherry picked from commit
d8ea7f838b1199d240d522ee3ce05d1c263b7ad4)
Lennart Poettering [Wed, 9 Sep 2020 21:06:40 +0000 (23:06 +0200)]
network: don't fail on various config parse errors
We typically don't fail on config parse errors (to maximize compat),
let's not do this in these cases either.
(cherry picked from commit
e5f1b999eb51681e895ad77281a6862478641845)
Lennart Poettering [Wed, 9 Sep 2020 16:56:24 +0000 (18:56 +0200)]
man: document that sd_bus_message_close_container() may only be called at end of container
Prompted-by: https://lists.freedesktop.org/archives/systemd-devel/2020-September/045264.html
(cherry picked from commit
8d29a1b9c52467f1b4c4c4c3c4b1be0dcd2bb5f5)
Mikael Szreder [Wed, 9 Sep 2020 19:26:21 +0000 (21:26 +0200)]
cryptsetup: Fix null pointer dereference (#16987)
cryptsetup: Fix null pointer dereference
Fix null pointer dereference in the pkcs11 related code of systemd-cryptsetup
(cherry picked from commit
664ad0f6f54257643fa069d9e1e9cad0f6fd7cc3)
Tobias Kaufmann [Fri, 31 Jul 2020 08:57:39 +0000 (10:57 +0200)]
core: fix set keep caps for ambient capabilities
The securebit keep-caps retains the capabilities in the permitted set
over an UID change (ambient capabilities are cleared though).
Setting the keep-caps securebit after the uid change and before execve
doesn't make sense as it is cleared during execve and there is no
additional user ID change after this point.
Altough the documentation (man 7 capabilities) is ambigious, keep-caps
is reset during execve although keep-caps-locked is set. After execve
only keep-caps-locked is set and keep-caps is cleared.
(cherry picked from commit
198dc1784514b800c3e69153839084a55ebf2e84)
Tobias Kaufmann [Fri, 31 Jul 2020 08:57:15 +0000 (10:57 +0200)]
core: fix comments on ambient capabilities
The comments on the code for ambient capabilities was wrong/outdated.
(cherry picked from commit
16fcb1918a0e4514b1d0d78259d4ffd646b5da59)
Yu Watanabe [Tue, 8 Sep 2020 17:33:03 +0000 (02:33 +0900)]
network: make log_link_error() or friends return void
(cherry picked from commit
d157714b6819d9e4faa93ef64a5041d5a8ae4779)
Yu Watanabe [Tue, 8 Sep 2020 17:28:36 +0000 (02:28 +0900)]
core: make log_unit_error() or friends return void
(cherry picked from commit
8ed6f81ba3b7be55d20a5d703c9aa7d4018b80ed)
Yu Watanabe [Tue, 8 Sep 2020 17:27:56 +0000 (02:27 +0900)]
core/slice: explicitly specify return value
(cherry picked from commit
93c5b904597ee86cbf65d8b5dc9d68428f2a2130)
Yu Watanabe [Tue, 8 Sep 2020 17:14:55 +0000 (02:14 +0900)]
udev: do not discard const qualifier
(cherry picked from commit
38104ee2a545a0e06fc261c0161aed322285f363)
Yu Watanabe [Tue, 8 Sep 2020 17:10:27 +0000 (02:10 +0900)]
sd-device: make log_device_error() or friends return void
(cherry picked from commit
ab54f12b783eea891d6414fbc14cd6fe7cbe4c80)
Yu Watanabe [Tue, 8 Sep 2020 17:08:24 +0000 (02:08 +0900)]
udev: explicitly specify return value
(cherry picked from commit
09c69ecaeb2c63b2b7e20728c4f4704bbb464a9c)
Yu Watanabe [Tue, 8 Sep 2020 17:07:15 +0000 (02:07 +0900)]
udev: return negative errno for invalid EVDEV_ABS_XXX= property
(cherry picked from commit
a718b951ac2c2186db22311b611b7e7ccdc30915)
Yu Watanabe [Tue, 8 Sep 2020 16:46:06 +0000 (01:46 +0900)]
udev: make log_rule_error() or friends return void
(cherry picked from commit
3b4e123173ba1e4cb6af504d98e0c018d9ccfc8a)
Lennart Poettering [Wed, 9 Sep 2020 17:37:38 +0000 (19:37 +0200)]
socket: fix copy/paste error
Fixes: CID1432653
(cherry picked from commit
4934ba2121d76229659939e19ab7d70a89446629)
Yu Watanabe [Tue, 8 Sep 2020 21:46:54 +0000 (06:46 +0900)]
udev: warn if failed to set buffer size for device monitor
(cherry picked from commit
e77f52e5f951e6b51f3b6eeee69f1f8bb965f4f3)
Yu Watanabe [Tue, 8 Sep 2020 14:28:22 +0000 (23:28 +0900)]
network: increase receive buffer size for device monitor
If networkd creates huge amount of netdevs, then the buffer of device
monitor becomes easily flowed.
Hopefully fixes #16865.
(cherry picked from commit
a725efb08b068055dcbf163426eef6b04a23aca0)
Yu Watanabe [Tue, 8 Sep 2020 14:26:28 +0000 (23:26 +0900)]
network: do not start device monitor if /sys is read-only
Follow-up for
bf331d87171b7750d1c72ab0b140a240c0cf32c3.
(cherry picked from commit
d31f33e3c9f6ea3bdc873ee52f4398edbec74527)
Yu Watanabe [Tue, 8 Sep 2020 15:33:11 +0000 (00:33 +0900)]
network: honor the buffer size specified in networkd.socket
(cherry picked from commit
e13af7bdb6236d91498a6a5936fc75237ebfa01d)
Yu Watanabe [Tue, 8 Sep 2020 15:25:23 +0000 (00:25 +0900)]
core/socket: use fd_set_{rcv,snd}buf()
(cherry picked from commit
ded71ab3bc580852a378b6cfac5e8d4053697b75)
Yu Watanabe [Tue, 8 Sep 2020 15:22:21 +0000 (00:22 +0900)]
sd-device-monitor: use fd_set_rcvbuf()
(cherry picked from commit
2807a79424a0be807bc904ca145f1db03ac7fbb0)
Yu Watanabe [Tue, 8 Sep 2020 16:12:38 +0000 (01:12 +0900)]
util: introduce fd_set_{snd,rcv}buf()
(cherry picked from commit
d9d9b2a0ae2befb645ef3aa420831423bcb9f58f)
Yu Watanabe [Tue, 8 Sep 2020 15:11:14 +0000 (00:11 +0900)]
util: try to set with SO_{RCV,SND}BUFFORCE when requested size is larger than the kernel limit
The commit
10ce2e0681ac16e7bb3619b7bb1a72a6f98a2f2c inverts the order of
SO_{RCV,SND}BUFFORCE and SO_{RCV,SND}BUF. However, setting buffer size with
SO_{RCV,SND}BUF does not fail even if the requested size is larger than
the kernel limit. Hence, SO_{RCV,SND}BUFFORCE will not use anymore and
the buffer size is always limited by the kernel limit even if we have
the priviledge to ignore the limit.
This makes the buffer size is checked after configuring it with
SO_{RCV,SND}BUF, and if it is still not sufficient, then try to set it
with FORCE command. With this commit, if we have enough priviledge, the
requested buffer size is correctly set.
Hopefully fixes #14417.
(cherry picked from commit
b92f350789e33942be0cf85af22a580c1fd483d6)
Yu Watanabe [Tue, 8 Sep 2020 15:07:50 +0000 (00:07 +0900)]
util: refuse to set too large value for socket buffer size
(cherry picked from commit
1263c85ef32ea35969748cd4304cd1a51d19e8d1)
Yu Watanabe [Tue, 8 Sep 2020 17:48:25 +0000 (02:48 +0900)]
network: ignore error on increasing netlink receive buffer size
(cherry picked from commit
8c63924c8d1eeb5a173669b8b06230bfe721f139)
Lennart Poettering [Mon, 7 Sep 2020 17:01:41 +0000 (19:01 +0200)]
tree-wide: if get_block_device() returns zero devno, check for it in all cases
And add a comment for the existing cases where things aren't clear
already.
(cherry picked from commit
d161680e7afb7ae01593ffc5deb6c02bbc08ed19)
Lennart Poettering [Mon, 7 Sep 2020 16:50:41 +0000 (18:50 +0200)]
btrfs: if BTRFS_IOC_DEV_INFO returns /dev/root generate a friendly error message
On systems that boot without initrd on a btrfs root file systems the
BTRFS_IOC_DEV_INFO ioctl returns /dev/root as backing device. That
sucks, since that is not a real device visible to userspace.
Since this has been that way since forever, and it doesn't look like the
kernel will get fixed soon for this, let's at least generate a useful
error message in this case.
This is not a bug fix, just a tweak to make this more recognizable.
Once the kernel gets fixed to report the correct device nodes in this
case, in a way userspace can make sense of them things will magically
work for systemd, too.
(Note that this doesn't add a log message about this to really all cases
we call get_device() in, but just the main ones that are called in early
boot context, after all all there's no benefit in seeing this message
too many times.)
https://github.com/systemd/systemd/issues/16953
https://bugs.freedesktop.org/show_bug.cgi?id=84689
https://bugzilla.kernel.org/show_bug.cgi?id=89721
(cherry picked from commit
67f0ac8c79bb08451a70ee314daf06ee081ef24d)
Zbigniew Jędrzejewski-Szmek [Tue, 8 Sep 2020 11:18:25 +0000 (13:18 +0200)]
basic/log: make log_{info,warning,...} return void
log_debug still returns 0. I think it is legitimate to use 'return log_debug()' to
return 0. It is different than the other functions, since we often want to supress
errors logged at debug level. This case is quite common in the codebase and
we could use 'return log_debug_errno()' to make the code more consise.
For all other variants, a separate return line is required.
Previous commit changes all the non-conforming instances, now we can make it mandatory.
(cherry picked from commit
44f0dd628ce4ca9565b0e02b8cb63ed8272529cd)
Zbigniew Jędrzejewski-Szmek [Tue, 8 Sep 2020 10:51:23 +0000 (12:51 +0200)]
tree-wide: correct cases where return log_{error,warning} is used without value
In various cases, we would say 'return log_warning()' or 'return log_error()'. Those
functions return 0 if no error is passed in. For log_warning or log_error this doesn't
make sense, and we generally want to propagate the error. In the few cases where
the error should be ignored, I think it's better to split it in two, and call 'return 0'
on a separate line.
(cherry picked from commit
c413bb28df0996be99fd6b3f2335dfe8739d62fb)
Zbigniew Jędrzejewski-Szmek [Fri, 4 Sep 2020 14:12:40 +0000 (16:12 +0200)]
test-execute/exec-dynamicuser-statedir.service: fix quoting
All backslashes that should be single in shell syntax need to be written as "\\" because
our parser will remove one level of quoting. Also, single quotes were doubly nested, which
cannot work.
Should fix the following message:
test-execute/exec-dynamicuser-statedir.service:16: Ignoring unknown escape sequences: "test $$(find / \( -path /var/tmp -o -path /tmp -o -path /proc -o -path /dev/mqueue -o -path /dev/shm -o -path /sys/fs/bpf -o -path /dev/.lxc \) -prune -o -type d -writable -print 2>/dev/null | sort -u | tr -d \\n) = /var/lib/private/quux/pief/var/lib/private/waldo"
(cherry picked from commit
0b3861d2247fd96ca1ff018bbf35c8465c43323c)
Zbigniew Jędrzejewski-Szmek [Sat, 5 Sep 2020 20:09:02 +0000 (22:09 +0200)]
man: fix quickhelp listing in sysusers.d(5)
Fixes #16958.
(cherry picked from commit
fc706b4816f75c01bd78bd5936e5f8740405093a)
Yu Watanabe [Fri, 14 Aug 2020 08:45:44 +0000 (17:45 +0900)]
network: fix NDisc handling for the case when multiple routers exist
69203fba700ea8d7b0c4f4e3d1e1f809ac4644a1 does not consider the case that
multiple routers exist, and causes #16719.
Fixes #16719.
(cherry picked from commit
50550722e3ba8c33c58c9a2f3da827877bd659cc)
Yu Watanabe [Fri, 4 Sep 2020 01:56:03 +0000 (10:56 +0900)]
network: expose route_{hash,compare}_func()
(cherry picked from commit
501b09dbf2ab75d90cd05ec4b44c92341e201e46)
Yu Watanabe [Fri, 4 Sep 2020 01:55:40 +0000 (10:55 +0900)]
network: expose address_{hash,compare}_func()
(cherry picked from commit
99a2878457b5e1a1b87ba2f638bf7aeacee98662)
Yu Watanabe [Fri, 14 Aug 2020 08:44:02 +0000 (17:44 +0900)]
util: expose in6_addr_{hash,compare}_func()
(cherry picked from commit
badd49288d54d33d1c89eec51a40dc3a774741c1)
Yu Watanabe [Wed, 26 Aug 2020 13:31:01 +0000 (22:31 +0900)]
network: fixes gateway assignment through DHCPv4
This fixes the following issue:
- If a DHCP lease does not contains router option, then routes with
`Gateway=_dhcp` setting introduce unexpected results.
This also makes several failure paths critical. And adjust warnings when
classless routes are provided.
(cherry picked from commit
2200c3cf56ca6ddede06c15ca1d9b3dfc60c33ae)
Yu Watanabe [Fri, 4 Sep 2020 08:03:28 +0000 (17:03 +0900)]
bash-completion: resolvectl: support 'log-level' command
(cherry picked from commit
3605aae16170c8f86bc080b5810233c8e0fe3307)
Yu Watanabe [Fri, 4 Sep 2020 07:58:32 +0000 (16:58 +0900)]
resolvectl: add 'log-level' to help message
Follow-up for
df9578498f3f566409fcb71229d9fc99e4ab0568.
(cherry picked from commit
bde4bc9bd29bcce4ccb9442bb8ed6678936268a6)
Zbigniew Jędrzejewski-Szmek [Tue, 1 Sep 2020 21:50:01 +0000 (23:50 +0200)]
core/socket: we may get ENOTCONN from socket_instantiate_service()
This means that the connection was aborted before we even got to figure out
what the service name will be. Let's treat this as a non-event and close the
connection fd without any further messages.
Code last changed in
934ef6a5.
Reported-by: Thiago Macieira <thiago.macieira@intel.com>
With the patch:
systemd[1]: foobar.socket: Incoming traffic
systemd[1]: foobar.socket: Got ENOTCONN on incoming socket, assuming aborted connection attempt, ignoring.
...
Also, when we get ENOMEM, don't give the hint about missing unit.
(cherry picked from commit
86e045ecefc404d4fccbeb78aa212ec4714a5763)
Gibeom Gwon [Wed, 26 Aug 2020 13:56:01 +0000 (22:56 +0900)]
homed: remember the secret even when the for_state is FIXATING_FOR_ACQUIRE
Remember the secret if the for_state is FIXATING_FOR_ACTIVATION or
FIXATING_FOR_ACQUIRE. This fixes login failures when logging in
to an unfixated user.
(cherry picked from commit
3d3d6e10daee37cd0636e15c2d4f29f14354cd72)
Lennart Poettering [Wed, 19 Aug 2020 15:42:33 +0000 (17:42 +0200)]
core: create per-user inaccessible node from the service manager
Previously, we'd create them from user-runtime-dir@.service. That has
one benefit: since this service runs privileged, we can create the full
set of device nodes. It has one major drawback though: it security-wise
problematic to create files/directories in directories as privileged
user in directories owned by unprivileged users, since they can use
symlinks to redirect what we want to do. As a general rule we hence
avoid this logic: only unpriv code should populate unpriv directories.
Hence, let's move this code to an appropriate place in the service
manager. This means we lose the inaccessible block device node, but
since there's already a fallback in place, this shouldn't be too bad.
(cherry picked from commit
3242980582d501ec2adbcc0f794c7161056812e8)
Lennart Poettering [Fri, 14 Aug 2020 16:56:54 +0000 (18:56 +0200)]
nspawn,pid1: pass "inaccessible" nodes from cntr mgr to pid1 payload via /run/host
Let's make /run/host the sole place we pass stuff from host to container
in and place the "inaccessible" nodes in /run/host too.
In contrast to the previous two commits this is a minor compat break, but
not a relevant one I think. Previously the container manager would place
these nodes in /run/systemd/inaccessible/ and that's where PID 1 in the
container would try to add them too when missing. Container manager and
PID 1 in the container would thus manage the same dir together.
With this change the container manager now passes an immutable directory
to the container and leaves /run/systemd entirely untouched, and managed
exclusively by PID 1 inside the container, which is nice to have clear
separation on who manages what.
In order to make sure systemd then usses the /run/host/inaccesible/
nodes this commit changes PID 1 to look for that dir and if it exists
will symlink it to /run/systemd/inaccessible.
Now, this will work fine if new nspawn and new pid 1 in the container
work together. as then the symlink is created and the difference between
the two dirs won't matter.
For the case where an old nspawn invokes a new PID 1: in this case
things work as they always worked: the dir is managed together.
For the case where different container manager invokes a new PID 1: in
this case the nodes aren't typically passed in, and PID 1 in the
container will try to create them and will likely fail partially (though
gracefully) when trying to create char/block device nodes. THis is fine
though as there are fallbacks in place for that case.
For the case where a new nspawn invokes an old PID1: this is were the
(minor) incompatibily happens: in this case new nspawn will place the
nodes in the /run/host/inaccessible/ subdir, but the PID 1 in the
container won't look for them there. Since the nodes are also not
pre-created in /run/systed/inaccessible/ PID 1 will try to create them
there as if a different container manager sets them up. This is of
course not sexy, but is not a total loss, since as mentioned fallbacks
are in place anyway. Hence I think it's OK to accept this minor
incompatibility.
(cherry picked from commit
9fac502920a648d82e21b207989bfc3c00fbdebc)
Lennart Poettering [Tue, 1 Sep 2020 18:29:28 +0000 (20:29 +0200)]
coredump: don't convert s → µs twice
We already append 000000 early on when parsing the cmdline args, let's
not do that a second time.
Fixes: #16919
(cherry picked from commit
64a5384fd2cde9b66a778c318036e7771f273f17)
afg [Tue, 1 Sep 2020 21:20:25 +0000 (05:20 +0800)]
firstboot: fill empty color if ansi_color unavailable from os-release
(cherry picked from commit
ae0d36c161ef0b8bde08d37674eb500061245728)
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 17:22:20 +0000 (19:22 +0200)]
varlink: do not parse invalid messages twice
Upon reception of a message which fails in json_parse(), we would proceed to
parse it again from a deferred callback and hang. Once we have realized that
the message is invalid, let's move the pointer in the buffer even if the
message is invalid. We don't want to look at this data again.
(before) $ build-rawhide/userdbctl --output=json user test.user
n/a: varlink: setting state idle-client
/run/systemd/userdb/io.systemd.Multiplexer: Sending message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test.user","service":"io.systemd.Multiplexer"}}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state idle-client → awaiting-reply
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state awaiting-reply → pending-disconnect
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state pending-disconnect → disconnected
^C
(after) $ n/a: varlink: setting state idle-client
/run/systemd/userdb/io.systemd.Multiplexer: Sending message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test.user","service":"io.systemd.Multiplexer"}}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state idle-client → awaiting-reply
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: Failed to parse JSON: Invalid argument
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state awaiting-reply → pending-disconnect
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state pending-disconnect → processing-disconnect
Got lookup error: io.systemd.Disconnected
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state processing-disconnect → disconnected
Failed to find user test.user: Input/output error
This should fix #16683 and https://bugs.gentoo.org/735072.
(cherry picked from commit
77472d06a4740d820ebccdb04e217d6b7d66dd50)
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 15:25:14 +0000 (17:25 +0200)]
userdbctl: add forgotten --output mode in help
(cherry picked from commit
c4651e3156463758ffde9a791197d62f76caf6ec)
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 14:23:16 +0000 (16:23 +0200)]
shared/{user,group}-record-nss: adjust filtering of "valid" passwords
We would reject various passwords that glibc accepts, for example ""
or any descrypted password. Accounts with empty password are definitely
useful, for example for testing or in scenarios where a password is not
needed. Also, using weak encryption methods is probably not a good idea,
it's not the job of our nss helpers to decide that: they should just
faithfully forward whatever data is there.
Also rename the function to make it more obvious that the returned answer
is not in any way certain.
(cherry picked from commit
8f796e40a561bd9200fde3c8885e6255a2dd4250)
Lennart Poettering [Mon, 31 Aug 2020 21:41:30 +0000 (23:41 +0200)]
doc: cross link sd_listen_fd() docs a bit
Let's make sure the sd_listen_fd() docs are really found from the
.socket file documentation as well as the FileDescriptorStoreMax=
documentation.
Let's also emphasize that that's where the order in which the fds are
passed are documented.
Fixes: #16647
(cherry picked from commit
df2f58176d0093f5798240d4d0a69aba21a8f2e2)
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 10:21:48 +0000 (12:21 +0200)]
Rework how we cache mtime to figure out if units changed
Instead of assuming that more-recently modified directories have higher mtime,
just look for any mtime changes, up or down. Since we don't want to remember
individual mtimes, hash them to obtain a single value.
This should help us behave properly in the case when the time jumps backwards
during boot: various files might have mtimes that in the future, but we won't
care. This fixes the following scenario:
We have /etc/systemd/system with T1. T1 is initially far in the past.
We have /run/systemd/generator with time T2.
The time is adjusted backwards, so T2 will be always in the future for a while.
Now the user writes new files to /etc/systemd/system, and T1 is updated to T1'.
Nevertheless, T1 < T1' << T2.
We would consider our cache to be up-to-date, falsely.
(cherry picked from commit
c2911d48ff0fc61fb3cfab7050110992a7390417)
Zbigniew Jędrzejewski-Szmek [Mon, 31 Aug 2020 18:44:00 +0000 (20:44 +0200)]
core: always try to reload not-found unit
This check was added in
d904afc730268d50502f764dfd55b8cf4906c46f. It would only
apply in the case where the cache hasn't been loaded yet. I think we pretty
much always have the cache loaded when we reach this point, but even if we
didn't, it seems better to try to reload the unit. So let's drop this check.
(cherry picked from commit
02103e57162946b5ac620c552123ff5e305a2791)
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 09:19:38 +0000 (11:19 +0200)]
pid1: use the cache mtime not clock to "mark" load attempts
We really only care if the cache has been reloaded between the time when we
last attempted to load this unit and now. So instead of recording the actual
time we try to load the unit, just store the timestamp of the cache. This has
the advantage that we'll notice if the cache mtime jumps forward or backward.
Also rename fragment_loadtime to fragment_not_found_time. It only gets set when
we failed to load the unit and the old name was suggesting it is always set.
In https://bugzilla.redhat.com/show_bug.cgi?id=
1871327
(and most likely https://bugzilla.redhat.com/show_bug.cgi?id=
1867930
and most likely https://bugzilla.redhat.com/show_bug.cgi?id=
1872068) we try
to load a non-existent unit over and over from transaction_add_job_and_dependencies().
My understanding is that the clock was in the future during inital boot,
so cache_mtime is always in the future (since we don't touch the fs after initial boot),
so no matter how many times we try to load the unit and set
fragment_loadtime / fragment_not_found_time, it is always higher than cache_mtime,
so manager_unit_cache_should_retry_load() always returns true.
(cherry picked from commit
c149d2b49128700a2ae361f43b9065b51c174838)
Zbigniew Jędrzejewski-Szmek [Fri, 28 Aug 2020 08:32:39 +0000 (10:32 +0200)]
core: rename manager_unit_file_maybe_loadable_from_cache()
The name is misleading, since we aren't really loading the unit from cache — if
this function returns true, we'll try to load the unit from disk, updating the
cache in the process.
(cherry picked from commit
81be23886d3d2099784890f35379fee119b351a8)
Lennart Poettering [Fri, 28 Aug 2020 19:18:14 +0000 (21:18 +0200)]
man: document fd ownership for sd-bus fd marshalling
Fixes: #8003
(cherry picked from commit
e2b40db616b4e723036f72a726e2f2f31d35ffe1)
Lennart Poettering [Fri, 28 Aug 2020 20:44:57 +0000 (22:44 +0200)]
resolved: make sure we initialize t->answer_errno before completing the transaction
We must have the error number around when completing the transaction.
Let's hence make sure we always initialize it *first* (we accidentally
did it once after).
Fixes: #11626
(cherry picked from commit
fd8a30170342cfe245ea6acac392c2b224f0ae1b)
Florian Klink [Sat, 29 Aug 2020 17:57:24 +0000 (19:57 +0200)]
homed: fix log message to honor real homework path
This seems to be overridable by setting the SYSTEMD_HOMEWORK_PATH env
variable, but the error message always printed the SYSTEMD_HOMEWORK_PATH
constant.
(cherry picked from commit
43269733ef5e987339b06bd407e4fccf5f76cbe3)
Fabrice Fontaine [Sat, 29 Aug 2020 21:17:18 +0000 (23:17 +0200)]
src/shared/dissect-image.c: fix build without blkdid (#16901)
N_DEVICE_NODE_LIST_ATTEMPTS is unconditionally used since version 246 and
https://github.com/systemd/systemd/commit/
ac1f3ad05f7476ae58981dcba45dfeb2c0006824
However, this variable is only defined if HAVE_BLKID is set resulting in
the following build failure if cryptsetup is enabled but not libblkid:
../src/shared/dissect-image.c:1336:34: error: 'N_DEVICE_NODE_LIST_ATTEMPTS' undeclared (first use in this function)
1336 | for (unsigned i = 0; i < N_DEVICE_NODE_LIST_ATTEMPTS; i++) {
|
Fixes:
- http://autobuild.buildroot.org/results/
67782c225c08387c1bbcbea9eee3ca12bc6577cd
(cherry picked from commit
28e2641a1aa506c5df93c7a0cb107aed8297b45e)
Lennart Poettering [Thu, 27 Aug 2020 13:46:03 +0000 (15:46 +0200)]
analyze: fix error handling in one case
(cherry picked from commit
0f849d0af983922e1571b958c9ca42f51e799190)
Kyle Russell [Fri, 28 Aug 2020 13:36:35 +0000 (09:36 -0400)]
units: add missing usb-gadget.target
(cherry picked from commit
dd050420390c6557354b0e3aaecd52abc4bf906c)
Lennart Poettering [Thu, 27 Aug 2020 13:45:29 +0000 (15:45 +0200)]
man: extend on the usec/sec discrepancy
Let's document the discrepancy between the Sec and USec suffixing of
unit files and D-Bus properties at three places: in "systemctl show"
(where it already was briefly mentioned), in the D-Bus interface
description (at one place at least, i.e. the most prominent of
properties that encapsulate time values, there are many more) and in the
general man page explaining time values.
By documenting this at all three places I think we now do as much as we
can do about this highlighting the discrepancy of the naming and the
reasons behind it.
Fixes: #2047
(cherry picked from commit
3c719357dcd56d4c826ec6a4e6870111c2ee8a36)
Ikey Doherty [Fri, 28 Aug 2020 13:23:44 +0000 (14:23 +0100)]
login/logind: Include sys/stat.h for struct stat usage
We need to include `<sys/stat.h>` for usage of the `struct stat` in
the Manager struct, much as we already include `<stdbool.h>` for C99
booleans.
This helps alleviate another minor build failure on non-glibc systems.
(cherry picked from commit
97207ac85cb8f8cba9459694255ff0396f020279)
Ikey Doherty [Thu, 27 Aug 2020 16:45:45 +0000 (17:45 +0100)]
partition/makefs: Include missing sys/file.h header
This file must be included on non-glibc systems to ensure
the `LOCK_EX` definition is available.
Signed-off-by: Ikey Doherty <ikey.doherty@lispysnake.com>
(cherry picked from commit
677bb0555a9b3b8accf1ecaa8e86d068eb679dda)
Yu Watanabe [Sat, 15 Aug 2020 10:01:49 +0000 (19:01 +0900)]
network: dhcp6: logs only new address
Closes #16731.
(cherry picked from commit
876dc2b0141de38fdf7f1b02644b5f454c967f61)
Daan De Meyer [Wed, 26 Aug 2020 22:08:52 +0000 (23:08 +0100)]
Don't run test-repart when loop devices are not available
(cherry picked from commit
f17bdf8264e231fa31c769bff2475ef698487d0b)
Yu Watanabe [Thu, 27 Aug 2020 07:35:25 +0000 (16:35 +0900)]
man: clarify that several networkctl commands takes device names
(cherry picked from commit
f2c676c6c016e24f246a21d70e359b9358a2f61d)
Yu Watanabe [Thu, 27 Aug 2020 07:32:13 +0000 (16:32 +0900)]
networkctl: label command does not take any argument
(cherry picked from commit
df696b1413abfc66e780f96e40f8ad2213af9341)
Michal Koutný [Wed, 26 Aug 2020 13:37:21 +0000 (15:37 +0200)]
missing: Add new Linux capability
Yet another new capability coming in Linux kernel v5.9.
Make sure we can recongize them even when built with older kernel headers.
(cherry picked from commit
94d21c2ef6cd6bb035d4c21c98ab001c0abd4cbe)
Lennart Poettering [Wed, 26 Aug 2020 21:10:50 +0000 (23:10 +0200)]
tty-ask-pw-agent: properly propagate error
(cherry picked from commit
a4fd6cd3f575eb7e1452a74c2e35548739e3b252)
Lennart Poettering [Wed, 26 Aug 2020 21:05:46 +0000 (23:05 +0200)]
tty-ask-pw-agent: the message string might not be set
(cherry picked from commit
66bff73b4f91f8d2fdd385f9f1e2b6339055c9e4)
Lennart Poettering [Wed, 26 Aug 2020 21:02:13 +0000 (23:02 +0200)]
tty-ask-pw-agent: make sure "--list" works correctly
Fixes: #16836
(cherry picked from commit
4c4a018caba30a58c3549924b8521074bbe5adad)
Olivier Le Moal [Thu, 27 Aug 2020 08:01:36 +0000 (10:01 +0200)]
add "list" verb to autocompleted commands
(cherry picked from commit
50574ed1ac2e27d8f25894c9db75bb0b4c28978f)
Olivier Le Moal [Wed, 26 Aug 2020 14:03:35 +0000 (16:03 +0200)]
shell-completion/zsh: add missing verbs for networkctl
(cherry picked from commit
6ff45bc1a18855cb9b0c43ba13843c11dd10728f)
Chris Down [Wed, 26 Aug 2020 17:49:27 +0000 (18:49 +0100)]
path: Improve $PATH search directory case
Previously:
1. last_error wouldn't be updated with errors from is_dir;
2. We'd always issue a stat(), even for binaries without execute;
3. We used stat() instead of access(), which is cheaper.
This change avoids all of those, by only checking inside X_OK-positive
case whether access() works on the path with an extra slash appended.
Thanks to Lennart for the suggestion.
(cherry picked from commit
33e1a5d8d3f792e1d98377fe439e123231032ec7)
Chris Down [Tue, 25 Aug 2020 20:59:11 +0000 (21:59 +0100)]
path: Skip directories when finalising $PATH search
Imagine $PATH /a:/b. There is an echo command at /b/echo. Under this
configuration, this works fine:
% systemd-run --user --scope echo .
Running scope as unit: run-rfe98e0574b424d63a641644af511ff30.scope
.
However, if I do `mkdir /a/echo`, this happens:
% systemd-run --user --scope echo .
Running scope as unit: run-rcbe9369537ed47f282ee12ce9f692046.scope
Failed to execute: Permission denied
We check whether the resulting file is executable for the performing
user, but of course, most directories are anyway, since that's needed to
list within it. As such, another is_dir() check is needed prior to
considering the search result final.
Another approach might be to check S_ISREG, but there may be more gnarly
edge cases there than just eliminating this obviously pathological
example, so let's just do this for now.
(cherry picked from commit
8b5cb69bc8b70d1dcc39ed2165907723099bd9d8)
Alec Moskvin [Sat, 1 Aug 2020 13:25:05 +0000 (09:25 -0400)]
rules: don't install 80-drivers.rules when kmod is disabled
(cherry picked from commit
dd47b25220f69f869679089da5cc848cf9cd0c78)
Ronan Pigott [Tue, 25 Aug 2020 02:33:37 +0000 (19:33 -0700)]
zsh: correct journalctl command completion parsing
(cherry picked from commit
45b156c1559da468f1c12aa5170858574c9b5831)
Zbigniew Jędrzejewski-Szmek [Sat, 22 Aug 2020 14:55:56 +0000 (16:55 +0200)]
basic/missing_syscall: fix syscall numbers for arm64 :(
(cherry picked from commit
b6ce3d2c0152a17210bb7fd31bb92a289f181a57)
Zbigniew Jędrzejewski-Szmek [Sat, 22 Aug 2020 09:58:15 +0000 (11:58 +0200)]
shared/install: fix preset operations for non-service instantiated units
Fixes https://github.com/coreos/ignition/issues/1064.
(cherry picked from commit
47ab95fe4315b3f7ee5a3694460a744bb88c52fd)
Zbigniew Jędrzejewski-Szmek [Sat, 22 Aug 2020 16:48:43 +0000 (18:48 +0200)]
nss-resolve: treat BUS_ERROR_NO_SUCH_UNIT the same as SD_BUS_ERROR_SERVICE_UNKNOWN too
Seems safer to do so.
(cherry picked from commit
8e34f4cc62aaeaa8881a1d6cd9136de5a22777a1)
Zbigniew Jędrzejewski-Szmek [Sat, 22 Aug 2020 16:48:03 +0000 (18:48 +0200)]
various: treat BUS_ERROR_NO_SUCH_UNIT the same as SD_BUS_ERROR_SERVICE_UNKNOWN
We return BUS_ERROR_NO_SUCH_UNIT a.k.a. org.freedesktop.systemd1.NoSuchUnit
in various places. In #16813:
Aug 22 06:14:48 core sudo[
2769199]: pam_systemd_home(sudo:account): Failed to query user record: Unit dbus-org.freedesktop.home1.service not found.
Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.home1.service': Unit dbus-org.freedesktop.home1.service not found.
Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activating via systemd: service name='org.freedesktop.home1' unit='dbus-org.freedesktop.home1.service' requested by ':1.6564' (uid=0 pid=
2769199 comm="sudo su ")
This particular error comes from bus_unit_validate_load_state() in pid1:
case UNIT_NOT_FOUND:
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not found.", u->id);
It seems possible that we should return a different error, but it doesn't really
matter: if we change pid1 to return a different error, we still need to handle
BUS_ERROR_NO_SUCH_UNIT as in this patch to handle pid1 with current code.
(cherry picked from commit
73d3ac8e2440cda3b7f2310f329f0798de6c041c)
Lennart Poettering [Mon, 24 Aug 2020 17:41:09 +0000 (19:41 +0200)]
man: drop reference to long gone .busname unit type
Seems we missed one occurence.
(cherry picked from commit
68dd195c1b8fdba3fccf166a1c3c2d7ca5a912fe)
Jan Chren [Mon, 24 Aug 2020 14:40:11 +0000 (16:40 +0200)]
man: fix a fix of a typo in systemd.service example
The fix from
cb263973acf83de22a86f08fe502a9cbd6c01d2b was made the other way around,
i.e. `SIGKILL` was changed to `SIGUSR1`, but the sentence is about a "termination signal", i.e. `SIGKILL`, not `SIGUSR1`.
(cherry picked from commit
be3f62faf5d498aaab4cf6ceb3ca56e0d994ddf5)
Clemens Gruber [Fri, 21 Aug 2020 14:03:23 +0000 (16:03 +0200)]
network: can: Fix CAN initialization
When introducing CAN-FD support, the .can_fd_mode was not initalized
with -1 and due to cm.mask containing the CAN_CTRLMODE_FD bit, it was
not ignored when FDMode was not configured but instead disabled.
The same thing happened when listen-only mode support was introduced.
On chips that do not support these features, this lead to an error:
can0: Failed to configure CAN link: Operation not supported
Fix it by intializing all the CAN related tristate variables
(.can_listen_only, .can_fd_mode and .can_non_iso) to -1.
(cherry picked from commit
f594b5feabee38dded4b7ae288fba6c3b6c79a45)
Zbigniew Jędrzejewski-Szmek [Sat, 22 Aug 2020 10:25:44 +0000 (12:25 +0200)]
Yu Watanabe [Fri, 21 Aug 2020 06:30:05 +0000 (15:30 +0900)]
man: fix invalid tag place
(cherry picked from commit
d91b9bbce881c7e0d2ee80208325be59924b0e8f)
Zbigniew Jędrzejewski-Szmek [Thu, 20 Aug 2020 15:41:19 +0000 (17:41 +0200)]
man: add conditionals to more man pages
Fixes #16701.
(cherry picked from commit
bb5a34fb3eeef824afe02b679d391853244161b1)
Zbigniew Jędrzejewski-Szmek [Thu, 20 Aug 2020 15:35:50 +0000 (17:35 +0200)]
meson: add ENABLE_ANALYZE conditional
(cherry picked from commit
b3259a6e5f05ebaf5282e624f80ecf04b77a0adb)
Lennart Poettering [Thu, 20 Aug 2020 11:44:12 +0000 (13:44 +0200)]
core: add missing conditions/asserts to unit file parsing
(cherry picked from commit
4f55a5b0bf1e68e4595120d8ac4b518654355fc3)