1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-13 12:58:20 +03:00

41769 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
bfc03cae41 shared/exec-util: null_or_empty_path() does not return boolean
We shouldn't report that the file is empty if the stating fails. Let's do the
same as in other places, and just ignore the error and let the subsequent
operation fail.

(cherry picked from commit 7d0c47dad0d4282c3924a654a8fe18fc5d7766f8)
2023-03-29 16:56:51 +02:00
David Tardon
e4c7553874 journal-vacuum: count size of all journal files
Currently, active journal files are excluded, which means that vacuuming
may not remove anything even if *MaxUse= has been exceeded.

(cherry picked from commit 9ea46af4f2368b41d57705bac09774778126507f)
2023-03-29 16:56:51 +02:00
Frantisek Sumsal
0e7745249b userdbctl: flush stdout before running the chain command
Otherwise it's quite difficult to capture the entire output:

$ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA//dxI2xLg4MgxIKKZv1nqwTEIlE/fdakii2Fb75pG+ foo@bar.tld
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMlaqG2rTMje5CQnfjXJKmoSpEVJ2gWtx4jBvsQbmee2XbU/Qdq5+SRisssR9zVuxgg5NA5fv08MgjwJQMm+csc= hello@world.tld
hello
$ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello | tee
hello

(cherry picked from commit 5b09499cacd3c1c95ab240d041e28cc954a5975d)
2023-03-29 16:56:51 +02:00
Frantisek Sumsal
1185e7f9d3 userdbctl: don't show legend when dumping JSON with services
(cherry picked from commit eedd1da9f992f9b9d38e298207428500b745156b)
2023-03-29 16:56:51 +02:00
Lennart Poettering
7822ae021b analyze: don't claim "@known" was an unlisted syscall
It's a sycall group of our own definition, and the output is erroneous
to claim otherwise. Let's hide it.

This adds syscall_set_add() which is nicely symmetric to the existing
syscall_set_remove().

Follow-up for: 6d6a08547c03f96dc798cda1ef4a8d3013d292d5

(cherry picked from commit 950c0ed38935198a67a57c645e499555eaf006eb)
2023-03-29 16:56:51 +02:00
Lennart Poettering
54f97c0ae5 seccomp-util: add some newer syscalls to existing groups
These three new syscalls are mostly just new flavours or extensions of
existing syscalls, hence add them to the same groups.

(cherry picked from commit 76e86b8dd8cca9f9fee120289945b29e1dbbe215)
2023-03-29 16:56:51 +02:00
Zbigniew Jędrzejewski-Szmek
90ba721560 xdg-autostart-generator: do not warn about unknown fields
My user manager says:
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:256: Unknown key name 'Actions' in section 'Desktop Entry', ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:258: Unknown section 'Desktop Action new-window'. Ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:343: Unknown section 'Desktop Action preferences'. Ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:12: Unknown key name 'Actions' in section 'Desktop Entry', ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:13: Unknown key name 'SingleMainWindow' in section 'Desktop Entry', ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:19: Unknown section 'Desktop Action Quit'. Ignoring.

This is not useful. Those are externally-provided files, and they are likely to
have entries which we know nothing about.

(cherry picked from commit b5a70eeecdb593f8498c0bc163d5a12297cfb55d)
2023-03-29 16:56:51 +02:00
наб
f6388f561c find-esp: don't silently error bootctl install if presumed XBOOTLDR part is stx_dev_major=0 but not btrfs
btrfs_get_block_device_fd() returns -ENOTTY if fstatfs().f_type !=
BTRFS_SUPER_MAGIC

btrfs_get_block_device_fd() is run by verify_fsroot_dir() by
verify_xbootldr() by find_xbootldr_and_warn() if
statx($presumed-XBOOTLDR).stx_dev_major == 0 ("maybe a btrfs device")

Every bootctl verb_install() runs find_xbootldr_and_warn(), by default
with /boot

If your /boot .stx_dev_major=0 but /not/ btrfs, bootctl install/update
quietly exits 1 with no note so as to what exactly failed (debug also
empty, and the strace isn't exactly clear since no syscall actually
failed)

This is the case on ZFS and the Debian filesystem layout: /boot/efi is
the ESP, and everything else under / is ZFS:
  $ sudo env SYSTEMD_LOG_LEVEL=debug bootctl update
  Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
  Found container virtualization none.
  File system "/boot" is not a FAT EFI System Partition (ESP) file system.
  Using EFI System Partition at /boot/efi.
  Checking whether /boot/efi/EFI/systemd/ contains any files…
  $ echo $?
  1
and funnier still:
  $ sudo bootctl update --graceful
  $ echo $?
  1

Which is great, and also breaks postinst, which runs precisely the
latter, with no feedback at all

By checking for -ENOTTY we accept that the path being investigated
"is not it" if it's on ZFS (and any other filesystem that returns
.stx_dev_major == 0 but isn't btrfs)

(cherry picked from commit ed89819f8fd7bfe99cd652082076e85e1417e4e9)
2023-03-29 16:56:51 +02:00
Tobias Powalowski
f492ca7b5d ukify: allow uncompressed kernel images for UNAME detection on aarch64 and riscv64 (#26929)
Uncompressed aarch64 and riscv64 kernels have a different startpoint than x86.
Example output from ukify:
aarch64: NotImplementedError: unknown file format (starts with b'MZ@\xfa')
riscv64: NotImplementedError: unknown file format (starts with b'MZo\x10')
Add check for (b'MZ') to catch both in one call.

Fix:
https://github.com/systemd/systemd/issues/26923
(cherry picked from commit bf9f07a62966043c0f1fd7ac4a249790643d1f9a)
2023-03-29 16:56:51 +02:00
Daan De Meyer
22c47d24a4 core: Settle log target if we're going to be closing all fds
Whenever we're going to close all file descriptors, we tend to close
the log and set it into open when needed mode. When this is done with
the logging target set to LOG_TARGET_AUTO, we run into issues because
for every logging call, we'll check if stderr is connected to the
journal to determine where to send the logging message. This check
obviously stops working when we close stderr, so we settle the log
target before we do that so that we keep using the same logging
target even after stderr is closed.

(cherry picked from commit a3b00f91bb985fa10bc33db5c7883e33dbdf83d0)
2023-03-29 16:56:51 +02:00
Yu Watanabe
ce06e000b8 activate: use log_set_open_when_needed()
Otherwise, several error logs may not be shown.

(cherry picked from commit a723521fd26d40ce90357e4e9b8131f1e1656ab5)
2023-03-29 16:56:51 +02:00
Kevin P. Fleming
b041337a7a bootctl: 'graceful' should ignore EFI variable failures
Suppress errors when creating/writing EFI variables during 'bootctl update' if
'--graceful' mode is active (as the documentation indicates).

Closes #26773.

(cherry picked from commit 06d104d58ffa23c958b9b2a2809c61fb25e6f762)
2023-03-29 16:56:51 +02:00
Antonio Alvarez Feijoo
ad2d77b899 gpt-auto-generator: fix typo
(cherry picked from commit dd23292c080f6e8b972c63b025ad3997972bc9e4)
2023-03-29 16:56:51 +02:00
David Tardon
c86983c58a systemctl: always print circular deps. at the end
Before:
a.target
○ └─b.target
    ├─...
●   └─paths.target

After:
a.target
○ └─b.target
●   ├─paths.target
    └─...

(cherry picked from commit bb7c4a93ea1167b1294f86307d712d45655e9632)
2023-03-29 16:56:51 +02:00
David Tardon
6903f28d8d systemctl: fix formatting of circular dep.
Before:
a.target
○ └─b.target
    └─...
●   └─paths.target

After:
a.target
○ └─b.target
    ├─...
●   └─paths.target

(cherry picked from commit 5a4711e4895e3f7091e0e4da654412232484a5ec)
2023-03-29 16:56:51 +02:00
David Tardon
cee098e4e1 systemctl: fix indentation of circular deps
We're still at level `level` here.

Before:
b.target
○ ├─a.target
  │   └─...
● └─paths.target

After:
b.target
○ ├─a.target
  │ └─...
● └─paths.target

Fixes #26052.

(cherry picked from commit a9f2f486f3d1dd1cd2a58cd384b0e88970e2fda9)
2023-03-29 16:56:51 +02:00
Yu Watanabe
7ca1a3a1d4 tmpfiles: show file type in octal, instead of hex
(cherry picked from commit 056ff0b455ec54c9cadd119b09d0ec36efdee808)
2023-03-29 16:56:51 +02:00
Daan De Meyer
d1d7788000 repart: Report better errors if partition sizes are too small
(cherry picked from commit e21be7976aba577e0ba66300e631c5ae7feb02d9)
2023-03-29 16:56:51 +02:00
Daan De Meyer
6c21f95640 repart: Zero full verity signature partition size
systemd-dissect requires the entirety of the partition following the
signature to be zeroed, so let's do just that.

(cherry picked from commit d28c6ce62c4915ec5f7e10dc49be5e51c2356dad)
2023-03-29 16:56:51 +02:00
Daan De Meyer
659e7f274e repart: Make sure we seek to beginning of partition target before copy
(cherry picked from commit 6eccec00fb50e1a35f5a11e3339d634541bcc3a8)
2023-03-29 16:56:51 +02:00
Mike Yuan
fd963d1bc8 sleep: fix default values unmatched with manual
(cherry picked from commit f05b4bb9a7a70092641f43486fc7a45c85fc9c63)
2023-03-29 16:56:51 +02:00
Zbigniew Jędrzejewski-Szmek
2ead535f0d man: document "Delegate=" a bit more
This case is a bit surprising, even if logical if one understands how the
parser works. Let's be more explicit.

Follow-up for 7b3693e4e4c9cae50fca65136278a62fae11327e.

(cherry picked from commit 449172f943acadc7fd1e2293a615c7cb0d87fcd6)
2023-03-29 16:26:39 +02:00
Daan De Meyer
1b51f6a8f0 mkfs-util: Always use "default" usage type for ext filesystems
If no usage type is explicitly specified, ext will choose one based
on the filesystem size. Let's override this and always use the
"default" usage type so that we can create filesystems that are
initially small but might grow later without opting in to the "small"
usage type.

(cherry picked from commit 59c3c195f432243a1d4b2a7210e9699db83cb335)
2023-03-29 16:13:18 +02:00
Morten Linderud
e7e6043ccf src: Fixup copy-paste error for terminal_urlify_man
Signed-off-by: Morten Linderud <morten@linderud.pw>
(cherry picked from commit 6dadf31d6123a9127ee6ceccbcc272d53ec5f8fa)
2023-03-29 16:11:37 +02:00
Will Fancher
c7280b7c1f mount: Include After=local-fs-pre.target by default in initrd
Although it may be true that /sysroot and its children don't belong in
local-fs.target, that doesn't mean they shouldn't come after
local-fs-pre.target. For instance, systemd-hibernate-resume@.service needs to
come before /sysroot and its children, but currently that only happens
coincidentally because of the ordering between systemd-fsck@.service and
local-fs-pre.target. As a result, mount units can be mistakenly started
simultaneously with systemd-hibernate-resume@.service, which can cause
corruption and data loss in the worst of cases.

(cherry picked from commit 6e017b19a804639101fc87b4b78c02f7639c6d0c)
2023-03-29 16:11:19 +02:00
Gerd Hoffmann
960eb5c85a 90-uki-copy.install: create $BOOT/EFI/Linux directory if needed
Do not consider a missing 'Linux' subdirectory an error.
Just create it instead.

(cherry picked from commit c7314ee7e290b3978e2f2d7726d07656eda071f9)
2023-03-29 16:04:17 +02:00
Gerd Hoffmann
d7b75c4a4a bootctl: tweak DOS header magic check
Read the magic first, try reading the full DOS exe header only in case
the magic check succeeds.

This avoids throwing an header read error on small dummy files as used
by test-kernel-install.

(cherry picked from commit 78088b8f43717a43661cd2c1627a9860904c4794)
2023-03-29 16:04:10 +02:00
Zbigniew Jędrzejewski-Szmek
4b12a1cf92 man: adjust description of CPUAccounting=
For any user on a semi-recent kernel, effectively this setting is pointless.
We should deprecate it once not needed anymore for the v1 hierarchy. For
now, adjust the description.

(cherry picked from commit 695e39dd632801871b4e96b39bc8e7511083a34e)
2023-03-28 18:59:01 +02:00
Luca Boccassi
6d3db6f092 core: log message when reloading finishes
Reloading might be slow, especially when under memory pressure, and watchdogs
might be triggered. It is useful to have timestamped telemetry in the journal
to see how long a reload takes.

(cherry picked from commit af2fb2f250e664973d947554414749e9b94d68a1)
2023-03-28 18:58:22 +02:00
Jan Engelhardt
c181761f9a doc: correct wrong use "'s" contractions
(cherry picked from commit 18fe76eba59dc494597b07e0114899b69f92cc12)
2023-03-28 18:57:49 +02:00
Jan Engelhardt
21266ac59d doc: replace wrong á preposition by à
(cherry picked from commit 3ff1721c219479ec51479970f1d81a3aa17e9b50)
2023-03-28 18:57:25 +02:00
Yu Watanabe
efbe08c27c test: add header build tests for newer C and C++ standards
(cherry picked from commit a6d46fe64b61c62dc5c0dadbad65134075b29303)
2023-03-28 18:54:32 +02:00
Cristian Rodríguez
25b5c24e59 Include <threads.h> if possible to get thread_local definition
IN C23, thread_local is a reserved keyword and we shall therefore
do nothing to redefine it. glibc has it defined for older standard
version with the right conditions.

v2 by Yu Watanabe:
Move the definition to missing_threads.h like the way we define e.g.
missing syscalls or missing definitions, and include it by the users.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
(cherry picked from commit 5545f336fd09148e8d9aa7f83ed19384deaf7a64)
2023-03-28 18:54:13 +02:00
Daan De Meyer
7e76a34146 journal-file: Fix return value in bump_entry_array()
(cherry picked from commit 0399902440fbaea5b163254f70be57dbedb7131e)
2023-03-28 18:31:47 +02:00
Zbigniew Jędrzejewski-Szmek
e32df1d6d8 core/main: restore the correct assert about array position
'pos' is incremented after each assignment. If we use the maximum number
of arguments, we end up with pos==9 after all the assignments, and it
points to where the next value would be assigned. This position must remain
NULL.

The assert I "fixed" was intentionally introduced in
26abdc73a212b90f7c4b71808a1028d2e87ab09f as a bugfix. So my "fix" repeated
the same error that was fixed back then.

(cherry picked from commit 14ecfc1cd2e8050214b56cf3588740e20666b3cd)
2023-03-28 18:29:17 +02:00
Zbigniew Jędrzejewski-Szmek
0e3706f770 core/main: fix setting of arguments for shutdown
Fixup for d2ebd50d7f9740dcf30e84efc75610af173967d2
and 6920049fad4fa39db5fec712f82f7f75b98fd4b9:
- add a comment that the last arg must be NULL and adjust the assert.
- move initialization around so that fields are declared,
  initialized, and consumed in the same order.
- move declaration of pos adjacent do declaration of command_line.
  This makes it easy to see that it was not initialized correctly.
- initialize buffers before writing the pointer into the args array.
  This makes no difference for the compiler, but it just feels "wrong"
  to do it in opposite order.

Because pos was off, we would ignore args after the timeout, and also
overwrite the buffer if enough args were used.

I think this is case shows clearly that declaring all variables at the
top of the function, with some initialized and other not, is very
error-prone. The compiler has no issue with declaring variables whereever,
and we should take advantage of this to make it keep declaration,
initialization, and use close. (Within reason of course.)

(cherry picked from commit 4688b08984cef43414a236d1c2afc5860a1703b9)
2023-03-28 18:29:01 +02:00
Yu Watanabe
0417b28755 core/main: make positional arguments followed by '=', then by value
To make ConditionKernelCommandLine= or friend not confused when we are
running in a container.

Addresses https://github.com/systemd/systemd/pull/26887#discussion_r1143358884.

(cherry picked from commit d2ebd50d7f9740dcf30e84efc75610af173967d2)
2023-03-28 18:28:32 +02:00
Yu Watanabe
0880a3af77 core/main: fix maximum number of arguments for shutdown command
Follow-up for c5673ed0de3bec38f68d8113d253842b47766e27.

(cherry picked from commit 6920049fad4fa39db5fec712f82f7f75b98fd4b9)
2023-03-28 18:25:17 +02:00
Yu Watanabe
bff4f7b3fd coredump: use unaligned_read_ne{32,64}() to parse auxv
Fixes a bug introduced by 3e4d0f6cf99f8677edd6a237382a65bfe758de03.

The auxv metadata is unaligned, as the length of the prefix
"COREDUMP_PROC_AUXV=" is 19. Hence, parse_auxv{32,64}() may triger
an undefined behavior (or at least cause slow down), which can be
detected when running on an undefined behavior sanitizer.

This also introduces a macro to define `parse_auxv{32,64}()`.

Fixes #26912.

(cherry picked from commit 9b032f932c4172fac379234d9d42cf2b266ccaea)
2023-03-28 18:22:57 +02:00
Yu Watanabe
591a82f24f core/transaction: do not log "(null)"
As we ignores the failure in merge_unit_ids(), so unit_ids may be NULL.

(cherry picked from commit 5803c24da5cf543a55c4fce9009a9c5f2b18519a)
2023-03-28 18:22:21 +02:00
Yu Watanabe
d084528c49 core/transaction: make merge_unit_ids() return non-NULL on success
(cherry picked from commit 999f16514367224cbc50cb3ccc1e4392e43f6811)
2023-03-28 18:22:19 +02:00
Yu Watanabe
7002c5c210 core/transaction: make merge_unit_ids() always return NUL-terminated string
Follow-up for 924775e8ce49817f96df19c2b06356c12ecfc754.

The loop run with `STRV_FOREACH_PAIR()`, hence `if (*(unit_id+1))` is
not a good way to detect if there exist a next entry.

Fixes #26872.

(cherry picked from commit 366eced4c81a15a25b9225347fa203aa67798b02)
2023-03-28 18:22:16 +02:00
Yu Watanabe
dbfd85dc95 bootctl: fix wrong type comparison
(cherry picked from commit de2c62e847f3b5b0c0796396086ebdce4e8a9ca4)
2023-03-28 18:21:41 +02:00
Dmitry V. Levin
56a81351af Revert "udev: prepare memory for extra NUL termination for NULSTR"
This reverts commit cd3c8a117ccf3505e49d34324473e2175ef0a9ce which was
papering over the bug instead of a proper fix made by the previous
commit.

(cherry picked from commit 8c499a61c46eb434db04d3ee4b116a0a755b3797)
2023-03-28 18:18:14 +02:00
Dmitry V. Levin
88d8ab119d udev-rules: fix matching of token types that support alternative patterns
For those token types that support matching of alternative patterns,
their token values are interpreted as nulstr, so make sure the parser
does the right thing and makes these token values terminated by two
subsequent NULs so they could be safely interpreted as nulstr.

Before this fix, the following rules would result to "echo foo" invocation:
  ENV{foo}=", RUN"
  ENV{foo}=="bar", RUN+="echo foo"
because the value of `ENV{foo}` is treated as nulstr, and it used to match
against alternative patterns, in this case `bar`, `, RUN`, and `="echo foo`.

Fixes: 25de7aa7b90c ("udev: modernize udev-rules.c")
(cherry picked from commit c43ff248f94266cfc93e300a2d3d163ed805e55b)
2023-03-28 18:18:12 +02:00
Zbigniew Jędrzejewski-Szmek
712cc39b23 core: fix "(null)" in output
We want an empty string, not NULL. I made some brainfart here.
Fixup for 1980a25dc03aa500d4ee2725d696f68d265cd4ca.

(cherry picked from commit add74820b72be58f57722000a343ee3b63195eff)
2023-03-28 18:16:09 +02:00
Brett Holman
59ae2a45a9 network: ipv4acd: update MAC address on change (#26753)
Commit 76a86ffdbee2dd9ef0f2b5338e14eb6ba7671456 added function
ipv4acd_update_mac() but invoked ipv4ll_update_mac(), which doesn't
align with debug or commit messages.

(cherry picked from commit 0a14f83a0edb2c809c932b5d98240dd10a6bb79a)
2023-03-28 18:15:21 +02:00
Lennart Poettering
59514a6d87 socket-util: fix socket_get_family()
Function didn't actually return anything useful. Quite a shame.

(cherry picked from commit 5f64d2bf332371bdfdcb91b588e57d4c0c20428f)
2023-03-28 18:14:28 +02:00
Zbigniew Jędrzejewski-Szmek
6aff33904f localed: print a custom message if libxkbcommon.so is unvailable
Follow-up for 82c2095a5e407bcf041dc7bde84791deec95ff9c.

> I feel like the logging here may be a bit confusing on the new path.
> Previously you did get a message that explained what was going on. Now you get
> an info message that the layout could not be compiled, and … that's all. I can
> imagine this being a confusing red herring if someone was trying to debug a
> problem and saw this message. Perhaps we should log something else instead/as
> well, on the case where libxkbcommon isn't present, to say that's what we're
> logging about and it just means we can't validate the configuration, not that
> it's definitely invalid?

(cherry picked from commit 080ecabfd78df6e97530c6d9aaa2e0e78746dd29)
2023-03-28 18:13:39 +02:00
Zbigniew Jędrzejewski-Szmek
cc367110aa localed: skip verification when libxkbcommon is not installed
When compliled without libxkbcommon, we do no verification and accept the
arguments as given. When compliled against with, if dlopen() works, we do the
verification. But if dlopen() fails, we would refuse the call and return
SD_BUS_ERROR_INVALID_ARGS. 5de344704df64d8f31448f1222432bc87ddcfbef added things
this way when converting to dlopen(), but it seems not very useful: it can be
expected that when the library is supported but missing at runtime, we degrade
softly, and that the behaviour is something inbetween the cases of hard disable
at compilation time and full support. But right now we behave more strictly then
if disabled at compilation. Change the code to just warn if dlopen fails, but
accept the arguments.

(There are various minimization scenarios where forcing the installation of
libxkbcommon is not useful. E.g. a small installation where we want to set the
keymap via logind, but the configuration is managed by a configuration
management system and is known to be valid. Verification via libxkbcommon is
just overhead in this case.)

800f65f827c9828d4c872d44b19ca8a008505690 moved the check earlier, so now even
a noop case of setting the values that were already in place can fail.
C.f. https://bugzilla.redhat.com/show_bug.cgi?id=2175244.

(cherry picked from commit 82c2095a5e407bcf041dc7bde84791deec95ff9c)
2023-03-28 18:13:08 +02:00