1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-22 22:03:43 +03:00

55644 Commits

Author SHA1 Message Date
Jan Janssen
e37912e4bc boot: Handle shift and logo keys too
Some firmware supports sending input events for shift and logo keys.
Previously, we would suppress these with EFI_NOT_READY unless
some other key was pressed alongside, but it is really the job of the
caller to decide how to handle these.

Note that for keys that already have a printable shift representation
the reported input event will not have the shift key bits set
(Shift+a is reported as A). Should some firmware turn out to violate the
spec here we can always remove that part.

(cherry picked from commit 3f9973bf368475d1f2f7f587e7af728dd6d84e10)
2022-03-05 21:03:32 +00:00
Jan Janssen
c6603da3ad boot: Properly check status code of console_key_read
In some cases there was a unlikely possibility that we would look
at an uninitialized key value.
Also, returning in case of unexpected input error cases should prevent
infinite looping.

(cherry picked from commit 1cb5d7857b205023a0473ec13df154ae2e254066)
2022-03-05 21:03:32 +00:00
Yu Watanabe
55ec995341 test: fix file descriptor leak in test-oomd-util
Fixes an issue reported in #22576.

(cherry picked from commit 282696ce52471f5e3c963b9d98dbc89fba3a1fba)
2022-03-05 21:03:32 +00:00
Yu Watanabe
92b86911c0 test: fix file descriptor leak in test-catalog
Fixes an issue reported in #22576.

(cherry picked from commit 62d4b3b36e9aba9e605ba042a75c374155b6e18b)
2022-03-05 21:03:32 +00:00
Yu Watanabe
b10cc2de7d test-oomd-util: fix conditional jump on uninitialised value
Fixes #22577.

(cherry picked from commit a6d6a51d83fae32212e1780e71b16517a4df9a57)
2022-03-05 21:03:32 +00:00
Yu Watanabe
1343c2efd5 test-oomd-util: style fixlets
(cherry picked from commit d9fe39b24a0a5464c83c7a754752ca21dbd2578f)
2022-03-05 21:03:32 +00:00
Franck Bui
2198c08d07 core: really skip automatic restart when a JOB_STOP job is pending
It's not clear why we rescheduled a service auto restart while a stop job for
the unit was pending. The comment claims that the unit shouldn't be restarted
but the code did reschedule an auto restart meanwhile.

In practice that was rarely an issue because the service waited for the next
auto restart to be rescheduled, letting the queued stop job to be proceed and
service_stop() to be called preventing the next restart to complete.

However when RestartSec=0, the timer expired right away making PID1 to
reschedule the unit again, making the timer expired right away... and so
on. This busy loop prevented PID1 to handle any queued jobs (and hence giving
no chance to the start rate limiting to trigger), which made the busy loop last
forever.

This patch breaks this loop by skipping the reschedule of the unit auto restart
and hence not depending on the value of u->restart_usec anymore.

Fixes: #13667
(cherry picked from commit c972880640ee19e89ce9265d8eae1b3aae190332)
2022-03-05 21:03:32 +00:00
Matthias Lisin
d016749c00 docs: swap Name and Partition Type UUID in header
(cherry picked from commit 7d5beae28ca75725a680b0ab3ef5728a252282e5)
2022-03-05 21:03:32 +00:00
Matthias Lisin
5a322fd54b tools: adjust re.match to recent gpt.h additions
with addition of SD_ID128_MAKE_UUID_STR entries to src/shared/gpt.h the tool
failed halfway due to falsly matching the new entries

(cherry picked from commit 5fa87e9651074e8b78f632e43f0c2001a27f5b60)
2022-03-05 21:03:32 +00:00
Luca Boccassi
7f28c0f3f3 mkosi CI: mask isc-dhcp-server units
The packages are installed to provide the dhcpd binary, used by
test/test-network/systemd-networkd-tests.py, but we don't need the units
to run, and in fact in some cases the image fails to boot because of
them:

Spawning container image on /home/runner/work/systemd/systemd/image.raw.
Press ^] three times within 1s to kill container.
● isc-dhcp-server.service  loaded failed failed ISC DHCP IPv4 server
● isc-dhcp-server6.service loaded failed failed ISC DHCP IPv6 server
Container image failed with error code 1.
Error: Process completed with exit code 1.

Mask the units with an --extra-tree.

(cherry picked from commit 21838f36a64e71dd6439692e57d629f27e4954ea)
2022-03-05 21:03:32 +00:00
Frantisek Sumsal
e59c381e23 systemctl: make --timestamp= affect the show verb as well
Currently the `--timestamp=` option has no effect on timestamps shown by
`systemctl show`, let's fix that.

Spotted in #22567.

Before:
```
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
ExecMainStartTimestamp=Sat 2021-12-11 15:25:57 CET
StateChangeTimestamp=Sat 2021-12-11 15:25:57 CET
InactiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
ActiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
ActiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
InactiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
ConditionTimestamp=Sat 2021-12-11 15:25:57 CET
AssertTimestamp=Sat 2021-12-11 15:25:57 CET
```

After:
```
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
ExecMainStartTimestamp=Sat 2021-12-11 14:25:57.177848 UTC
StateChangeTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
InactiveExitTimestamp=Sat 2021-12-11 14:25:57.177871 UTC
ActiveEnterTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
ActiveExitTimestamp=Sat 2021-12-11 14:25:57.144677 UTC
InactiveEnterTimestamp=Sat 2021-12-11 14:25:57.176331 UTC
ConditionTimestamp=Sat 2021-12-11 14:25:57.176980 UTC
AssertTimestamp=Sat 2021-12-11 14:25:57.176980 UTC

```

(cherry picked from commit a59e5c625da5a6e0c46e493d55f2f4212e9457ca)
2022-03-05 21:03:32 +00:00
Lennart Poettering
367041af81 pid1: set SYSTEMD_NSS_DYNAMIC_BYPASS=1 env var for dbus-daemon
There's currently a deadlock between PID 1 and dbus-daemon: in some
cases dbus-daemon will do NSS lookups (which are blocking) at the same
time PID 1 synchronously blocks on some call to dbus-daemon. Let's break
that by setting SYSTEMD_NSS_DYNAMIC_BYPASS=1 env var for dbus-daemon,
which will disable synchronously blocking varlink calls from nss-systemd
to PID 1.

In the long run we should fix this differently: remove all synchronous
calls to dbus-daemon from PID 1. This is not trivial however: so far we
had the rule that synchronous calls from PID 1 to the dbus broker are OK
as long as they only go to interfaces implemented by the broke itself
rather than services reachable through it. Given that the relationship
between PID 1 and dbus is kinda special anyway, this was considered
acceptable for the sake of simplicity, since we quite often need
metadata about bus peers from the broker, and the asynchronous logic
would substantially complicate even the simplest method handlers.

This mostly reworks the existing code that sets SYSTEMD_NSS_BYPASS_BUS=
(which is a similar hack to deal with deadlocks between nss-systemd and
dbus-daemon itself) to set SYSTEMD_NSS_DYNAMIC_BYPASS=1 instead. No code
was checking SYSTEMD_NSS_BYPASS_BUS= anymore anyway, and it used to
solve a similar problem, hence it's an obvious piece of code to rework
like this.

Issue originally tracked down by Lukas Märdian. This patch is inspired
and closely based on his patch:

       https://github.com/systemd/systemd/pull/22038

Fixes: #15316
Co-authored-by: Lukas Märdian <slyon@ubuntu.com>
(cherry picked from commit de90700f36f2126528f7ce92df0b5b5d5e277558)
2022-03-05 21:03:32 +00:00
Lennart Poettering
4ec9aec4b6 docs: $SYSTEMD_NSS_BYPASS_BUS is not honoured anymore, don't document it
It was removed back in 1684c56f40f020e685e70b3d1785d596ff16f892

Follow-up for: 1684c56f40f020e685e70b3d1785d596ff16f892

(cherry picked from commit cec16155e3dab4f123ba073223477a4ef2cf10f9)
2022-03-05 21:03:32 +00:00
Lennart Poettering
cf390149cb pid1: lookup owning PID of BusName= name of services asynchronously
A first step of removing blocking calls to the D-Bus broker from PID 1.
There's a lot more to got (i.e. grep src/core/ for sd_bus_creds
basically), but it's a start.

Removing blocking calls to D-Bus broker deals systematicallly with
deadlocks caused by dbus-daemon blocking on synchronous IPC calls back
to PID1 (e.g. Varlink calls through nss-systemd). Bugs such as #15316.

Also-see: https://github.com/systemd/systemd/pull/22038#issuecomment-1042958390
(cherry picked from commit e39eb045a502d599e6cd3fda7a46020dd438d018)
2022-03-05 21:03:32 +00:00
Lennart Poettering
a51e540b27 pid1: watch bus name always when we have it
Previously we'd only watch configured service bus names if Type=dbus was
set. Let's also watch it for other types. This is useful to pick up the
main PID of such a service. In fact the code to pick it up was already
in place, alas it didn't do anything given the signal was never received
for it. Fix that.

(It's also useful for debugging)

(cherry picked from commit 1e8b312e5a22538f91defb89cf2997e09e106297)
2022-03-05 21:03:32 +00:00
Yu Watanabe
d57147ef56 resolve: synthesize empty domain only when A and/or AAAA key is requested
Follow-up for 3b2ac14ac45bef01cf489c3231b868936866444b (#22231).

Before this commit.
---
$ dig -t SRV '.'

; <<>> DiG 9.16.24-RH <<>> -t SRV .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16836
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;.				IN	SRV

;; Query time: 1 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Fri Feb 04 12:01:09 JST 2022
;; MSG SIZE  rcvd: 28
---

After this commit.
---
$ dig -t SRV '.'

; <<>> DiG 9.16.24-RH <<>> -t SRV .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19861
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;.				IN	SRV

;; AUTHORITY SECTION:
.			86394	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2022020302 1800 900 604800 86400

;; Query time: 20 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Fri Feb 04 12:00:12 JST 2022
;; MSG SIZE  rcvd: 103
---

Fixes #22401.

(cherry picked from commit 30fa3aa1fa56d9a1a4f3a26c0bc02253d44dfa0f)
2022-02-24 10:20:14 +01:00
Yu Watanabe
54ab65f5f3 resolve: make dns_scope_good_domain() take DnsQuery*
(cherry picked from commit 176a9a2cca47f7c1553d96f7dd51c2193a269dbc)
2022-02-24 10:20:14 +01:00
Yu Watanabe
499115dbc3 resolve: drop never matched condition
As dns_scope_good_domain() does not return negative errno.

(cherry picked from commit 830f50ab1e03fa7ee262876ed42023d10e89688d)
2022-02-24 10:20:14 +01:00
Yu Watanabe
89b439ee00 resolve: synthesize null address, IPv4 broadcast address, or invalid domain
These are filtered in `dns_scope_good_domain()`, but not synthesized.

Fixes #22229.

(cherry picked from commit 46b53e8035fb60c9a7f26dd32d6689ab3b7da97c)
2022-02-24 10:20:14 +01:00
Yu Watanabe
0fd3ccca64 resolve: synthesize empty name
Do not return any error for empty name. Just returns empty answer.

Before:
---
$ dig .

; <<>> DiG 9.16.24-RH <<>> .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 13617
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;.				IN	A

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jan 24 05:49:30 JST 2022
;; MSG SIZE  rcvd: 28
---

After:
---
$ dig .

; <<>> DiG 9.16.24-RH <<>> .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7957
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;.				IN	A

;; Query time: 1 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jan 24 06:05:02 JST 2022
;; MSG SIZE  rcvd: 28
---

Replaces #22197.

Fixes RHBZ#2039854 (https://bugzilla.redhat.com/show_bug.cgi?id=2039854).

(cherry picked from commit 3b2ac14ac45bef01cf489c3231b868936866444b)
2022-02-24 10:20:14 +01:00
Yu Watanabe
df08c12062 dns-domain: re-introduce dns_name_is_empty()
(cherry picked from commit 7bdf41983044268b4bc2f9d34462db7f89ba284a)
2022-02-24 10:20:14 +01:00
Frantisek Sumsal
477b85f438 packit: drop unnumbered patches as well
(cherry picked from commit 729c6b6af8e3cef259b80746f7f7f10cc63d309f)
2022-02-22 21:47:38 +00:00
Yu Watanabe
336711e062 sd-dhcp-server: do not offer server address
The server address may be in the pool.

(cherry picked from commit 9e0cb8b61f46a2164290a2380db89e45876b370c)
2022-02-22 21:47:38 +00:00
Yu Watanabe
995086918c sd-dhcp-server: do not assign address reserved for static leases to non-matching clients
This fix the root cause of the issue #22253.

(cherry picked from commit bd1a3eb65b9e308028c18e1ed7ffde474a3b1244)
2022-02-22 21:47:38 +00:00
Yu Watanabe
0478298bf9 sd-dhcp-server: explicitly refuse when conflicting address is requested
(cherry picked from commit 7e98fe05a0b9cdfdad326f34189cd37257d9d4e4)
2022-02-22 21:47:38 +00:00
Yu Watanabe
71d05ec458 sd-dhcp-server: do not assign an address from pool when a static lease for the client ID exists
(cherry picked from commit e2ba408084935fffa0c73007528de7babf9309c8)
2022-02-22 21:47:38 +00:00
Yu Watanabe
316f6bdb39 sd-dhcp-server: rename get_pool_offset() -> address_is_in_pool()
As, the value of pool_offset is not used.

(cherry picked from commit 5cc8be890db8611b9003304769ec82c3548be6e1)
2022-02-22 21:47:38 +00:00
Yu Watanabe
7f36fb25d5 sd-dhcp-server: rename server_send_nak() -> server_send_nak_or_ignore()
And logs error in the function.

(cherry picked from commit eb5bff9c9de2bd218f5ac431e3aead4b5747ecd9)
2022-02-22 21:47:38 +00:00
Yu Watanabe
1dcd82a7bf sd-dhcp-server: set DHCPLease::server before hashmap_put()
Otherwise, if the second push is failed, then the first hashmap contains
dirty entry.

Also, this makes hashmap_remove_value() used when removing leases to
make not wrong lease is removed from the hashmap.

Note, this just hide the root cause of the issue #22253, which will be
fixed in later commit.

Fixes #22253.

(cherry picked from commit 8a7d048d1ddb8916482f1422405d3e0e4bccb279)
2022-02-22 21:47:38 +00:00
Frantisek Sumsal
fa6e263273 ci: fix clang-13 installation
For some reason Ubuntu Focal repositories now have `llvm-13` virtual
package which can't be installed, but successfully fools our check,
resulting in no clang/llvm being installed...

```
$ apt show llvm-13
Package: llvm-13
State: not a real package (virtual)
N: Can't select candidate version from package llvm-13 as it has no candidate
N: Can't select versions from package 'llvm-13' as it is purely virtual
N: No packages found

$ apt install --dry-run llvm-13
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package llvm-13 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'llvm-13' has no installation candidate
```

(cherry picked from commit b491d74064f9d5e17a71b38b014434237169a077)
2022-02-22 21:47:38 +00:00
Evgeny Vereshchagin
c92297a20c ci: replace apt-key with signed-by
to limit the scope of the key to apt.llvm.org only.

This is mostly inspired by https://blog.cloudflare.com/dont-use-apt-key/

(cherry picked from commit bfa6bd1be098adc4710e1819b9cd34d65b3855da)
2022-02-22 21:47:38 +00:00
Yu Watanabe
66411cea19 network: dhcp-pd: fix prefix length of address assigned to upstream interface
This effectively revert ab0c82d9f749cc397a6b7e0327ddb2c08cd7d7e0.

I have no idea why I did that...

Fixes #22559.

(cherry picked from commit 38488babe791639860068905177a415822b6b98b)
2022-02-22 21:47:38 +00:00
Yu Watanabe
919d398668 resolve: add reference of the original bus message to the aux queries
Otherwise, the error in aux queries cannot be replied.

Fixes #22477.

(cherry picked from commit 08275791d85a1852e79951212f6cbbc727db789a)
2022-02-22 21:47:38 +00:00
Yu Watanabe
084c88983e resolve: refuse AF_UNSPEC when resolving address
Fixes #22480.

(cherry picked from commit 0234f0c0531682e7f28a4ef51852c102c6e97267)
2022-02-22 21:47:38 +00:00
Yu Watanabe
d026bd21ea udev-util: add parentheses to make coverity silent
Fixes CID#1474365.

(cherry picked from commit 9fa31df62dd504e8f3e43710df504a467ed430fa)
2022-02-22 21:47:38 +00:00
Yu Watanabe
a7cf77914b network: call ethtool after link is initialized by udevd
Fixes #22538.

(cherry picked from commit e1658632aefc963c4a651de433cceb3a9512afd6)
2022-02-22 21:47:38 +00:00
Yu Watanabe
7b121ab288 network: use udev_available() where applicable
(cherry picked from commit 82f52245baa2fe26f1de7b50a036d3746deb7df1)
2022-02-22 21:47:38 +00:00
Yu Watanabe
c809c046be udev-util: introduce udev_available() helper function
(cherry picked from commit f92c5bb18cee41d48b95d61a2a2dc613203844ca)
2022-02-22 21:47:38 +00:00
Richard Neill
160eeab224 virt: Fix Xen Dom0 detection logic to no longer report as VM
Fixes regression introduced in 599be274c13c503806c85073d7beb1a155ac27bd

Moving the Xen check before the CPUID check, in order to handle the case where
a Xen domain is nested within a hypervisor which can be detected by via the
CPUID check, had an unintended consequence of causing Dom0 to report as a Xen
VM when it is not nested.

This patch stops further checks once it has been determined that Dom0 is not
nested within another hypervisor, meaning that the non-nested case matches its
previous logic (where it does not report as a VM).

Also, tidy the conditionals for the Xen and UML checks by removing handling of
a VIRTUALIZATION_VM_OTHER result, which has no code path.

Fixes #22511

(cherry picked from commit ea583ed5a366cf51b80bd363db95e828a25ec27e)
2022-02-22 21:47:38 +00:00
Luca Boccassi
e69b2a3a69 Partially revert "sd-dhcp-server: refuse too large packet to send"
This test fails on this branch:

 949/1228 fuzz-dhcp-server-relay-message_clusterfuzz-testcase-minimized-fuzz-dhcp-server-relay-message-4972399731277824_address,undefined FAIL           0.00s (exit status 127)12:43
--- command ---12:43
01:47:36 UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1' /usr/bin/env /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-server-relay-message:address,undefined /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/test/fuzz/fuzz-dhcp-server-relay-message/clusterfuzz-testcase-minimized-fuzz-dhcp-server-relay-message-497239973127782412:43
--- stderr ---12:43
/usr/bin/env: ‘/tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-server-relay-message:address,undefined’: No such file or directory

This partially reverts commit 76bcd1d6d26ebe0424e2c5edc7f5a31a82ae3a7c.
2022-02-15 14:17:47 +00:00
Luca Boccassi
2614461383 Revert "tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains"
The test fails on this branch:

 948/1228 fuzz-dhcp-client_minimized-from-555a2b073b8d208655b68c294f8dfd592a11e50a_address,undefined                                      FAIL           0.00s (exit status 127)12:43
--- command ---12:43
01:47:36 UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1' /usr/bin/env /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-client:address,undefined /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/test/fuzz/fuzz-dhcp-client/minimized-from-555a2b073b8d208655b68c294f8dfd592a11e50a12:43
--- stderr ---12:43
/usr/bin/env: ‘/tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-client:address,undefined’: No such file or directory

This reverts commit 87728a590ad82391e76a275024c9039625ff2b67.
2022-02-15 14:17:47 +00:00
Luca Boccassi
2e323d198d meson: disable export-dbus-interfaces target when cross-compiling
ERROR:
Cannot use target systemd as a generator because it is built for the
host machine and no exe wrapper is defined or needs_exe_wrapper is
true. You might want to set `native: true` instead to build it for
the build machine.

(cherry picked from commit 0628d48ec2af1c25bede6d94ae49107b17651b68)

Conflicts:
	meson.build
2022-02-14 22:14:08 +00:00
Jan Janssen
5a9113cb0b boot: Correctly check the return value of CheckEvent
Fixes: #22428
(cherry picked from commit ac3979abd7a38725b66c1ce0607fa905b3a3d782)
2022-02-14 22:04:02 +00:00
Yu Watanabe
ab30fe12ed test-network: add missing tests for bridge properties
(cherry picked from commit b6d5dab7bbb8ecf4ce1229840085daa15ab4cf57)
2022-02-14 22:03:45 +00:00
Yu Watanabe
514a4c051c network: bridge: fix endian of vlan protocol
Fixes #22469.

(cherry picked from commit 6eb35be8e0fa5f1f00dddd558cf4dc3642d9e53e)
2022-02-14 22:03:45 +00:00
Daan De Meyer
ea4a694876 journal: Improve handling of corruption during upwards entry iteration
If we're going upwards in the journal file during entry iteration and we
can't reach the current entry due to corruption, start iterating upwards
from the last reachable entry array. This is equivalent to skipping
all entries in the array that can't be reached anymore.

Fixes #22431

(cherry picked from commit 952d1e784a0ad47e0c2c832d28299987c3c25529)
2022-02-14 22:03:20 +00:00
Daan De Meyer
88c711885f journal: Fix upwards iteration of entry items in case of corruption
8d801e35cb155faa08235a5af8b4d6ad60715837 didn't take into account
upwards iteration of entry items when we're working on a corrupted
journal file. Instead of moving to the previous entry array, we'd
always move to the next array, regardless of the iteration direction.

To fix this, we introduce bump_entry_array() that moves to the next
or previous entry array depending on the given direction. Since the
entry array chains are singly linked lists, we have to start iterating
from the front to find the previous array. We only reach this logic
if we're working on a corrupted journal file so being slow here shouldn't
matter too much.

(cherry picked from commit aa00163d79309f9873512a4cc14a48c05fee7c65)
2022-02-14 22:03:20 +00:00
Yu Watanabe
1c37ac98d6 resolve: reuse timer event source for DnsQuery
If the query get CNAME or DNAME, then the query will be restarted.
Even in that case, previously, the event source was freed and allocated
again. Let's slightly optimize it.

(cherry picked from commit ecdfb9a1ae0a09d22a976e2ca0dc99aacc6b9d1f)
2022-02-14 22:03:07 +00:00
Yu Watanabe
0533d1aab6 resolve: use _cleanup_ attribute for freeing DnsQuery
(cherry picked from commit c704288c473fa08820566fdb16c38726d24db026)
2022-02-14 22:03:07 +00:00
Yu Watanabe
4dbc210124 resolve: fix possible memleak
Fortunately, unlike the issue fixed in the previous commit, the memleak
should be superficial and not become apparent, as the queries handled
here are managed by the stub stream, and will be freed when the stream
is closed.

Just for safety, and slightly reducing the runtime memory usage by the
stub stream.

(cherry picked from commit fe8c5ce615ee2123f17b1f0b3728c439e19e4b5b)
2022-02-14 22:03:07 +00:00