1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-14 04:58:28 +03:00

57056 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
6ec4c852c9 shared/specifier: provide proper error messages when specifiers fail to read files
ENOENT is easily confused with the file that we're working on not being
present, e.g. when the file contains %o or something else that requires
os-release to be present. Let's use -EUNATCH instead to reduce that chances of
confusion if the context of the error is lost.

And once we have pinpointed the reason, let's provide a proper error message:

+ build/systemctl --root=/tmp/systemctl-test.TO7Mcb enable some-some-link6@.socket
/tmp/systemctl-test.TO7Mcb/etc/systemd/system/some-some-link6@.socket: Failed to resolve alias "target@A:%A.socket": Protocol driver not attached
Failed to enable unit, cannot resolve specifiers in "target@A:%A.socket".
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
7962116fc8 shared/specifier: clarify and add test for missing data
In systemd.unit we document that unset fields resolve to "". But we didn't
directly test this, so let's do that. Also, we return -ENOENT if the file
is missing, which we didn't document or test.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
3a84a3c9df man/os-release: add a note about repeating entries
We didn't actually say that keys should not be repeated. At least the
examples in docs (both python and shell) would do that, and any simple
parser that builds a dictionary would most likely behave the same way.
But let's document this expectation, but also say how to deal with malformed
files.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
25407ad2a7 basic/env-file: make load-env-file deduplicate entries with the same key
We generally assume parsing like the shell would do it, so the last value
should win when there are repeats.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
80e72f80bc test-os-util: add basic tests for os-release parsing 2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
df78419d10 basic: add new variable $SYSTEMD_OS_RELEASE to override location of os-release
The test for the variable is added in test-systemctl-enable because there we
can do it almost for free, and the variable is most likely to be used with
'systemctl enable --root' anyway.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
ecd6c000d3 man: clarify the descriptions of aliases and linked unit files
This just describes the rules that are implemented by the manager, and this
pull request does not change any of them.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
367c47c886 tests: add helper for creating tempfiles with content
I put it in tests because I think we're most likely to use it in tests.
If necessary, it can be moved somewhere else later.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
50c5f5a3d9 test: add test for systemctl link & enable
This test has overlap with test-install-root, but it tests things at a
different level, so I think it's useful to add. It immediately shows various
bugs which will be fixed in later patches.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
e75a26d045 shared/install: add a bit more quoting
When we are printing a valid unit name, quoting isn't necessary, because
unit names cannot contain whitespace or other confusing characters. In particular
if the unit name is prefixed by " unit " or something else that clearly
identifies the string as a unit name, quoting would just add unnecessary
noise. But when we're printing paths or invalid names, it's better to add
quotes for clarity.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
047d37dc3d shared/install: reuse the standard symlink verification subroutine
We save a few lines, but the important thing is that we don't have two
different implementations with slightly different rules used for enablement
and loading. Fixes #22000.

Tested with:
- the report in #22000, it now says:
$ SYSTEMD_LOG_LEVEL=debug systemctl --root=/ enable test.service
Suspicious symlink /etc/systemd/system/test.service→/etc/systemd/system/myown.d/test.service, treating as alias.
unit_file_resolve_symlink: self-alias: /etc/systemd/system/test.service → test.service, ignoring.
running_in_chroot(): Permission denied
Suspicious symlink /etc/systemd/system/test.service→/etc/systemd/system/myown.d/test.service, treating as alias.
unit_file_resolve_symlink: self-alias: /etc/systemd/system/test.service → test.service, ignoring.
Failed to enable unit, refusing to operate on linked unit file test.service

- a symlink to /dev/null:
...
unit_file_resolve_symlink: linked unit file: /etc/systemd/system/test3.service → /dev/null
Failed to enable unit, unit /etc/systemd/system/test3.service is masked.

- the same from the host:
...
unit_file_resolve_symlink: linked unit file: /var/lib/machines/rawhide/etc/systemd/system/test3.service → /var/lib/machines/rawhide/dev/null
Failed to enable unit, unit /var/lib/machines/rawhide/etc/systemd/system/test3.service is masked.

- through the manager:
$ sudo systemctl enable test.service
Failed to enable unit: Refusing to operate on alias name or linked unit file: test.service
$ sudo systemctl enable test3.service
Failed to enable unit: Unit file /etc/systemd/system/test3.service is masked.

As seen in the first example, the warning is repeated. This is because we call
the lookup logic twice: first for sysv-compat, and then again for real. I think
that since this is only for broken setups, and when sysv-compat is enabled, and
in an infrequent manual operation, at debug level, this is OK.
2022-03-29 16:16:02 +02:00
Zbigniew Jędrzejewski-Szmek
48542eac39 basic/stat-util: add null_or_empty_path_with_root() 2022-03-29 15:07:05 +02:00
Luca Boccassi
2350712e32 portable: allow reattaching when one image has a version and the other does not
A reattach might go from img.raw to img_0.1.raw or viceversa, but this is
not allowed right now as we try to match the full name.

Also take into account that running strcspn(a, '/') on an image name, without
leading path, will return the length of the full string, but the versions
might be different so they won't match, eg:

img_0.1.raw -> 12
img_0.1.1.raw -> 14

So adjust the check to take that into account, and skip it if we are not
dealing with directories
2022-03-29 14:02:48 +01:00
Andy Chi
f09f6dc2c8 hwdb: Add mic mute key mapping for HP Elite x360
On the new Elite x360 2 in 1 HP laptops, the microphone mute hotkey is "Fn+F8" and
the scancode for this hotkey is 0x81, but this scancode was mapped to
fn_esc in the HP generic keymap section. To fix this problem, we add
a machine specific keymap section to add the correct keymap rule.
2022-03-29 14:48:26 +02:00
Zbigniew Jędrzejewski-Szmek
9825181143 basic/unit-file: split out the subroutine for symlink verification
The old logs used __func__, but this doesn't make sense now, because the
low-level function will be used in other places. So those are adjusted to be
more generic.
2022-03-29 14:19:28 +02:00
Yu Watanabe
f777e745a7 udev: do not call sd_event_source_disable_unref() in workers for event sources created by the main process
Fixes a bug introduced by 9612da361a825d70a9fd392f3ee5a53bf8896887.
2022-03-29 10:29:44 +02:00
Yu Watanabe
8166950763 inotify-util: fix wrong warnings in FOREACH_INOTIFY_EVENT()
Follow-up for 00adc340bb15bc9d634db6caa48f1c964b99f79a.

This fixes the wrong "Received invalid inotify event, ignoring." warnings
caused by the missing curly brackets and the priorities of `&&` and `?:`.

This also replaces the ternary operators with `||`.
2022-03-29 13:20:16 +09:00
Franck Bui
6d39da79c8 build: include status of TPM2 in the feature string show by --version 2022-03-29 05:20:20 +09:00
Yu Watanabe
2afb2f4a9d
Merge pull request #22885 from poettering/kill-clock-boottime-or-monotonic
time-util: assume CLOCK_BOOTTIME always exists
2022-03-29 03:06:54 +09:00
Gaël PORTAY
f3b3cab2f2
veritysetup: fix typo (#22886) 2022-03-29 02:09:36 +09:00
Yu Watanabe
288bd40620 fix typo 2022-03-29 01:21:51 +09:00
Yu Watanabe
0c6e746b86 Update NEWS
- categorize entries
- add several news for networkd and udevd
2022-03-29 01:19:18 +09:00
Lennart Poettering
ba4e0427e9 time-util: assume CLOCK_BOOTTIME always exists
Let's raise our supported baseline a bit: CLOCK_BOOTTIME started to work
with timerfd in kernel 3.15 (i.e. back in 2014), let's require support
for it now.

This will raise our baseline only modestly from 3.13 → 3.15.
2022-03-28 16:55:41 +02:00
Yu Watanabe
ec4954d934 network: rename netdev kind virtual-wlan -> wlan
The Kind= setting in [Match] section of .network files takes "wlan".
This makes the same setting in .netdev files matches the one in .network
files.
2022-03-28 23:53:12 +09:00
Lennart Poettering
af9ae75026 bootspec: normalize function names/parameter lists
This normalizes naming of functions operating on BootConfig objects.
Let's always call them boot_config_xyz(), like our usual way to name
stuff.

moreover, move the BootConfig parameter to the beginning, as it's not a
return value (which we typically move to the end of the parameter list),
but simply an object, that even happens to be initialized already.

With these changes the functions are more like our usual way to call
things, and less surprises are good.
2022-03-28 16:02:15 +02:00
Lennart Poettering
3f8e42c038 bootspec: don't needlessly inline boot_config_find_entry()
the function contains a loop and if expressions and whatnot. Let's
define it as regular function, to make the header easier to read and let
the compiler more freedom on whether to inline this or not.
2022-03-28 16:01:58 +02:00
Lennart Poettering
d412691a91 bootctl: use boot_config_default_entry() where appropriate 2022-03-28 16:01:54 +02:00
Lennart Poettering
f7a7a5e267 bootspec: assess default/selected entries *after* we augmented entry list with entries from loader
Fixes: #22580
2022-03-28 16:01:36 +02:00
Lennart Poettering
92067ab672 bootspec: normalize oom handling in boot_load_efi_entry_pointers()
OOM should usually be fatal, hence make it so here, too.
2022-03-28 16:01:32 +02:00
Lennart Poettering
85e17916d3 bootspec: rename type1 parsers to say "type1" explicitly in the name
This just got too confusing for me. With this change we'll now have
_unified as common suffix for stuff loading unified kernels (i.e. type
1), and _type1 as common suffix for type1 entries.

Just some renaming.
2022-03-28 16:01:28 +02:00
Lennart Poettering
d486a0eaaa bootspec: try harder to suppress duplicate enumerated entries
For testing purposes I run one of my system symlinking /boot/loader/ to
/efi/loader/. This triggers annoying behaviour in boot entry
enumeration: the code ends up iterating through the 'entries' subdir of
both, thinking one was actually in the ESP and the other in XBOOTLDR,
and thus distinct. This would result in duplicate entries.

Let's address that, and filter out duplicates via their inode numbers:
never process the same inode twice. This should protect us from any
confusion effectively, regardless which inodes are symlinked (or even
bind mounted).
2022-03-28 16:01:10 +02:00
Lennart Poettering
85f4ae2f50 bootspec: pass around BootConfig struct instead of entries/n_entries fields only
This simplifies the parameter lists quite a bit, at zero change in
behaviour.
2022-03-28 16:01:06 +02:00
Lennart Poettering
d04f033111 bootspec: don't use conf_files_list() for finding type #1 entries
We can't really use conf_files_list() for finding type #1 entries, since
it is case-sensitive, but type #1 entries are typically placed on VFAT,
i.e. are case-insensitive.

hence, use readdir_all() instead, which is quite similar, but gives us
all files, and allows us to do a case-insensitive check.

While we are at it, use openat() on the open dir to open the file, and
pass that around, to make things a tiny bit more race-free.
2022-03-28 16:01:02 +02:00
Lennart Poettering
0d1506d4a8 bootctl: optionally, output entries in JSON format
Replaces: #18387
Fixes: #18094
2022-03-28 16:00:25 +02:00
наб
53350c7bba Use new default-user-shell option instead of hard-coding bash in nspawn and user-record
Defaults to /bin/bash, no changes in the default configuration

The fallback shell for non-root users is as-specified,
and the interactive shell for nspawn sessions is started as
  exec(default-user-shell, "-" + basename(default-user-shell), ...)
before falling through to bash and sh
2022-03-28 14:24:46 +02:00
Luca Boccassi
505df87ea8 docs: use native type instead of byte stream in COREDUMP_PACKAGE_METADATA
The first three fields of a note are binary, so they are subject to
flipping due to endianess. Instead of a stream of bytes, just use
the native 4-bytes type so that it gets encoded automatically.

Implemented in the tools via: https://github.com/systemd/package-notes/pull/31
2022-03-28 14:19:42 +02:00
Romain Naour
608c3b0293 missing-syscall: define MOVE_MOUNT_T_EMPTY_PATH if missing
MOVE_MOUNT_T_EMPTY_PATH has been added to systemd 250 by [1]
but it's defined in kernel headers since version 5.2.

[1] c7bf079bbc19e3b409acc0c7acc3e14749211fe2
2022-03-28 16:37:59 +09:00
Luca Boccassi
d13ce742e1
Merge pull request #22834 from yuwata/network-sriov-request-queue
network: sriov: use request queue
2022-03-26 19:12:42 +00:00
Luca Boccassi
6b72105a78 portable: clarify error when detach fails to match to existing unit
Clarify that it's looking at attached units, not at units inside the referenced
image. Also take into account extensions.
2022-03-26 11:20:39 +00:00
Zbigniew Jędrzejewski-Szmek
d6297626dd NEWS: tweaks 2022-03-25 16:32:16 +01:00
Xiaotian Wu
0172289348 basic: update the Arch tuples for LoongArch 2022-03-26 00:29:38 +09:00
Yu Watanabe
dd2396f20d
Merge pull request #22861 from poettering/journald-sigterm
journald: don't let SIGTERM starve indefinitely
2022-03-26 00:27:47 +09:00
Daan De Meyer
e5531be27b
Merge pull request #22857 from poettering/journal-file-flags
journal: add flags param to journal_file_open(), replacing bools
2022-03-25 10:16:12 +01:00
Lennart Poettering
47f04c2a69 journal-file: if we are going down, don't use event loop to schedule post
The event loop is already shutting down, hence no point in using it
anymore, it's not going to run any further iteration.
2022-03-25 10:03:00 +01:00
Lennart Poettering
19252b2548 journald: make sure SIGTERM handling doesn't get starved out
Fixes: #22642
2022-03-25 10:03:00 +01:00
Lennart Poettering
e540c5a621 journal: don't talk about -1 in context of unsigned values 2022-03-25 09:59:09 +01:00
Lennart Poettering
49615dbd81 journal-file: merge compress/seal bool args into a single flags param
Just some modernization/refactoring.

No change in behaviour, just let's do how we do things these days: use
flags param instead of list of bools.
2022-03-25 09:59:09 +01:00
Lennart Poettering
6fb57abcfa
Merge pull request #22717 from yuwata/udev-lock-block-device-by-main-process
udev: do not skip events when device is already locked
2022-03-25 09:43:12 +01:00
Lennart Poettering
a35420d85d journal-remote: constify a few parameters 2022-03-25 09:21:38 +01:00
Lennart Poettering
88a19c7e04
Merge pull request #22859 from poettering/hardware-rename
machine-info: rename VENDOR=/MODEL= → HARDWARE_VENDOR=/HARDWARE_MODEL=
2022-03-25 09:12:14 +01:00