Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 14:20:30 +0000 (16:20 +0200)]
nss-resolve: fix parsing of io.systemd.Resolve.ResolveAddress reply
Since the switch to varlink in
0c73f4f075a2d23f7cabe708b589f19f4bbbec37, the
code wasn't functional. The JSON_VARIANT_UNSIGNED/JSON_VARIANT_STRING mismatch
meant that we'd reject any reply. Once past that, the code would use
unitialized 'c' and 'n' variables, so it's lucky we never got that far ;)
With -Wmaybe-unitialized, gcc would warn.
I think that declaring the huge list of local variables with very short names
at the top of the function was making it harder to understand what is going on
in the function. So let's rename the variables a bit, and initialize them upon
declaration if possible.
$ build/test-nss-hosts resolve 1.1.1.1 1.0.0.1 10.38.5.41
======== resolve ========
_nss_resolve_gethostbyaddr2_r("1.1.1.1") → status=NSS_STATUS_SUCCESS
errno=999/--- h_errno=0/Resolver Error 0 (no error) ttl=0
"one.one.one.one"
AF_INET 1.1.1.1
_nss_resolve_gethostbyaddr_r("1.1.1.1") → status=NSS_STATUS_SUCCESS
errno=999/--- h_errno=0/Resolver Error 0 (no error)
"one.one.one.one"
AF_INET 1.1.1.1
_nss_resolve_gethostbyaddr2_r("1.0.0.1") → status=NSS_STATUS_SUCCESS
errno=999/--- h_errno=0/Resolver Error 0 (no error) ttl=0
"one.one.one.one"
AF_INET 1.0.0.1
_nss_resolve_gethostbyaddr_r("1.0.0.1") → status=NSS_STATUS_SUCCESS
errno=999/--- h_errno=0/Resolver Error 0 (no error)
"one.one.one.one"
AF_INET 1.0.0.1
_nss_resolve_gethostbyaddr2_r("10.38.5.41") → status=NSS_STATUS_SUCCESS
errno=999/--- h_errno=0/Resolver Error 0 (no error) ttl=0
"squid.redhat.com"
alias "squid.corp.redhat.com"
alias "squid2.corp.redhat.com"
alias "squid3.corp.redhat.com"
alias "squid4.corp.redhat.com"
alias "squid5.corp.redhat.com"
AF_INET 10.38.5.41
_nss_resolve_gethostbyaddr_r("10.38.5.41") → status=NSS_STATUS_SUCCESS
errno=999/--- h_errno=0/Resolver Error 0 (no error)
"squid.redhat.com"
alias "squid.corp.redhat.com"
alias "squid2.corp.redhat.com"
alias "squid3.corp.redhat.com"
alias "squid4.corp.redhat.com"
alias "squid5.corp.redhat.com"
AF_INET 10.38.5.41
(I have 10.38.5.41 squid.redhat.com squid.corp.redhat.com squid2.corp.redhat.com squid3.corp.redhat.com squid4.corp.redhat.com squid5.corp.redhat.com
in /etc/hosts for testing.)
Luca Boccassi [Tue, 23 Jun 2020 12:09:42 +0000 (13:09 +0100)]
portabled: add --extension parameter for layered images support
Add an --extension parameter to portablectl, and new DBUS methods
to attach/detach/reattach/inspect.
Allows to append separate images on top of the root directory (os-release
will be searched in there) and mount the images using an overlay-like
setup (unit files will be searched in there) using the new ExtensionImages
service option.
Luca Boccassi [Sat, 27 Mar 2021 19:11:08 +0000 (19:11 +0000)]
gcrypt: do not ignore return values
Check the return code from gcrypt's functions. In some
cases just log, as it shoulnd't really happen.
Fixes various Coverity issues:
CID #
1444702
CID #
1444704
CID #
1444706
CID #
1444711
CID #
1444712
CID #
1444713
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 16:09:13 +0000 (17:09 +0100)]
rpm: when disabling a unit, do not complain if systemd is not running
$ sudo dnf remove --installroot=/var/tmp/img1 systemd-networkd
...
Running scriptlet: systemd-networkd-248~rc4-4.fc32.x86_64 1/1
Removed /etc/systemd/system/multi-user.target.wants/systemd-networkd.service.
Removed /etc/systemd/system/sockets.target.wants/systemd-networkd.socket.
Removed /etc/systemd/system/dbus-org.freedesktop.network1.service.
Removed /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service.
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
(Another option would be make --now do nothing if systemd is not running.
But I think that's not too good. 'disable --now' doing nothing would be OK,
since if systemd is not running, the service is not running either, so we are
in the desired state. But that argument doesn't work for 'enable --now'. And
accepting 'disable --now' but not 'enable --now' seems overly complex. So I
think it is better to make the scriptlet handle this case explicitly.)
Also, let's reindent the file to 4 spaces. Very deeply nested scriptlets are
harder to read, and the triggers file is indented to 4 spaces already.
Jan Janssen [Fri, 26 Mar 2021 15:37:33 +0000 (16:37 +0100)]
resolved.conf: Add hostnames for default DNS servers
Deepak Rawat [Tue, 30 Mar 2021 03:22:16 +0000 (20:22 -0700)]
logind: Add new flag for kexec reboot
Add new flag to allow kexec reboot if kernel is already loaded.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:47:12 +0000 (10:47 +0200)]
Merge pull request #19109 from poettering/resolved-transaction-log-tweaks
resolved: minor tweaks to transaction logic and logging
Lennart Poettering [Tue, 23 Mar 2021 15:10:31 +0000 (16:10 +0100)]
shared: add new IMAGE_VERSION=/IMAGE_ID= field to /etc/os-release
This specifes two new optional fields for /etc/os-release:
IMAGE_VERSION= and IMAGE_ID= that are supposed to identify the image of
the current booted system by name and version.
This is inspired by the versioning stuff in
https://github.com/systemd/mkosi/pull/683.
In environments where pre-built images are installed and updated as a
whole the existing os-release version/distro identifier are not
sufficient to describe the system's version, as they describe only the
distro an image is built from, but not the image itself, even if that
image is deployed many times on many systems, and even if that image
contains more resources than just the RPMs/DEBs.
In particular, "mkosi" is a tool for building disk images based on
distro RPMs with additional resources dropped in. The combination of all
of these together with their versions should also carry an identifier
and version, and that's what IMAGE_VERSION= and IMAGE_ID= is supposed to
be.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:42:21 +0000 (10:42 +0200)]
Merge pull request #19064 from yuwata/resolve-fix-cache-19049
resolve: several trivial cleanups
gaoyi [Fri, 19 Mar 2021 07:16:56 +0000 (15:16 +0800)]
udevd: don't kill worker in manager_kill_workers when it's running
If worker is running, kill worker may lead uevent unprocessed.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:38:37 +0000 (10:38 +0200)]
Merge pull request #18990 from yuwata/network-dhcpv6-use-domains
network: also introduce UseDomains= for [DHCPv6] section
Lennart Poettering [Wed, 31 Mar 2021 08:37:49 +0000 (10:37 +0200)]
Merge pull request #19101 from poettering/mount-util-fixes
Make recursive bind remounting handle failures gracefully
Lennart Poettering [Tue, 23 Mar 2021 13:07:53 +0000 (14:07 +0100)]
dissect: make the --image= switch of our various tools honour Verity data
This adds simple Verity support to
mount_image_privately_interactively(): we dicover the verity metadata
and use it.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:36:03 +0000 (10:36 +0200)]
Merge pull request #18989 from yuwata/ordered-set-put-strdup
ordered-set: make ordered_set_put_strdup() allocate OrderedSet object
Lennart Poettering [Tue, 23 Mar 2021 13:05:56 +0000 (14:05 +0100)]
repart: make sure CopyFiles= works with a / suffixed path
If we define a partition with CopyFiles=/efi/ this should just work.
However it previously didn't because basename() would return the
trailing slash.
Let's fix this by moving things to path_extract_{directory|filename}()
Lennart Poettering [Fri, 19 Mar 2021 17:34:06 +0000 (18:34 +0100)]
machine-id-setup: support --image= mode
Lennart Poettering [Wed, 31 Mar 2021 08:35:17 +0000 (10:35 +0200)]
Merge pull request #18971 from poettering/sysusers-creds
let's read LoadCredentials=/SetCredentials= style cred in sysusers/firstboot and when asking for passwords
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:32:09 +0000 (10:32 +0200)]
Merge pull request #18982 from keszybz/test-nss-users
Add a new test for user/group resolution in nss modules
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:31:32 +0000 (10:31 +0200)]
Merge pull request #18958 from poettering/dissect-no-root
dissect-image: support images without rootfs but with /usr partition + support simple partition versioning via strverscmp() on part label
Luca Boccassi [Tue, 9 Mar 2021 14:57:44 +0000 (14:57 +0000)]
compress: support streaming lz4 without full input mmap
The advantage of stream compression is keeping a low memory profile,
but the lz4 stream compressor usage mmaps the whole file in memory.
Change it to read bits by bits, like the other stream compression
helpers.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:28:26 +0000 (10:28 +0200)]
Merge pull request #18886 from anitazha/shutdownconsole
logging shutdown to /dev/console
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:27:06 +0000 (10:27 +0200)]
Merge pull request #18850 from yuwata/sd-device-monitor-cleanups
sd-device-monitor: trivial cleanups
Henri Chain [Wed, 24 Feb 2021 15:13:21 +0000 (16:13 +0100)]
Introduce ExitType
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 08:25:23 +0000 (10:25 +0200)]
Merge pull request #18777 from yuwata/network-set-ifname-to-engines
network: set ifname to dhcp4 client or friends
Lennart Poettering [Tue, 30 Mar 2021 20:59:02 +0000 (22:59 +0200)]
Merge pull request #19157 from keszybz/read-medium-sized-virtual-file
basic/fileio: fix reading of not-too-small virtual files
Lennart Poettering [Tue, 30 Mar 2021 20:00:11 +0000 (22:00 +0200)]
NEWS: prep release date
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 19:58:59 +0000 (21:58 +0200)]
test-fileio: test for read_full_virtual_file()
It was already called through other places, but indirectly.
Let's add some direct invocations.
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 15:29:44 +0000 (17:29 +0200)]
basic/fileio: fix reading of not-too-small virtual files
This code is trying to do two things: when reading a file with working
st.st_size, detect when the file size changes between the fstat() and our
allocation of the buffer based on the returned size, and the subsequent read().
When reading a file without st.st_size, read up to READ_FULL_BYTES_MAX.
But this second scenario was partially broken: we'd start with size = 4095, and
double the size up to three times, i.e. up to 32767. But we want to read up to
READ_FULL_BYTES_MAX.
So let's listentangle the two cases a bit: if a file returns non-zero st._size,
proceed as before. But if we don't know the size, let's immediately allocate
the buffer of maximum size of READ_FULL_BYTES_MAX. I think that allocating 4MB
and 1MB is going to take pretty much the same time as long as the memory is not
written to, so by allocating 1MB, 2MB, and 4MB, we wouldn't really be saving
anything internally, but wasting time on repeated reads, if the file is long
enough.
Also, don't do the seek if we know we're going to return an error immediately
after.
This should fix reading of any files in /proc, which all have size == 0. In
particular, various files read by coredump might be larger than 32767.
What about /sys? The file there return a fake value, usually 4096. So we'll
allocate a small buffer and read that.
Luca Boccassi [Tue, 30 Mar 2021 18:01:01 +0000 (19:01 +0100)]
Merge pull request #19149 from anitazha/oomdlogging
oomd: make it more clear when a kill happens
Luca Boccassi [Tue, 30 Mar 2021 17:13:16 +0000 (18:13 +0100)]
Merge pull request #19155 from keszybz/hwdb-contrib-v248
hwdb update + contrib list
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 12:45:22 +0000 (14:45 +0200)]
oomd: fix iteration over candidates to kill
Anita Zhang [Fri, 26 Mar 2021 10:01:38 +0000 (03:01 -0700)]
oomd: make it more clear when a kill happens
Improve the logging to only print if systemd-oomd killed something. And
also print which cgroup was targeted.
Demote general swap above/pressure above messages to debug.
[zjs: fix some issuelets found in review]
Lennart Poettering [Tue, 30 Mar 2021 11:29:55 +0000 (13:29 +0200)]
Merge pull request #19131 from keszybz/resolvectl-warn-less
Suppress warnings in resolvectl about --type=
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 08:01:12 +0000 (10:01 +0200)]
selinux: do not crash if policy becomes unavailable after reload
https://bugzilla.redhat.com/show_bug.cgi?id=
1944171
This was in F33, systemd-246.13, but the logic in the code didn't change.
Thread 1 (Thread 0x7fb5f0341b80 (LWP 1974)):
№0 selabel_lookup_common (rec=0x0, translating=0, key=0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service", type=40960) at label.c:167
'rec' is the handle that we passed.
№1 0x00007fb5f13ae87f in selabel_lookup_raw (rec=<optimized out>, con=con@entry=0x7fffef307380, key=key@entry=0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service", type=type@entry=40960) at label.c:256
lr = <optimized out>
'rec' is passed through as is to selabel_lookup_common().
№2 0x00007fb5f1561b2d in selinux_create_file_prepare_abspath (abspath=0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service", mode=40960) at ../src/basic/selinux-util.c:368
filecon = 0x0
r = <optimized out>
__PRETTY_FUNCTION__ = "selinux_create_file_prepare_abspath"
__func__ = "selinux_create_file_prepare_abspath"
№3 0x00007fb5f1561ec3 in mac_selinux_create_file_prepare (path=<optimized out>, mode=40960) at ../src/basic/selinux-util.c:431
r = 0
abspath = 0x55f616ac4750 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service"
__PRETTY_FUNCTION__ = "mac_selinux_create_file_prepare"
We checked label_hnd != NULL, but then we apparently called
avc_netlink_check_nb(), which reset label_hnd. Yay for global state!
№4 0x00007fb5f1549950 in symlink_atomic_label (from=0x55f6169d8b50 "
69a8dcf7a7ac46b29306f2fddbed3edc", to=0x55f616ab8380 "/run/user/1000/systemd/units/invocation:systemd-tmpfiles-clean.service") at ../src/basic/label.c:55
r = <optimized out>
__PRETTY_FUNCTION__ = "symlink_atomic_label"
In the logs:
Mar 29 14:48:44 fedorapad.home systemd[1974]: selinux: avc: received policyload notice (seqno=2)
Mar 29 14:48:44 fedorapad.home systemd[1974]: Failed to initialize SELinux labeling handle: No such file or directory
Mar 29 14:48:44 fedorapad.home systemd[1974]: selinux: avc: received policyload notice (seqno=3)
Mar 29 14:48:44 fedorapad.home systemd[1974]: selinux: avc: received setenforce notice (enforcing=0)
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 11:17:42 +0000 (13:17 +0200)]
hwdb: update fingerprint autosuspend rules
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 11:16:30 +0000 (13:16 +0200)]
hwdb: update for v248
As usual, it seems to be additions and updates, no major removals.
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:49:41 +0000 (12:49 +0200)]
NEWS: update contributor list for v248 final
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:45:14 +0000 (12:45 +0200)]
git-contrib: use non-breaking spaces in names
Some people have initials or abbreviated parts in the name and looks strange
when a line break occurs in the middle. Let's keep each name in one line.
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:43:23 +0000 (12:43 +0200)]
mailmap: two more names
Luca Boccassi [Mon, 29 Mar 2021 21:31:21 +0000 (22:31 +0100)]
Revert "fix wrong statement JOURNAL_FILE_FORMAT.md doc"
This reverts commit
119063d2b149667a91e0e08e4bdf82a0eb6a7efd.
Yangyang Shen [Mon, 29 Mar 2021 12:29:54 +0000 (20:29 +0800)]
fix wrong statement JOURNAL_FILE_FORMAT.md doc
Christian Hesse [Sun, 28 Mar 2021 11:00:49 +0000 (13:00 +0200)]
units: make locale directory writable for systemd-localed
With
8f20232fcb52dbe6255f3df6101fc057af90bcfa systemd-localed supports
generating locales when required. This fails if the locale directory is
read-only, so make it writable.
Closes #19138
Fangrui Song [Mon, 29 Mar 2021 06:35:06 +0000 (23:35 -0700)]
sd-bus: set retain attribute on BUS_ERROR_MAP_ELF_REGISTER
LLD 13 and GNU ld 2.37 support -z start-stop-gc which allows garbage
collection of C identifier name sections despite the __start_/__stop_
references. Simply set the retain attribute so that GCC 11 (if
configure-time binutils is 2.36 or newer)/Clang 13 will set the
SHF_GNU_RETAIN section attribute to prevent garbage collection.
Without the patch, there are linker errors like the following with -z
start-stop-gc.
```
ld: error: undefined symbol: __start_SYSTEMD_BUS_ERROR_MAP
>>> referenced by bus-error.c:93 (../src/libsystemd/sd-bus/bus-error.c:93)
>>> sd-bus_bus-error.c.o:(bus_error_name_to_errno) in archive src/libsystemd/libsystemd_static.a
```
Zbigniew Jędrzejewski-Szmek [Mon, 29 Mar 2021 08:51:32 +0000 (10:51 +0200)]
Merge pull request #19116 from keszybz/readvirtualfile-opt
Optimize read_full_virtual_file() and another coverity issue
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 13:14:38 +0000 (14:14 +0100)]
resolvectl: suppress warning about --type for names with a dot
People don't generally type the trailing dot by mistake, so let's treat this as
indication that they want to resolve this particular hostname.
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 19:22:29 +0000 (20:22 +0100)]
Merge pull request #19129 from keszybz/test-random-range
Test random_u64_range()
Luca Boccassi [Fri, 26 Mar 2021 12:03:11 +0000 (12:03 +0000)]
test-dhcp6-client: add one more assert on memory mapping
Same as
7489d0640a4864d4b47fd8fda77f8eb7cf2e3fe8, one more case
that was missed.
Coverity CID #
1394277
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 19:16:09 +0000 (20:16 +0100)]
Merge pull request #19125 from keszybz/cat-config
config files: recommend systemd-analyze cat-config
Lennart Poettering [Wed, 24 Feb 2021 16:04:55 +0000 (17:04 +0100)]
resolved: tweak how we signal authoritative answers
let's make sure we set the "aa" bit in the stub only if we answer with
fully authoritative data. For this ensure:
1. Either all data is synthetic, including all CNAME/DNAME redirects
2. Or all data comes from the local trust anchor or the local zones
(i.e. not the network or the cache)
Follow-up for
4ad017cda57b04b9d65e7da962806cfcc50b5f0c
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 11:19:18 +0000 (12:19 +0100)]
tests: drop calls to unsetenv SYSTEMD_MEMPOOL
Coverity was complaining that we don't check the return value, which we stopped
doing in
772e0a76f34914f6f81205e912e4744c6b23f704.
But it seems that we don't want those calls at all. The test was originally
added with the call in
a6ee01caf3409ba9820e8824b9262fbac31a9f77, but I don't
see why we should override this. If the user wants to execute the test with
mempool disabled, we shouldn't ignore that.
Coverity CID#
1444464, CID#
1444466.
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 12:50:13 +0000 (13:50 +0100)]
basic/fileio: use malloc_usable_size() to use all allocated memory
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 11:10:32 +0000 (12:10 +0100)]
basic/fileio: optimize buffer sizes in read_full_virtual_file()
We'd proceed rather inefficiently: the initial buffer size was LINE_MAX/2,
i.e. only 1k. We can read 4k at the same cost.
Also, we'd try to allocate 1025, 2049, 4097 bytes, i.e. always one higher than
the power-of-two size. Effectively the allocation would be bigger, and we'd
waste the additional space. So let's allocate aligned to the power-of-two size.
size=4095, 8191, 16383, so we allocate 4k, 8k, 16k.
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 10:58:35 +0000 (11:58 +0100)]
basic/fileio: simplify calculation of buffer size in read_full_virtual_file()
We'd first assign a value up to SSIZE_MAX, and then immediately check if we
have a value bigger than READ_FULL_BYTES_MAX. This wasn't exactly wrong, but a
bit roundabout. Let's immediately assign the value from the appropriate range
or error out.
Coverity CID#
1450973.
David Tardon [Fri, 26 Mar 2021 11:34:28 +0000 (12:34 +0100)]
use the right member to define property
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 11:42:52 +0000 (12:42 +0100)]
test-random-util: add stochastic test for random_u64_range()
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 11:42:22 +0000 (12:42 +0100)]
test-random-util: modernization
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 13:09:28 +0000 (14:09 +0100)]
resolvectl: do not warn about single hostnames for names we synthesize
https://github.com/systemd/systemd/pull/17535#discussion_r534005801
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 13:08:03 +0000 (14:08 +0100)]
resolved: split out function to determine the local llmnr hostname
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 12:25:04 +0000 (13:25 +0100)]
resolvectl: reword note about "raw record types"
As noted in https://github.com/systemd/systemd/pull/17535#discussion_r534129256,
"raw" is misleading in this context. Let's use a more descriptive term.
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 12:07:55 +0000 (13:07 +0100)]
basic/log: fix log_trace()
log_trace() was always on. It's supposed to be opt-in.
Lennart Poettering [Thu, 11 Mar 2021 16:48:59 +0000 (17:48 +0100)]
update TODO
Lennart Poettering [Thu, 11 Mar 2021 19:17:10 +0000 (20:17 +0100)]
ask-password: when querying for a password, try to read from credential store first
This adds generic support for the SetCredential=/LoadCredential= logic
to our password querying infrastructure: if a password is requested by a
program that has a credential store configured via
$CREDENTIALS_DIRECTORY we'll look in it for a password.
The "systemd-ask-password" tool is updated with an option to specify the
credential to look for.
Lennart Poettering [Thu, 11 Mar 2021 16:49:18 +0000 (17:49 +0100)]
man: document in nspawn docs how to make use of the new firstboot/sysusers features
Lennart Poettering [Thu, 11 Mar 2021 10:47:57 +0000 (11:47 +0100)]
firstboot: allow provisioning of firstboot params via creds too
Lennart Poettering [Thu, 11 Mar 2021 10:43:17 +0000 (11:43 +0100)]
firstboot: slightly reorder variable declaration
Let's put the locale fields which we process together next to each
other.
Lennart Poettering [Thu, 11 Mar 2021 10:47:15 +0000 (11:47 +0100)]
units: make sure to query console settings before we apply them
Lennart Poettering [Thu, 11 Mar 2021 09:34:20 +0000 (10:34 +0100)]
sysusers: read passwords from the credentials logic
Let's make use of our own credentials infrastructure in our tools: let's
hook up systemd-sysusers with the credentials logic, so that the root
password can be provisioned this way. This is really useful when working
with stateless systems, in particular nspawn's "--volatile=yes" switch,
as this works now:
# systemd-nspawn -i foo.raw --volatile=yes --set-credential=passwd.plaintext-password:foo
For the first time we have a nice, non-interactive way to provision the
root password for a fully stateless system from the container manager.
Yay!
Lennart Poettering [Thu, 11 Mar 2021 09:04:05 +0000 (10:04 +0100)]
core: when inheriting credentials from manager to service, make missing creds graceful
Let's be a bit less strict when setting up credentials: if the service
manager didn't receieve a cred, and we shall propagate it down via
LoadCredentials= don't fail. Fail on all other errors though, as before,
and on explicitly listed paths.
Lennart Poettering [Thu, 11 Mar 2021 09:02:46 +0000 (10:02 +0100)]
core: allow omitting second part of LoadCredentials= argument
This allows "LoadCredentials=foo" to be used as shortcut for
"LoadCredentials=foo:foo", i.e. it's a very short way to inherit a
credential under its original name from the service manager into a
service.
Lennart Poettering [Wed, 10 Mar 2021 22:03:40 +0000 (23:03 +0100)]
util: add creds-util.[ch] with helpers for dealing with credentials
Lennart Poettering [Wed, 24 Mar 2021 12:45:25 +0000 (13:45 +0100)]
test: add explicit test for bind_remount_one_with_mountinfo()
Lennart Poettering [Wed, 24 Mar 2021 12:44:56 +0000 (13:44 +0100)]
test: add test for bind_remount_recursive()
Lennart Poettering [Wed, 24 Mar 2021 13:19:04 +0000 (14:19 +0100)]
mount-util: generate failure if bind_remount_one_with_mountinfo() is called on non-existing path
Lennart Poettering [Wed, 24 Mar 2021 13:17:20 +0000 (14:17 +0100)]
mount-util: handle remount failures gracefully if flags already match
In bind_remount_one_with_mountinfo() let's handle mount failures
gracefully if the flags already match anyway. This isn't perfect, since
it mixes up superblock and mount point flags, but it's close enough.
Lennart Poettering [Wed, 24 Mar 2021 13:16:45 +0000 (14:16 +0100)]
mount-util: fold what we need from get_mount_flags() bind_remount_one_with_mountinfo()
And get rid of get_mount_flags() altogether.
(This drops the statvfs() fallback that get_mount_flags() did. That
fallback was incomplete however, and mostly hid errors. Our primary
avenue to get mount flags is /proc/self/mountinfo and we should trust
it, and fix bugs we might encounter with it, but not tape over it.
Dropping the fallback is relevant in particular as it actually returned
mount flags for any path, not just mount points, which was very icky.)
Lennart Poettering [Wed, 24 Mar 2021 13:07:32 +0000 (14:07 +0100)]
mount-util: store mount flags in "todo" list in + handle submounts gracefully
This replaces the "todo" set with a "todo" hash map that stores the
mount flags we found. This makes an explicit call to get_mount_flags()
unncessary, since we have the flags handy right-away, and lowers our
work from O(n^2) to O(n). Nice!
The "done" set is also improved slightly: we'll use more modern ways to
allocate it, via set_ensure_consume(), and freeing-via-hash_ops.
Finally, failures on submount remounts are now handled gracefully,
there are just too many reasons why they might fail, given NFS, autofs,
FUSE which weird access controls, where even root might lack the privs
to do something.
Fixes: #16156
Lennart Poettering [Wed, 24 Mar 2021 13:06:22 +0000 (14:06 +0100)]
mount-util: extend comment a bit, mention that we aren't atomic in behaviour
Lennart Poettering [Wed, 24 Mar 2021 13:02:29 +0000 (14:02 +0100)]
mount-util: shortcut things after generating top-level bind mount
Instead of marking the bind mount read-only right-away, let's just
restart the loop, so that we'll pick it up like any other mount and then
remount like that.
Lennart Poettering [Wed, 24 Mar 2021 12:56:55 +0000 (13:56 +0100)]
mount-util: reorder a few things
Let's always query one property, check it, and then query the next,
preferring "cheap" ones over "slow" ones (i.e. cheap are the ones we can
check directly, and slow are the ones we need to check with some loop of
some kind).
Lennart Poettering [Wed, 24 Mar 2021 12:49:06 +0000 (13:49 +0100)]
path: drop simplification of path in bind_remount_recursive_with_mountinfo()
We only use path-aware comparisons and hashops, hence no need to
simplify, we can use the path as it is.
Lennart Poettering [Wed, 24 Mar 2021 12:47:17 +0000 (13:47 +0100)]
mount-until: make sure we'll exit bind_remount_recursive_with_mountinfo() loop eventually
Just some robustness given that /proc/self/mountinfo was previously
broken in the kernel.
Lennart Poettering [Tue, 23 Mar 2021 21:28:16 +0000 (22:28 +0100)]
mountpoint-util: rebreak some comments
Lennart Poettering [Tue, 23 Mar 2021 21:26:06 +0000 (22:26 +0100)]
mountpoint-util: a symlink is never a mount point
The various flavours of stat() basically tell us for free if something
is a symlink. If it is, then it's definitely not a mount point. Use
that.
All other inode types can be mount point, just symlinks cannot.
Lennart Poettering [Wed, 24 Mar 2021 09:49:23 +0000 (10:49 +0100)]
test-namespace: drop spurious double new line
Lennart Poettering [Wed, 24 Mar 2021 17:45:55 +0000 (18:45 +0100)]
resolved: use sd_event_add_time_relative() where appropriate
Lennart Poettering [Wed, 24 Mar 2021 17:45:35 +0000 (18:45 +0100)]
resolved: reset initial_jitter_elapsed properly
This fixes resetting of initial_jitter_elapsed: the first time the timer
hits after initial_jitter_scheduled is set we need to mark things as
elapsed.
(Also improve log messages around this while we are at it)
Lennart Poettering [Wed, 24 Mar 2021 16:18:02 +0000 (17:18 +0100)]
resolved: mention transaction ID in jitter log message
Lennart Poettering [Wed, 24 Mar 2021 16:17:17 +0000 (17:17 +0100)]
resolved: use random_u64_range() for randomizing initial transaction jitter
Lennart Poettering [Wed, 24 Mar 2021 16:15:55 +0000 (17:15 +0100)]
resolved: don't mention confusing server switch on server-less protocols
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 08:27:11 +0000 (09:27 +0100)]
Add READMEs in all .d directories
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 07:43:03 +0000 (08:43 +0100)]
config files: recommend systemd-analyze cat-config
This adds the same line to most of our .conf files.
Not for systemd/user.conf though, since we can't correctly display it right
now:
$ systemd-analyze cat-config --user systemd/user.conf
Option --user is not supported for cat-config right now.
For sysusers.d, tmpfiles.d, rules.d, etc, there is no single file. Maybe
we should short READMEs in /usr/lib/sysusers.d, /usr/lib/tmpfiles.d, etc.?
Inspired by #19118.
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 19:41:05 +0000 (20:41 +0100)]
docs: link to stable releases in the bug template
Also, ask people to use a recent stable release and provide useful version information.
Inspired by #19118.
Zbigniew Jędrzejewski-Szmek [Thu, 25 Mar 2021 20:31:27 +0000 (21:31 +0100)]
Merge pull request #19112 from poettering/more-stub-fixes
resolved: two more tweaks to the stub
Luca Boccassi [Thu, 25 Mar 2021 19:33:58 +0000 (19:33 +0000)]
Merge pull request #19117 from bluca/coverity
Two small coverity issues
Lennart Poettering [Wed, 24 Mar 2021 22:29:16 +0000 (23:29 +0100)]
resolved: rework CNAME logic a bit more
When following CNAME/DNAME redirects in the stub we currently first
iterate through the packet and pick up what we can use (in
dns_stub_collect_answer_by_question() and friends), following all
CNAMEs/DNAMEs, and would then issue dns_query_process_cname() to move
the DnsQuery object forward too, where we'd then possibly restart
the query and pick things up again, as above.
There's one thought error in this though: dns_query_process_cname()
tries to be smart and will internally follow not just a single
CNAME/DNAME redirect, but a chain of them if they are contained inside
the same packet until we reach the point where the answer is not
included in the packet anymore, where we'd restart the query. This was
great as long as we only focussed on the D-Bus and Varlink resolver
APIs, since there the CNAME/DNAME chain in the middle doesn't actually
matter, we just return information about the final name of the RR and
its content, and aren't interested in the chain to it. For the DNS stub
this is different however: there we need to place the full CNAME/DNAME
chain (and all the appropriate metadata RRs) in the stub reply.
Hence rework this so that we build on the fact that the previous commit
split dns_query_process_cname() in two:
1. dns_query_process_cname_one() will do exactly one CNAME/DNAME
redirect step. This will be called by the stub, so that we can pick
up matching RRs for every single step along the way.
2. dns_query_process_cname_many() will follow a chain as long as that's
possible within the same packet. It's thus pretty much identical to
the old dns_query_process_cname() call. This is what we now use in
the D-Bus and Varlink APIs. dns_query_process_cname_many() is
basically just a loop around dns_query_process_cname_one().
Any logic to follow and pick up RRs manually in the stub along the
CNAME/DNAME path is now dropped (i.e.
dns_stub_collect_answer_by_question() becomes trivially simple again),
we solely rely on dns_query_process_cname_one() to follow CNAME/DNAME
now: each step followed by a full call of dns_stub_assign_sections() to
copy out the RRs that matter.
Net result: things are a bit simpler again, as the only place we follow
CNAME/DNAME redirects is DnsQuery again, and stub answers are always
complete: they contain all CNAME/DNAME RRs on the way including all
their metadata we might pick up in the other sections.
Lennart Poettering [Thu, 25 Mar 2021 10:43:52 +0000 (11:43 +0100)]
resolved: split dns_query_process_cname() into two separate functions
This does some refactoring: the dns_query_process_cname() function
becomes two: dns_query_process_cname_one() and
dns_query_process_cname_many(). The former will process exactly one
CNAME chain element, the latter will follow a chain for as long as
possible within the current packet.
dns_query_process_cname_many() is mostly identical to the old
dns_query_process_cname(), and all existing code is moved over to using
that.
This is mostly preparation for the next commit, where we make direct use
of dns_query_process_cname_one().
This also renames the DNS_QUERY_RESTARTED return value to
DNS_QUERY_CNAME. That's because in the dns_query_process_cname_many()
case as before if we return this we restarted the query in case we
reached the end of the chain without a conclusive answer, as before. But
in dns_query_process_cname_one() we'll only go one step anyway, and
leave restarting if needed to the caller. Hence DNS_QUERY_RESTARTED is a
bit of a misnomer in that case.
This also gets rid of the weird tail recursion in
dns_query_process_cname() and replaces it with an explicit loop in
dns_query_process_cname_many(). The old recursion wasn't a security
issue since we put a limit on the number of CNAMEs we follow anyway, but
it's still icky to scale stack use by that.
Luca Boccassi [Thu, 25 Mar 2021 11:47:13 +0000 (11:47 +0000)]
test-dhcp6-client: add one more assert on memory mapping
Static analyzers need a hint that optval is not pointing
off the end of the msg_advertise array, since pos can go
up to the full length of it. The array is manually
constructed so we know this won't happen, but adding one
more assert should be enough to avoid false positives.
Coverity CID #
1394277
Luca Boccassi [Thu, 25 Mar 2021 10:49:06 +0000 (10:49 +0000)]
test-firewall-util: add more asserts on allocated variables
Makes things nicer for readers, and hopefully gives static analyzers
a hint on the origin/cleanup of the ctx pointer.
Coverity CID #
1451399
Lennart Poettering [Wed, 24 Mar 2021 21:02:55 +0000 (22:02 +0100)]
resolved: tweak sections we add answer RRs to
Previously we'd stick all answer sections RRs we acquired into
the authoritative section if we didn't find them directly answering our
question. Let's put them into additional instead. The authoritative
section should hence only include what comes from the upstream
authoritative section, and nothing else.
Lennart Poettering [Wed, 24 Mar 2021 17:36:41 +0000 (18:36 +0100)]
resolved: pass mDNS reply packets to each transaction exactly once
Previously we'd iterate through the RRs of an mDNS reply and then find
exactly one matching transaction on our scope for it, and pass it as
reply to that. If multiple RRs of the same packet match we'd pas the
packet multiple times to the transaction even.
This all doesn't really work anymore since there can be multiple open
transactions for the same key (with different flags), and it's kinda
ugly anywy. Hence let's turn this around: let's iterate through the
transactions and check if any of the included RRs match it, and if so
pass the packet to that transaction exactly once.
This speeds up mDNS a bit, since previously we'd oftentimes fail to find
all suitable transactions for an mDNS reply (because there can be
multiple transactions for the same RR key with different flags, and we
checked exactly one flag combination). Which would then mean the
transaction would time out, and be retried – at which point the cache
would be populated and thus it would still succeed, but only after this
timeout. With this fix this is corrected: every transaction that matches
will get the reply, instantly as we get it.