]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agocondition: if spelunking through /sys/class/tpmrm doesn't work ask EFI if TPM2 exists 18558/head
Lennart Poettering [Thu, 11 Feb 2021 22:12:46 +0000 (23:12 +0100)] 
condition: if spelunking through /sys/class/tpmrm doesn't work ask EFI if TPM2 exists

This makes ConditionSecurity=tpm2 work reliably during early boot: if
Linux doesn't know about the TPM2 then maybe the firmware does.

3 years agobootctl: show whether the firmware has TPM2 support
Lennart Poettering [Thu, 11 Feb 2021 22:11:56 +0000 (23:11 +0100)] 
bootctl: show whether the firmware has TPM2 support

3 years agoefi-loader: add efi_has_tpm2() helper
Lennart Poettering [Thu, 11 Feb 2021 22:10:07 +0000 (23:10 +0100)] 
efi-loader: add efi_has_tpm2() helper

The helper checks if the UEFI firmware is hooked up to a TPM2 chip. This
is useful to know in trusted boot scenarios, in particular during early
boot in auto-enroll scenarios where we want to know whether TPM2 is
available or not, and the Linux drivers are not loaded yet, and where it
might or not be worth waiting for it.

3 years agoefivars: debug log if we fail to detect whether /sys/firmware/efi/ exists
Lennart Poettering [Thu, 11 Feb 2021 22:09:54 +0000 (23:09 +0100)] 
efivars: debug log if we fail to detect whether /sys/firmware/efi/ exists

3 years agoMerge pull request #18550 from keszybz/coverity-inspired-fixes
Luca Boccassi [Thu, 11 Feb 2021 15:44:25 +0000 (15:44 +0000)] 
Merge pull request #18550 from keszybz/coverity-inspired-fixes

Coverity inspired fixes

3 years agoMerge pull request #17902 from bugaevc/fix-container-detection
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 11:56:01 +0000 (12:56 +0100)] 
Merge pull request #17902 from bugaevc/fix-container-detection

improve container detection

3 years agohomework: fix unitialized variable 18550/head
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 11:00:09 +0000 (12:00 +0100)] 
homework: fix unitialized variable

Coverity CID#1444703.

3 years agohomework: reduce scope of iterator variables
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 10:59:22 +0000 (11:59 +0100)] 
homework: reduce scope of iterator variables

3 years agobasic/locale-util: reduce variable scope
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:55:01 +0000 (09:55 +0100)] 
basic/locale-util: reduce variable scope

3 years agofsck: make sure we don't read an unitialized variable
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:50:49 +0000 (09:50 +0100)] 
fsck: make sure we don't read an unitialized variable

This use on %n was completely unnecessary: fprintf returns the number of
characters written. And the issue was that if fprintf failed for whatever
reason, it would not process the %n and m would be unitialized. Rework the
code a bit to simplify it.

Coverity CID#1444708.

3 years agosd-journal: add forgotten unmap in error path
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:35:52 +0000 (09:35 +0100)] 
sd-journal: add forgotten unmap in error path

Bug introduced in 4b5bc5396c090ee41c45cab9052372d296c4a2f4 :(

Coverity CID#1444709.

3 years agoshared/generator: add missing initializer
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:23:22 +0000 (09:23 +0100)] 
shared/generator: add missing initializer

Coverity CID#1444710.

3 years agoudev: add assert to make coverity happy
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:17:46 +0000 (09:17 +0100)] 
udev: add assert to make coverity happy

Coverity says:
CID 1446387 (#1 of 1): Bad bit shift operation (BAD_SHIFT)
8. negative_shift: In expression 1U << (int)cmd, shifting by a negative amount
has undefined behavior. The shift amount, cmd, is -22.

I don't think there's any issue, unless we forget to set token->data
appropriately. Let's add an assert.

3 years agoMerge pull request #18545 from poettering/netlink-seqno-fix
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 07:24:39 +0000 (08:24 +0100)] 
Merge pull request #18545 from poettering/netlink-seqno-fix

sd-netlink seqnum fixes

3 years agonetworkd: add UseFQDN option for DHCPv6
Vinnie Magro [Fri, 29 Jan 2021 00:24:34 +0000 (16:24 -0800)] 
networkd: add UseFQDN option for DHCPv6

Similar to DHCPv4's UseHostname option, add a UseFQDN config option in
[DHCPv6] to set the system's transient hostname if the FQDN option is
set in the DHCPv6 response from the server.

3 years agoMerge pull request #17823 from poettering/resolved-just-bypass
Zbigniew Jędrzejewski-Szmek [Wed, 10 Feb 2021 23:10:25 +0000 (00:10 +0100)] 
Merge pull request #17823 from poettering/resolved-just-bypass

resolved: just the dnssec bypass logic

3 years agosd-netlink: spread out sequence numbers a bit 18545/head
Lennart Poettering [Wed, 10 Feb 2021 22:05:51 +0000 (23:05 +0100)] 
sd-netlink: spread out sequence numbers a bit

An (imperfect) fix for #14760.

This makes collisions unlikely, but still theoretically possible.

Fixes: #14760
3 years agosd-netlink: reduce indentation levels a bit
Lennart Poettering [Wed, 10 Feb 2021 17:12:58 +0000 (18:12 +0100)] 
sd-netlink: reduce indentation levels a bit

3 years agosd-netlink: use getsockopt_int() where appropriate
Lennart Poettering [Wed, 10 Feb 2021 17:11:20 +0000 (18:11 +0100)] 
sd-netlink: use getsockopt_int() where appropriate

3 years agosd-netlink: revamp message serial handling
Lennart Poettering [Wed, 10 Feb 2021 16:59:46 +0000 (17:59 +0100)] 
sd-netlink: revamp message serial handling

Let's use uint32_t everywhere to maintain the seqno, since that's what
the kernel does. Prviously in the reply_callback logic we used 64bit,
for no apparent reason.

Using 32bit also provides us with the benefit that we can avoid using
uint64_hash_ops, and can use trivial_hash_ops instead for the reply
hashmap, so that we can store the seqno in the key pointer directly.

While we are at it, let's make sure we never run into serial collisions
internally (32bit is a lot, but not that much), and let's put a limit on
outstanding serials, to catch programming errors.

3 years agotmpfiles: explicitly say we need /proc/ to run
Lennart Poettering [Wed, 10 Feb 2021 16:11:34 +0000 (17:11 +0100)] 
tmpfiles: explicitly say we need /proc/ to run

I don't think it's realistic to operate without /proc/. Hence, let's
make this explicit.

If one day someone finds a way to do what we need without /proc/ we can
certainly drop this check again, but for now I think it's a lot
friendlier to users to make this explicitly early on instead continuing
to run and then not do what we need to do, oftentimes failing in cryptic
ways.

After all, invoking the tool without /proc/ is not an error that was
specific to some of the lines we process, but it's systematic error that
will show its ugly face in many codepaths down the line.

Fixes: #14745
3 years agonetwork: use SD_BUS_METHOD_WITH_ARGS() macro
Yu Watanabe [Wed, 10 Feb 2021 16:32:01 +0000 (01:32 +0900)] 
network: use SD_BUS_METHOD_WITH_ARGS() macro

3 years agocore: improve log message when unit deactivates cleanly
Lennart Poettering [Wed, 10 Feb 2021 15:15:20 +0000 (16:15 +0100)] 
core: improve log message when unit deactivates cleanly

Whenever a unit deactivates sucessfully we so far generated a message
"unit xyz: succeeded". This is a bit confusing, since various unit types
cannot really "succeed", e.g. a device unit can't really "suceed", not
can a swap unit. In particular in the latter case people would probably
assume that a swap unit that "suceeded" would actually mean a swap was
active now, but the opposite is actually true.

Let's improve this by saying "Deactivated successfully", which hopefully
clears this up.

(I thought about saying "terminated" or "completed" or "finished" or so
instead, but that too doesn#t make sense if you think about unit types
like swaps or devices.)

3 years agoMerge pull request #18440 from bluca/portable_upgrade
Lennart Poettering [Wed, 10 Feb 2021 20:26:14 +0000 (21:26 +0100)] 
Merge pull request #18440 from bluca/portable_upgrade

portable: add 'reattach' verb and DBUS interface

3 years agotmpfiles: v/q/Q: Add env var to skip check for rootfs in subvolume
Adrian Vovk [Tue, 9 Feb 2021 21:20:32 +0000 (16:20 -0500)] 
tmpfiles: v/q/Q: Add env var to skip check for rootfs in subvolume

3 years agovirt: detect cgroups namespaces 17902/head
Sergey Bugaev [Sun, 20 Dec 2020 11:43:01 +0000 (14:43 +0300)] 
virt: detect cgroups namespaces

detect_container() is now able to detect if we're running in a cgroup namespace.

3 years agovirt: detect Docker and Podman containers
Sergey Bugaev [Sat, 19 Dec 2020 18:00:22 +0000 (21:00 +0300)] 
virt: detect Docker and Podman containers

Docker doesn't set $container, so it cannot be detected that way. Instead, we
check for presence of /.dockerinit, which it creates. Podman does set
$container, but some Red Hat images (in particular, Fedora images) override
$container to equal "oci". So to correctly detect Podman containers, we check
for presence of /run/.containerenv, which is created by Podman and is now the
official way to get information about the container from within the container.

Fixes https://github.com/systemd/systemd/issues/15393

3 years agoportable: add 'reattach' verb and DBUS interface 18440/head
Luca Boccassi [Mon, 1 Feb 2021 14:29:40 +0000 (14:29 +0000)] 
portable: add 'reattach' verb and DBUS interface

Add 'reattach' verb to portablectl, and corresponding DBUS interface
to systemd-portabled.
Takes the same parameters as 'attach', but it will do a 'detach' (and
it will refuse to proceed if it cannot be done) first, matching on
the unversioned prefix of the new image. Eg:

portablectl reattach /tmp/foo_2.raw

will cause foo_1.raw to be detached, and foo_2.raw to be attached.

The key difference with a manual 'detach old' plus 'attach new' is that
the running units are not disturbed until after the attach completed,
and if --now is passed they are then restarted.
A 'detach' is not allowed normally if the units are running.

By using a restart-after-deploy method, 'reattach' allows for minimal
interruption of service and also for features that only work on restart
(eg: file descriptor store) to work as intended.

The DBUS interface returns two lists: first the removals from the detach
that were not immediately re-added in the attach, so that the caller
can stop the relevant units, and then the list of additions that are
either new or updates, so that the caller can restart/enable the
relevant units. portablectl already implements this with the existing
--now/--enable switches.

3 years agoportable: allow Detach to match images with different version suffixes
Luca Boccassi [Fri, 5 Feb 2021 21:24:54 +0000 (21:24 +0000)] 
portable: allow Detach to match images with different version suffixes

3 years agotest: setup var/tmp in the test image as well
Luca Boccassi [Tue, 2 Feb 2021 21:13:44 +0000 (21:13 +0000)] 
test: setup var/tmp in the test image as well

3 years agotest: add empty /etc/resolv.conf in test image
Luca Boccassi [Tue, 2 Feb 2021 17:16:41 +0000 (17:16 +0000)] 
test: add empty /etc/resolv.conf in test image

Portable services have a BindPath pointing to it, so it needs to
be available in the image

3 years agotest-50-dissect: move minimal image setup to common setup function
Luca Boccassi [Fri, 28 Aug 2020 13:17:31 +0000 (14:17 +0100)] 
test-50-dissect: move minimal image setup to common setup function

So that it can be re-used for other tests by simply setting
TEST_INSTALL_VERITY_MINIMAL=1 in test.sh, without having to
replicate the setup commands.

3 years agoMerge pull request #18542 from yuwata/bash-completion-update
Zbigniew Jędrzejewski-Szmek [Wed, 10 Feb 2021 18:31:11 +0000 (19:31 +0100)] 
Merge pull request #18542 from yuwata/bash-completion-update

bash-completion: add missing options

3 years agoMerge pull request #18536 from poettering/uid-refs-simplify
Yu Watanabe [Wed, 10 Feb 2021 18:18:15 +0000 (03:18 +0900)] 
Merge pull request #18536 from poettering/uid-refs-simplify

dynamic uid/gid reference handling simplifications

3 years agoMerge pull request #11484 from keszybz/udevadm-error-logs
Yu Watanabe [Wed, 10 Feb 2021 18:17:47 +0000 (03:17 +0900)] 
Merge pull request #11484 from keszybz/udevadm-error-logs

Use real return codes in _from_string() functions

3 years agobash-completion: loginctl: add -P option 18542/head
Yu Watanabe [Wed, 10 Feb 2021 17:50:41 +0000 (02:50 +0900)] 
bash-completion: loginctl: add -P option

3 years agobash-completion: coredumpctl: add --json and -n options
Yu Watanabe [Wed, 10 Feb 2021 17:50:22 +0000 (02:50 +0900)] 
bash-completion: coredumpctl: add --json and -n options

3 years agotest: count call instructions as well
Frantisek Sumsal [Wed, 10 Feb 2021 09:16:09 +0000 (10:16 +0100)] 
test: count call instructions as well

Binaries on the latest Arch Linux use `call` instructions instead of
`callq`, which breaks the ASan detection and eventually the image
building process (due to insufficient space).

3 years agoTranslations update from Weblate (#18537)
Weblate (bot) [Wed, 10 Feb 2021 15:55:41 +0000 (16:55 +0100)] 
Translations update from Weblate (#18537)

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
3 years agoci: build on Fedora ELN as well
Frantisek Sumsal [Wed, 10 Feb 2021 14:06:40 +0000 (15:06 +0100)] 
ci: build on Fedora ELN as well

ELN builds with a slightly different content set and RHEL-like options,
which should, theoretically, help a bit with RHEL stuff.

3 years agoMerge pull request #18506 from keszybz/fuzz-systemctl-parse-argv
Yu Watanabe [Wed, 10 Feb 2021 15:29:22 +0000 (00:29 +0900)] 
Merge pull request #18506 from keszybz/fuzz-systemctl-parse-argv

Fuzzer for systemctl argline parsing

3 years agoMerge pull request #18521 from poettering/coredumpctl-table
Lennart Poettering [Wed, 10 Feb 2021 14:58:56 +0000 (15:58 +0100)] 
Merge pull request #18521 from poettering/coredumpctl-table

coredumpctl improvements (mostly about table formatting)

3 years agocore: fix manager_ref_gid() parameter name in header 18536/head
Lennart Poettering [Wed, 10 Feb 2021 14:47:56 +0000 (15:47 +0100)] 
core: fix manager_ref_gid() parameter name in header

It should match what we do for manager_ref_uid() and in the .c file.

3 years agomanager: simplify uid-ref/gid-ref a code a bit
Lennart Poettering [Wed, 10 Feb 2021 14:46:47 +0000 (15:46 +0100)] 
manager: simplify uid-ref/gid-ref a code a bit

Let's drop unused function arguments, and needless double pointers where
we can.

no actual change in behaviour, just simplifications

(I tried to track down #14026 without success, and this came out of it)

3 years agotest-string-util: add missing comma 11484/head
Zbigniew Jędrzejewski-Szmek [Wed, 10 Feb 2021 07:00:33 +0000 (08:00 +0100)] 
test-string-util: add missing comma

Coverity CID#1446368.

3 years agoresolved: rework a few functions to return early on error
Zbigniew Jędrzejewski-Szmek [Wed, 8 May 2019 08:55:39 +0000 (10:55 +0200)] 
resolved: rework a few functions to return early on error

The implementation is a bit ugly because we set the output variable
twice. But we were already doing this on error, so this is not
significantly worse. Doing this allows us to avoid goto's, and the
compiler should be able to figure this out and only set once.

3 years agomachinectl: write arg_* only after verifying the value
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 15:07:19 +0000 (16:07 +0100)] 
machinectl: write arg_* only after verifying the value

3 years agotree-wide: propagate error code from _from_string() functions
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 15:06:36 +0000 (16:06 +0100)] 
tree-wide: propagate error code from _from_string() functions

Now that we know we have something useful, no need to make an answer up.

3 years agoReturn -EINVAL from _from_string() functions
Zbigniew Jędrzejewski-Szmek [Fri, 18 Jan 2019 15:26:31 +0000 (16:26 +0100)] 
Return -EINVAL from _from_string() functions

We'd return -1 (-EPERM), even though we have a general rule to use real errno
values. The particular case that caught my attention was:

$ sudo udevadm control -l asdf
Failed to parse log priority 'asdf': Operation not permitted

... but "git grep 'r =.*_from_string' src/" return 110 hits. Confusingly, some
of the _from_string functions already return a proper errno value, so not all
of those are broken, but probably quite a few.

3 years agotree-wide: use -EINVAL for enum invalid values
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 16:17:47 +0000 (17:17 +0100)] 
tree-wide: use -EINVAL for enum invalid values

As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617.

This does not touch anything exposed in src/systemd. Changing the defines there
would be a compatibility break.

Note that tests are broken after this commit. They will be fixed in the next one.

3 years agoudev: make sure UdevBuiltinCommand is properly converted
Zbigniew Jędrzejewski-Szmek [Wed, 10 Feb 2021 07:32:23 +0000 (08:32 +0100)] 
udev: make sure UdevBuiltinCommand is properly converted

3 years agosd-bus: drop some bitfields in sd_bus_slot
Zbigniew Jędrzejewski-Szmek [Wed, 10 Feb 2021 13:03:10 +0000 (14:03 +0100)] 
sd-bus: drop some bitfields in sd_bus_slot

A hole was/is present after the booleans, so changing them to be one byte each
doesn't change the structure size (122 bits on amd64). If we add more stuff
later, it might make sense to turn some of those into bitfields again. For now,
let's take the easy route. EINVAL fits into type now.

Code size it minimally reduced:
-rwxrwxr-x 1 zbyszek zbyszek 4109792 Feb 10 14:00 build/libsystemd.so.0.30.0
-rwxrwxr-x 1 zbyszek zbyszek 4109712 Feb 10 14:01 build/libsystemd.so.0.30.0

3 years agogithub: expressly ask for logs in github issue template
Lennart Poettering [Wed, 10 Feb 2021 13:11:44 +0000 (14:11 +0100)] 
github: expressly ask for logs in github issue template

Apparently it's not obvious that logs are a good thing to provide, hence
let's explicitly ask for them.

3 years agosd-netlink: pahole optimization of sd_netlink_slot
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 18:51:50 +0000 (19:51 +0100)] 
sd-netlink: pahole optimization of sd_netlink_slot

By rearranging the fields, we can avoid one of the holes (on amd64).
By adding more space for .type, -EINVAL can be used as a value later on.
The structure is reduced from 96 to 88 bytes (on amd64).

Text size is also smaller:
-rwxrwxr-x 1 zbyszek zbyszek 4109832 Feb  9 19:50 build/libsystemd.so.0.30.0
-rwxrwxr-x 1 zbyszek zbyszek 4109792 Feb  9 19:51 build/libsystemd.so.0.30.0

3 years agoshared/json: make JsonVariant.type field wider
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 16:08:06 +0000 (17:08 +0100)] 
shared/json: make JsonVariant.type field wider

pahole shows that this doesn't make a difference, but we can fit -EINVAL
into .type without warnings.

3 years agosd-event: drop one bitfield from sd_event_source
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 16:02:18 +0000 (17:02 +0100)] 
sd-event: drop one bitfield from sd_event_source

pahole analysis confirms that the structure size does not change (there
was/is a hole after the sequence of bitfields anyway).

3 years agocore: drop bitfields in Manager object
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 15:43:03 +0000 (16:43 +0100)] 
core: drop bitfields in Manager object

Every bitfield may make the object a little smaller, but requires additional
code when accessing the field. So it only makes sense in objects that are
created in many many copies. The Manager is pretty much a singleton.

-rwxrwxr-x 1 zbyszek zbyszek 4443840 Feb  9 16:14 build/systemd
-rwxrwxr-x 1 zbyszek zbyszek 4442552 Feb  9 16:42 build/systemd

We save 1288 bytes of code by "wasting" a few bytes on storage. (The speed
advantages are probably more important, but harder to measure…)

3 years agoAdd comma in structured initialization in a few places
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 15:32:55 +0000 (16:32 +0100)] 
Add comma in structured initialization in a few places

It just looks nicer…

3 years agocore: do not initialize variable which is unconditionally set below
Zbigniew Jędrzejewski-Szmek [Wed, 8 May 2019 09:09:10 +0000 (11:09 +0200)] 
core: do not initialize variable which is unconditionally set below

3 years agotest-tables: make the assert more readable
Zbigniew Jędrzejewski-Szmek [Fri, 18 Jan 2019 16:31:32 +0000 (17:31 +0100)] 
test-tables: make the assert more readable

Doing it all in one line and with negation in front seemed like a good
idea at some point, but I think it is vastly easier to understand when
it is split out a bit.

3 years agotest-tables: fix warning about NULL used in printf
Zbigniew Jędrzejewski-Szmek [Wed, 10 Feb 2021 06:49:17 +0000 (07:49 +0100)] 
test-tables: fix warning about NULL used in printf

With the simplified asserts, newer gcc is able to (correctly) figure
out that NULL was being passed.

3 years agoclock-util: modernize settimeofday() timezone calls
Lennart Poettering [Wed, 10 Feb 2021 11:09:38 +0000 (12:09 +0100)] 
clock-util: modernize settimeofday() timezone calls

Let's use structured initialization, and avoid the weird `tv_null`
indirection.

No changes in behaviour, just some clean-ups.

3 years agoFix coverity warning in test-string-util.c
Luca Boccassi [Wed, 10 Feb 2021 11:10:27 +0000 (11:10 +0000)] 
Fix coverity warning in test-string-util.c

CID 1446368:  Incorrect expression  (MISSING_COMMA)

3 years agocoredumpctl: include coredump size in output 18521/head
Lennart Poettering [Tue, 9 Feb 2021 16:41:10 +0000 (17:41 +0100)] 
coredumpctl: include coredump size in output

This improves the output of the "list" and "info" verbs and adds
coredump size information to the output.

For doing that a common helper function is added that analyzes the
coredump file on disk.

3 years agoman: document new coredumpctl features
Lennart Poettering [Tue, 9 Feb 2021 15:43:55 +0000 (16:43 +0100)] 
man: document new coredumpctl features

3 years agocoredumpctl: modernize table output
Lennart Poettering [Tue, 9 Feb 2021 15:40:44 +0000 (16:40 +0100)] 
coredumpctl: modernize table output

Let's use our table formatter for generating the coredump table. Bring
support up to our current standards, with a bit of color, JSON output
and so on.

Also adds supports for setting a max for the number of lines to
generate. (with the new -n switch)

The existing -1 switch now becomes a synonym for "-n 1 --reverse"

Fixes: #3271
3 years agoformat-table: when generating json, synthesize "null" for invalid ifindex
Lennart Poettering [Tue, 9 Feb 2021 15:39:49 +0000 (16:39 +0100)] 
format-table: when generating json, synthesize "null" for invalid ifindex

This matches what we do for other cell types that have an invalid value.

3 years agoformat-table: make UID/GID/PID fields first class citizens + add signal cell type
Lennart Poettering [Tue, 9 Feb 2021 15:36:07 +0000 (16:36 +0100)] 
format-table: make UID/GID/PID fields first class citizens + add signal cell type

This way we can display invalid UIDs/GIDs/PIDs as n/a while still
storing them as is.

Also, let's add a new cell type for unix signal, that is stored as
integer, but displayed as signal name string.

3 years agoanalyze: slightly reword PrivatTmp= message
Lennart Poettering [Wed, 10 Feb 2021 09:50:23 +0000 (10:50 +0100)] 
analyze: slightly reword PrivatTmp= message

Apparently there way confusion about "does not apply". Let's say "is not
appropriate".

Fixes: #13095
3 years agoresolved: drop timestamp parameter to dns_cache_put() we don't ever pass 17823/head
Lennart Poettering [Fri, 5 Feb 2021 19:19:11 +0000 (20:19 +0100)] 
resolved: drop timestamp parameter to dns_cache_put() we don't ever pass

3 years agoresolved: avoid NOTIMP error when looking up not supported requests
Lennart Poettering [Fri, 30 Oct 2020 16:47:43 +0000 (17:47 +0100)] 
resolved: avoid NOTIMP error when looking up not supported requests

Some folks argue that NOTIMP should only be returned if a specific QTYPE
is not supported. While I don#t think the RFCs are too clear about that,
let's use REFUSED instead, which appears to be a less controversial
choice of error code.

Prompted-by: #17218
3 years agoresolved: add support for answering DNSSEC questions on the stub
Lennart Poettering [Thu, 5 Nov 2020 10:01:52 +0000 (11:01 +0100)] 
resolved: add support for answering DNSSEC questions on the stub

This substantially beefs up the local DNS stub feature set in order to
allow local clients to do DNSSEC validation through the stub.

Previously we'd return NOTIMP if we'd get a DO or DO+CD lookup. With
this change we'll instead:

1. If we get DO+CD requests (i.e. DNSSEC with no local checking) we'll
   proxy DNS queries and response mostly unmodified to/from upstream DNS
   servers if possible (this is called "bypass" mode).  We will patch in
   new request IDs, (and patch them back out on reply), so that we can
   sanely keep track of things.  We'll also maintain a minimal local
   cache for such lookups, always keeping the whole DNS packets in it
   (if we reply from cache we'll patch the TTLs of all included RRs).

2. If we get DO requests without CD (i.e. DNSSEC with local checking)
   we'll resolve and validate locally. In this mode we will not proxy
   packets, but generate our own. We will however cache the combination
   of answer RRs (along with their packet section assignments) we got
   back in the cache, and use this information to generate reply packets
   from the DNS stub.

In both cases: if we determine a lookup is to be answered from LLMNR or
mDNS we'll always revert to non-DNSSEC, non-proxy operation as before.
Answers will lack the DO bit then, since the data cannot be validated
via DNSSEC by the clients.

To make this logic more debuggable, this also adds query flags for
turning off RR sources. i.e. cache/network/zone/trust anchor/local
synthesis may now be disabled individually for each lookup.

The cache is substantially updated to make all this work: in addition to
caching simple RRs for lookup RR keys, we'll now cache the whole packets
and the whole combination of RRs, so that we can answer DO and DO+CD
replies sensibly according to the rules described above. This sounds
wasteful, but given that the
DnsResourceRecord/DnsResourceKey/DnsAnswer/DnsPacket
objects are all ref-counted and we try to merge references the actual
additional memory used should be limited (but this might be something to
optimize further later on).

To implement classic RR key lookups and new-style packet proxy lookups
(i.e. the ones necessary for DO+CD packet proxying, as described above)
DnsTransaction and DnsQuery objects now always maintain either a
DnsResourceKey/DnsQuestion as lookup key or a DnsPacket for "bypass"
mode.

Fixes: #4621 #17218
3 years agoresolved: DNS_CLASS_ANY lookups are OK too
Lennart Poettering [Thu, 5 Nov 2020 10:01:36 +0000 (11:01 +0100)] 
resolved: DNS_CLASS_ANY lookups are OK too

3 years agoresolved: if dns_packet_append_answer() fails count how many RRs were successfully...
Lennart Poettering [Thu, 5 Nov 2020 08:53:02 +0000 (09:53 +0100)] 
resolved: if dns_packet_append_answer() fails count how many RRs were successfully added

This is useful later when handling the truncation case: if we can't add
all RRs we'd like to add we need to set the TC bit, but still report the
number of RRs we added (and not the number of RRs we would have liked to
add) to the packet.

3 years agoresolved: add RRSIG field to DnsAnswerItem
Lennart Poettering [Wed, 4 Nov 2020 21:59:44 +0000 (22:59 +0100)] 
resolved: add RRSIG field to DnsAnswerItem

3 years agoresolved: add new DnsAnswerFlags indicating originating section when parsing
Lennart Poettering [Wed, 4 Nov 2020 20:17:26 +0000 (21:17 +0100)] 
resolved: add new DnsAnswerFlags indicating originating section when parsing

Let's beef up our parser a bit: let's store in the DnsAnswerFlags field
(that is stored as part of DnsAnswerItem) which DNS packet section (i.e.
answer, authoritative, additional) an RR originates from.

This is useful when propagating answers from an upstream DNS server
eventually, as we can place the data in the right sections downstream
too.

3 years agoresolved: replace DNS_ANSWER_FOREACH_FULL() iterator macro with DNS_ANSWER_FOREACH_ITEM()
Lennart Poettering [Wed, 4 Nov 2020 19:51:15 +0000 (20:51 +0100)] 
resolved: replace DNS_ANSWER_FOREACH_FULL() iterator macro with DNS_ANSWER_FOREACH_ITEM()

The more fields DnsAnswerItem gains the less sense it makes to pass
every field of it as separate parameter to an iterator macro. Let's
simplify things here, in preparation of adding more fields to the
structure later on: let's just return the structure itself in the loop,
rather than the individual fields.

3 years agoresolved: slight modernizations of resolved-dns-answer.c functions
Lennart Poettering [Fri, 30 Oct 2020 16:53:34 +0000 (17:53 +0100)] 
resolved: slight modernizations of resolved-dns-answer.c functions

Let's follow our own coding style an initialized return values on all
cases of "success".

3 years agoresolved: add dns_answer_contains() helper
Lennart Poettering [Wed, 28 Oct 2020 19:50:44 +0000 (20:50 +0100)] 
resolved: add dns_answer_contains() helper

3 years agoresolved: add logic for patching TTLs of full packets
Lennart Poettering [Wed, 28 Oct 2020 13:55:40 +0000 (14:55 +0100)] 
resolved: add logic for patching TTLs of full packets

3 years agoresolved: add logic for patching OPT max udp size of existing packet
Lennart Poettering [Wed, 28 Oct 2020 14:03:55 +0000 (15:03 +0100)] 
resolved: add logic for patching OPT max udp size of existing packet

3 years agoresolved: introduce dns_transaction_key() helper for getting RR key for transaction
Lennart Poettering [Tue, 27 Oct 2020 17:33:29 +0000 (18:33 +0100)] 
resolved: introduce dns_transaction_key() helper for getting RR key for transaction

This is a simple search&replace excercise: instead of accessing the
"key" field of the transaction directly, let's use a small inline helper
that does this for us.

This appears pointless for now, but this will become useful later when
we introduce "bypass" transactions, that reuse the original client DNS
packet for queries instead of synthesizing a packet of our own. In that
case transactions either have regular "key" field initialized as before,
or the "bypass" packet field instead. The new dns_transaction_key()
helper allows us to hide the differences for most cases as we can later
teach it to access the "bypass" packet's question key transparently.

No change in behaviour.

3 years agoresolved: add helper dns_packet_dup() for duplicating packets
Lennart Poettering [Tue, 27 Oct 2020 15:40:39 +0000 (16:40 +0100)] 
resolved: add helper dns_packet_dup() for duplicating packets

3 years agoMerge pull request #18518 from poettering/inhibit-limit-columns
Lennart Poettering [Tue, 9 Feb 2021 16:14:25 +0000 (17:14 +0100)] 
Merge pull request #18518 from poettering/inhibit-limit-columns

put a width limit on the "systemd-inhibit --list" table

3 years agoinhibit: cut off overly long "who" fields 18518/head
Lennart Poettering [Tue, 9 Feb 2021 14:03:46 +0000 (15:03 +0100)] 
inhibit: cut off overly long "who" fields

systemd-inhibit when invoked with a command line will put the whole
command line in the "who" field of the inhibitor lock. This can get
extremely long for shell expressions, making the table "systemd-inhibit
--list" shows ridiculously weirdly formatted. Let's put a limit on the
column width: half of the screen, not more.

3 years agoformat-table: don't hit assert if column got less width than it asked for
Lennart Poettering [Tue, 9 Feb 2021 14:02:21 +0000 (15:02 +0100)] 
format-table: don't hit assert if column got less width than it asked for

If one field in a specific column has a maximum size limit, other fields
in the same column might affected by it and get less than they asked
for. Let's make sure we can handle this, and don't assert on this
because surprisingly we got less than what we asked for.

3 years agosystemctl: remove comment about --failed being deprecated 18506/head
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 13:14:16 +0000 (14:14 +0100)] 
systemctl: remove comment about --failed being deprecated

Follow-up for bef19548a2430909019d7cff095b8600c796c3ef.

3 years agofuzz-systemctl-parse-argv: a new fuzzer
Zbigniew Jędrzejewski-Szmek [Sun, 7 Feb 2021 17:30:42 +0000 (18:30 +0100)] 
fuzz-systemctl-parse-argv: a new fuzzer

Does what the name suggests. Obviously inspired by sudoers, but note that
our tools are not supposed to be installed suid, so there is no privilege
boundary to cross here.

3 years agoMerge pull request #18470 from mrc0mmand/ci-clang-12
Luca Boccassi [Tue, 9 Feb 2021 13:06:40 +0000 (13:06 +0000)] 
Merge pull request #18470 from mrc0mmand/ci-clang-12

ci: run build test with clang-12 as well

3 years agoMerge pull request #18416 from yuwata/strverscmp
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 13:06:18 +0000 (14:06 +0100)] 
Merge pull request #18416 from yuwata/strverscmp

util: introduce strverscmp_improved()

3 years agofuzz-journal-remote: do not assert on resource conditions
Zbigniew Jędrzejewski-Szmek [Mon, 8 Feb 2021 09:20:03 +0000 (10:20 +0100)] 
fuzz-journal-remote: do not assert on resource conditions

We have a number of issues where oss-fuzz reports input-independent crashes of
fuzz-journal-remote. Instead of asserting that stuff that allocated fds and
memory never fails, let's instead just return an error.

https://oss-fuzz.com/testcase-detail/4791099424112640
https://oss-fuzz.com/testcase-detail/4531912477638656

I don't see any docs as to whether LLVMFuzzerTestOneInput() is allowed to
return non-zero. Propagating the error code is easiest, so let's just do that.
If it turns out that this causes oss-fuzz to still report a failure, we can
suppress that later.

3 years agolog: do not use uninitialized value
Yu Watanabe [Tue, 9 Feb 2021 10:07:35 +0000 (19:07 +0900)] 
log: do not use uninitialized value

Follow-up for 85cf96e3f567cd51f79d671bbf3559550fdd67b7.

3 years agoci: temporarily pin Arch repositories to glibc 2.32-5
Frantisek Sumsal [Tue, 9 Feb 2021 11:49:31 +0000 (12:49 +0100)] 
ci: temporarily pin Arch repositories to glibc 2.32-5

glibc 2.33-3 shipped on 2021-02-06 breaks running Arch containers on
systems with older kernels (like Ubuntu Focal). Until the issue is
resolved, let's pin the Arch repositories to glibc 2.32-5 to mitigate
the annoying CI fails.

See: https://bugs.archlinux.org/task/69563

3 years agoMerge pull request #18346 from yuwata/hostnamectl-try-to-set-transient-hostname
Zbigniew Jędrzejewski-Szmek [Tue, 9 Feb 2021 11:42:25 +0000 (12:42 +0100)] 
Merge pull request #18346 from yuwata/hostnamectl-try-to-set-transient-hostname

hostnamectl: try to set transient hostname even if setting static or pretty hostname failed

3 years agotest-network: support protocol and linkdown flag for ff00::/8 route
Yu Watanabe [Tue, 9 Feb 2021 05:12:25 +0000 (14:12 +0900)] 
test-network: support protocol and linkdown flag for ff00::/8 route

Fixes #18507.

3 years agonetwork: Delay addition of IPv6 Proxy NDP addresses
Kevin P. Fleming [Sat, 6 Feb 2021 15:58:43 +0000 (10:58 -0500)] 
network: Delay addition of IPv6 Proxy NDP addresses

Setting of IPv6 Proxy NDP addresses must be done at the same
time as static addresses, static routes, and other link attributes
that must be configured when the link is up. Doing this ensures
that they are reconfigured on the link if the link goes down
and returns to service.

3 years agotree-wide: replace strverscmp() and str_verscmp() with strverscmp_improved() 18416/head
Yu Watanabe [Sat, 30 Jan 2021 16:12:27 +0000 (01:12 +0900)] 
tree-wide: replace strverscmp() and str_verscmp() with strverscmp_improved()

3 years agostring-util: introduce strverscmp_improved()
Yu Watanabe [Wed, 3 Feb 2021 20:55:59 +0000 (05:55 +0900)] 
string-util: introduce strverscmp_improved()

Unfortunately, strverscmp() from libc or str_verscmp() do not correctly
handle pre-release version, e.g. 247 vs 247~rc1.

This implement a new comparison function, which is based on the RPM's
rpmvercmp().

3 years agofundamental: move several macros and functions into src/fundamental/
Yu Watanabe [Wed, 3 Feb 2021 18:21:08 +0000 (03:21 +0900)] 
fundamental: move several macros and functions into src/fundamental/

sd-boot has a copy of a subset of codes from libbasic. This makes
sd-boot share the code with libbasic, and dedup the code.

Note, startswith_no_case() is dropped from sd-boot, as
- it is not used,
- the previous implementation is not correct,
- gnu-efi does not have StrniCmp() or so.

3 years agohostnamectl: use Table 18346/head
Yu Watanabe [Fri, 29 Jan 2021 07:48:03 +0000 (16:48 +0900)] 
hostnamectl: use Table