1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00
Commit Graph

63344 Commits

Author SHA1 Message Date
Yu Watanabe
1479799c4d proc-cmdline: use proc_cmdline_key_string() when we search for key 2023-03-24 15:20:05 +09:00
Yu Watanabe
b3e9a267ce proc-cmdline: rename variable 2023-03-24 15:20:05 +09:00
Yu Watanabe
a175b98171 proc-cmdline: insert an empty line between variable declaration and assertion 2023-03-24 15:20:05 +09:00
Daan De Meyer
ba54d73055 chase-symlinks: Use xopenat() instead of open_mkdir_at()
We don't rely on any of the extra functionality of open_mkdir_at()
so let's just use xopenat() directly.
2023-03-23 23:25:33 +00:00
Luca Boccassi
2a775d5faf
Merge pull request #26935 from keszybz/test-parse_aux
Add test for auxv parsing
2023-03-23 23:13:42 +00:00
Luca Boccassi
d024c4d0e1
Merge pull request #26949 from DaanDeMeyer/xopenat-reopen
loop-util: Add loop_device_make_by_path_at()
2023-03-23 23:08:21 +00:00
Lennart Poettering
b839101aac fileio: add new helper fdopen_independent()
This is a combination of fdopen() and fd_reopen(). i.e. it first reopens
the fd, and then converts that into a FILE*.

We do this at various places already manually. let's move this into a
helper call of its own.
2023-03-23 22:48:00 +00:00
Lennart Poettering
05bda20f07
Merge pull request #26953 from poettering/encrypted-cred-mini-refactor
core: minor refactoring of allowlisting TPM devices when encrypted creds are loaded
2023-03-23 21:21:45 +01:00
Lennart Poettering
df637af460 pid1: allowlist all tpm devices for a unit when encrypted creds are needed
We might be configured to use some ther device than /dev/tpmrm0, hence
allow them all by allowlisting the tpm char device class as a whole.
2023-03-23 18:22:43 +01:00
Lennart Poettering
50a4217bbe core: move encrypted credential check to execute.c
This is an operation on an ExecContext, hence it probably should be
placed there.
2023-03-23 18:22:27 +01:00
Zbigniew Jędrzejewski-Szmek
f39546a881 test-coredump-util: also test parse_auxv() with unaligned data 2023-03-23 18:07:45 +01:00
Zbigniew Jędrzejewski-Szmek
2f809d29e8 test-coredump-util: add tests for parse_aux()
The test files are /proc//auxv files copies from various architecutres
signified by the file name suffix.

Those tests are fairly simple, but when we run them on n architectures, we do
~n² cross-arch tests.
2023-03-23 18:06:46 +01:00
Zbigniew Jędrzejewski-Szmek
cb38fdbedb coredump: split out parse_auxv() to src/shared/
No functional change. (We already checked for ELFCLASS32 or ELFCLASS64 before,
so even though there's a new check for other architectures, the only caller
only passes ELFCLASS32 or ELFCLASS64.)
2023-03-23 18:04:22 +01:00
Daan De Meyer
972c8db589 loop-util: Add loop_device_make_by_path_at()
On top of taking a directory file descriptor, we use xopenat() so
that the function can also be used to work on existing file
descriptors to image files including all the logic to use O_DIRECT
and fallback to O_RDONLY if needed.
2023-03-23 17:36:17 +01:00
Daan De Meyer
06ca2db39d fs-util: Allow xopenat() to reopen existing file descriptors 2023-03-23 17:31:55 +01:00
Mike Yuan
f1710073c7
Merge pull request #26214 from YHNdnzj/sd-notify-change-notifyaccess
core: support overriding NOTIFYACCESS= through sd-notify during runtime
2023-03-24 00:11:29 +08:00
Daan De Meyer
1441a6a751 docs: Explicitly tell developers to enable mkosi required meson options
We need repart, bootctl, analyze and ukify for mkosi so let's make
sure those get built in the HACKING guide.
2023-03-23 13:09:09 +00:00
наб
ed89819f8f 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)
2023-03-23 13:35:25 +01:00
Zbigniew Jędrzejewski-Szmek
d175b709e4 test-fileio: add test for return value of read_one_line_file()
Prompted by https://github.com/systemd/systemd/pull/26904#pullrequestreview-1349890241.
2023-03-23 13:32:45 +01:00
Daan De Meyer
1d5240cfaa
Merge pull request #26936 from DaanDeMeyer/xopenat-lock
fs-util: Add xopenat_lock()
2023-03-23 07:49:12 +01:00
Daan De Meyer
a7253c7fec
Merge pull request #26916 from DaanDeMeyer/log-context-ref
log: Avoid pushing the same fields more than once on the log context
2023-03-22 22:07:45 +01:00
Daan De Meyer
2646b86dd6 fs-util: Add xopenat_lock()
open/create a file/directory and lock it using the given lock type.
2023-03-22 21:54:20 +01:00
Mike Yuan
da037170c4 edit-util: alloc correct amount of memory 2023-03-22 23:25:25 +08:00
Yu Watanabe
9b032f932c coredump: use unaligned_read_ne{32,64}() to parse auxv
Fixes a bug introduced by 3e4d0f6cf9.

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.
2023-03-22 16:17:13 +01:00
Tobias Powalowski
bf9f07a629
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
2023-03-22 12:24:57 +00:00
Daan De Meyer
a3b00f91bb 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.
2023-03-22 13:20:08 +01:00
David Tardon
8d0747abb7 labeler: add journal label also for sd-journal stuff 2023-03-22 13:18:55 +01:00
Mike Yuan
b64f5ddaca
test: add tests for NOTIFYACCESS override through sd_notify 2023-03-22 19:22:10 +08:00
Daan De Meyer
bd7a79528c stat-util: Add verify_regular_at() 2023-03-22 12:17:14 +01:00
Daan De Meyer
997bc9ec56
Merge pull request #26829 from DaanDeMeyer/copy-at
copy: Add more at() helpers
2023-03-22 09:53:51 +01:00
Kevin P. Fleming
06d104d58f 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.
2023-03-22 09:16:49 +01:00
Yu Watanabe
206760a4bc
Merge pull request #26928 from jamacku/update-shellcheck
ci: trigger `differential-shellcheck` workflow on push
2023-03-22 15:13:38 +09:00
Jan Macku
a33d7c4cc9 ci: limit permissions for differential-shellcheck 2023-03-22 06:56:34 +01:00
Jan Macku
50ba79710e ci: trigger differential-shellcheck workflow on push
Also update `differential-shellcheck` to latest version - https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases

Fixes: https://github.com/redhat-plumbers-in-action/differential-shellcheck/issues/215
2023-03-22 06:56:34 +01:00
Mike Yuan
19dff6914d
core: support overriding NOTIFYACCESS= through sd-notify during runtime
Closes #25963
2023-03-22 06:33:12 +08:00
Daan De Meyer
427d9c34e6 copy: Add more at() helpers 2023-03-21 20:53:09 +01:00
Daan De Meyer
7c2f5495e2 copy: Move chattr arguments to full function signatures
These are almost never used, so let's move them to the _full()
functions signatures.
2023-03-21 20:53:09 +01:00
Daan De Meyer
f3e03bd04e
Merge pull request #26828 from DaanDeMeyer/tmpfile-at
tmpfile-util: Add open_tmpfile_linkable_at() and link_tmpfile_at()
2023-03-21 20:52:17 +01:00
Lennart Poettering
42db4a8db7 fd-util: make sure fd_reopen() works with AT_FDCWD systematically
Prompted by:

https://github.com/systemd/systemd/pull/26827#pullrequestreview-1341171981
2023-03-21 20:51:55 +01:00
Daan De Meyer
1c2e550ec4
Merge pull request #26866 from DaanDeMeyer/chase-fix
chase-symlinks: Add CHASE_FILENAME and more at() helpers
2023-03-21 20:50:48 +01:00
Daan De Meyer
4d62ee559d execute: Add kernel cmdline arguments for tty term, rows and columns
Let's allow configuring tty term and size using kernel cmdline arguments
so that when running in a VM we can communicate the terminal TERM and size
from the host via SMBIOS extra kernel cmdline arguments.
2023-03-21 20:50:17 +01:00
Daan De Meyer
c84d14c525 docs: Fix vscode debugging section in HACKING.md
Let's account for the recent changes in mkosi in the debugging
with vscode section.
2023-03-21 17:47:51 +00:00
Daan De Meyer
12ef261794 chase-symlinks: Add more chase_symlinks_at() helpers
Copies of the corresponding chase_symlinks() helpers.
2023-03-21 16:08:35 +01:00
Daan De Meyer
88f2ee8601 chase-symlinks: Return zero from access() and stat() helpers
We never check if r > 0 when using these helpers, so let's just
return zero like we usually do.
2023-03-21 16:08:35 +01:00
Daan De Meyer
63bfd52f48 chase-symlinks: Add CHASE_EXTRACT_FILENAME flag
Useful in combination with CHASE_PARENT to get a directory file
descriptor to the parent directory of the resolved path and the
filename of the resolved path in the parent directory (which might
not be the same as the filename of the input path because of symlinks).
2023-03-21 16:08:29 +01:00
Thomas Blume
c5ba7a2a4d udev-rules: fix nvme symlink creation on namespace changes
The nvme by-id symlink changes to the latest namespace when a new namespace gets
added, for example by connecting multiple NVMe/TCP host controllers via nvme
connect-all.
That is incorrect for persistent device links.
The persistent symbolic device link should continue to point to the same NVMe
namespace throughout the lifetime of the current boot.
Therefore the namespace id needs to be added to the link name.
2023-03-21 15:46:45 +01:00
Daan De Meyer
d294857ea6 tmpfile-util: Add open_tmpfile_linkable_at() and link_tmpfile_at() 2023-03-21 15:20:01 +01:00
Daan De Meyer
14460a8a2b fs-util: Add open_parent_at() 2023-03-21 15:20:01 +01:00
Daan De Meyer
aea3ca3613 lock-util: Add make_lock_file_at() 2023-03-21 15:19:33 +01:00
Daan De Meyer
4b2af439eb unit: Add LOG_CONTEXT_PUSH_UNIT()
A helper macro to push all unit related fields onto the log context.
We also modify exec_spawn() to use it.
2023-03-21 14:59:16 +01:00