systemd/.git
4 years agoproc-cmdline: allow backslash escapes when parsing /proc/cmdline
Lennart Poettering [Tue, 6 Apr 2021 09:45:47 +0000 (11:45 +0200)]
proc-cmdline: allow backslash escapes when parsing /proc/cmdline

So far when parsing /proc/cmdline we'd consider backslashes as
mechanisms for escaping whitepace or quotes. This changes things so that
they are retained as they are instead. The kernel itself doesn't allow such
escaping, and hence we shouldn't do so either (see lib/cmdline.c in the
kernel sources; it does support "" quotes btw).

This fix is useful to allow specifying backslash escapes in the "root="
cmdline option to be passed through to systemd-fstab-generator. Example:

    root=/dev/disk/by-partlabel/Root\x20Partition

Previously we'd eat up the "\" so that we'd then look for a device
/dev/disk/by-partlabel/Rootx20Partition which never shows up.

(cherry picked from commit d997861ea7dae633174cd80ab55552c020526b62)

4 years agoman/systemd-cryptenroll: Fix sd-boot manvolnum from 8 to 7
Morten Linderud [Wed, 7 Apr 2021 10:10:10 +0000 (12:10 +0200)]
man/systemd-cryptenroll: Fix sd-boot manvolnum from 8 to 7

Off-by-one error in the documentation index. The volume number for
systemd-boot/sd-boot is 7.

Signed-off-by: Morten Linderud <morten@linderud.pw>
(cherry picked from commit 29d898cc7be4b2e91f13bba83fef46bbe995f08e)

4 years agoBump test-random-util timeout
Luca Boccassi [Tue, 6 Apr 2021 19:24:17 +0000 (20:24 +0100)]
Bump test-random-util timeout

It is using log_trace, which we enabled in the CI, so now it's
slower and it is timing out. Bump the timeout from 30s to 120s.

(cherry picked from commit 65d09d575cf74c34098ff4f3ab53fc7587805811)

4 years agotpm2-util: properly load tpm2 libraries befre unsealing
Lennart Poettering [Tue, 6 Apr 2021 09:46:19 +0000 (11:46 +0200)]
tpm2-util: properly load tpm2 libraries befre unsealing

We forgot a call to dlopen_tpm2() in the unseal codepaths. As long as
automatic TPM2 device discovery was used that didn't matter, since in
that codepaths we'd have another call dlopen_tpm2(). But with an
explicitly configured TPM2 device things should work too, hence add the
missing call.

Fixes: #19206
(cherry picked from commit 1b30720c1b22df75e147cc201f240db23881672d)

4 years agoresolve: copy rd flag from the query to response
KoyamaSohei [Sat, 3 Apr 2021 16:13:37 +0000 (01:13 +0900)]
resolve: copy rd flag from the query to response

(cherry picked from commit da846b30312863cc30b32c1d43988a44673c5b8f)

4 years agobash-completion: localize words and cword variables
Sibo Dong [Sat, 3 Apr 2021 03:33:59 +0000 (23:33 -0400)]
bash-completion: localize words and cword variables

The words and cword variables are not localized in all Bash completion
scripts that call _init_completion.

cur, prev, words, and cword (and split if using the -s flag) are all
variables that should be localized in Bash completion scripts before
calling _init_completion (even if they don't otherwise appear in the
calling script). This is done for cur and prev, but not for words and
cword. Letting words and cword remain unlocalized may clobber variables
the user is using for other purposes, which is bad.

This issue can be resolved by declaring words and cword as local
variables.

Resolves #19188.

(cherry picked from commit f34173a048061b3f7e551e9a7c04f00e5a106fac)

4 years agoqrcode-util: set case-sensitive for generating QR codes
Gibeom Gwon [Mon, 5 Apr 2021 14:11:23 +0000 (23:11 +0900)]
qrcode-util: set case-sensitive for generating QR codes

Until now, string treated case-insensitive, always converted to
uppercase. This can cause confusion such as user enter uppercased
recovery key.

(cherry picked from commit fd11201b93c1f3c32831873b746236202f500e91)

4 years agotest-firewall-util: skip if iptables nat table does not exist
Anita Zhang [Fri, 2 Apr 2021 09:49:37 +0000 (02:49 -0700)]
test-firewall-util: skip if iptables nat table does not exist

(cherry picked from commit afbcd905526111e3a1bd55b0d6d5ee4413734735)

4 years agofuzzer: add a test case for #19178
Frantisek Sumsal [Fri, 2 Apr 2021 16:07:26 +0000 (18:07 +0200)]
fuzzer: add a test case for #19178

(cherry picked from commit 080a602771ef51230a51f247b8b728d0483e2f28)

4 years agotest-oomd-util: fix running in mkosi
Anita Zhang [Fri, 2 Apr 2021 02:06:26 +0000 (19:06 -0700)]
test-oomd-util: fix running in mkosi

When this test is run in mkosi, the previously tested cgroup that we write
xattrs into and the root cgroup are the same.

Since the root cgroup is a live cgroup anyways (vs. the test cgroups which are
remade each time) let's generate the expected preference values from reading
the xattrs instead of assuming it will be NONE.

(cherry picked from commit 080ca0d830d69dea5fb2b07aace54a4402bf7294)

4 years agomeson: link with libm for math functions
Anita Zhang [Fri, 2 Apr 2021 01:44:26 +0000 (18:44 -0700)]
meson: link with libm for math functions

Fixes this error I got building on F33:
  /usr/bin/ld: test-random-util.p/src_test_test-random-util.c.o: undefined
  reference to symbol 'sqrt@@GLIBC_2.2.5'
  /usr/bin/ld: /usr/lib64/libm.so.6: error adding symbols: DSO missing
  from command line

(cherry picked from commit ea460d79644560bcb1ed2adb4cf30413f285492a)

4 years agodocs: use current spelling "macOS" not "OS X" etc.
Carlo Teubner [Fri, 2 Apr 2021 08:03:02 +0000 (09:03 +0100)]
docs: use current spelling "macOS" not "OS X" etc.

(cherry picked from commit 6d3831cee58dcbdb7ea8a86ca621fec38f5b279b)

4 years agosystemd-notify: Fix return value of --booted
Joerg Behrmann [Tue, 30 Mar 2021 14:29:59 +0000 (16:29 +0200)]
systemd-notify: Fix return value of --booted

(cherry picked from commit 8ab34a49dbf75fd731973359a6f24c212682f479)

4 years agoresolved: avoid passing unitialized variable
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 09:12:57 +0000 (11:12 +0200)]
resolved: avoid passing unitialized variable

The issue was introduced in the refactoring in 775ae35403f8f3c01b7ac13387fe8aac1759993f.
We would pass an initialized value to a helper function. We would only *use*
it if it was initialized. But the mere passing of an unitialized variable is
UB, so let's not do that. This silences a gcc warning.

(cherry picked from commit e7d48709ed6c8569286463552f3df36bbdce8824)

4 years agotest-device-util: let's verify that we return proper error from log_device_*
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:11:30 +0000 (10:11 +0200)]
test-device-util: let's verify that we return proper error from log_device_*

(cherry picked from commit 0246f42980ed87dfca79fd4a8ec67a81d824e427)

4 years agonss-resolve: fix parsing of io.systemd.Resolve.ResolveAddress reply
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.)

(cherry picked from commit 77fac974fe396dbe4fb679b748bfa89db1136e0c)

4 years agoshared/conf-parser: fix unitialized variable
Zbigniew Jędrzejewski-Szmek [Wed, 31 Mar 2021 15:24:26 +0000 (17:24 +0200)]
shared/conf-parser: fix unitialized variable

Introduced in 4f9ff96a55187927a4164a19df580329f4c6522b.

(cherry picked from commit 9fd8d678ba41ad39348758d5d329fe8d4451813f)

4 years agorpm: when disabling a unit, do not complain if systemd is not running
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.

(cherry picked from commit a59eb7d78f2f7aea0524b4f16cbb0fe3ef1b9aac)

4 years agoresolved: reset initial_jitter_elapsed properly
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)

(cherry picked from commit 213cb4f7e443241ef942cfbd0263cde33b4672c1)

4 years agoresolved: don't mention confusing server switch on server-less protocols
Lennart Poettering [Wed, 24 Mar 2021 16:15:55 +0000 (17:15 +0100)]
resolved: don't mention confusing server switch on server-less protocols

(cherry picked from commit ca55fb8840858b86d1b026f9c020e92e8350af78)

4 years agoresolve: drop meaningless bitfield specifier
Yu Watanabe [Sat, 20 Mar 2021 17:33:36 +0000 (02:33 +0900)]
resolve: drop meaningless bitfield specifier

This also rearrange the members to remove holes in the struct.

(cherry picked from commit 8e95506a2216729093639f5646bd1003cd16a422)

4 years agoshutdown: log on container exit
Anita Zhang [Fri, 5 Mar 2021 04:00:05 +0000 (20:00 -0800)]
shutdown: log on container exit

(cherry picked from commit 016f36ae72611210d6517b37429bfbdc26c5e31c)

4 years agoshutdown: set always_reopen_console
Anita Zhang [Fri, 5 Mar 2021 03:56:16 +0000 (19:56 -0800)]
shutdown: set always_reopen_console

Back in v232 systemd-shutdown would log to /dev/console. However after
the addition of always_reopen_console (v233) it would log to STDERR.
This caused some debugging issues as container systemd-shutdown logs
weren't being logged to console as the arg `--log-target=console` suggested.

Since it appears that always_reopen_console was intended for pid1, set
it in systemd-shutdown as well so logs will go to /dev/console.

(cherry picked from commit f975f1cc748929942188ae1490cf8480f8a64877)

4 years agokernel-insteall: do not remove the first slash in $ENTRY_DIR
Yu Watanabe [Wed, 28 Apr 2021 18:07:47 +0000 (03:07 +0900)]
kernel-insteall: do not remove the first slash in $ENTRY_DIR

Follow-up for cd0d230e7bf87f979722de7e364619dfa71bd6a2.

Fixes #19456.

(cherry picked from commit 2ff739a6ac4adb44f7ea0f534087ee7276302eee)

4 years agohostnamectl: fix hyperlink in "Operating System" field
Yu Watanabe [Tue, 4 May 2021 09:00:12 +0000 (18:00 +0900)]
hostnamectl: fix hyperlink in "Operating System" field

This fixes a bug introduced by 822be62fb23ed0ec1062ffd18057e53f6c2f8c01.

Before this, if terminal width is not enough, the all subsequent lines
are included in the hyperlink.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1955475.

(cherry picked from commit 8fc1efa88fb935ab4357fa39ed71ccb70df55d7e)

4 years agoLoadCredentials: do not assert on invalid syntax
Luca Boccassi [Thu, 1 Apr 2021 21:18:29 +0000 (22:18 +0100)]
LoadCredentials: do not assert on invalid syntax

LoadCredentials=foo causes an assertion to be triggered, as we
are not checking that the rvalue's right hand side part is non-empty
before using it in unit_full_printf.

Fixes #19178

# printf [Service]nLoadCredential=passwd.hashed-password.rootn > hello.service
# systemd-analyze verify ./hello.service
...
Assertion 'format' failed at src/core/unit-printf.c:232, function unit_full_printf(). Aborting.
Aborted (core dumped)

4 years agoMerge pull request #19157 from keszybz/read-medium-sized-virtual-file v248 v248-2
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

4 years agoNEWS: prep release date
Lennart Poettering [Tue, 30 Mar 2021 20:00:11 +0000 (22:00 +0200)]
NEWS: prep release date

4 years agotest-fileio: test for read_full_virtual_file()
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.

4 years agobasic/fileio: fix reading of not-too-small virtual files
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.

4 years agoMerge pull request #19149 from anitazha/oomdlogging
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

4 years agoMerge pull request #19155 from keszybz/hwdb-contrib-v248
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

4 years agooomd: fix iteration over candidates to kill
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 12:45:22 +0000 (14:45 +0200)]
oomd: fix iteration over candidates to kill

4 years agooomd: make it more clear when a kill happens
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]

4 years agoMerge pull request #19131 from keszybz/resolvectl-warn-less
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=

4 years agoselinux: do not crash if policy becomes unavailable after reload
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)

4 years agohwdb: update fingerprint autosuspend rules
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 11:17:42 +0000 (13:17 +0200)]
hwdb: update fingerprint autosuspend rules

4 years agohwdb: update for v248
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.

4 years agoNEWS: update contributor list for v248 final
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:49:41 +0000 (12:49 +0200)]
NEWS: update contributor list for v248 final

4 years agogit-contrib: use non-breaking spaces in names
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.

4 years agomailmap: two more names
Zbigniew Jędrzejewski-Szmek [Tue, 30 Mar 2021 10:43:23 +0000 (12:43 +0200)]
mailmap: two more names

4 years agoRevert "fix wrong statement JOURNAL_FILE_FORMAT.md doc"
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.

4 years agofix wrong statement JOURNAL_FILE_FORMAT.md doc
Yangyang Shen [Mon, 29 Mar 2021 12:29:54 +0000 (20:29 +0800)]
fix wrong statement JOURNAL_FILE_FORMAT.md doc

4 years agounits: make locale directory writable for systemd-localed
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

4 years agosd-bus: set retain attribute on BUS_ERROR_MAP_ELF_REGISTER
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
```

4 years agoMerge pull request #19116 from keszybz/readvirtualfile-opt
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

4 years agoresolvectl: suppress warning about --type for names with a dot
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.

4 years agoMerge pull request #19129 from keszybz/test-random-range
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()

4 years agotest-dhcp6-client: add one more assert on memory mapping
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

4 years agoMerge pull request #19125 from keszybz/cat-config
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

4 years agoresolved: tweak how we signal authoritative answers
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

4 years agotests: drop calls to unsetenv SYSTEMD_MEMPOOL
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.

4 years agobasic/fileio: use malloc_usable_size() to use all allocated memory
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

4 years agobasic/fileio: optimize buffer sizes in read_full_virtual_file()
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.

4 years agobasic/fileio: simplify calculation of buffer size in read_full_virtual_file()
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.

4 years agouse the right member to define property
David Tardon [Fri, 26 Mar 2021 11:34:28 +0000 (12:34 +0100)]
use the right member to define property

4 years agotest-random-util: add stochastic test for random_u64_range()
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()

4 years agotest-random-util: modernization
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 11:42:22 +0000 (12:42 +0100)]
test-random-util: modernization

4 years agoresolvectl: do not warn about single hostnames for names we synthesize
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

4 years agoresolved: split out function to determine the local llmnr hostname
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

4 years agoresolvectl: reword note about "raw record types"
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.

4 years agobasic/log: fix log_trace()
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.

4 years agoAdd READMEs in all .d directories
Zbigniew Jędrzejewski-Szmek [Fri, 26 Mar 2021 08:27:11 +0000 (09:27 +0100)]
Add READMEs in all .d directories

4 years agoconfig files: recommend systemd-analyze cat-config
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.

4 years agodocs: link to stable releases in the bug template
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.

4 years agoMerge pull request #19112 from poettering/more-stub-fixes
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

4 years agoMerge pull request #19117 from bluca/coverity
Luca Boccassi [Thu, 25 Mar 2021 19:33:58 +0000 (19:33 +0000)]
Merge pull request #19117 from bluca/coverity

Two small coverity issues

4 years agoresolved: rework CNAME logic a bit more
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.

4 years agoresolved: split dns_query_process_cname() into two separate functions
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.

4 years agotest-dhcp6-client: add one more assert on memory mapping
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

4 years agotest-firewall-util: add more asserts on allocated variables
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

4 years agoresolved: tweak sections we add answer RRs to
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.

4 years agoresolved: pass mDNS reply packets to each transaction exactly once
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.

4 years agoresolved: upgrade log level to LOG_NOTICE if we switch to fallback server (or back)
Lennart Poettering [Wed, 24 Mar 2021 20:21:08 +0000 (21:21 +0100)]
resolved: upgrade log level to LOG_NOTICE if we switch to fallback server (or back)

This is inspired by a recent thread on fedora-devel: it's noteworthy
when we switch to the fallback servers, since it might (or might not)
indicate some configuration problem.

Fixes: #18788

4 years agopo: Translated using Weblate (Korean)
simmon [Thu, 25 Mar 2021 03:01:51 +0000 (04:01 +0100)]
po: Translated using Weblate (Korean)

Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: simmon <simmon@nplob.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/ko/
Translation: systemd/main

4 years agoresolved: don't suppress OPT if we have no OPT
Lennart Poettering [Wed, 24 Mar 2021 19:36:02 +0000 (20:36 +0100)]
resolved: don't suppress OPT if we have no OPT

This is inspired by #18917. It suppresses a misleading log message about
suppressing OPT where we might not actually have OPT.

4 years agoMerge pull request #19076 from yuwata/firewall-util-modernizations
Luca Boccassi [Wed, 24 Mar 2021 23:19:59 +0000 (23:19 +0000)]
Merge pull request #19076 from yuwata/firewall-util-modernizations

firewall-util: modernize code and improve test

4 years agolocal-addresses: fix use of uninitialized value
David Tardon [Wed, 24 Mar 2021 13:45:02 +0000 (14:45 +0100)]
local-addresses: fix use of uninitialized value

This can happen if ifi fails to be read from the netlink message and the
error is ENODATA.

Fixes the following valgrind message when running netstat:

==164141== Conditional jump or move depends on uninitialised value(s)
==164141==    at 0x524AE60: address_compare (local-addresses.c:29)
==164141==    by 0x48BCC78: msort_with_tmp.part.0 (msort.c:105)
==164141==    by 0x48BC9E4: msort_with_tmp (msort.c:45)
==164141==    by 0x48BC9E4: msort_with_tmp.part.0 (msort.c:53)
==164141==    by 0x48BCF85: msort_with_tmp (msort.c:45)
==164141==    by 0x48BCF85: qsort_r (msort.c:297)
==164141==    by 0x52500FC: UnknownInlinedFun (sort-util.h:47)
==164141==    by 0x52500FC: local_gateways.constprop.0 (local-addresses.c:310)
==164141==    by 0x5251C05: _nss_myhostname_gethostbyaddr2_r (nss-myhostname.c:456)
==164141==    by 0x5252006: _nss_myhostname_gethostbyaddr_r (nss-myhostname.c:500)
==164141==    by 0x498E7FE: gethostbyaddr_r@@GLIBC_2.2.5 (getXXbyYY_r.c:274)
==164141==    by 0x498E560: gethostbyaddr (getXXbyYY.c:135)
==164141==    by 0x121353: INET_rresolve.constprop.0 (inet.c:212)
==164141==    by 0x1135B9: INET_sprint (inet.c:261)
==164141==    by 0x121BFC: addr_do_one.constprop.0.isra.0 (netstat.c:1156)

4 years agotest-firewall-util: use assert_se() at most places
Yu Watanabe [Mon, 22 Mar 2021 13:44:25 +0000 (22:44 +0900)]
test-firewall-util: use assert_se() at most places

Otherwise, we cannot notice any failures...

4 years agopo: Translated using Weblate (Dutch)
Pjotr Vertaalt [Wed, 24 Mar 2021 09:16:18 +0000 (10:16 +0100)]
po: Translated using Weblate (Dutch)

Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: Pjotr Vertaalt <pjotrvertaalt@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/nl/
Translation: systemd/main

4 years agoprocess-util: dont allocate max length to read /proc/PID/cmdline
Anita Zhang [Tue, 23 Mar 2021 07:49:28 +0000 (00:49 -0700)]
process-util: dont allocate max length to read /proc/PID/cmdline

Alternative title: Replace get_process_cmdline()'s fopen()/fread() with
read_full_virtual_file().

When RLIMIT_STACK is set to infinity:infinity, _SC_ARG_MAX will
return 4611686018427387903 (depending on the system, but definitely
something larger than most systems have). It's impractical to allocate this
in one go when most cmdlines are much shorter than that.

Instead use read_full_virtual_file() which seems to increase the buffer
depending on the size of the contents.

4 years agopid1: do not use generated strings as format strings (#19098)
Lincoln Ramsay [Wed, 24 Mar 2021 07:37:25 +0000 (17:37 +1000)]
pid1: do not use generated strings as format strings (#19098)

The generated string may include %, which will confuse both the
xprintf call, and the VA_FORMAT_ADVANCE macro.

Pass the generated string as an argument to a "%s" format string
instead.

4 years agonetwork: fix ipv6 tunnel encapsulation limit (#19087)
hide [Tue, 23 Mar 2021 16:05:25 +0000 (01:05 +0900)]
network: fix ipv6 tunnel encapsulation limit (#19087)

The encapsulation limit of IPv6 tunnel can not be set to 4, which is the default value of the encapsulation limit.

4 years agorepart: remove spurious empty double newlines
Lennart Poettering [Sat, 20 Mar 2021 21:13:54 +0000 (22:13 +0100)]
repart: remove spurious empty double newlines

4 years agoblockdev-util: actually specify an access mode on open()
Lennart Poettering [Tue, 23 Mar 2021 13:04:59 +0000 (14:04 +0100)]
blockdev-util: actually specify an access mode on open()

Linux is pretty lenient here, but we should specify the access mode.

4 years agoupdate TODO
Lennart Poettering [Tue, 23 Mar 2021 13:42:58 +0000 (14:42 +0100)]
update TODO

4 years agopo: Added translation using Weblate (Dutch)
Pjotr Vertaalt [Tue, 23 Mar 2021 09:20:59 +0000 (10:20 +0100)]
po: Added translation using Weblate (Dutch)

Co-authored-by: Pjotr Vertaalt <pjotrvertaalt@gmail.com>
4 years agoman: document differences in clean exit status for Type=oneshot
David Tardon [Fri, 19 Mar 2021 09:05:47 +0000 (10:05 +0100)]
man: document differences in clean exit status for Type=oneshot

See commit 1f0958f640b87175cd547c1e69084cfe54a22e9d .

4 years agoman: rate limited services can be restartet from timer or socket
Christian Hesse [Tue, 23 Mar 2021 06:57:03 +0000 (07:57 +0100)]
man: rate limited services can be restartet from timer or socket

If rate limiting kicks in for Restart= logic it is still possible for a
timer or socket to restart the service.

4 years agosd-event: disable epoll_pwait2 for now
Zbigniew Jędrzejewski-Szmek [Fri, 12 Mar 2021 09:20:38 +0000 (10:20 +0100)]
sd-event: disable epoll_pwait2 for now

This reverts the gist of commit 798445ab84cff51bde7fcf936f0fb19c37cf858c.

Unfortunately the new syscall causes test-event to hang. 32 bit architectures
seem affected: i686 and arm32 in fedora koji. 32 bit build of test-event hangs
reliably under valgrind:

$ PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig meson build-32 -Dc_args=-m32 -Dc_link_args=-m32 -Dcpp_args=-m32 -Dcpp_link_args=-m32 && ninja -C build-32 test-event && valgrind build/test-event

If I set epoll_pwait2_absent=true, so the new function is never called, then
the issue does not reproduce. It seems to be strictly tied to the syscall.

On amd64, the syscall is not used, at least with the kernel that Fedora
provides. The kernel patch 58169a52ebc9a733aeb5bea857bc5daa71a301bb says:

  For timespec, only support this new interface on 2038 aware platforms
  that define __kernel_timespec_t. So no CONFIG_COMPAT_32BIT_TIME.

And Fedora sets CONFIG_COMPAT_32BIT_TIME=y. I expect most other distros will too.

On amd64: epoll_wait_usec: epoll_pwait2: ret=-1 / errno=38
On i686 (same kernel): epoll_wait_usec: epoll_pwait2: ret=2 / errno=0

Is this some kind of emulation? Anyway, it seems that this is what is going wrong.

So let's disable the syscall until it becomes more widely available and the
kinks have been ironed out.

Fixes test-event issue in #19052.

4 years agoMerge pull request #19075 from keszybz/calendarspec-loop
Zbigniew Jędrzejewski-Szmek [Tue, 23 Mar 2021 08:06:16 +0000 (09:06 +0100)]
Merge pull request #19075 from keszybz/calendarspec-loop

Fix infinite loop in calendarspec calculation when timezone has negative DST save value

4 years agofirewall-util: refuse IPv6 firewall rules when kernel does not support IPv6
Yu Watanabe [Tue, 23 Mar 2021 03:02:54 +0000 (12:02 +0900)]
firewall-util: refuse IPv6 firewall rules when kernel does not support IPv6

4 years agofirewall-util: gracefully handle -EOVERFLOW returned from older kernel
Yu Watanabe [Mon, 22 Mar 2021 16:57:51 +0000 (01:57 +0900)]
firewall-util: gracefully handle -EOVERFLOW returned from older kernel

4 years agofirewall-util: do not use goto for retrying
Yu Watanabe [Mon, 22 Mar 2021 16:52:07 +0000 (01:52 +0900)]
firewall-util: do not use goto for retrying

4 years agofirewall-util: add missing return value check
Yu Watanabe [Mon, 22 Mar 2021 16:34:30 +0000 (01:34 +0900)]
firewall-util: add missing return value check

4 years agofirewall-util: probe firewall backend in fw_ctx_new()
Yu Watanabe [Tue, 23 Mar 2021 05:38:18 +0000 (14:38 +0900)]
firewall-util: probe firewall backend in fw_ctx_new()

FirewallContext is used by networkd and nspawn. Both allocates the
context when it is really necessary. Hence, it is not necessary to delay
probing backend.

Moreover, if iptables backend is not enabled on build, and nftables is
not supported by kernel, previously `fw_nftables_init()` is called
everytime when we try to configure masquerade or dnat. It causes
significant performance loss.

Fixes test-firewall-util issue in #19052.

4 years agonetwork: allocate FirewallContext lazily
Yu Watanabe [Tue, 23 Mar 2021 05:37:05 +0000 (14:37 +0900)]
network: allocate FirewallContext lazily

4 years agofirewall-util: logs which backend will be used
Yu Watanabe [Mon, 22 Mar 2021 13:33:23 +0000 (22:33 +0900)]
firewall-util: logs which backend will be used

This also modernizes code a bit.

4 years agoshared/calendarspec: when mktime() moves us backwards, jump forward
Zbigniew Jędrzejewski-Szmek [Mon, 22 Mar 2021 11:51:47 +0000 (12:51 +0100)]
shared/calendarspec: when mktime() moves us backwards, jump forward

When trying to calculate the next firing of 'Sun *-*-* 01:00:00', we'd fall
into an infinite loop, because mktime() moves us "backwards":

Before this patch:
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
...

We rely on mktime() normalizing the time. The man page does not say that it'll
move the time forward, but our algorithm relies on this. So let's catch this
case explicitly.

With this patch:
$ TZ=Europe/Dublin faketime 2021-03-21 build/systemd-analyze calendar --iterations=5 'Sun *-*-* 01:00:00'
Normalized form: Sun *-*-* 01:00:00
    Next elapse: Sun 2021-03-21 01:00:00 GMT
       (in UTC): Sun 2021-03-21 01:00:00 UTC
       From now: 59min left
       Iter. #2: Sun 2021-04-04 01:00:00 IST
       (in UTC): Sun 2021-04-04 00:00:00 UTC
       From now: 1 weeks 6 days left           <---- note the 2 week jump here
       Iter. #3: Sun 2021-04-11 01:00:00 IST
       (in UTC): Sun 2021-04-11 00:00:00 UTC
       From now: 2 weeks 6 days left
       Iter. #4: Sun 2021-04-18 01:00:00 IST
       (in UTC): Sun 2021-04-18 00:00:00 UTC
       From now: 3 weeks 6 days left
       Iter. #5: Sun 2021-04-25 01:00:00 IST
       (in UTC): Sun 2021-04-25 00:00:00 UTC
       From now: 1 months 4 days left

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1941335.

4 years agoMerge pull request #19079 from poettering/resolved-ipv6-cache-fix
Luca Boccassi [Mon, 22 Mar 2021 23:20:11 +0000 (23:20 +0000)]
Merge pull request #19079 from poettering/resolved-ipv6-cache-fix

fix CNAME/DNAME following in combined A/AAAA replies