1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 14:55:37 +03:00
Commit Graph

57197 Commits

Author SHA1 Message Date
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 9612da361a.
2022-03-29 10:29:44 +02:00
Yu Watanabe
8166950763 inotify-util: fix wrong warnings in FOREACH_INOTIFY_EVENT()
Follow-up for 00adc340bb.

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] c7bf079bbc
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
Benjamin Berg
c2b42ec413 xdg-autostart-service: Fix binary escaping and simplify code a bit
Instead of escaping each component separately, we can instead use
quote_command_line. Doing so simplifies the code and fixes an issue
where spaces inside the executable name were not escaped.

Co-Authored-By: David Edmundson <kde@davidedmundson.co.uk>
2022-03-25 14:50:41 +09:00
Yu Watanabe
8603a229e9 efi-loader: drop harmful assertion
This fixes a bug introduced by 7be4b23649.

The function `efi_loader_get_device_part_uuid()` handles NULL
gracefully, and it is called with NULL in gpt-auto-generator.

Fixes #22862.
2022-03-25 14:29:44 +09:00
Frantisek Sumsal
41d1aaea64 test: use flock when calling mkfs.btrfs
As stated in https://github.com/systemd/systemd/issues/21819#issuecomment-1064377645
`mkfs.btrfs` doesn't hold the lock for the whole duration of
`mkfs.btrfs`, thus causing unexpected races & test fails. Let's
wrap the `mkfs.btrfs` calls in an flock wrapper to mitigate this.

Hopefully fixes: #21819
2022-03-25 10:28:07 +09:00
Frantisek Sumsal
ed1cbdc347 Revert "test: temporary workaround for #21819"
This reverts commit 95e35511bb.
2022-03-25 10:28:07 +09:00
Yu Watanabe
82a5de9fd2 udev: assume block device is not locked when a new event is queued
Then, hopefully, previously requeued events are processed earlier.
2022-03-25 10:28:07 +09:00
Yu Watanabe
7b7959fba5 udev: split worker_lock_block_device() into two
This also makes return value initialized when these function return 0 to
follow our coding style.

Just a preparation for later commits.
2022-03-25 10:28:07 +09:00
Yu Watanabe
5d354e525a udev: requeue event when the corresponding block device is locked by another process
Previously, if a block device is locked by another process, then the
corresponding worker skip to process the corresponding event, and does
not broadcast the uevent to libudev listners. This causes several issues:

- During a period of a device being locked by a process, if a user trigger
  an event with `udevadm trigger --settle`, then it never returned.

- When there is a delay between close and unlock in a process, then the
  synthesized events triggered by inotify may not be processed. This can
  happens easily by wrapping mkfs with flock. This causes severe issues
  e.g. new devlinks are not created, or old devlinks are not removed.

This commit makes events are requeued with a tiny delay when the corresponding
block devices are locked by other processes. With this way, the triggered
uevent may be delayed but is always processed by udevd. Hence, the above
issues can be solved. Also, it is not necessary to watch a block device
unconditionally when it is already locked. Hence, the logic is dropped.
2022-03-25 10:28:03 +09:00
Yu Watanabe
0c3d8182c9 udev: store action in struct Event 2022-03-25 10:25:27 +09:00
Yu Watanabe
c17ab900cb udev: introduce device_broadcast() helper function 2022-03-25 10:25:26 +09:00