Commit graph

70975 commits

Author SHA1 Message Date
Emanuele Giuseppe Esposito ebd1a30093 bootspec: refactor find_sections
Prepare for the incoming changes that introduce PE addons support.
Addons will contain a .cmdline section, but not .osrel.
2024-02-14 04:56:42 -05:00
Adrian Vovk c425c8854f hashmap: Add helper to dump sorted keys
Currently, hashmap_dump_sorted sorts by key and then returns the values
in order sorted by key. This commit adds another helper that does the
same but returns the sorted keys instead
2024-02-14 09:35:36 +01:00
Yu Watanabe d1cde7f051 sd-journal: drop unused function prototype
Follow-up for 8b4fbbb0a1.

The function was renamed and moved by
035b0f8fe8.
Maybe the prototype is mistakenly re-introduced on rebase.
2024-02-14 09:31:13 +01:00
Mike Yuan 872ffc8a82 core/load-fragment: modernize config_parse_socket_listen
Prompted by #31304
2024-02-14 09:23:07 +01:00
Lennart Poettering 64e18af731
Merge pull request #31206 from AdrianVovk/user-record-fields
Added some more user record fields
2024-02-14 09:22:23 +01:00
Adrian Vovk 83b4576195 env-util: Add helper to store current log level
This is useful after a fork but before an exec into a binary that uses
systemd's logging utilities. For example, this should be used in dbus
services that fork off worker processes: currently, the log level set by
the LogControl dbus API will be lost because of the exec, and the worker
process will not have the correct log level set.
2024-02-14 09:21:45 +01:00
Lennart Poettering 2fe27f966f
Merge pull request #31297 from AdrianVovk/sha256-util-lib
basic: Add some sha256 helper functions
2024-02-14 09:19:56 +01:00
Yu Watanabe 8bd473ff25 core: allow to specify /dev/rfkill for ListenSpecial=
Follow-up for 8049bce619.

Fixes #31294.
2024-02-14 09:14:59 +01:00
Adrian Vovk 80d07162e7 format-utils: Expose FORMAT_UID and FORMAT_GID
This pulls this generally useful helper out of sysusers and into the
util lib, and updates the places throughout the codebase where it makes
sense to use it.
2024-02-14 09:14:13 +01:00
Adrian Vovk e2a40cc7b9 homed: Add some missing asserts
These functions expect secrets to be passed in (some even dereference
the variables), but fail to assert that they're non-null. So this commit
adds some assertions
2024-02-14 09:13:46 +01:00
Adrian Vovk 49e55abb7f
user-record: Add languages field
This field is like preferredLanguage, but takes a priority list of
languages instead. If an app isn't translated into a user's primary
language, it can fall back to one of the other languages in the list
thus making the app more accessible to the user.

For instance: in my experience, many Ukrainians are fluent in Russian,
often significantly better than English (especially if they are of a
generation that grew up during the USSR). Such a person might set this
new variable to ["uk_UA.UTF-8", "ru_UA.UTF-8"] so that software that
lacks Ukrainian translations will first try Russian translations before
defaulting to English.

Fixes #31290
2024-02-13 17:39:14 -05:00
Adrian Vovk fa485e8fc5
locale-util: Restrict valid locales
This further restricts the charset of locales to better reflect what
locales actually look like.

This allows us to safely join locale names using the `:` character, for
instance, which cannot appear in a locale name and is used by the
`$LANGUAGE` env var
2024-02-13 17:31:36 -05:00
Adrian Vovk 592ca6f0ef
pam_systemd: Let user record override env vars
The user record should be the source of truth for the user's environment
variables, and the user should be able to override them in much the same
way that they can if they simply append the variable to their ~/.profile

For example, before $LANG would never get set to the user's preferred
language, because the service manager always ensures that $LANG is set
to something (either the localed config, or a compiled-in default). Thus
the user's preferredLanguage setting was always ignored
2024-02-13 17:31:35 -05:00
Luca Boccassi e1390da025 varlink: fix dead code
'e' is already checked in the previous branch, no need to check it again,
it cannot be NULL.

CID#1534465

Follow-up for 9bca989183
2024-02-13 21:43:59 +00:00
Yu Watanabe 604b200108 test: fix typo
Follow-up for d02018afdb.
2024-02-14 04:04:12 +09:00
Yu Watanabe 964756923b test: fix typo
Follow-up for 3456c89ac2.
2024-02-14 04:03:09 +09:00
Yu Watanabe a14d3b48f7 cryptsetup: fix typo
Follow-up for c5daf14c88.
2024-02-14 04:01:52 +09:00
Adrian Vovk 0bac442251
basic: Add some sha256 helper functions
Adds a util function to sha256 an open fd (moved from dissect). Also
adds functions to check if a string contains a valid sha256 hash, and
parse it into a sha256 array.
2024-02-13 13:59:27 -05:00
Yu Watanabe dcd484e545 tools: fix typo
Follow-up for 6d55e3a364.
2024-02-14 03:58:35 +09:00
Frantisek Sumsal 5b1aa0e19a core: escape spaces when serializing as well
Otherwise they might get stripped when reading the serialized data back.

Resolves: #31214
2024-02-14 02:22:58 +08:00
Adrian Vovk a7a67dfd9d
fundamental: Add overflow-safe math helpers
ADD_SAFE/SUB_SAFE/MUL_SAFE do addition/subtraction/multiplication
respectively with an overflow check. If an overflow occurs these return
false, otherwise true. Example: (c = a + b) would become ADD_SAFE(&c, a,
b)

INC_SAFE/DEC_SAFE/MUL_ASSIGN_SAFE are like above but they also reassign
the first argument. Example: (a += b) would become INC_SAFE(&a, b)
2024-02-13 13:08:20 -05:00
Daan De Meyer 6d55e3a364 Use tilde for rc tag versioning
tilde sorts lower in the version comparison spec:
https://uapi-group.org/specifications/specs/version_format_specification/

➜  systemd git:(strip) systemd-analyze compare-versions 249\~rc1 249
249\~rc1 < 249
➜  systemd git:(strip) systemd-analyze compare-versions 249-rc1 249
249-rc1 > 249

Also update tools/meson-vcs-tag.sh to use carets instead of hyphens
for the git part of the version as carets are allowed to be part of
a version by pacman while hyphens are not and both sort higher than
a version without the git part.
2024-02-13 18:14:36 +01:00
김인수 ccc5673cc9 po: Translated using Weblate (Korean)
Currently translated at 100.0% (227 of 227 strings)

Co-authored-by: 김인수 <simmon@nplob.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/ko/
Translation: systemd/main
2024-02-13 10:49:37 +01:00
Lennart Poettering c9cdbaed17
Merge pull request #30380 from keszybz/tmpfiles-dry-run
Make tmpfiles/sysusers nicer with local files and implement tmpfiles --dry-run
2024-02-13 09:45:50 +01:00
Ondrej Kozina c5daf14c88 cryptsetup: Add optional support for linking volume key in keyring.
cryptsetup 2.7.0 adds feature to link effective volume key in custom
kernel keyring during device activation. It can be used later to pass
linked volume key to other services.

For example: kdump enabled systems installed on LUKS2 device.
This feature allows it to store volume key linked in a kernel keyring
to the kdump reserved memory and reuse it to reactivate LUKS2 device
in case of kernel crash.
2024-02-13 09:45:08 +01:00
Lennart Poettering 10048b2e20 update TODO 2024-02-13 09:17:43 +01:00
Frantisek Sumsal 16343f52ba
Merge pull request #31271 from fbuihuu/test-69-debugging-improvements
Test 69 debugging improvements
2024-02-12 21:14:43 +01:00
Lennart Poettering 9321b5187f
Merge pull request #31284 from poettering/btrfs-alignment
btrfs: various clean-ups including alignment fixes
2024-02-12 17:50:13 +01:00
cunshunxia c18c7e2322 Fix OOMPolicy= version in manpage of systemd.scope
OOMPolicy in scope units is separately supported in
version v253, so I think it cannot be directly used
in the manpage with the version from the service.

fix:#30836
2024-02-12 16:49:42 +00:00
Luca Boccassi 27af7c2b4c
Merge pull request #31162 from poettering/tint-tweaks
ptyfwd: some tweaks to terminal handling
2024-02-12 16:47:09 +00:00
Franck Bui cf14d11447 test/test-shutdown.py: optionally display the test I/Os in a dedicated log file
Given that the test involves screen(1), sending various control sequences to
resize/clear the screen, most of the logs sent from the python script were
nearly impossible to read or mixed with other messages sent to the console
hence making the debug harder when the test is run manually.

This patch introduces an option to redirect the pexpect IOs into a file (to be
used in $STATEDIR/TEST-69-SHUTDOWN/run-nspawn).

The pexpect logs are also enabled later so the boot logs are skipped since
those are already included in the journal.
2024-02-12 16:57:51 +01:00
Lennart Poettering a85daa97d9
Merge pull request #31233 from poettering/pcrlock-varlink
pcrlock: add simple Varlink API + some varlinkctl tweaks
2024-02-12 15:48:03 +01:00
Lennart Poettering 801bf40c3b btrfs-util: apparently btrfs ioctls return unaligned data. deal with it.
Kinda sad, that interfaces like this exist in 2024. But let's deal with
it: before we access "struct btrfs_ioctl_search_header" let's copy it
out, and access it only in the aligned copy.

Fixes: #31282
2024-02-12 15:35:15 +01:00
Lennart Poettering e5c41c6138 btrfs-util: use memdup_suffix0() instead of strndup() at one more place
The structure we copy this out is a large (unaligned) binary blob, hence
let's better use the memdup_suffix0() so that gcc doesn't make
assumption about the source being a valid string.
2024-02-12 15:35:11 +01:00
Lennart Poettering 05f38c897f btrfs-util: rework btrfs_is_nocow_fd() around fd_is_fs_type() + read_attr_fd()
Let's our safer helpers where appropriate.
2024-02-12 15:35:03 +01:00
Mike Yuan eef2b1a7b1
core/load-fragment: fix typo (sanety -> sanity)
Follow-up for 435e1098ee
2024-02-12 21:44:50 +08:00
Lennart Poettering 8b68a199c2
Merge pull request #31242 from poettering/socket-uid-account
pid1: make MaxConnectionsPerSource= do something useful on AF_UNIX sockets
2024-02-12 14:07:51 +01:00
Lennart Poettering 39d69836ad missing: change our close_range() syscall wrapper to map glibc's
So glibc exposes a close_range() syscall wrapper now, but they decided
to use "unsigned" as type for the fds. Which is a bit weird, because fds
are universally understood to be "int". The kernel internally uses
"unsigned", both for close() and for close_range(), but weirdly,
userspace didn't fix that for close_range() unlike what they did for
close()... Weird.

But anyway, let's follow suit, and make our wrapper match glibc's.

Fixes #31270
2024-02-12 14:07:19 +01:00
Zbigniew Jędrzejewski-Szmek 2479f0bb09 TODO: add --dry-run/-n 2024-02-12 13:34:39 +01:00
Zbigniew Jędrzejewski-Szmek b214427752 TEST-22: add --dry-run calls
aCdDefLprRwxXz are tested with --dry-run.
I added a primitive test of bc.
There were no tests for AhHt, and I didn't add those either.
2024-02-12 13:34:32 +01:00
Zbigniew Jędrzejewski-Szmek 983dbcefe8 systemd-tmpfiles: use statx_mount_same
It was pointed out in review that the preexisting code should be updated
(https://github.com/systemd/systemd/pull/30380#discussion_r1426899180).
2024-02-12 13:34:25 +01:00
Zbigniew Jędrzejewski-Szmek 9e90d4f42e tmpfiles: implement --dry-run
The idea is simple: skip the final operation that creates or removes things
or changes the attributes, but otherwise go through the rest of the code.
This results in quite a lot of fairly repetitive conditions in the low-level
code. Another approach would be to print earlier, at a higher level, but then
we'd have less precise information about what is about to happen.
2024-02-12 13:33:30 +01:00
Michal Koutný 5734d5d04c service: Demote log level of NotifyAccess= messages to debug
The situation is a service like

        Type=notify
        NotifyAccess=main

and the service uses some of the systemd helper utilities, e.g.
coredumpctl. The service process will pass NOTIFY_SOCKET to the helper
child (accidentally) and the result is a spurious notification and
the warning message:

> Jan 18 09:38:01 host systemd[1]: sdnotify.service: Got notification message from PID 13736, but reception only permitted for main PID 13549

Notification from helpers seem like an unintentional composition of the
commit c118b577fa ("coredumpctl: define main through macro") and commit
6b636c2d27 ("main-func: send main exit code to parent via sd_notify() on
exit"). The former used the handy macro for a main function, the latter
equipped any main function with the notification. (Further extended in
the commit 623a00020f ("notify: Add EXIT_STATUS field").)

Since notification from systemd utitilities are meant to extend
rudimentary exit()/wait() pair generally, they may happen to land into
service's NOTIFY_SOCKET. Tone down messages of notification that won't
match NotifyAccess=.
2024-02-12 12:20:39 +01:00
Lennart Poettering a66ab6d801
Merge pull request #31076 from CodethinkLabs/vmspawn/directory_image_support
[vmspawn] directory type image support
2024-02-12 12:20:16 +01:00
Mike Yuan d7ececa107
Merge pull request #31028 from yuwata/journalctl-raise
journalctl: call all cleanup functions before raise()
2024-02-12 19:16:15 +08:00
Mike Yuan 4d0b06d535
Merge pull request #31181 from fbuihuu/gpt-auto-more-defensive
gpt-auto-generator: be more defensive when checking the presence of E…
2024-02-12 19:12:17 +08:00
Lennart Poettering e0abffe600 update TODO 2024-02-12 12:04:18 +01:00
Lennart Poettering d02018afdb test: add brief test for prclock varlink interfaces and varlinkctl --collect 2024-02-12 12:04:18 +01:00
Lennart Poettering 24835e9933 varlinkctl: if "call" verb is used, imply "-j"
For the other verbs turning off JSON mode makes sense, but for "call"
not so much, after all the contents of a method call reply is JSON we
couldn't really show any other way.

Hence, when JSON output was not configured otherwise in "call", default
to the same as -j.
2024-02-12 12:04:18 +01:00
Lennart Poettering 7781d28fd7 varlinkctl: add new --collect switch
It exposes the varlink_collect() call we internally provide: it collects
all responses of a method call that is issued with the "more" method
call flag. It then returns the result as a single JSON array.
2024-02-12 12:04:18 +01:00