Lennart Poettering [Tue, 29 Sep 2020 15:25:15 +0000 (17:25 +0200)]
resolved: expose a new bus property that informs about the /etc/resolv.conf mode
It can be one of "foreign", "missing", "stub", "static", "uplink",
depending on how /etc/resolv.conf is set up:
foreign → someone/something else manages /etc/resolv.conf,
systemd-resolved is just the consumer
missing → /etc/resolv.conf is missing altogether
stub/static/uplink → the file is managed by resolved, with the
well-known modes
Fixes: #17159
(cherry picked from commit
4261ab654c0df009b5a37a30593d58d47fec617f)
Ronan Pigott [Wed, 30 Sep 2020 06:51:08 +0000 (23:51 -0700)]
loginctl: add -P as short for --value --property=
(cherry picked from commit
60b254ca1a4ac81b71dd5de8c396c663bafa64a7)
nl6720 [Wed, 30 Sep 2020 05:09:25 +0000 (08:09 +0300)]
sysusers: use "!*" instead of "!!" as an invalid group password
This basically implements
fc58c0c7bf7e4f525b916e3e5be0de2307fef04e for gshadow.
gpasswd may not have a lock/unlock that behaves the same as passwd, but
according to gshadow(5) the logic of the password field is the same.
(cherry picked from commit
bbbfe49b5eb0c571c10fa7991c10bac620f3c453)
Lennart Poettering [Tue, 29 Sep 2020 13:59:28 +0000 (15:59 +0200)]
seccomp-util: add cacheflush() syscall to @default syscall set
This is like membarrier() I guess and basically just exposes CPU
functionality via kernel syscall on some archs. Let's whitelist it for
everyone.
Fixes: #17197
(cherry picked from commit
8e24b1d23f5fa711bfdfd38bcfef525de04cd3c1)
Ronan Pigott [Wed, 30 Sep 2020 07:11:48 +0000 (00:11 -0700)]
zsh: loginctl: complete alias 'self'
(cherry picked from commit
0fb8f025065ddaf3d197cce6776962ff64de5300)
Pass Automated Testing Suite [Mon, 28 Sep 2020 15:49:55 +0000 (17:49 +0200)]
path-lookup: Correct order of XDG_CONFIG_HOME and XDG_CONFIG_DIRS
According to the XDG Base Directory Specification [1] XDG_CONFIG_HOME
should take precedence over XDG_CONFIG_DIRS.
Fixes: https://github.com/systemd/systemd/issues/16095
[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
(cherry picked from commit
e3820eeaf11f3b4614cbdfbc85675bc16a486e21)
nl6720 [Tue, 29 Sep 2020 13:10:08 +0000 (16:10 +0300)]
docs: update old documentation links
(cherry picked from commit
f856778b9c87d2dc9a6924db0cf26374aa7235c3)
Yu Watanabe [Tue, 29 Sep 2020 04:44:28 +0000 (13:44 +0900)]
udevadm: do not ignroe error caused by unpriviledged user invoking the command
This effectively reverts commit
67acde4869a9505f9721e31fa5167c82445e0e12.
After commits
569ad251adde02dc0915758fe027e0346e50738a and
67acde4869a9505f9721e31fa5167c82445e0e12, -EACCES errors are ignored,
and thus 'udevadm trigger' succeeds even when it is invoked by non-root
users. Moreover, on -EACCES error, log messages are shown in debug
level, so usually we see no message, and users are easily confused
why uevents for devices are not triggered.
(cherry picked from commit
88da55e28b467999da005591d3252a98f4436522)
Lennart Poettering [Mon, 28 Sep 2020 14:29:36 +0000 (16:29 +0200)]
man: fix reference to unit file
It' "systemd-tmpfiles-clean" not "systemd-tmpfiles-cleanup"
Fixes: #17171
(cherry picked from commit
6457e88902a9e2cf0b7f184a8e50a7ef666bcc78)
Anita Zhang [Thu, 17 Sep 2020 08:49:17 +0000 (01:49 -0700)]
core: move reset_arguments() to the end of main's finish
Fixes #16991
fb39af4ce42d7ef9af63009f271f404038703704 replaced `free_arguments()` with
`reset_arguments()`, which frees arg_* variables as before, but also resets all
of them to the default values. `reset_arguments()` was positioned
in such a way that it overrode some arg_* values still in use at shutdown.
To avoid further unintentional resets, I moved `reset_arguments()`
right before the return, when nothing else will be using the arg_* variables.
(cherry picked from commit
7d9eea2bd3d4f83668c7a78754d201b226acbf1e)
bauen1 [Fri, 25 Sep 2020 16:45:29 +0000 (18:45 +0200)]
core: ensure that namespace tmp directories always get the correct label
If a namespace with PrivateTmp=true is constructed we need to restore
the context of the namespaces /tmp directory (i.e.
/tmp/systemd-private-XXXXX/tmp) to the (default) context of /tmp .
Otherwise filetransitions might result in the namespaces tmp directory
having the wrong context.
(cherry picked from commit
19cd4e1967ddb0a576688793a050a9f01e714928)
Samuel BF [Sun, 27 Sep 2020 20:01:44 +0000 (22:01 +0200)]
Removing unused n_fields in journal-gatewayd
(cherry picked from commit
d99d1aaa21e216b2c2f520b58f847248407ba768)
Lennart Poettering [Thu, 24 Sep 2020 13:08:22 +0000 (15:08 +0200)]
loop-util: apparently opening a loop device sometimes results in ENXIO, handle this
(cherry picked from commit
77ad674b51ceb598aae1adaa7abe572ad0262f39)
Jonathan Lebon [Wed, 23 Sep 2020 19:23:58 +0000 (15:23 -0400)]
cryptsetup-generator: use "/proc/cmdline" as source when appropriate
Right now, we always say `/etc/crypttab` even if the source was fully
derived from the kargs.
Let's match what `systemd-fstab-generator` does and use `/proc/cmdline`
when that's the case.
(cherry picked from commit
62ca7d3b38dbbfbffa0aa0d3746b6be2916530b5)
Zbigniew Jędrzejewski-Szmek [Tue, 22 Sep 2020 17:05:17 +0000 (19:05 +0200)]
test-seccomp: accept ENOSYS from sysctl(2) too
It seems that kernel 5.9 started returning that.
(cherry picked from commit
0af05e485a3a88f454c714901eb6109307dc893e)
Zbigniew Jędrzejewski-Szmek [Mon, 21 Sep 2020 22:00:59 +0000 (00:00 +0200)]
test/run-integration-tests: do not run the tests if only "clean" is passed
(cherry picked from commit
abf6346c5e65ec1ab1f83841e9bd07a2e301dde8)
mog422 [Thu, 24 Sep 2020 15:04:52 +0000 (00:04 +0900)]
sd-dhcp6-client: Fix sending prefix delegation request (#17136)
SD_DHCP6_OPTION_IA_NA does not exist in DHCP6_ADVERTISE packet if DHCP server only provides prefix delegation. So the attempt to send the DHCP6_REQUEST packet fails on r = dhcp6_option_append_ia(&opt, &optlen, &client->lease->ia); forever.
(cherry picked from commit
26a63b81322a3bd8b9fbd43f75897c391708de2c)
Lennart Poettering [Wed, 23 Sep 2020 11:56:51 +0000 (13:56 +0200)]
catalog: add missing @ to German catalog file
(cherry picked from commit
3142135098ed625fd79966c86338e2bbc8f134b2)
Lennart Poettering [Wed, 23 Sep 2020 08:21:27 +0000 (10:21 +0200)]
machine: fix error code propagation in two cases
(cherry picked from commit
d5bc4e68987a527448ee5a00cc433fc5abec4028)
Roy Chen (陳彥廷) [Wed, 23 Sep 2020 09:52:22 +0000 (17:52 +0800)]
man: sd_bus_message_new: fix typo
(cherry picked from commit
f280aecd38bb1a62ac02fb1033644a97993860b2)
Ronan Pigott [Wed, 23 Sep 2020 00:52:53 +0000 (17:52 -0700)]
zsh: add systemd-path completions
(cherry picked from commit
cf18af825aa4a55debcf2ed88a5b930dfbc0d23f)
Lennart Poettering [Mon, 21 Sep 2020 15:30:03 +0000 (17:30 +0200)]
homed: in images that lack mkfs.btrfs automatically fall back to ext4
It's better to tweak suboptimal defaults than to just fail with
compiled-in defaults.
(cherry picked from commit
a512e330ce3eb7150c28664e17603df2ef876a2a)
Lennart Poettering [Mon, 21 Sep 2020 15:21:12 +0000 (17:21 +0200)]
homed: show actual file system in messages about file systems
(cherry picked from commit
f2ba663ea5135419a0b69d3748975a74dbb88a87)
Lennart Poettering [Wed, 2 Sep 2020 14:37:42 +0000 (16:37 +0200)]
user-record: don't refuse login when last pw change time is in the future
The RTC is like just off, it's a weird system state, let's continue
without requiring pw change.
(cherry picked from commit
3e0b54867e22523cffda3b80e179df89b6d81bcd)
Lennart Poettering [Wed, 2 Sep 2020 14:36:27 +0000 (16:36 +0200)]
homed: ignore ratelimiting counters when timestamp is from future
This likely indicates that the system clock is simply wrong, hence allow
access in this case.
Fixes: #15917
(cherry picked from commit
61a29a020c5c6611a22a84c1456e8da7aa656194)
Lennart Poettering [Wed, 2 Sep 2020 14:35:22 +0000 (16:35 +0200)]
homed: don't block logins into accounts with future change time
This might happen if the system clock is wrong, and we should allow
access in this case (though certainly log about it).
(cherry picked from commit
51a95db6dcb720608eccaac01328b66ef7cc0d30)
Lennart Poettering [Fri, 18 Sep 2020 20:01:49 +0000 (22:01 +0200)]
units: pass CAP_SYS_RESOURCE to homed
The ext4 fs resize ioctl needs CAP_SYS_RESOURCE, irritatingly. Let's
grant it to homed hence.
Fixes: #15115
(cherry picked from commit
c9ef77ec5ff5e7e283181e9dcfb93acfb0656ae6)
Lennart Poettering [Tue, 28 Jul 2020 15:53:21 +0000 (17:53 +0200)]
tmpfiles: properly prefix paths in debug outputs
This is otherwise very confusing...
(cherry picked from commit
b8e35011f726925d4c1640c5b721c18f7da9bd97)
Lennart Poettering [Thu, 6 Aug 2020 21:33:29 +0000 (23:33 +0200)]
units: order systemd-user-sessions.service after home.mount
This should make /home as automount work reasonably well.
If /home is an automount this has little effect at boot, because if the
automount is not triggered it doesn't matter how the associated mount is
ordered.
It does matter at shutdown however, where home.mount is likely active
now. There the ordering means we'll end sessions first, and only then
deactivate home.mount.
Fixes: #16291
(cherry picked from commit
bbac7da2b379dfe951db23278ebe8a728ecce7a5)
Marc Kleine-Budde [Wed, 5 Aug 2020 12:10:21 +0000 (14:10 +0200)]
Update DISCOVERABLE_PARTITIONS.md
This patch fixes a typo in the link to the systemd-id128 documentation.
(cherry picked from commit
3f449f2106b2e9335d17ebac0410f6a548345c57)
Joerg Behrmann [Tue, 4 Aug 2020 09:31:44 +0000 (11:31 +0200)]
docs: spelling fixes
(cherry picked from commit
c90b6abc91fdf2c7d39b886581e3b277b0e6fe5b)
Beniamino Galvani [Wed, 22 Jul 2020 03:03:47 +0000 (05:03 +0200)]
dhcp6: remove assertions in dhcp6_option_parse_domainname()
Assertions are for programming errors; here the input comes directly
from the DHCP response packet.
(cherry picked from commit
af710b535b4ceacd0aecec6748a4f8ee57742e99)
Chris Down [Mon, 3 Aug 2020 10:35:11 +0000 (11:35 +0100)]
doc: Put proot under "container" section
Missed in #15426. Otherwise, it ends up only taking the first two rows
of the table, in no section.
(cherry picked from commit
45ba6a585321cc655ce53d22d631747961330d69)
Yu Watanabe [Mon, 12 Oct 2020 00:06:28 +0000 (09:06 +0900)]
network: directly compare with in_addr element for IPv4 case
When peer address is set, address_compare() (or address_equal()) mostly
does not work in link_is_static_address_configured(), as an Address object
stored in a Link does not contain peer addresses. So, we need to also
compare with in_addr element for IPv4 case.
Fixes #17304.
(Based on
9b9c5fff16784b007f6ec313adafd29f4f737ab5)
Kir Kolyshkin [Sat, 1 Aug 2020 02:24:15 +0000 (19:24 -0700)]
kernel-install/90-loaderentry: fix when /boot is not mountpoint
I happen to have a machine where /boot is not a separate mountpoint,
but rather just a directory under /. After upgrade to recent Fedora,
I found out that grub2 can't find any new kernels.
This happens because loadentry script generates kernel and initrd file
paths relative to /boot, while grub2 expects path to be relative to the
root of filesystem on which they are residing.
This commit fixes this issue by using stat's %m to find the mount point
of a partition holding the images, and using it as a prefix to be
removed from ENTRY_DIR_ABS.
Note that %m for stat requires coreutils 8.6, released in Oct 2010.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit
1cdbff1c844ce46f1d84d8feeed426ebfd550988)
Lennart Poettering [Fri, 18 Sep 2020 17:37:05 +0000 (19:37 +0200)]
homed: make clean that --storage=directory --image-path=/dev/some-block-device is not supported
The directory backend needs a file system path, and not a raw block
device. That's only supported for the LUKS2 backend.
Let's make this clearer in the man page and also generate a better error
message if attempted anyway.
Fixes: #17068
(cherry picked from commit
f9d525ae558105bf7fd77ad76e4fdb135bb9f634)
Lennart Poettering [Fri, 18 Sep 2020 16:53:12 +0000 (18:53 +0200)]
homed: make sure our worker processes finish before we exit
When exiting, let's explicitly wait for our worker processes to finish
first. That's useful if unmounting of /home/ is scheduled to happen
right after homed is down, as we then can be sure that the home
directories are properly unmounted and detached by the time homed is
fully terminated (otherwise it might happen that our worker gets killed
by the service manager, thus leaving the home directory and its backing
devices up/left for auto-clean which might be async).
Likely fixes #16842
(cherry picked from commit
9796a9fbad5bae4d66bb40d848f6245d1ee327d8)
Lennart Poettering [Wed, 16 Sep 2020 20:16:10 +0000 (22:16 +0200)]
nspawn: fix fd leak on failure path
(cherry picked from commit
2fef50cd9eee59cea6145639f6bd464939fac624)
Lennart Poettering [Wed, 16 Sep 2020 20:11:48 +0000 (22:11 +0200)]
nspawn: check return of setsid()
Let's verify that everything works the way we expect it to work, hence
check setsid() return code.
(cherry picked from commit
efe426624046089b74b70708e61f304f3cd414a7)
Lennart Poettering [Thu, 17 Sep 2020 15:24:33 +0000 (17:24 +0200)]
dissect: is_loop_device() returns negative on error, don't mistake that is true
(cherry picked from commit
3afda7c7976c25db786948a961873fa5c2c8e0e9)
Lennart Poettering [Thu, 17 Sep 2020 15:32:34 +0000 (17:32 +0200)]
dissect: always invalidate secondary arch partitions if we found primary arch
Let's suppress the secondary arch data, since we never ever want to
mount it if we found the primary arch.
Previously we only suppressed in the Verity case, but there's little
reason to entertain the idea of a secondary arch in non-Verity
environments either, we are not going to use them, and should not do
decryption or anything like that.
(cherry picked from commit
74cb2db9f403dfe17cabc6dac48b0f49a84eb03f)
Yu Watanabe [Thu, 17 Sep 2020 05:49:47 +0000 (14:49 +0900)]
util: wireguard is merged into upstream kernel
(cherry picked from commit
e29e5db7dff1442ef73cbcd0c898e11078e1042d)
Lennart Poettering [Wed, 16 Sep 2020 15:51:25 +0000 (17:51 +0200)]
repart: don't mark image files generated with --empty=create executable
(cherry picked from commit
5332d7c6ff3c56340c7477e1e7604f61092a2868)
Zbigniew Jędrzejewski-Szmek [Tue, 15 Sep 2020 15:56:32 +0000 (17:56 +0200)]
man: substitute path to rc.local in the man page
Different systems use different paths for it and users are confused when the
man page has a path different than the one on the local system.
https://bugzilla.redhat.com/show_bug.cgi?id=
1876905
(cherry picked from commit
c2ee27a5e7fa1c6a71341579baa2d941c6e3e6e6)
Zbigniew Jędrzejewski-Szmek [Tue, 15 Sep 2020 15:44:26 +0000 (17:44 +0200)]
meson: RC_LOCAL_SCRIPT_PATH_START to RC_LOCAL_PATH
RC_LOCAL_SCRIPT_PATH_START and RC_LOCAL_SCRIPT_PATH_STOP were was originally
added in the conversion to meson based on the autotools name. In
44508946534eee032927c263b79464832656dd6e RC_LOCAL_SCRIPT_PATH_STOP was dropped.
We don't need to use such a long name.
(cherry picked from commit
452d2dfd52f1cc686395663a6cd4c778306bd309)
Zbigniew Jędrzejewski-Szmek [Tue, 15 Sep 2020 12:52:47 +0000 (14:52 +0200)]
socket-proxy: allow localhost addresses
With this change, only manager_connect() in timesync.d uses AI_ADDRCONFIG. There
we are connecting to a remove server, so the flag is appropriate.
(cherry picked from commit
7e5f1d4b3fb02075762a55063edf9e510142e4c9)
Zbigniew Jędrzejewski-Szmek [Tue, 15 Sep 2020 12:49:36 +0000 (14:49 +0200)]
sd-bus: allow localhost addresses
By settings AI_ADDRCONFIG in hints we cannot for example resolve "localhost"
when the local machine only has a loopback interface. This seems like an
unnecessary restriction, drop it.
Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=
1839007.
(cherry picked from commit
d0e5db44d9e1cf61ca75c8a86ffed19cc1b7fe5f)
Franck Bui [Tue, 15 Sep 2020 09:49:09 +0000 (11:49 +0200)]
fstab-generator: add 'nofail' when NFS 'bg' option is used
Otherwise a 'Before=remote-fs.target' dependency is added to the mount unit
which defeats the purpose of 'bg' option.
(cherry picked from commit
e66d2eeeeb4332ca94aeb62e95ec76f1f17ee9b7)
Juergen Hoetzel [Tue, 15 Sep 2020 06:09:51 +0000 (08:09 +0200)]
busctl: add missing shortopt -l
(cherry picked from commit
150c430fd499082164b6ddbd2f501e2333261a78)
Christian Göttsche [Mon, 14 Sep 2020 17:40:42 +0000 (19:40 +0200)]
socket-util: reset length argument for second getsockopt call in fd_[gs]et_rcvbuf
In case the first getsockopt() call changes the value.
(cherry picked from commit
67f5ae2d6986d0271fa6223a68fe0104957de863)
Zbigniew Jędrzejewski-Szmek [Mon, 14 Sep 2020 20:32:52 +0000 (22:32 +0200)]
test: use pclose() for popen()
Coverity CID#
1432701.
(cherry picked from commit
649bde89caccdb1187ac744bd76051fdcd687218)
Lennart Poettering [Fri, 11 Sep 2020 17:57:09 +0000 (19:57 +0200)]
core: propagate unit start limit hit state to triggering path unit
We already do this for socket and automount units, do it for path units
too: if the triggered service keeps hitting the start limit, then fail
the triggering unit too, so that we don#t busy loop forever.
(Note that this leaves only timer units out in the cold for this kind of
protection, but it shouldn't matter there, as they are naturally
protected against busy loops: they are scheduled by time anyway).
Fixes: #16669
(cherry picked from commit
47ab8f73e3468b6e5a48218eacdb830e978d2cfd)
Lennart Poettering [Fri, 11 Sep 2020 17:49:33 +0000 (19:49 +0200)]
core: propagate triggered unit in more load states
In
4c2ef3276735ad9f7fccf33f5bdcbe7d8751e7ec we enabled propagating
triggered unit state to the triggering unit for service units in more
load states, so that we don't accidentally stop tracking state
correctly.
Do the same for our other triggering unit states: automounts, paths, and
timers.
Also, make this an assertion rather than a simple test. After all it
should never happen that we get called for half-loaded units or units of
the wrong type. The load routines should already have made this
impossible.
(cherry picked from commit
0377cd2936ae5cac0c9d76a4b58889f121c097c4)
Lennart Poettering [Mon, 14 Sep 2020 10:35:19 +0000 (12:35 +0200)]
bootctl: handle if LoaderSystemToken is invalid for some reason
This points to some firmware issue, but we should still be able to
correct things if this happens. Hence log about this and fix it.
Fixes: #17041
(cherry picked from commit
ad0b610b0c1c2595c32b6235e7ac5ad7fba6e0aa)
Lennart Poettering [Fri, 11 Sep 2020 15:43:05 +0000 (17:43 +0200)]
test-fileio: test test strings with shell, too
(cherry picked from commit
df8b14b59119c61f660037710bbb3899db441ef7)
Lennart Poettering [Fri, 11 Sep 2020 13:18:07 +0000 (15:18 +0200)]
test-env-file: add test that tests our env file read + writer + shell against each other
Should hopefully make regressions on this unlikely.
(cherry picked from commit
55f99c26c678b4bf4fb697a57d540b0266aa3f49)
Lennart Poettering [Fri, 11 Sep 2020 13:14:03 +0000 (15:14 +0200)]
env-file: bring our decoding of double-quoted strings in env files in line with shell
In shell, inside of double quotes only a select few chars should be
escaped. If other chars are escaped this has no effect. Correct the list
of chars that need such escaping.
Also, make sure we can read back the stuff we wrote out without loss.
Fixes: #16788
(cherry picked from commit
de008e537dc6e3504f988fa9bd358f783016df8a)
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)