1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00
Commit Graph

58194 Commits

Author SHA1 Message Date
наб
e01f55dab5 kernel-install: don't log each initrd on its own line in verbose mode
(cherry picked from commit 2f9f8b96d4)
2022-06-02 20:07:11 +02:00
наб
c6dd6afe02 kernel-install: actually ignore the last two arguments
(cherry picked from commit c60ca42571)
2022-06-02 20:07:10 +02:00
Evgeny Vereshchagin
75a700e233 tests: link tests using fabs against libm explicitly
Some compiler wrappers like honggfuzz pass -fno-builtin explicitly
and because of that the tests where fabs is used fail to compile
with something like
```
FAILED: test-bus-marshal
...
/usr/bin/ld: test-bus-marshal.p/src_libsystemd_sd-bus_test-bus-marshal.c.o: undefined reference to symbol 'fabs@@GLIBC_2.2.5'
/usr/bin/ld: /usr/lib64/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
```

Fun fact: it took honggfuzz less than a minute to discover
https://github.com/advisories/GHSA-gmc7-pqv9-966m used by
systemd to compress/descompress some stuff.

(cherry picked from commit f232c83c72)
2022-06-02 20:07:10 +02:00
Yu Watanabe
a5c4e29b2c sd-bus: fix buffer overflow
Fixes #23486.

(cherry picked from commit 89b6a3f13e)
2022-06-02 20:07:10 +02:00
Nick Rosbrook
f00716615d sd-hwdb: include sys/stat.h in hwdb-internal.h
Include this header to fix errors when including hwdb-internal.h:
  ../src/libsystemd/sd-hwdb/hwdb-internal.h:16:21: error: field ‘st’ has incomplete type
     16 |         struct stat st;

(cherry picked from commit 9745b51c73)
2022-06-02 20:04:07 +02:00
Frantisek Sumsal
0239991775 test: bump the post-reboot expect() timeout
as it may take a bit longer on slower machines:

```
[  OK  ] Reached target System Reboot.
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Failed to open watchdog device /dev/watchdog0, ignoring: No such file or directory
binfmt_misc is not mounted, not detaching entries.
Sending SIGTERM to remaining processes...
ERROR:test-shutdown:Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7f3d4bcd20b0>
command: /systemd-meson-build/systemd-nspawn
<...snip...>
buffer (last 100 chars): 'mbinfmt_misc is not mounted, not detaching entries.\x1b[0m\r\nSending SIGTERM to remaining processes...\r\n'
before (last 100 chars): 'mbinfmt_misc is not mounted, not detaching entries.\x1b[0m\r\nSending SIGTERM to remaining processes...\r\n'
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 572528
child_fd: 5
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile('H login: ')
INFO:test-shutdown:killing child pid 572528
E: nspawn failed with exit code 1
```

(cherry picked from commit 3e624bb13b)
2022-06-02 20:04:07 +02:00
Zbigniew Jędrzejewski-Szmek
f8bb8d4b82 shared/find-esp: fix inverted check for XBOOTLDR type
(cherry picked from commit 4e12442554)
2022-06-02 20:04:06 +02:00
Zbigniew Jędrzejewski-Szmek
cfd6a14c7d man/homectl: adjust man page to match code
Fixes #22966. Since there are competing conventions, let's not
change our code, but make the docs match what is implemented.

(cherry picked from commit b72308d344)
2022-06-02 20:04:06 +02:00
Zbigniew Jędrzejewski-Szmek
11b8069929 man/sd-bus: discuss negative-return values and add example
Fixes #22816.

(cherry picked from commit 8f24777156)
2022-06-02 20:04:06 +02:00
Zbigniew Jędrzejewski-Szmek
7c2b2f279c man/shutdown: explain -h more
Fixes #23401

(cherry picked from commit 5ee38adea4)
2022-06-02 20:04:06 +02:00
Zbigniew Jędrzejewski-Szmek
7a73f995e2 man/automount: say that automounts should not be nested
Fixes #21832.

(cherry picked from commit 223a359f21)
2022-06-02 20:04:06 +02:00
Zbigniew Jędrzejewski-Szmek
0d3ba825e2 man/systemd.automount: move the main description up and clarify deps
(cherry picked from commit 93dbc22a95)
2022-06-02 20:04:06 +02:00
Eduard Tolosa
d5be915999 loader.conf: Clarify the default value of timeout.
(cherry picked from commit 815068d3a3)
2022-06-02 20:04:06 +02:00
Rahil Bhimjiani
4bd2056fbc [sd-boot] improve documentation of beep
(cherry picked from commit 97e7d4945d)
2022-06-02 20:04:06 +02:00
Anita Zhang
e10683b13a test-seccomp: check for CAP_IPC_OWNER before calling shmat()
shmat() requires the CAP_IPC_OWNER capability. When running test-seccomp
in environments with root + CAP_SYS_ADMIN, but not CAP_IPC_OWNER,
memory_deny_write_execute_shmat would fail. This fixes it.

(cherry picked from commit 7e46a5c093)
2022-06-02 20:04:06 +02:00
Yu Watanabe
131206de78 core/device: do not downgrade device state if it is already enumerated
On switching root, a device may have a persistent databse. In that case,
Device.enumerated_found may have DEVICE_FOUND_UDEV flag, and it is not
necessary to downgrade the Device.deserialized_found and
Device.deserialized_state. Otherwise, the state of the device unit may
be changed plugged -> dead -> plugged, if the device has not been mounted.

Fixes #23429.

[mwilck: cherry-picked from #23437]

(cherry picked from commit 4fc69e8a09)
2022-05-27 11:52:27 +09:00
Martin Wilck
4f86dd2849 core/device: device_coldplug(): don't set DEVICE_DEAD
dm-crypt device units generated by systemd-cryptsetup-generator
habe BindsTo= dependencies on their backend devices. The dm-crypt
devices have the db_persist flag set, and thus survive the udev db
cleanup while switching root. But backend devices usually don't survive.
These devices are neither mounted nor used for swap, thus they will
seen as DEVICE_NOT_FOUND after switching root.

The BindsTo dependency will cause systemd to schedule a stop
job for the dm-crypt device, breaking boot:

[   68.929457] krypton systemd[1]: systemd-cryptsetup@cr_root.service: Unit is stopped because bound to inactive unit dev-disk-by\x2duuid-3bf91f73\x2d1ee8\x2d4cfc\x2d9048\x2d93ba349b786d.device.
[   68.945660] krypton systemd[1]: systemd-cryptsetup@cr_root.service: Trying to enqueue job systemd-cryptsetup@cr_root.service/stop/replace
[   69.473459] krypton systemd[1]: systemd-cryptsetup@cr_root.service: Installed new job systemd-cryptsetup@cr_root.service/stop as 343

Avoid this by not setting the state of the backend devices to
DEVICE_DEAD.

Fixes the LUKS setup issue reported in #23429.

(cherry picked from commit cf1ac0cfe4)
2022-05-27 11:52:27 +09:00
Frantisek Sumsal
b3781ad821 test: store the key on a separate device
(cherry picked from commit 6b70d3cf81)
2022-05-27 11:52:27 +09:00
Frantisek Sumsal
dd46f0356d test: generate a custom initrd for TEST-24 if $INITRD is unset
Co-Authored-By: Yu Watanabe <watanabe.yu+github@gmail.com>
(cherry picked from commit b22d90e594)
2022-05-27 11:52:27 +09:00
Frantisek Sumsal
165279a79d test: cover initrd->sysroot transition in TEST-24
This should cover cases regarding devices with `OPTIONS+="db_persist"`
during initrd->sysroot transition.

See:
  * https://github.com/systemd/systemd/issues/23429
  * https://github.com/systemd/systemd/pull/23218
  * https://github.com/systemd/systemd/pull/23489
  * https://bugzilla.redhat.com/show_bug.cgi?id=2087225
(cherry picked from commit 1fb7f8e15e)
2022-05-27 11:52:27 +09:00
Yu Watanabe
e6b1694183 Revert "Revert "core/device: ignore DEVICE_FOUND_UDEV bit on switching root""
This reverts commit 011161de61.
2022-05-27 11:52:27 +09:00
Zbigniew Jędrzejewski-Szmek
dcda9f3d07 kernel-install: ignore extra args passed when invoked as installkernel
kernel's 'make install' invokes install.sh which calls /sbin/install-kernel.
Thus we are invoked as e.g.
  /sbin/installkernel 5.18.0 arch/x86/boot/bzImage System.map /boot
The last two arguments would be passed as "initrds".

Before , we would just quitely ignore
/boot, because it doesn't pass the 'test -f' test, and possibly try to do
something with System.map. 742561efbe tightened
the check, so we now throw an error.

It seems that the correct thing is to ignore those two arguments, because
our plugin syntax has no notion of System.map. And the installation directory
we can figure out ourselves better. Effectively, this makes things behave
like before, but less by accident.

Fixes #23490.

(cherry picked from commit 620ecc9c4b)
2022-05-24 23:32:34 +02:00
Luca Boccassi
011161de61 Revert "core/device: ignore DEVICE_FOUND_UDEV bit on switching root"
This reverts commit 75d7b5989f.

This commit was confirmed to have introduced a regression with LUKS,
so revert it for now.

https://github.com/systemd/systemd/issues/23429

Conflicts:
	src/core/device.c
2022-05-25 03:33:18 +09:00
Daan De Meyer
eb76587f33 bootctl: Make sure bootctl install returns 0 on success
This backports the same fix from 6e9165397f
in systemd upstream that we can't backport directly because that commit
introduces a new feature.
2022-05-24 15:27:09 +01:00
Luca Boccassi
b622e95f2f
Merge pull request #23463 from bluca/hwdb
Finalize NEWS and hwdb for v251
2022-05-21 14:23:41 +01:00
Luca Boccassi
7f2ec323f6 NEWS: finalize 2022-05-21 12:55:07 +01:00
Luca Boccassi
5ea8bcd93d hwdb: update via ninja -C build update-hwdb 2022-05-21 12:44:36 +01:00
Luca Boccassi
410b996a72 NEWS: update contributors list 2022-05-21 12:43:19 +01:00
Yu Watanabe
30e29edf4c sysext: refuse empty release ID to avoid triggering assertion
Otherwise, the assertion in extension_release_validate() will be
triggered.
2022-05-21 06:37:56 +09:00
Yu Watanabe
1f97c2da0c test: add test for bus introspection of portable1
Follow-up for #23454.
2022-05-21 06:31:19 +09:00
Yu Watanabe
f65dcad5b7
Merge pull request #23439 from keszybz/kernel-install-verbose
Make kernel-install --verbose more verbose and some autodetection logic fixups
2022-05-21 04:26:03 +09:00
Yu Watanabe
3833c3356b
Merge pull request #23451 from medhefgo/boot-static-assert
boot: C11/static_assert
2022-05-21 04:22:17 +09:00
Luca Boccassi
54cd2d6869 sd-bus: add comment and test in sd_bus_path_decode() for empty string
3970	        e = object_path_startswith(path, prefix);
(gdb) p path
$1 = 0x55c5a166f768 "/org/freedesktop/portable1/image"
(gdb) p prefix
$2 = 0x55c59ffc2928 "/org/freedesktop/portable1/image"
(gdb) p e
$1 = 0x5581a1675788 ""

This can be a bit confusing in certain cases, so add a comment and a
test to make the behaviour clearer and explicit.
2022-05-21 03:44:09 +09:00
Yu Watanabe
cd532c633f
Merge pull request #23454 from keszybz/portable-introspect
Fix bus introspection of portable1
2022-05-21 03:41:22 +09:00
Zbigniew Jędrzejewski-Szmek
1b43f86893 kernel-install: restore priority of check for /boot/loader/entries
Before 9e82a74cb0, we had a check like the
following:

if [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
    ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then
    ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
elif [[ -d /boot/efi/loader/entries ]] || [[ -d /boot/efi/$MACHINE_ID ]]; then
    ENTRY_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
…

In stock Fedora 34-, /efi isn't used, but grub creates /boot/loader/entries and
installs kernels and initrds directly in /boot. Thus the second arm of the
check wins, and we end up with BOOT_ROOT=/boot.

After 9e82a74cb0, we iterate over the inner
directory first and over the second directory later:

[ -d /efi/<machine-id> ]
[ -d /boot/efi/<machine-id> ]
[ -d /boot/<machine-id> ]
[ -d /efi/Default ]
[ -d /boot/efi/Default ]
[ -d /boot/Default ]
[ -d /efi/loader/entries ]
[ -d /boot/efi/loader/entries ]
[ -d /boot/loader/entries ]

This was partially reverted by 447a822f8e which
removed Default from the list, and a5307e173b,
which moved checks for /boot up, so we ended up with:

[ -d /efi/<machine-id> ]
[ -d /boot/<machine-id> ]
[ -d /boot/efi/<machine-id> ]
[ -d /efi/loader/entries ]
[ -d /boot/loader/entries ]
[ -d /boot/efi/loader/entries ]

6637cf9db6 added autodetection of an entry
token, so we end up checking the following suffixes:

<machine-id>, $IMAGE_ID, $ID, Default

But the important unchanged characteristic is that we iterate over the suffix
first. Sadly this breaks Fedora, because we find /boot/efi/<machine-id> before
we could find /boot/loader/entries. It seems that every possible aspect of
behaviour matters for somebody, so we need to keep the original order of
detection.

With the patch:

[ -d /efi/<machine-id> ]
...
[ -d /efi/loader/entries ]
[ -d /boot/<machine-id> ]
...
[ -d /boot/loader/entries ]
[ -d /boot/efi/<machine-id> ]
...
[ -d /boot/efi/loader/entries ]

Note that we need to check for "loader/entries" too, even though it is not
an entry-token candidate, so that we get the same detection priority as
before.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2071034.
2022-05-20 15:34:17 +02:00
Zbigniew Jędrzejewski-Szmek
5943d85f34 portabled: wrap long lines and fix typo in error message 2022-05-20 15:01:56 +02:00
Zbigniew Jędrzejewski-Szmek
4313e2b69f portabled: refuse queries for empty image name
I took inspiration from pid1:
bus_unit_find()
  → find_unit()
    → manager_load_unit_from_dbus_path()
      → unit_name_from_dbus_path()
        → !startswith(path, "/org/freedesktop/systemd1/unit/")
          → return -EINVAL
          ←
        ←
      ←
    ← if (r < 0) return 0
  ← 0
←

i.e. we return 0 when queried for "/org/freedesktop/systemd1/unit".

Fixes #23445.
2022-05-20 14:59:50 +02:00
Yu Watanabe
d316426eee shared/extension-release: drop unnecessary strna() wrapper
These are not NULL.
2022-05-20 14:26:47 +02:00
Luca Boccassi
7b2e763242 portable: reject root directories without an ID field in os-release
We always require at least ID to be set in os-release, reject
and propagate error to the caller instead of asserting later
2022-05-20 13:08:45 +01:00
Luca Boccassi
a2cf73f0b6 dissect: ID from os-release should be non-empty, not just non-NULL 2022-05-20 12:05:34 +01:00
Jan Janssen
6c405f20a3 macro: Use C11 static_assert
Now that we require C11 everywhere, we can always use static_assert.
2022-05-20 12:49:50 +02:00
Jan Janssen
b1672234e0 boot: Build with C11 too 2022-05-20 12:47:43 +02:00
Zbigniew Jędrzejewski-Szmek
eb45cf97a9 kernel-install: fix detection of entry-token if $BOOT_ROOT is configured
If $BOOT_ROOT is specified, but entry-token not, we'd skip the detection
altogether, effectively defaulting to entry-token=machine-id.
The case where $BOOT_ROOT was not specied, but entry-token was configured
was handled correctly.
This patch makes the handling of both symmetrical, i.e. will only set what
wasn't configured.
2022-05-20 09:44:22 +02:00
Zbigniew Jędrzejewski-Szmek
4db4c28dc6 kernel-install: debug the configuration detection if --verbose
No changes to behaviour, but let's print everything out as we discover it.

The docs say that BOOT_ROOT can be specified by the environment. I have
it locally in /etc/kernel/install.conf, and then the override doesn't work.
It'd be nice to handle such cases more reliably.
2022-05-20 09:44:22 +02:00
Khem Raj
29b7114c5d Add sys/stat.h for S_IFDIR
Fixes
../git/src/shared/mkdir-label.c:13:61: error: use of undeclared identifier 'S_IFDIR'
        r = mac_selinux_create_file_prepare_at(dirfd, path, S_IFDIR);

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2022-05-20 14:54:02 +09:00
Daan De Meyer
dcb4e45ad8 sd-bus: Fix introspect memory leak
We have to free the contents of the set on top of the set itself.

Fixes #23443.
2022-05-20 14:53:28 +09:00
Zbigniew Jędrzejewski-Szmek
b21ba8ac6b kernel-install: bail if machine id generation fails
The call is unlikely to fail, but systemd-id128 might not be installed.
We shouldn't continue with the empty string.
2022-05-19 15:38:25 +02:00
Zbigniew Jędrzejewski-Szmek
94cbddf439 kernel-install: actually export KERNEL_INSTALL_VERBOSE
:(
2022-05-19 15:38:25 +02:00
Zbigniew Jędrzejewski-Szmek
1ab191b3a9
Merge pull request #23432 from bnf/docs-relative-links
docs: use relative links
2022-05-19 08:54:49 +02:00
Daan De Meyer
1751d8c80c portable: Remove unnecessary assert()
Fixes #23433

matches is plumbed through until it finally gets used in unit_match()
which can deal with NULL matches so the assert() is unnecessary and
can be removed.

The two call sites of extract_image_and_extensions() also don't
assert() on matches either.
2022-05-19 15:39:25 +09:00