systemd/.git
4 years agoresolved: fix braino with reference counting and linked lists
Zbigniew Jędrzejewski-Szmek [Fri, 14 May 2021 08:49:24 +0000 (10:49 +0200)]
resolved: fix braino with reference counting and linked lists

In 0e0fd08fc832b8f42e567d722d388eba086da5ff I added reference counts to keep
track of the DnsQueryCandidate objects. Unfortunately, dns_query_unref_candidates()
was written as

     while (q->candidates)
           dns_query_candidate_unref(q->candidates);

i.e. it would keep dropping the reference count as many times as needed for it
to hit 0, making the patch less than fully effective.

dns_query_unref_candidates() is renamed to dns_query_detach_candidates() and
changed to drop exactly one reference from each of the linked candidates.

Example failure:
==463== Invalid read of size 8
==463==    at 0x419C93: dns_query_candidate_go (resolved-dns-query.c:159)
==463==    by 0x41A143: dns_query_candidate_notify (resolved-dns-query.c:304)
==463==    by 0x434BD6: dns_transaction_complete (resolved-dns-transaction.c:437)
==463==    by 0x436A0F: dns_transaction_process_dnssec (resolved-dns-transaction.c:976)
==463==    by 0x4378C1: dns_transaction_process_reply (resolved-dns-transaction.c:1387)
==463==    by 0x437CE9: on_dns_packet (resolved-dns-transaction.c:1444)
==463==    by 0x4B2DC9B: source_dispatch (sd-event.c:3512)
==463==    by 0x4B2FB1F: sd_event_dispatch (sd-event.c:4077)
==463==    by 0x4B2FFFA: sd_event_run (sd-event.c:4138)
==463==    by 0x4B301D6: sd_event_loop (sd-event.c:4159)
==463==    by 0x464A24: run (resolved.c:92)
==463==    by 0x464B3C: main (resolved.c:99)
==463==  Address 0x5f409d0 is 32 bytes inside a block of size 72 free'd
==463==    at 0x48410E4: free (vg_replace_malloc.c:755)
==463==    by 0x418EDF: mfree (alloc-util.h:48)
==463==    by 0x4197E8: dns_query_candidate_free (resolved-dns-query.c:67)
==463==    by 0x4198B7: dns_query_candidate_unref (resolved-dns-query.c:70)
==463==    by 0x41A2E3: dns_query_unref_candidates (resolved-dns-query.c:337)
==463==    by 0x41C5FE: dns_query_cname_redirect (resolved-dns-query.c:1028)
==463==    by 0x41CA04: dns_query_process_cname_one (resolved-dns-query.c:1128)
==463==    by 0x41CA80: dns_query_process_cname_many (resolved-dns-query.c:1157)
==463==    by 0x40C0BD: bus_method_resolve_hostname_complete (resolved-bus.c:198)
==463==    by 0x41B312: dns_query_complete (resolved-dns-query.c:562)
==463==    by 0x41C1AC: dns_query_accept (resolved-dns-query.c:922)
==463==    by 0x41C2C4: dns_query_ready (resolved-dns-query.c:955)
==463==    by 0x41A162: dns_query_candidate_notify (resolved-dns-query.c:314)
==463==    by 0x434BD6: dns_transaction_complete (resolved-dns-transaction.c:437)
==463==    by 0x438995: dns_transaction_prepare (resolved-dns-transaction.c:1728)
==463==    by 0x43921D: dns_transaction_go (resolved-dns-transaction.c:1928)
==463==    by 0x419C7C: dns_query_candidate_go (resolved-dns-query.c:163)
==463==    by 0x41A143: dns_query_candidate_notify (resolved-dns-query.c:304)
==463==    by 0x434BD6: dns_transaction_complete (resolved-dns-transaction.c:437)
==463==    by 0x436A0F: dns_transaction_process_dnssec (resolved-dns-transaction.c:976)
==463==    by 0x4378C1: dns_transaction_process_reply (resolved-dns-transaction.c:1387)
==463==    by 0x437CE9: on_dns_packet (resolved-dns-transaction.c:1444)
==463==    by 0x4B2DC9B: source_dispatch (sd-event.c:3512)
==463==    by 0x4B2FB1F: sd_event_dispatch (sd-event.c:4077)
==463==    by 0x4B2FFFA: sd_event_run (sd-event.c:4138)
==463==    by 0x4B301D6: sd_event_loop (sd-event.c:4159)
==463==    by 0x464A24: run (resolved.c:92)
==463==    by 0x464B3C: main (resolved.c:99)
==463==  Block was alloc'd at
==463==    at 0x483E86F: malloc (vg_replace_malloc.c:380)
==463==    by 0x418F81: malloc_multiply (alloc-util.h:96)
==463==    by 0x419378: dns_query_candidate_new (resolved-dns-query.c:23)
==463==    by 0x41B42C: dns_query_add_candidate (resolved-dns-query.c:582)
==463==    by 0x41BB7A: dns_query_go (resolved-dns-query.c:762)
==463==    by 0x40CE3A: bus_method_resolve_hostname (resolved-bus.c:464)
==463==    by 0x4A84B86: method_callbacks_run (bus-objects.c:414)
==463==    by 0x4A87961: object_find_and_run (bus-objects.c:1323)
==463==    by 0x4A87FEE: bus_process_object (bus-objects.c:1443)
==463==    by 0x4AA3434: process_message (sd-bus.c:2964)
==463==    by 0x4AA3623: process_running (sd-bus.c:3006)
==463==    by 0x4AA4110: bus_process_internal (sd-bus.c:3226)
==463==    by 0x4AA41EF: sd_bus_process (sd-bus.c:3253)
==463==    by 0x4AA5343: io_callback (sd-bus.c:3604)
==463==    by 0x4B2DC9B: source_dispatch (sd-event.c:3512)
==463==    by 0x4B2FB1F: sd_event_dispatch (sd-event.c:4077)
==463==    by 0x4B2FFFA: sd_event_run (sd-event.c:4138)
==463==    by 0x4B301D6: sd_event_loop (sd-event.c:4159)
==463==    by 0x464A24: run (resolved.c:92)
==463==    by 0x464B3C: main (resolved.c:99)

Fixes #19376.

(cherry picked from commit c856ef0457c35e9edfdbf085b69ec81c126d48e5)
(cherry picked from commit 89324e233eef767334d9bfe5eed96956c973c2ad)

4 years agonetwork:dhcp4_server_configure returns if not able to get timezone
tramsay [Mon, 5 Apr 2021 22:12:49 +0000 (17:12 -0500)]
network:dhcp4_server_configure returns if not able to get timezone

When /etc/localtime is a symbolic link pointing to another symbolic
link, get_timezone will return -EINVAL instead of the timezone.
This issue can cause systemd-networkd DHCPServer to fail.

Instead of returning failure, log a warning indicating that that
the timezone will not be sent.

modified:   networkd-dhcp-server.c

(cherry picked from commit 7b5018ca9e6d3279887ec7113818f41d5b831c4d)
(cherry picked from commit 37c4cfde0ce613f0f00544d3f4e2e72bf93d9c76)

4 years agomeson: call find_program() once and reuse the variable everywhere
Zbigniew Jędrzejewski-Szmek [Fri, 14 May 2021 12:16:17 +0000 (14:16 +0200)]
meson: call find_program() once and reuse the variable everywhere

Meson 0.58 has gotten quite bad with emitting a message every time
a quoted command is used:
Program /home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh found: YES (/home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program xsltproc found: YES (/usr/bin/xsltproc)
Configuring custom-entities.ent using configuration
Message: Skipping bootctl.1 because ENABLE_EFI is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Message: Skipping journal-remote.conf.5 because HAVE_MICROHTTPD is false
Message: Skipping journal-upload.conf.5 because HAVE_MICROHTTPD is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Message: Skipping loader.conf.5 because ENABLE_EFI is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
...

Let's suffer one message only for each command. Hopefully we can silence
even this when https://github.com/mesonbuild/meson/issues/8642 is
resolved.

(cherry picked from commit 596f5101f29c10256208132bfa9c502bf898fd8b)

4 years agorun: update checks to allow running with a user's bus
Anita Zhang [Thu, 13 May 2021 08:17:51 +0000 (01:17 -0700)]
run: update checks to allow running with a user's bus

systemd-run is documented to as being able to connect and run on a
specific user bus with "--user --machine=lennart@.host" arguments.
This PR updates some logic that prevented this from working.

(cherry picked from commit cbdc29492097e24ef3320280bc2a8dedbce02d9a)
(cherry picked from commit cc589cce9815cabb0bed6d0695ec3ff77beebd06)

4 years agoresolved.conf.in: add missing Quad9 servers
Michael Catanzaro [Tue, 11 May 2021 13:24:55 +0000 (08:24 -0500)]
resolved.conf.in: add missing Quad9 servers

The example configuration is missing half of Quad9's addresses.

(cherry picked from commit aa2b370dddc7e37df33769a488d6c3dce89b4e17)
(cherry picked from commit 4b8d52f4f09fe7f514cc982ad945153565503127)

4 years agoresolved: be more careful with weird links with low MTUs
Lennart Poettering [Tue, 11 May 2021 20:21:52 +0000 (22:21 +0200)]
resolved: be more careful with weird links with low MTUs

Apparently CAN links will show up in rtnetlink with very low MTUs. We
shouldn't consider them relevant if no IP is spoken over them, since
these MTUs are irrelevant for us then.

Hence, let's check if there's an address assigned to the link before
considering its MTU.

As additional safety net filter out MTUs smaller than the minimum DNS
packet size, too.

Finally, in case we don't find any suitable interface MTU, let's default
to 1500 as the generic Ethernet MTU.

Fixes: #19396
(cherry picked from commit 5a0d0b8f9cdfcbb82c4a89b28f0ebce414c9ecfe)
(cherry picked from commit 3fd268d20979850a70453ed5f8891a0f03344bf2)

4 years agoresolved: add udp_header_size() helper
Lennart Poettering [Mon, 16 Nov 2020 20:00:24 +0000 (21:00 +0100)]
resolved: add udp_header_size() helper

(cherry picked from commit 4565863fff974e69d23a7c5a5237528bc5573a17)

4 years agocore: don't accidentally unref a varlink connection twice
Lennart Poettering [Fri, 12 Mar 2021 21:21:58 +0000 (22:21 +0100)]
core: don't accidentally unref a varlink connection twice

Let's make sure that our close handler unrefs a connection again that we
are already unreffing a few stack frames up by invalidating the pointer
first, and dropping the ref counter only after that.

Replaces: 39ad3f1c092b5dffcbb4b1d12eb9ca407f010a3c

Fixes: #18025
(cherry picked from commit d65e974e67e47222cdebd9d0b6becd6642547ce2)
(cherry picked from commit 68da6997a9323c127a45ca019d32fa97ff0d7cca)

4 years agoRevert "varlink: avoid using dangling ref in varlink_close_unref()"
Lennart Poettering [Fri, 12 Mar 2021 21:21:40 +0000 (22:21 +0100)]
Revert "varlink: avoid using dangling ref in varlink_close_unref()"

This reverts commit 39ad3f1c092b5dffcbb4b1d12eb9ca407f010a3c.

(cherry picked from commit cc6b0a18ff73325e2ecf0c5d857f4fdca75d97b4)
(cherry picked from commit 906b89a284308a64e599e7e4230763bb60a16895)

4 years agopam: fix typo try_authtok → use_authtok
Lennart Poettering [Wed, 12 May 2021 08:33:27 +0000 (10:33 +0200)]
pam: fix typo try_authtok → use_authtok

This was a copy/paste mistae apparently, there's not "try_authtok" and
this was supposed to copy what Fedora uses, which uses "use_authtok"
correctly. Hence adjust this.

Fixes: #19369
(cherry picked from commit 971c07fc6812315c2b27015dfcc652a747f919ed)
(cherry picked from commit ca276dcddc4def7348e2cb897fbf7a8b26bfc5ed)

4 years agobootctl: same entry path check case-insensitive
zsien [Mon, 10 May 2021 07:42:54 +0000 (15:42 +0800)]
bootctl: same entry path check case-insensitive

Some motherboards convert the path to uppercase under certain circumstances
(e.g. after booting into the Boot Menu in the ASUS ROG STRIX B350-F GAMING).

(cherry picked from commit 5c2e5957678462d871c5c2ea5261becec5f8f80f)
(cherry picked from commit 379679f807072b4d554711bc61b769d72ecc98d6)

4 years agoman: network: use `networkctl list` instead of `status` to list network interface...
Lucas Magasweran [Mon, 10 May 2021 08:11:28 +0000 (10:11 +0200)]
man: network: use `networkctl list` instead of `status` to list network interface type

To determine the network interface type for use in the `Type=` directive, it is more concise to use the `list` command. Whereas, the `status` command requires an interface parameter.

For example, on a RaspberryPi 4 the following shows that the `wlan0` interface type `wlan` is more coveniently listed by the `list` command.

```
root@raspberrypi4-64:~# networkctl list
IDX LINK  TYPE     OPERATIONAL SETUP
  1 lo    loopback carrier     unmanaged
  2 eth0  ether    routable    configured
  3 wlan0 wlan     off         unmanaged

3 links listed.
```

Whereas the `networkctl status` command doesn't include this information.

```
root@raspberrypi4-64:~# networkctl status
●   State: routable
  Address: 192.168.1.141 on eth0
           fd8b:8779:b7a4::f43 on eth0
           fd8b:8779:b7a4:0:dea6:32ff:febe:d1ce on eth0
           fe80::dea6:32ff:febe:d1ce on eth0
  Gateway: 192.168.1.1 (CZ.NIC, z.s.p.o.) on eth0
      DNS: 192.168.1.1

May 07 14:17:18 raspberrypi4-64 systemd-networkd[212]: eth0: Gained carrier
May 07 14:17:19 raspberrypi4-64 systemd-networkd[212]: eth0: Gained IPv6LL
May 07 14:17:19 raspberrypi4-64 systemd-networkd[212]: eth0: DHCPv6 address fd8b:8779:b7a4::f43/128 timeout preferred -1 valid -1
May 07 14:17:21 raspberrypi4-64 systemd-networkd[212]: eth0: DHCPv4 address 192.168.1.141/24 via 192.168.1.1
```

To get the interface type using the `status` command you need to specify an additional argument.

```
root@raspberrypi4-64:~# networkctl status wlan0
● 3: wlan0
                     Link File: /lib/systemd/network/99-default.link
                  Network File: n/a
                          Type: wlan
                         State: off (unmanaged)
                          Path: platform-fe300000.mmcnr
                        Driver: brcmfmac
                    HW Address: dc:a6:32:be:d1:cf (Raspberry Pi Trading Ltd)
                           MTU: 1500 (min: 68, max: 1500)
                         QDisc: noop
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 1/1
```

(cherry picked from commit 2480ca95bac0f1bed350ba8d5aef1ef92be0f8a4)
(cherry picked from commit 56ba53b17338f37c211a1c1ee0686ff4e5c09d28)

4 years agonetwork: examples: use wlan for Type instead of wifi
Lucas Magasweran [Mon, 10 May 2021 08:09:56 +0000 (10:09 +0200)]
network: examples: use wlan for Type instead of wifi

(cherry picked from commit b419e8776bc2dc1ca113c8332ed465724bff053a)
(cherry picked from commit bf3d671b379cc683375d62f109f133c1703dd828)

4 years agoresolve: remove RRs from zones before an update
Roman Beranek [Fri, 30 Apr 2021 13:51:44 +0000 (15:51 +0200)]
resolve: remove RRs from zones before an update

During an update of RRs, the records of each DNS-SD service are
replaced with new ones. However the old RRs can only be removed from
the mDNS scopes as long as they remain accessible from the DnssdService
structures, otherwise they remain stuck there.

Therefore the removal must take place before the update.

(cherry picked from commit ee3713b71ddf182852a399953968a2b39af22104)
(cherry picked from commit 46ee05ed1fca9c5637ec5cfbb4f71c84f94b3db6)

4 years agonss-systemd: properly handle empty membership lists
Lennart Poettering [Wed, 5 May 2021 16:57:30 +0000 (18:57 +0200)]
nss-systemd: properly handle empty membership lists

When we are queried for membership lists on a system that has exactly
zero, then we'll return ESRCH immediately instead of at EOF. Which is
OK, but we need to handle this in various places, and not get confused
by it.

(cherry picked from commit a1aa41e4e175c2712b97600d7e10e9d6c58e5543)
(cherry picked from commit d0f8a01a74e5a1bed4d687339abde774cb944579)

4 years agonss-systemd: reset the right field
Lennart Poettering [Wed, 5 May 2021 14:05:43 +0000 (16:05 +0200)]
nss-systemd: reset the right field

(cherry picked from commit 1fdfca4da739f47516513afc66d4c7008c9badfd)
(cherry picked from commit 18babc7b290de4c0108b2fe39400c3e9c471ef67)

4 years agosystem-conf: drop reference to ShutdownWatchdogUsec=
Franck Bui [Tue, 27 Apr 2021 08:59:24 +0000 (10:59 +0200)]
system-conf: drop reference to ShutdownWatchdogUsec=

Commit 65224c1d0e50667a87c2c4f840c49d4918718f80 renamed ShutdownWatchdogUsec
into RebootWatchdogUsec but left a reference of ShutdownWatchdogUsec in
system.conf.

(cherry picked from commit 45b1fc3a88b2f5102ecabfabdf0ee4f175aecd64)
(cherry picked from commit 54b5a1b21b69d674e55b69be79ef86e5b2215406)

4 years agosystemctl: hide some empty properties without --all
Frantisek Sumsal [Mon, 26 Apr 2021 20:03:19 +0000 (22:03 +0200)]
systemctl: hide some empty properties without --all

Fixes: #19423
(cherry picked from commit 1ceaad69378272c64da4ecaab0d59ebb7a92ca0a)
(cherry picked from commit af3a3dd2f1360973560d21d1aeec9531e953162a)

4 years agocore/service: also reject deserialized commands with no argv[0]
Zbigniew Jędrzejewski-Szmek [Fri, 23 Apr 2021 10:40:07 +0000 (12:40 +0200)]
core/service: also reject deserialized commands with no argv[0]

I'm pretty sure that bad things would happen later on.

(cherry picked from commit 90204792461030dbc8645d8511e7ac8d1b4f1ca2)
(cherry picked from commit d113fd4e0756b1b6f5543a47d0943af4564293ff)

4 years agocore/service: fix deserialization of non-absolute commands
Zbigniew Jędrzejewski-Szmek [Fri, 23 Apr 2021 10:39:03 +0000 (12:39 +0200)]
core/service: fix deserialization of non-absolute commands

We'd fail with:
Apr 23 10:58:26 systemd[1]: Deserializing state...
Apr 23 10:58:26 systemd[1]: testsuite-01.service: Failed to parse serialized command "ExecStart 0 sh "sh" "-e" "-x" "-c" "systemctl --state=failed --no-legend --no-pager >/failed ; systemctl daemon-reload ; echo OK >/testok"": Invalid argument
Apr 23 10:58:26 systemd[1]: testsuite-01.service: Reinstalled deserialized job testsuite-01.service/start as 209

This was missed in 5008da1ec1, and apparently nobody noticed until now :(

(cherry picked from commit 1a128a468ddd1070651478c36eae76e31f580b67)
(cherry picked from commit 27606d5448dcaef17d256ced7e89b963a13cfec4)

4 years agonetwork: update comment and log message
Yu Watanabe [Mon, 26 Apr 2021 00:03:33 +0000 (09:03 +0900)]
network: update comment and log message

After 4b30f2e135ee84041bb597edca7225858f4ef4fb, reading stable_secret
sysctl property fails with -ENOMEM, instead of -EIO.
This is due to read_full_virtual_file() uses read() as the backend while
read_one_line_file() uses fgetc(). And each functions return different
error on fails.

Anyway, the failure is harmless here. So, the log message and comment is
updated.

Closes one of the issues in #19410.

(cherry picked from commit 0e27527170aa0179f2a4b3b55b78ddc049f815b9)
(cherry picked from commit 2417e9b59aa654e4b3def3399576ebbc2cdd7c95)

4 years agocore: allow services stuck in reloading state to exit
Peter Morrow [Tue, 13 Apr 2021 16:20:42 +0000 (17:20 +0100)]
core: allow services stuck in reloading state to exit

If a service is in reloading state but has exited do not delay
the final exit until the service reload timer expires. Instead allow
the service to exit immediately since we can't expect the service to
ever transition out of reloading state.

For example if a service sent RELOADING=1 but crashed before it could
send READY=1 then it should be restarted if the service had
Restart= configured.

Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
(cherry picked from commit bbe19f68846bb3cd5fcf3e4f612268064df53b53)
(cherry picked from commit f5ea4ced2e4fb61bc2940b1b82540bb87e3fa0c9)

4 years agofix: point to the correct drop-ins subdirectory for confs
Jóhann B. Guðmundsson [Wed, 21 Apr 2021 21:09:29 +0000 (21:09 +0000)]
fix: point to the correct drop-ins subdirectory for confs

(cherry picked from commit eb34cce1787259de4cea1430fa017b6bd25bc4c1)
(cherry picked from commit 3d896e8b03b39c5bd68ef026536acb7496ae995f)

4 years agoman: dedent examples in sd-id128 to 2 columns
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 13:09:22 +0000 (15:09 +0200)]
man: dedent examples in sd-id128 to 2 columns

In man pages, horizontal space it at premium, and everything should
generally be indented with 2 spaces to make it more likely that the
examples fit on a user's screen.

C.f. 798d3a524ea57aaf40cb53858aaa45ec702f012d.

(cherry picked from commit e0a41aa4c6674f04723388c05b7cd81cc2ffd613)
(cherry picked from commit 80a7922d16c9f4b7964342dcd99d66f1ab006777)

4 years agojournald: enforce longer line length limit during "setup" phase of stream protocol
Yangyang Shen [Wed, 24 Mar 2021 13:23:01 +0000 (21:23 +0800)]
journald: enforce longer line length limit during "setup" phase of stream protocol

This PR made modification on Lennart Poettering's basis. Fix the LineMax's function failure problem.

Signed-off-by: Yangyang Shen <shenyangyang4@huawei.com>
(cherry picked from commit 80e9720616df0eeaba75874fd86fbfbe8b7a03a7)
(cherry picked from commit 9d5c5e4fab6e4816babbd4b74787b43fa5e4440a)

4 years agosd-device: use right clock when comparing initialization usec
Lennart Poettering [Tue, 20 Apr 2021 13:56:03 +0000 (15:56 +0200)]
sd-device: use right clock when comparing initialization usec

we actually use CLOCK_MONOTONIC for the timestamp, hence when
comparing/subtracting it from the current time, also use
CLOCK_MONOTONIC.

(cherry picked from commit 02ef01ade3b16c05dfc8698181d7f562f4934ef3)
(cherry picked from commit 873ad71291e942054dd96ca1a9000cc98f21487a)

4 years agosd-device: use right type for usec_initialized
Lennart Poettering [Tue, 20 Apr 2021 15:06:21 +0000 (17:06 +0200)]
sd-device: use right type for usec_initialized

(cherry picked from commit a156eb89c827206ee5b51d53016ba63be0c90449)
(cherry picked from commit d6b0efcdd83a937363267ed751fd9a1085505394)

4 years agodocument DefaultOOMPolicy
Miroslav Suchý [Tue, 20 Apr 2021 08:23:01 +0000 (10:23 +0200)]
document DefaultOOMPolicy

the `man systemd.service` say:
   Defaults to the setting DefaultOOMPolicy= in systemd-system.conf(5) is set to
but there is no such line in this config.
This is the default value I extracted from
   systemctl show --property=DefaultOOMPolicy

(cherry picked from commit 0084d4f6b58f70c9955fa2259c29d65d87e1e855)
(cherry picked from commit 48027216bdc1d77f208f3606c05489046ea30ace)

4 years agowifi-util: do not set zero errno to log_debug_errno()
Yu Watanabe [Tue, 20 Apr 2021 00:23:33 +0000 (09:23 +0900)]
wifi-util: do not set zero errno to log_debug_errno()

(cherry picked from commit 66205cb3f597e43c8446d122fa4cc849c4f101d7)
(cherry picked from commit 8eaf2da0f6c9fbea42d44343c30361dcf79702bf)

4 years agodissect: ext4 and loopback files are unimpressed by read-only access
Lennart Poettering [Mon, 19 Apr 2021 20:47:33 +0000 (22:47 +0200)]
dissect: ext4 and loopback files are unimpressed by read-only access

Even if we set up a loopback device read-only and mount it read-only
this means nothing, ext4 will still write through to the backing storage
file.

Yes, I lost 6h debugging time on this.

Apparently, we have to specify "norecovery" when mounting such file
systems, to force them into truly read-only mode. Let's do so.

(cherry picked from commit b620bf332f575ba9b8e4cd60c93446a0c35c23e8)
(cherry picked from commit 8c7bc71e772899a401b377711b63de32a67c951d)

4 years agorepart: deal with empty partition label sensibly
Lennart Poettering [Fri, 19 Mar 2021 21:45:15 +0000 (22:45 +0100)]
repart: deal with empty partition label sensibly

libfdisk appears to return NULL when encountering an empty partition
label, let's handle this sanely, and treat NULL and "" for the current
label as the same, but for the new label as distinct: there NULL means
nothing is set, and "" means an actual empty label.

(cherry picked from commit be9ce0188ebb414319f0c003f805ea02b5eb473e)
(cherry picked from commit b3b84982d0e72d3160ff7ecb6193c6439c1fc27e)

4 years agorepart: handle DISCARD failing with EBUSY gracefully
Lennart Poettering [Fri, 19 Mar 2021 21:25:09 +0000 (22:25 +0100)]
repart: handle DISCARD failing with EBUSY gracefully

(cherry picked from commit 22163eb51b682afe969f9381d56315dade874ec1)
(cherry picked from commit da72383bf769e83af7ba94d51dad8ac62b5754eb)

4 years agorepart: fix incorrect error code propagation
Lennart Poettering [Mon, 19 Apr 2021 15:35:54 +0000 (17:35 +0200)]
repart: fix incorrect error code propagation

(cherry picked from commit a0ff9971802b664aaa12481c46cec11eae77ea51)
(cherry picked from commit a9b9f49b089f297b8ba2acf2b71f7fbd71f65e21)

4 years agoshell-completion: use base.lst, not xorg.lst
Peter Hutterer [Tue, 20 Apr 2021 07:09:48 +0000 (17:09 +1000)]
shell-completion: use base.lst, not xorg.lst

Since 2005 xorg.lst has been the legacy symlink to the real file base.lst.

(cherry picked from commit 7a4afd3a15f201a2230dce1f640fc37d18bc39ac)
(cherry picked from commit 6b5621353981ee36280e6c4f08540fc24c19ca26)

4 years agosd-login: fix wrong constructor used in sd_login_monitor manpage example
Jason Francis [Mon, 19 Apr 2021 16:16:26 +0000 (12:16 -0400)]
sd-login: fix wrong constructor used in sd_login_monitor manpage example

(cherry picked from commit 941c5275eaaf8d22915eb876045d2173bdbb7d4c)
(cherry picked from commit 17cb088d6dd3ac940a299c6c7201085252f1367d)

4 years agosd-login: correct prototype of sd_peer_get_cgroup
Jason Francis [Mon, 19 Apr 2021 16:13:03 +0000 (12:13 -0400)]
sd-login: correct prototype of sd_peer_get_cgroup

(cherry picked from commit a8310e39e996b9b5f63d897879aecf8988261bdb)
(cherry picked from commit fa7f835f79d4da8ee6d7403be43a0ba4d24b9fb2)

4 years agofileio: use take_fdopen_unlocked()
Yu Watanabe [Fri, 16 Apr 2021 01:08:36 +0000 (10:08 +0900)]
fileio: use take_fdopen_unlocked()

This fixes maybe-uninitialized warning:
```
../src/basic/fileio.c: In function ‘chase_symlinks_and_fopen_unlocked’:
../src/basic/fileio.c:1026:19: warning: ‘f’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1026 |         *ret_file = f;
      |         ~~~~~~~~~~^~~

```

(cherry picked from commit 6604fb0207ee10e8dc05d67f6fe45de0b193b5c4)
(cherry picked from commit 277277cbf0386be082555f92b5fce0521fee17b3)

4 years agoman: correct requirements for systemd-oomd.service
Anita Zhang [Fri, 16 Apr 2021 07:42:44 +0000 (00:42 -0700)]
man: correct requirements for systemd-oomd.service

Fixes: #19331
(cherry picked from commit 169be51f94b7017fea1394dcb412d3afdfd7cea5)
(cherry picked from commit 7208e7465b6cb1563cad46f568c78c725790d237)

4 years agojournald: fix %m usage
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 20:06:02 +0000 (22:06 +0200)]
journald: fix %m usage

(cherry picked from commit cf5a2ee82517429a34d9f5bef853cabe055e3e59)
(cherry picked from commit 4186be9a05e162c04d1b72a9ba95224c0a9aa2c3)

4 years agoshared/module-util: fix errno value passed to log function
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 15:10:36 +0000 (17:10 +0200)]
shared/module-util: fix errno value passed to log function

If r == 0, no harm done. But if r > 0, this would be interpreted as an
errno value, wrongly.

(cherry picked from commit a2eb2267e44580446ecad37e7206e729cfd78155)
(cherry picked from commit e70a773f85ceb64435de3d47c12b07c08605f591)

4 years agopartition, random-seed, logind: fix log messages with %m
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 10:14:01 +0000 (06:14 -0400)]
partition, random-seed, logind: fix log messages with %m

We would print "...: Success", which is not too terrible, but not pretty
either.

(cherry picked from commit 111a3aae71fa019710216cc5b7aa95b7c8db0937)
(cherry picked from commit c032a26df67903e0c65150b5cc68ade35aa47c03)

4 years agosd-device: improve log message and tweak style
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 09:54:17 +0000 (05:54 -0400)]
sd-device: improve log message and tweak style

We shouldn't say the attribute is missing right after ruling out ENOENT.

(cherry picked from commit aca591ac55e5ee364905aec975388c5e30d0476c)
(cherry picked from commit e31914aa17df889ae10f0964a8bbc8c00e0f045b)

4 years agotest: use systemd-run --wait in TEST-44-LOG-NAMESPACE
Luca Boccassi [Wed, 14 Apr 2021 20:26:50 +0000 (21:26 +0100)]
test: use systemd-run --wait in TEST-44-LOG-NAMESPACE

The test appears to be occasionally failing. It uses systemd-run to echo
'hello world' into a namespaced journal and then uses journalctl to look for it,
but it doesn't wait.
In the failed runs it can't find it, but the automated journal dump shows
the message at the end.

Use --wait to avoid races.

(cherry picked from commit cf9844ffabd7fd51f22e729692b79d55cd7bdd76)
(cherry picked from commit 2c17e13ae48b94a0fd02c7746d723b26a0f3dc65)

4 years agolibsystemd-network: fix dhcp option buffer confusion
Zbigniew Jędrzejewski-Szmek [Wed, 14 Apr 2021 08:55:09 +0000 (04:55 -0400)]
libsystemd-network: fix dhcp option buffer confusion

We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a306fd2ba454d3ee333d63df71aa3873.

(cherry picked from commit 828b603a791edd04a5c3603456aa8caca44ce67e)
(cherry picked from commit cd1fc467f72e607bcd2464651b68f31bd2a8791a)

4 years agomeson.build: typo
Sevan Janiyan [Wed, 14 Apr 2021 23:01:53 +0000 (00:01 +0100)]
meson.build: typo

(cherry picked from commit d5b3e5104448ebfecd334c26dbdd3a8274440b1e)
(cherry picked from commit 812384ce37acd909d70f9295a3b0fce98c8cf840)

4 years agorfkill: add some casts to silence -Werror=sign-compare
Luca Boccassi [Tue, 13 Apr 2021 12:17:53 +0000 (13:17 +0100)]
rfkill: add some casts to silence -Werror=sign-compare

(cherry picked from commit ab1aa6368a883bce88e3162fee2bea14aacedf23)

Fixes https://github.com/systemd/systemd-stable/issues/101.

(cherry picked from commit 074475abc1d6187de88b77dcc4fe0c4d2ab804f5)

4 years agonetwork: add missing default setting in networkd.conf
Yu Watanabe [Sun, 11 Apr 2021 12:25:16 +0000 (21:25 +0900)]
network: add missing default setting in networkd.conf

(cherry picked from commit 6bfadad9bb6eaf614da92eba0a9b6243e8645018)
(cherry picked from commit ee24f9346630b6d59e88ef0989f943444e752569)

4 years agoudev: delete useless codes
gaoyi [Tue, 13 Apr 2021 10:59:46 +0000 (18:59 +0800)]
udev: delete useless codes

It seems no one will touch queue.bin

(cherry picked from commit 993eb00016a75cf085eed85cf626a6995e96ab3d)
(cherry picked from commit a511010f380397e8bb08816288e31b1666dc11b9)

4 years agoload-fragment: parse specifiers in CPUAffinity= (#19281)
Francois Gervais [Mon, 12 Apr 2021 22:25:29 +0000 (18:25 -0400)]
load-fragment: parse specifiers in CPUAffinity= (#19281)

(cherry picked from commit 54cfe9a75f0e84d0604d39b87b1d919542336809)
(cherry picked from commit bf3bd598136397b5371188bcdec0127e56a1db9a)

4 years agomeson: do not fail if rsync is not installed with meson 0.57.2
Zbigniew Jędrzejewski-Szmek [Mon, 12 Apr 2021 12:03:32 +0000 (14:03 +0200)]
meson: do not fail if rsync is not installed with meson 0.57.2

https://github.com/mesonbuild/meson/issues/8641

Our CI started to fail. Even if the change is reverted in meson,
we need a quick workaround here.

(cherry picked from commit 7c5fd25119a495009ea62f79e5daec34cc464628)
(cherry picked from commit f6435a07c1ca4b895573eba4a64dcf4bef3fb92b)

4 years agosd-device: header needs an include because it uses sd_device type
Zbigniew Jędrzejewski-Szmek [Thu, 1 Apr 2021 08:09:11 +0000 (10:09 +0200)]
sd-device: header needs an include because it uses sd_device type

(cherry picked from commit 023e75df4c2904e493c4c8ff62df9fa99709d408)
(cherry picked from commit 004ab84cf201af928aa5d795ef89aa815b7e1776)

4 years agobpf-firewall: attach with BPF_F_ALLOW_MULTI if kernel supports
Julia Kartseva [Thu, 4 Feb 2021 06:15:27 +0000 (22:15 -0800)]
bpf-firewall: attach with BPF_F_ALLOW_MULTI if kernel supports

Reduced version of [0].
Use BPF_F_ALLOW_MULTI attach flag for bpf-firewall if kernel supports
it.

Aside from addressing security issue in [0] attaching with 'multi'
allows further attaching of cgroup egress, ingress hooks specified by
BPFProgram=.

[0] https://github.com/systemd/systemd/pull/17495/commits/4e42210d40f96e185a55d43041dd6b962ea830dd

(cherry picked from commit a442ccb4ebdbc3a9ff9d4504eb9724092149fd42)
(cherry picked from commit 0af3810d4b1c8bb4f0683758f47e042e8cb76972)

4 years agoman: fix discriptions for --exec-delay
gaoyi [Mon, 12 Apr 2021 08:09:47 +0000 (16:09 +0800)]
man: fix discriptions for --exec-delay

There are two ambiguity in the original description:
1. It will delay all RUN instructions, include builtin.
2. It will delay before running RUN, not each of RUN{program} instructions.

(cherry picked from commit 45f5efdea7e5e94bd47fc24b9bd404c77b5771a0)
(cherry picked from commit cb92f5601ad169e8f86a61319b73a8fd9e19950b)

4 years agotest-repart: use cryptsetup and losetup autoclose
Luca Boccassi [Fri, 9 Apr 2021 09:56:13 +0000 (10:56 +0100)]
test-repart: use cryptsetup and losetup autoclose

The test occasionally fails as the umount is not yet completed when
cryptsetup close is invoked.
Both cryptsetup and losetup have supported deferred cleanup for some
time now, so use it instead to avoid races.

++ losetup -P --show --find /tmp/test-repart.dMOfYQ8UUF/zzz
+ LOOP=/dev/loop6
+ VOLUME=test-repart-11882
+ touch /tmp/test-repart.dMOfYQ8UUF/empty-password
+ cryptsetup open --type=luks2 --key-file=/tmp/test-repart.dMOfYQ8UUF/empty*** test-repart-11882
+ mkdir /tmp/test-repart.dMOfYQ8UUF/mount
+ mount -t ext4 /dev/mapper/test-repart-11882 /tmp/test-repart.dMOfYQ8UUF/mount
+ diff -r /tmp/test-repart.dMOfYQ8UUF/mount/def /tmp/test-repart.dMOfYQ8UUF/definitions
+ umount /tmp/test-repart.dMOfYQ8UUF/mount
+ cryptsetup close test-repart-11882
Device test-repart-11882 is still in use.
+ rm -rf /tmp/test-repart.dMOfYQ8UUF

(cherry picked from commit 0efcbecd8b266526bf4a8fd06b9b7e7c5c43566d)
(cherry picked from commit 059da06d666c9f3caa7f5ad9d663f6acc430095b)

4 years agoTEST-22-TMPFILES: add reproducer for bug with X
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 20:35:19 +0000 (22:35 +0200)]
TEST-22-TMPFILES: add reproducer for bug with X

(cherry picked from commit 1672be86021b5ae8e80d095409a4fffcba7cbb75)
(cherry picked from commit 280b157fca7b44b19ec0067ebb88d2c16df1b6e1)

4 years agoman: fix quickhelp listing in tmpfiles.d(5)
Zbigniew Jędrzejewski-Szmek [Wed, 7 Apr 2021 16:26:15 +0000 (18:26 +0200)]
man: fix quickhelp listing in tmpfiles.d(5)

Unlike many other small/big letter combos, this one has the recursive
version attached to the lowercase letter.

(cherry picked from commit 3dd61ee5be0291380d341571e138713d2f89125a)
(cherry picked from commit ba8032c414dcf7c627cee3e979654bc5e294def3)

4 years agotmpfiles: use a entry in hashmap as ItemArray in read_config_file()
Masahiro Matsuya [Wed, 31 Mar 2021 02:44:24 +0000 (11:44 +0900)]
tmpfiles: use a entry in hashmap as ItemArray in read_config_file()

[zjs: squash commits and use size_t as appropriate.

Bug seems to have been introduced in 811a15877825da9e53f9a2a8603da34589af6bbb.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1944468.]

(cherry picked from commit bec890e3cd6dac249cb12ce9430fdb78b6cf546b)
(cherry picked from commit b266eeb0aee24a0c5868c3a46066c0329b2d1141)

4 years agomkosi.arch: add rsync build dependency
Luca Boccassi [Sat, 10 Apr 2021 19:13:02 +0000 (20:13 +0100)]
mkosi.arch: add rsync build dependency

Program rsync found: NO

man/meson.build:187:0: ERROR: Program 'rsync' not found

(cherry picked from commit a7b7cab66df8c0a701bc6da3a309fa80c90a880b)
(cherry picked from commit dca590b4b54b3f88919d78645e8c9a4febede850)

4 years agoExtend characters set for PKCS11 URI
Oleg Popov [Sat, 10 Apr 2021 14:21:25 +0000 (17:21 +0300)]
Extend characters set for PKCS11 URI

There are tokens with dots (and other symbols) in PKCS11 URI:

pkcs11:model=Rutoken%20ECP;manufacturer=Aktiv%20Co.;serial=3xxxxxxb;token=livelace
pkcs11:model=PRO;manufacturer=Aladdin%20R.D.;serial=CC62FB25;token=val%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00;id=%33%32%31%30%33%61%36%37%36%65%32%34%35%62%32%31;type=private
(cherry picked from commit b204bdd4ccae2c76422e7383bd51b664d7e2cfd3)
(cherry picked from commit 27eec0eb045b62b19657b7662dd10594362515a2)

4 years agoresolved: add RFC 8375 "home.arpa" to list of default NTA
Lennart Poettering [Sat, 10 Apr 2021 12:58:54 +0000 (14:58 +0200)]
resolved: add RFC 8375 "home.arpa" to list of default NTA

RFC 8375 introduced "home.arpa" as special TLD for home networks. Let's
hence add it to our default list of NTAs.

(cherry picked from commit 1065501406d6ca608444c3bd19db546e82009450)
(cherry picked from commit 8d55dcd0b89c21538ce388da559b0b4b87be7f20)

4 years agounits: install dbus-org.freedesktop.oom1.service alias
Anita Zhang [Sat, 10 Apr 2021 07:50:50 +0000 (00:50 -0700)]
units: install dbus-org.freedesktop.oom1.service alias

Fixes: #18469
(cherry picked from commit b5a80aa9d89cd82e53181cfd3288bba694622786)
(cherry picked from commit ae08aef85f8eae26e715d661ef53acfd2c0241f3)

4 years agogpt-auto-generator: don't generate systemd-cryptsetup@.service when --Dlibcryptsetup...
gaoyi [Tue, 6 Apr 2021 02:44:33 +0000 (10:44 +0800)]
gpt-auto-generator: don't generate systemd-cryptsetup@.service when --Dlibcryptsetup=false

(cherry picked from commit 5b1375035b617bbee8b22a997be527d1b7a392f8)
(cherry picked from commit aa6b8490870d3a793becf41cc63479043a934a73)

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)
(cherry picked from commit 0e6d3243ad3c5ae719c23e14b159c27344523583)

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)
(cherry picked from commit 90aee910f6e6d54e78651ee8a9d95823b88b527d)

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)
(cherry picked from commit f1c0eea4939320b5317f58b9577a6751f289b7fe)

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)
(cherry picked from commit 98365420f25a3b0fdc01937b767e0ef530d2dce7)

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)
(cherry picked from commit b819fff474661d6d43ee47b41031462f9c0a9af4)

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)
(cherry picked from commit 480fd82088ad6e44644c568fe37c5d945738a61b)

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)
(cherry picked from commit 315a28e2c74efe2afb33d70f4bc83dda1424b8a1)

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)
(cherry picked from commit 5ea1cd471149acdce4588a5ca7071d8adbd26adc)

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)
(cherry picked from commit d51d8172d66506448fb1612c85df7b452264e08e)

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)
(cherry picked from commit baa8bd89efa752633805c5b04b02d1dbde5ea0bb)

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
```

(cherry picked from commit 945317a4b69d33752c9513bb8994fe8d5a786ea6)

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.

(cherry picked from commit e355fb6fb1c926d0ac109c35704b301e37172c4e)

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

(cherry picked from commit d83e90c73cf25a839f5e60f355baa0d38364ff41)

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.

(cherry picked from commit 3b0754b16c5535fd48f48ca39f69335ef695efe7)

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

(cherry picked from commit cb6c4f37dc4ade1ed1dea461803ebdceab1e5941)

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
(cherry picked from commit 9b564bbca5fcfb251b7990c8642c82846d09338b)

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)

(cherry picked from commit d2f4a9488ce0847da754614706fadefbca9ed2a4)

4 years agouserdb: honour USERDB_AVOID_SHADOW flag also when iterating
Lennart Poettering [Mon, 3 May 2021 18:06:15 +0000 (20:06 +0200)]
userdb: honour USERDB_AVOID_SHADOW flag also when iterating

(cherry picked from commit 7c67419117f19a85cf3e7e1513c072be2b767a74)
(cherry picked from commit 74fbb83ac2613930f9939f31c9633a97a28da4eb)

4 years agouserdb: add missing 'else'
Lennart Poettering [Fri, 30 Apr 2021 21:09:35 +0000 (23:09 +0200)]
userdb: add missing 'else'

(cherry picked from commit d4f560df4f75d8bc5816a515c000f62cb796fa9f)
(cherry picked from commit c8abe13637cadcd8b91179ab3d8106d91b53ea88)

4 years agouserdb: remove unnecesary repeated if check
Lennart Poettering [Fri, 30 Apr 2021 21:08:55 +0000 (23:08 +0200)]
userdb: remove unnecesary repeated if check

(cherry picked from commit 77fe7d15931cc17c933ae8778c4161112783dc79)
(cherry picked from commit dd8454c17694e6857447f0dd8fb3ff4b409b3bdc)

4 years agouserdb: count NSS records too
Lennart Poettering [Fri, 30 Apr 2021 21:08:21 +0000 (23:08 +0200)]
userdb: count NSS records too

(cherry picked from commit 27a5a22f0354568e1c7e6292689ad947aa16aaac)
(cherry picked from commit 31844743c6b1333317c154e017d7121c5d689f8f)

4 years agosd-device: reject empty driver name
Zbigniew Jędrzejewski-Szmek [Wed, 5 May 2021 15:02:49 +0000 (17:02 +0200)]
sd-device: reject empty driver name

If ":" was the last char in the string, we would call access() on ".../drivers/", which
would pass. It probably doesn't matter, but let's reject this anyway.

(cherry picked from commit 52a89a5f08230439f07c043d59ded1270842137b)
(cherry picked from commit 92e5ba438d48a798807104d8aed4e480c58c6465)

4 years agosd-device: use memdupa_suffix0() where appropriate
Zbigniew Jędrzejewski-Szmek [Wed, 5 May 2021 14:57:39 +0000 (16:57 +0200)]
sd-device: use memdupa_suffix0() where appropriate

No functional change intended.

(cherry picked from commit 3e2d0c6ab2abc0ab85440580931b2462bb73cfda)
(cherry picked from commit 37eeb9c03f86227e94d8e1fa046ca0c0d2b6d237)

4 years agosd-device: minor optimization for sd_device_new_from_device_id()
Yu Watanabe [Sun, 7 Mar 2021 06:24:15 +0000 (15:24 +0900)]
sd-device: minor optimization for sd_device_new_from_device_id()

(cherry picked from commit ff7a8d2938b24cb7ca7b69900395ecf837a43a23)
(cherry picked from commit d7ea7c486a0101dae06a9aca290bfafa46bc1fe2)

4 years agosd-device: do no allocate strings of unknown length on the stack
Zbigniew Jędrzejewski-Szmek [Wed, 5 May 2021 14:49:41 +0000 (16:49 +0200)]
sd-device: do no allocate strings of unknown length on the stack

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33881.

Not only we would duplicate unknown input on the stack, we would do it
over and over. So let's first check that the input has reasonable length,
but also allocate just one fixed size buffer.

(cherry picked from commit e17c95af8e450caacde692875b30675cea75211f)
(cherry picked from commit 5172ef4a58bda5be18dcdbbe0abd2c6bb4f08743)

4 years agomeson: don't fail if latest tag's commit is signed
наб [Fri, 16 Apr 2021 11:00:37 +0000 (13:00 +0200)]
meson: don't fail if latest tag's commit is signed

Today this is v248 with 938bdfc0fa737d86eb3ecc70506e11e5f740e0dc, which,
if you don't know about the github webflow key fails to configure with
  meson.build:724:8: ERROR:  String "gpg: Signature made Tue 30 Mar 2021 22:59:02 CEST\ngpg:                using RSA key 4AEE18F83AFDEB23\ngpg: Can't check signature: No public key\n1617137942\n" cannot be converted to int
or, if you do, with
  meson.build:724:8: ERROR:  String 'gpg: Signature made Tue 30 Mar 2021 22:59:02 CEST\ngpg:                using RSA key 4AEE18F83AFDEB23\ngpg: Good signature from "GitHub (web-flow commit signing) <noreply@github.com>" [unknown]\ngpg: WARNING: This key is not certified with a trusted signature!\ngpg:          There is no indication that the signature belongs to the owner.\nPrimary key fingerprint: 5DE3 E050 9C47 EA3C F04A  42D3 4AEE 18F8 3AFD EB23\n1617137942\n' cannot be converted to int

(cherry picked from commit 2d945027244c02fab8d388353f034a2d82ca151b)
(cherry picked from commit 964a13d17be3426ecf539a5155e2cb8b4c16fb31)

4 years agonetwork: can: do not warn if link does not exist anymore
Yu Watanabe [Thu, 29 Apr 2021 22:00:45 +0000 (07:00 +0900)]
network: can: do not warn if link does not exist anymore

(cherry picked from commit ed52cce33f588bbeb3d7f5d7f5e76a85cf6e4f89)
(cherry picked from commit 8b881617609e530b846faa27a32db070536fb0d4)

4 years agonetwork: drop duplicated link_up_can()
Yu Watanabe [Thu, 29 Apr 2021 21:57:15 +0000 (06:57 +0900)]
network: drop duplicated link_up_can()

(cherry picked from commit f282ce20aaa767f5395b065f2be587cdef3e5491)
(cherry picked from commit 179a92c9d8b2df688764095ce1d242de20ee72fa)

4 years agosd-bus: fix vtable named argument logic
Yu Watanabe [Thu, 29 Apr 2021 19:00:02 +0000 (04:00 +0900)]
sd-bus: fix vtable named argument logic

Fixes #19468.

(cherry picked from commit c068a17f6a18d3ebfabe88fc49e24a923d0bdd0a)
(cherry picked from commit 618b8bfa38873a45704753b882ada90c0f3492c5)

4 years agoClarify that these values are in bytes
Steve Bonds [Thu, 25 Mar 2021 14:40:39 +0000 (07:40 -0700)]
Clarify that these values are in bytes

Similar to `ProcessSizeMax`. The defaults in percentages can be misunderstood to mean the values for these parameters will be in percentages.

(cherry picked from commit 88c2c8a0ba13de31061a22a352410c18ffacab9a)
(cherry picked from commit a9ab73ca9f79d0830e71716359a9710fc165ccca)

4 years agoman: importd also provides the option of import-fs for machinectl (#19477)
syyhao1994 [Fri, 30 Apr 2021 07:55:50 +0000 (15:55 +0800)]
man: importd also provides the option of import-fs for machinectl (#19477)

(cherry picked from commit 96ae72ce1ad41674078e45b197df35ad18041dc2)
(cherry picked from commit 59cde3bba171abfefd8bf25e4ed07d43700c5e84)

4 years agosystemd-coredump: Add conflict with shutdown.target
Alexander Sverdlin [Sun, 18 Apr 2021 23:53:45 +0000 (01:53 +0200)]
systemd-coredump: Add conflict with shutdown.target

Otherwise a coredump started at the inconvinient moment can stop
shutdown.target leaving the system in a halfway-down state:

Pulling in shutdown.target/start from systemd-poweroff.service/start
Added job shutdown.target/start to transaction.
...
Keeping job shutdown.target/start because of systemd-poweroff.service/start
...
[  OK  ] Stopped target Remote File Systems.
shutdown.target: starting held back, waiting for: systemd-networkd.socket
sysinit.target: stopping held back, waiting for: remount_tmp.service
systemd-coredump.socket: Incoming traffic
...
systemd-coredump@0-243-0.service: Trying to enqueue job systemd-coredump@0-243-0.service/start/replace
Added job systemd-coredump@0-243-0.service/start to transaction.
Pulling in systemd-journald.socket/start from systemd-coredump@0-243-0.service/start
Added job systemd-journald.socket/start to transaction.
Pulling in system.slice/start from systemd-journald.socket/start
Added job system.slice/start to transaction.
Pulling in -.slice/start from system.slice/start
Added job -.slice/start to transaction.
Pulling in system-systemd\x2dcoredump.slice/start from systemd-coredump@0-243-0.service/start
Added job system-systemd\x2dcoredump.slice/start to transaction.
Pulling in system.slice/start from system-systemd\x2dcoredump.slice/start
Pulling in shutdown.target/stop from system-systemd\x2dcoredump.slice/start
Added job shutdown.target/stop to transaction.
...
Keeping job systemd-poweroff.service/stop because of umount.target/stop
Keeping job shutdown.target/stop because of systemd-coredump@0-243-0.service/start

(cherry picked from commit 4e947bd04944e58df4103eee4cb8180b5008f143)
(cherry picked from commit e11d3ec13c1ee7af65893e94d09d8b3b66cd99c9)

4 years agonetwork: dhcp4: downgrade log level when interface is removed
Yu Watanabe [Wed, 28 Apr 2021 15:07:09 +0000 (00:07 +0900)]
network: dhcp4: downgrade log level when interface is removed

(cherry picked from commit e558d4f47a9c01b007fc193cabcf0dea8370a5f1)
(cherry picked from commit 0881deb1951a55701cf6ea743132458459e3a650)

4 years agoset boot time from monotonic time (#19444)
caoxia2008cxx [Thu, 29 Apr 2021 09:05:01 +0000 (17:05 +0800)]
set boot time from monotonic time (#19444)

utmp: calculate boot timestamp from monotonic timestamp instead of realtime timestamp
(cherry picked from commit f813b62316395205f4c744cde43885081b5f88ae)
(cherry picked from commit 05a09679982a8062e934a3590fc1c62798dbb82f)

4 years agonetwork: ndisc: fix ipv6 route preference for routes with Gateway=_ipv6ra
Yu Watanabe [Wed, 28 Apr 2021 13:26:48 +0000 (22:26 +0900)]
network: ndisc: fix ipv6 route preference for routes with Gateway=_ipv6ra

(cherry picked from commit 086a351ad9c39f49d050822b28e22aa461edec29)
(cherry picked from commit 4f475a445a87cd5d53b85fac0bb3bad9fcbd6315)

4 years agonetwork: neighbor: downgrade log level
Yu Watanabe [Wed, 28 Apr 2021 13:18:45 +0000 (22:18 +0900)]
network: neighbor: downgrade log level

As commented in the code, kernel sends messages about neighbors after
a link is removed.

(cherry picked from commit 27a213392f642fdd2a9dbce914bbfda9a72aafc1)
(cherry picked from commit beaae1f8d1d958e95117550604aa6462d1a636b8)

4 years agonetwork: link: downgrade log level
Yu Watanabe [Wed, 28 Apr 2021 13:17:39 +0000 (22:17 +0900)]
network: link: downgrade log level

The error is harmless, and will be ignored. Let's downgrade log level.

(cherry picked from commit 83e7c37b19bd36c78b235ac3047b758fcf82ad78)
(cherry picked from commit 1db3be80337b79e3b9afda9d50c61e6aed5aff28)

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)

(cherry picked from commit 7960ba96d165169999b6ee434a90faadb144ea5e)