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

60948 Commits

Author SHA1 Message Date
Nick Rosbrook
efc5612e47 test-network: add a test for renaming device to current altname
(cherry picked from commit f68f644a16)
2023-02-10 20:28:11 +00:00
Nick Rosbrook
7299341bd1 sd-netlink: add a test for rtnl_set_link_name()
Add a test that verifies a deleted alternative name is restored on error
in rtnl_set_link_name().

(cherry picked from commit b338a8bb40)
2023-02-10 20:28:11 +00:00
Nick Rosbrook
c6722b6975 udev: attempt device rename even if interface is up
Currently rename_netif() will not attempt to rename a device if it is
already up, because the kernel will return -EBUSY unless live renaming
is allowed on the device. This restriction will be removed in a future
kernel version [1].

To cover both cases, always attempt to rename the interface and return 0
if we get -EBUSY.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=bd039b5ea2a9

(cherry picked from commit 53584e7b61)
2023-02-10 20:28:11 +00:00
Nick Rosbrook
42d8817bd6 sd-netlink: restore altname on error in rtnl_set_link_name
If a current alternative name is to be used to rename a network
interface, the alternative name must be removed first. If interface
renaming fails, restore the alternative name that was deleted if
necessary.

(cherry picked from commit 4d600667f8)
2023-02-10 20:28:11 +00:00
Nick Rosbrook
3dc5b19f10 sd-netlink: do not swap old name and alternative name
Commit 434a348380 ("netlink: do not fail when new interface name is
already used as an alternative name") added logic to set the old
interface name as an alternative name, but only when the new name is
currently an alternative name. This is not the desired outcome in most
cases, and the important part of this commit was to delete the new name
from the list of alternative names if necessary.

(cherry picked from commit 080afbb57c)
2023-02-10 20:28:11 +00:00
Nick Rosbrook
7918496dcf udev/net: allow new link name as an altname before renaming happens
When configuring a link's alternative names, the link's new name to-be
is not allowed to be included because interface renaming will fail if
the new name is already present as an alternative name. However,
rtnl_set_link_name will delete the conflicting alternative name before
renaming the device, if necessary.

Allow the new link name to be set as an alternative name before the
device is renamed. This means that if the rename is later skipped (i.e.
because the link is already up), then the name can at least still be
present as an alternative name.

(cherry picked from commit d0b31efc1a)
2023-02-10 20:28:11 +00:00
Yu Watanabe
5ce6c73f2d nss-myhostname: do not return empty result with NSS_STATUS_SUCCESS
Fixes a bug introduced by db50d326a4.

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

(cherry picked from commit 1c3762937e)
2023-02-10 20:28:11 +00:00
Yu Watanabe
7503626feb nss-myhostname: fix inverted condition in
Fixes a bug introduced by db50d326a4.

(cherry picked from commit a3b993ca3f)
2023-02-10 20:28:11 +00:00
msizanoen1
86686e4292 unit: always return 1 in log_kill
This ensures that cg_kill_items returns the correct value to let the
manager know that a process was killed.

(cherry picked from commit 500cd2e83b)
2023-02-10 20:28:11 +00:00
Yu Watanabe
aa7c7f8d58 udev: make get_virtfn_info() provide physical PCI device
Fixes a bug introduced by 78463c6c4f.

Fixes #25545.

(cherry picked from commit cf74e2e16f)
2023-02-10 20:28:11 +00:00
Ilya Leoshkevich
f62e7b4704 bpf: fix restrict_fs on s390x
Linux kernel's bpf-next contains BPF LSM support for s390x. systemd's
test-bpf-lsm currently fails with this kernel.

This is an endianness issue: in the restrict_fs bpf program,
magic_number has type unsigned long (64 bits on s390x), but magic_map
keys are uint32_t (32 bits). Accessing magic_map using 64-bit keys may
work by accident on little-endian systems, but fails hard on big-endian
ones.

Fix by casting magic_number to uint32_t.

(cherry picked from commit 907046282c)
2023-02-10 20:28:11 +00:00
Yu Watanabe
318b6f60b8 network: dhcp-server: do not create DHCPServer object when the DHCP server is running in relaying mode
Follow-up for c95df5879e.

Fixes #26196.

(cherry picked from commit 2cb1cabb41)
2023-02-10 20:28:11 +00:00
Tuetuopay
b0f514ba56 network/dhcp4: accept local subnet routes from DHCP
RFC3442 specifies option 121 (Classless Static Routes) that allow a DHCP
server to push arbitrary routes to a client. It has a Local Subnet
Routes section expliciting the behavior of routes with a null (0.0.0.0)
gateway.

Such routes are to be installed on the interface with a Link scope, to
mark them as directly available on the link without any gateway.

Networkd currently drops those routes, which is against the RFC, as
Linux has proper support for such routes.

Fixes: 7f20627 ("network: dhcp4: ignore gateway in static routes if destination is link-local or in the same network")
(cherry picked from commit 1d84a3c779)
2023-02-10 20:28:11 +00:00
Lennart Poettering
b71ade8779 resolvectl: don't filter loopback DNS server from global DNS server list
"resolvectl status" shows per-link DNS servers separately from global
ones. When querying the global list, it will contain both per-link and
global servers however. Thus, to not show duplicate info we filter all
entries that actually have a non-zero ifindex set (under the assumption
that that's a per-link server).

This doesn't work if people configured 127.0.0.1 as global server
though, as we'll add ifindex 1 to it since
6e32414a66 unconditionally even for global
servers.

Let's address that by excluding entries with ifindex 1 from suppression.
This is safe as resolved ignores loopback ifaces, hence never will have
per-link servers on ifindex 1.

Note that this splits up the "with_ifindex" parameter into a second
parameter "only_global", since they semantically do two different
things. One controls whether we shall expect/parse an ifindex dbus
field. The other controls whether we shall filter all ifindex values set
!= 0. These are effectively always used in conjunction hence making them
the same actually worked. However this is utterly confusing I think,
which as I guess is resulting in the confusion around #25796 (which
removes the whole check)

Replaces: #25796
(cherry picked from commit 889a1b9f4e)
2023-02-10 20:28:11 +00:00
Lennart Poettering
ed26f98f2f resolvectl: fix type of ifindex D-Bus field, and make sure to initialize to zero in all code paths
(cherry picked from commit a5e6c8498c)
2023-02-10 20:28:11 +00:00
msizanoen1
7d4ea095d5 udev: match device tags in rules using current device tags
This ensures that udev scripts using `TAG-="..."` and expecting later
udev rules to honor it will work properly. An use case is removing the
`uaccess` tag from a device without overriding the original file and
ensuring that `73-seat-uaccess.rules` won't run the uaccess builtin later.

(cherry picked from commit 3102499039)
2023-02-10 20:28:11 +00:00
Jia Zhang
6882211df7 boot: don't convert the trailing newline in mangle_stub_cmdline()
It is pretty convenient to add .cmdline using /proc/cmdline like
this:
  --add-section .cmdline=/proc/cmdline --change-section-vma .cmdline=0x25000

However, it always returns a trailing newline, and stub will
convert it to a whitespace by mangle_stub_cmdline() in next boot.
Thus the resulting /proc/cmdline would contain a trailing
whitespace. When /proc/cmdline is used to generate .cmdline again,
the resulting UKI is mangled.

To address this kind of inconvenience, mangle_stub_cmdline() should
skip converting the trailing newline, and try to chomp all the
trailing whitespaces.

Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
(cherry picked from commit 486cf22c35)
2023-02-10 20:28:11 +00:00
Lennart Poettering
f3d620f5d2 docs: remove /dev/tty* confusion
The text said /dev/tty* as a whole was the VT subsystem and that VT is
not supported in containers.

But that's not accurate as /dev/tty* will match /dev/tty too and that
one device node is special and is not related to VT: it always points to
the current process own controlling tty, regardless what that is.

hence, rewrite /dev/tty* as /dev/tty[0-9]*.

(cherry picked from commit 6ae5c39af1)
2023-02-10 20:28:11 +00:00
Lennart Poettering
3856b97f8b units: pull in loop.ko and dm-mod.ko before repart
We want to make use of that when formatting file systems, hence let's
pull in these modules explicitly.

(This is necessary because we are an early boot service that might run
before systemd-tmpfiles-dev.service, which creates /dev/loop-control and
/dev/mapper/control.)

Alternatively we could just order ourselves after
systemd-tmpfiles-dev.service, but I think there's value in adding an
explicit minimal ordering here, since we know what we'll need.

Fixes: #25775
(cherry picked from commit ce7dcfd6b0)
2023-02-10 20:28:11 +00:00
Lennart Poettering
67467efd58 units: change modprobe@dm-mod.service → modprobe@dm_mod.service
Follow-up for 8f1359bf85

(cherry picked from commit 143a1f1039)
2023-02-10 20:28:11 +00:00
Lennart Poettering
2d495affef pcrphase: gracefully exit if TPM2 support is incomplete
If everything points to the fact that TPM2 should work, but then the
driver fails to initialize we should handle this gracefully and not
cause failing services all over the place.

Fixes: #25700
(cherry picked from commit 0318d54539)
2023-02-10 20:28:11 +00:00
Yu Watanabe
c6f2f5a90d sleep: enumerate only existing and non-device batteries
The enumerator is now mostly consistent with on_ac_power() in
udev-util.c.

(cherry picked from commit fe8e0f8e79)
2023-02-10 17:00:49 +01:00
Yu Watanabe
6753be212f sleep: fix indentation
(cherry picked from commit 3332cfe176)
2023-02-10 17:00:49 +01:00
Yu Watanabe
036b72b593 sleep: introduce siphash24_compress_id128()
Also, rename get_battery_identifier() to siphash24_compress_device_sysattr().

This also makes any errors in sd_id128_get_machine() or id128_get_product()
ignored. For the machine ID, the failure should not be significant unless
the file stored in the discharge level is reused by another system, which
is quite unusual. For the product ID, if the firmware provides useless
ID (all zero or all 0xFF), then loading/storing the discharge rate
becomes completely broken, that should be avoided.

Note, now sysattrs are used instead of properties in uevent files, but
both provide the same information, hence no functionality should be
changed.

(cherry picked from commit a7795a4ecf)
2023-02-10 17:00:49 +01:00
Yu Watanabe
a251e6aa47 sleep: simplify code a bit
- use device_get_sysattr_int(),
- drop redundant log message.

(cherry picked from commit 3d9ca76f36)
2023-02-10 17:00:49 +01:00
Yu Watanabe
b84a05fc57 sleep: coding style fixlets
(cherry picked from commit 3c3f46013e)
2023-02-10 17:00:49 +01:00
Yu Watanabe
eea08d150c sleep: introduce SuspendEstimationSec=
Before v252, HibernateDelaySec= specifies the maximum timespan that the
system in suspend state, and the system hibernate after the timespan.

However, after 96d662fa4c, the setting is
repurposed as the default interval to measure battery charge level and
estimate the battery discharging late. And if the system has enough
battery capacity, then the system will stay in suspend state and not
hibernate even if the time passed. See issue #25269.

To keep the backward compatibility, let's introduce another setting
SuspendEstimationSec= for controlling the interval to measure
battery charge level, and make HibernateDelaySec= work as of v251.

This also drops implementation details from the man page.

Fixes #25269.

(cherry picked from commit 4f58b656d9)
2023-02-10 17:00:49 +01:00
Yu Watanabe
1baf68d728 sleep: drop unnecessary temporal vaiable and initialization
(cherry picked from commit 2ed56afeb3)
2023-02-10 17:00:49 +01:00
Yu Watanabe
792a1be91c sleep: fetch_batteries_capacity_by_name() does not return -ENOENT
(cherry picked from commit d812e104c7)
2023-02-10 17:00:49 +01:00
Yu Watanabe
40c997ae1d sleep: rename hibernate_delay_sec -> _usec
(cherry picked from commit 3d23df005e)
2023-02-10 17:00:49 +01:00
Yu Watanabe
856a02f338 rules: add missing line continuation
Fixes a bug introduced by 953c928c24.

Fixes #25811.

(cherry picked from commit de8409ac43)
2023-02-10 17:00:49 +01:00
Luca Boccassi
61f5710d0b packit: remove ukify handling
added in v253
2023-01-26 09:12:21 +01:00
Daan De Meyer
4dc37994e2 test-execute: Skip when /sys is read-only
The test depends on /sys being writable, so let's skip it when /sys
is read-only.

(cherry picked from commit 34b5977015)
2023-01-26 09:12:21 +01:00
Michael Biebl
9605a45763 test: skip firstboot --prompt-keymap check if keymaps are missing
Fixes: #26165
(cherry picked from commit d173c9ebb0)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
8f84df0da3 partition: fix build with newer linux/btrfs.h uapi header
linux/btrfs.h needs  to be included after sys/mount.h, as since [0]
linux/btrfs.h includes linux/fs.h causing build errors:

```
In file included from /usr/include/linux/fs.h:19,
                 from ../src/basic/linux/btrfs.h:29,
                 from ../src/partition/growfs.c:6:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
   35 |   MS_RDONLY = 1,                /* Mount read-only.  */
      |   ^~~~~~~~~
[1222/2169] Compiling C object systemd-creds.p/src_creds_creds.c.o
ninja: build stopped: subcommand failed.
```

See: https://github.com/systemd/systemd/issues/8507

[0] a28135303a

(cherry picked from commit ed614f17fc)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
240513ceca basic/linux: update linux uapi headers
IPPROTO_L2TP was moved from linux/l2tp.h to linux/in.h [0], so let's
reflect that change to fix build with newer kernels:

```
In file included from ../src/libsystemd/sd-netlink/netlink-types-genl.c:10:
../src/basic/linux/l2tp.h:16: error: "IPPROTO_L2TP" redefined [-Werror]
   16 | #define IPPROTO_L2TP            115
      |
In file included from ../src/libsystemd/sd-netlink/netlink-types-genl.c:3:
/usr/include/netinet/in.h:85: note: this is the location of the previous definition
   85 | #define IPPROTO_L2TP            IPPROTO_L2TP
      |
cc1: all warnings being treated as errors
```

When at it, update the rest of the headers we ship as well.

[0] 65b32f801b

(cherry picked from commit a95ff98ec4)
2023-01-26 09:12:21 +01:00
Nick Rosbrook
9b42646b22 test: handle Debian's /etc/default/locale in testsuite-74.firstboot.sh
This handles a Debian-specific quirk where /etc/default/locale is used
instead of /etc/locale.conf. There is currently special handling for
this in testsuite-73.sh, so the quirk should be handled here too for
consistency.

(cherry picked from commit bb59fdc1e3)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
97ebe90879 test: cover some interactive/error paths in firstboot
(cherry picked from commit dbd8dbdfc1)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
ddc1898ebd test: re-enable skipped systemd-firstboot --locale-messages= test
Since the original issue should be resolved by #25253.

(cherry picked from commit 59377dbef2)
2023-01-26 09:12:21 +01:00
Nick Rosbrook
07e4787106 test: make sure mount point exists in testsuite-64.sh
(cherry picked from commit 84e5b9225d)
2023-01-26 09:12:21 +01:00
Callum Farmer
953e5fc093 boot: Use objcopy with arm64
Binutils 2.38 added support for efi-app-aarch64
Still use binary mode if we have an older objcopy
Add check for incompatible gnu-efi crt0 containing the header section
which gets added by objcopy and if used results in duplicate header
and subsequently a broken binary

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
(cherry picked from commit 9c100c4e70)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
34157bba08 sleep: fix memleak
Those hashmaps are created anew in each iteration of the loop. The
leak wasn't really a problem, because the loop is bounded and the
hashmaps were not huge, but it's nicer to be correct.

(cherry picked from commit de5d8b40ed)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
224f912cba sleep: reduce double logging and improve messages and comments a bit
read_battery_capacity_percentage() was already logging, but with a slightly
different wording.

More could be done, I just touched the most noticable places. Especially
in debug messages, it is much more useful to be direct about what couldn't
be accessed or parsed, instead of providing "descriptive names" which are
not useful to the user at all, who then needs to read the code to figure out
what was the actual property name.

(cherry picked from commit 099810a65b)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
5c94225d0c sleep: do not abort if we try to query capacity of missing battery
Fixes #25584.

From the issue:
Assertion 'capacity >= 0' failed at src/shared/sleep-config.c:58, function PTR_TO_CAPACITY(). Aborting.

(gdb) bt

The problem is that PTR_TO_CAPACITY(hashmap_get(last_capacity, battery_name))
will abort if it's called with a name not present in the hashmap. We want to
skip the device silently in this case instead.

(cherry picked from commit 7ebbe4a5ce)
2023-01-26 09:12:21 +01:00
Luca Boccassi
786b7a7208 core: ensure init.scope is realized after drop-ins have been loaded
If we add a drop-in for init.scope (e.g.: to set some memory limit),
it will be loaded long after the cgroup has already been realized.
Do it again when creating the special unit.

(cherry picked from commit 020b2e41ea)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
c2fef536d5 test: bump the container spawn timeout to 60s
As 30s might be not enough on busy systems (and we already bumped the
reboot timeout from 30s to 60s for this reason).

(cherry picked from commit d932022ddf)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
e4ed752f23 test: bump the client-side timeout in sd-bus as well
Since c78d18215b D-Bus services now have 60s to start, but the client
side (sd-bus) still waits only for 25s before giving up:

```
[  226.196380] testsuite-71.sh[556]: + assert_in 'Static hostname: H' ''
[  226.332965] testsuite-71.sh[576]: + set +ex
[  226.332965] testsuite-71.sh[576]: FAIL: 'Static hostname: H' not found in:
[  228.910782] sh[577]: + systemctl poweroff --no-block
[  232.255584] hostnamectl[565]: Failed to query system properties: Connection timed out
[  236.827514] systemd[1]: end.service: Consumed 2.131s CPU time.
[  237.476969] dbus-daemon[566]: [system] Successfully activated service 'org.freedesktop.hostname1'
[  237.516308] systemd[1]: system-modprobe.slice: Consumed 1.533s CPU time.
[  237.794635] systemd[1]: testsuite-71.service: Main process exited, code=exited, status=1/FAILURE
[  237.818469] systemd[1]: testsuite-71.service: Failed with result 'exit-code'.
[  237.931415] systemd[1]: Failed to start testsuite-71.service.
[  238.000833] systemd[1]: testsuite-71.service: Consumed 5.651s CPU time.
[  238.181030] systemd[1]: Reached target testsuite.target.
```

Let's override the timeout in sd-bus as well to mitigate this.

Follow-up to c78d18215b.

(cherry picked from commit e0cbb73911)
2023-01-26 09:12:21 +01:00
Michael Biebl
1c325f6d7f test: fix TEST-73-LOCALE on Debian
Fix incorrection assumption about the Debian patch being buggy and
actually making TEST-73-LOCALE fail on Debian.

```
 # localectl set-locale LANG=C.UTF-8
 # cat /etc/default/locale
 LANG=C.UTF-8
```

(cherry picked from commit a4bc35740a)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
905705b280 shared/install: rework an assert to appease gcc-13
With the previous form, gcc is confused and thinks that .type might be unset.

Fixes #26118.

(cherry picked from commit 8f5d716a71)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
9a9c5ca26f shared/install: rework InstallChange to always have .path set
We would set .path in all cases except INSTALL_CHANGE_AUXILIARY_FAILED, where
we would just just .source. This special case is just not worth it, because
we can't easily assert that .path is set. Let's remove this special case to
help the compiler know that .path is actually set.

Avoids a warning with gcc-13.0.1-0.1.fc38.x86_64.

(cherry picked from commit 4a4af850b3)
2023-01-26 09:12:21 +01:00