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

60964 Commits

Author SHA1 Message Date
Robin Humble
015b0ca928 pid1: fix segv triggered by status query (#26279)
If any query makes it to the end of install_info_follow() then I think symlink_target is set to NULL.
If that is followed by -EXDEV from unit_file_load_or_readlink(), then that causes basename(NULL)
which segfaults pid 1.

This is triggered by eg. "systemctl status crond" in RHEL9 if

/etc/systemd/system/crond.service
  -> /ram/etc/systemd/system/crond.service
  -> /usr/lib/systemd/system/.crond.service.blah.blah
  -> /usr/lib/systemd/system/crond.service

(cherry picked from commit 19cfda9fc3)
2023-02-10 20:28:11 +00:00
Jan Janssen
7573078a7d meson: Install missing udev rule
(cherry picked from commit 4c6d1e1665)
2023-02-10 20:28:11 +00:00
Jan Janssen
6d8885af57 meson: Install missing bash-completions
(cherry picked from commit 7b2f84e3f2)
2023-02-10 20:28:11 +00:00
Jan Janssen
aa79d157af meson: Install missing network file
(cherry picked from commit 17be6f2709)
2023-02-10 20:28:11 +00:00
Jan Janssen
5bad071f73 meson: Install all catalogs
(cherry picked from commit 3774ff06f2)
2023-02-10 20:28:11 +00:00
Rudi Heitbaum
a8b9c4766d glibc: Conditionally #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
(cherry picked from commit 1bb6ba08b1)
2023-02-10 20:28:11 +00:00
Zbigniew Jędrzejewski-Szmek
8ad3d68acd sysusers: insist that root group is 0
In https://bugzilla.redhat.com/show_bug.cgi?id=2156900 sysusers was reporting a
conflict between the following lines:
  u root 0:0 "Super User" /root /bin/bash
  u root    0     "Super User" /root

The problem is that those configurations are indeed not equivalent. If group 0
exists with a different name, the first line would just create the user, but the
second line would create a 'root' group with a different GID. The second
behaviour seems definitely wrong. (Or at least more confusing in practice than
the first one. The system is in a strange shape, but the second approach takes
an additional step than is worse than doing nothing.)

When this line was initially added, we didn't have the uid:gid functionality for
'u', so we didn't think about this too much. But now we do, so we should use it.

$ build/systemd-sysusers --root=/var/tmp/inst7 --inline 'g foobar 0'
Creating group 'foobar' with GID 0.

$ build/systemd-sysusers --root=/var/tmp/inst7 --inline 'u root 0 "Zuper zuper"'
src/sysusers/sysusers.c:1365: Creating group 'root' with GID 999.
src/sysusers/sysusers.c:1115: Suggested user ID 0 for root already used.
src/sysusers/sysusers.c:1183: Creating user 'root' (Zuper zuper) with UID 999 and GID 999.

vs.

$ build/systemd-sysusers --root=/var/tmp/inst7 --inline 'u root 0:0 "Zuper zuper"'
src/sysusers/sysusers.c:1183: Creating user 'root' (Zuper zuper) with UID 0 and GID 0.

(cherry picked from commit 49bb7fe5f8)
2023-02-10 20:28:11 +00:00
Arsen Arsenović
817b8441c4 importd: Always specify file unpacked by tar
Despite popular belief, the default file extracted by GNU tar is not stdin.  It
is the value of the TAPE environment variable, falling back on a compile-time
constant.  On my system, the default value is /dev/full, which causes tar to
just spin forever due to --ignore-zeros.  Always specifying this flag is the
safe thing to do.

  ~$ tar --show-defaults
  --format=gnu -f/dev/full -b20 --quoting-style=escape
  --rmt-command=/usr/sbin/grmt

See also: ``(tar)defaults'', available via Info viewers, and in HTML form at:
https://www.gnu.org/s/tar/manual/html_node/defaults.html

(cherry picked from commit 181eea677d)
2023-02-10 20:28:11 +00:00
Dmitry V. Levin
212aa36d03 tmpfiles: avoid double specifier expansion in L lines
Starting with commit 2f3b873a49, when the path contains a specifier
and the argument is omitted, tmpfiles used to perform specifier
expansions twice: first specifier expansion was applied to the path
itself, and afterwards the result of the first expansion was used
in the constructed argument and expanded once again.

Resolves: #26244
Fixes: 2f3b873a49 ("tmpfiles: copy/link /usr/share/factory/ files when the source argument is omitted")
(cherry picked from commit 05381430a5)
2023-02-10 20:28:11 +00:00
Dmitry V. Levin
80b5af843b tmpfiles: fix specifier expansion in arguments of C lines
Make sure the argument of "C" type undergoes specifier expansion
before it's checked for validity.  In particular, starting with
commit ce610af143, the check for path existence used to fail
in case of presence of any specifier in the argument.

Also, starting with commit 2f3b873a49, when the path contains
a specifier and the argument is omitted, tmpfiles used to perform
specifier expansions twice: first specifier expansion was applied
to the path itself, and afterwards the result of the first expansion
was used in the constructed argument and expanded once again.

Finally, starting with commit 849958d1ba, when the argument begins
with %h specifier, tmpfiles used to complain that the source path
is not absolute.

Resolves: #25381
Fixes: ce610af143 ('tmpfiles: in C lines, make missing source graceful error')
Fixes: 2f3b873a49 ('tmpfiles: copy/link /usr/share/factory/ files when the source argument is omitted')
Fixes: 849958d1ba ('tmpfiles: add new "C" line for copying files or directories')
(cherry picked from commit 1ed8887e3b)
2023-02-10 20:28:11 +00:00
Yu Watanabe
7aeb2a8d4e sd-dhcp-server: allow to send header only message
If we receive a header only message, and the server is running in relay
mode, then the assertion was triggered.

Fixes #26151.

(cherry picked from commit b52031dbbc)
2023-02-10 20:28:11 +00:00
Daan De Meyer
ab877f7072 resolve: Skip creating stubs if missing CAP_NET_BIND_SERVICE
If we don't have CAP_NET_BIND_SERVICE, we won't be able to bind
the stub listener socket, so let's skip creating it and log a warning.

We do the same for the extra stubs if they're configured on privileged
ports.

(cherry picked from commit 0398c084ef)
2023-02-10 20:28:11 +00:00
Daan De Meyer
3a49291f4b nspawn: Drop CAP_NET_BIND_SERVICE when in userns but not in netns
If we're in a user namespace but not unsharing the network namespace,
we won't be able to bind any privileged ports even with
CAP_NET_BIND_SERVICE, so let's drop it from the retained capabilities
so services can condition themselves on that.

(cherry picked from commit 2642d22adc)
2023-02-10 20:28:11 +00:00
Jan Janssen
ce56d12f01 boot: Use aarch64 virtual counter
This should be used in VMs and should also yield the same value when
running on real devices. It is also what grub uses.

Fixes: #26224
(cherry picked from commit 2df8574af0)
2023-02-10 20:28:11 +00:00
William Roberts
e1b0f8c20c sha256: header needs stddef
The sha256 header uses size_t which is within stddef, so add it.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
(cherry picked from commit 6ae3bd82d0)
2023-02-10 20:28:11 +00:00
Lennart Poettering
278e0d5b19 sha256: external headers should be included with <>
(cherry picked from commit 17b296a118)
2023-02-10 20:28:11 +00:00
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