1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-07 17:17:44 +03:00
Commit Graph

55748 Commits

Author SHA1 Message Date
Lennart Poettering
4a90c12f4f clang-format: we actually typically use 16ch continuation indentation
We use 8 for blocks, and 16 for continuation in most cases afaics, hence
say so in .clang-format too

(cherry picked from commit 92148fb777)
2022-03-05 21:03:32 +00:00
Yu Watanabe
81d3e2abff test: fix file descriptor leak in test-psi-util
Fixes an issue reported in #22576.

(cherry picked from commit be99883e13)
2022-03-05 21:03:32 +00:00
Yu Watanabe
d9189c3111 test: fix file descriptor leak in test-tmpfiles.c
Also fixes a typo in assertion.

Fixes an issure reported in #22576.

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

(cherry picked from commit 19962747ca)
2022-03-05 21:03:32 +00:00
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 3f9973bf36)
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 1cb5d7857b)
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 282696ce52)
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 62d4b3b36e)
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 a6d6a51d83)
2022-03-05 21:03:32 +00:00
Yu Watanabe
1343c2efd5 test-oomd-util: style fixlets
(cherry picked from commit d9fe39b24a)
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 c972880640)
2022-03-05 21:03:32 +00:00
Matthias Lisin
d016749c00 docs: swap Name and Partition Type UUID in header
(cherry picked from commit 7d5beae28c)
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 5fa87e9651)
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 21838f36a6)
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 a59e5c625d)
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 de90700f36)
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 1684c56f40

Follow-up for: 1684c56f40

(cherry picked from commit cec16155e3)
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 e39eb045a5)
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 1e8b312e5a)
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 3b2ac14ac4 (#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 30fa3aa1fa)
2022-02-24 10:20:14 +01:00
Yu Watanabe
54ab65f5f3 resolve: make dns_scope_good_domain() take DnsQuery*
(cherry picked from commit 176a9a2cca)
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 830f50ab1e)
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 46b53e8035)
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 3b2ac14ac4)
2022-02-24 10:20:14 +01:00
Yu Watanabe
df08c12062 dns-domain: re-introduce dns_name_is_empty()
(cherry picked from commit 7bdf419830)
2022-02-24 10:20:14 +01:00
Frantisek Sumsal
477b85f438 packit: drop unnumbered patches as well
(cherry picked from commit 729c6b6af8)
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 9e0cb8b61f)
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 bd1a3eb65b)
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 7e98fe05a0)
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 e2ba408084)
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 5cc8be890d)
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 eb5bff9c9d)
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 8a7d048d1d)
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 b491d74064)
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 bfa6bd1be0)
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 ab0c82d9f7.

I have no idea why I did that...

Fixes #22559.

(cherry picked from commit 38488babe7)
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 08275791d8)
2022-02-22 21:47:38 +00:00
Yu Watanabe
084c88983e resolve: refuse AF_UNSPEC when resolving address
Fixes #22480.

(cherry picked from commit 0234f0c053)
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 9fa31df62d)
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 e1658632ae)
2022-02-22 21:47:38 +00:00
Yu Watanabe
7b121ab288 network: use udev_available() where applicable
(cherry picked from commit 82f52245ba)
2022-02-22 21:47:38 +00:00
Yu Watanabe
c809c046be udev-util: introduce udev_available() helper function
(cherry picked from commit f92c5bb18c)
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 599be274c1

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 ea583ed5a3)
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 76bcd1d6d2.
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 87728a590a.
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 0628d48ec2)

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 ac3979abd7)
2022-02-14 22:04:02 +00:00
Yu Watanabe
ab30fe12ed test-network: add missing tests for bridge properties
(cherry picked from commit b6d5dab7bb)
2022-02-14 22:03:45 +00:00
Yu Watanabe
514a4c051c network: bridge: fix endian of vlan protocol
Fixes #22469.

(cherry picked from commit 6eb35be8e0)
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 952d1e784a)
2022-02-14 22:03:20 +00:00