1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-25 06:03:40 +03:00

58002 Commits

Author SHA1 Message Date
Yu Watanabe
761fc09a00 sha256: use memcpy() when result buffer is unaligned
Fixes #23578.

(cherry picked from commit c7a5eabeba1bc12adab79d2dc2cb20a78fe33227)
2022-06-02 20:07:11 +02:00
Antonio Alvarez Feijoo
98a39c3014 man: add missing arguments to systemd-creds synopsis
(cherry picked from commit 5ad0109cd8ec31b6a7fd72e0fdeaabde2669afe7)
2022-06-02 20:07:11 +02:00
Benjamin Franzke
7ee5cde343 resolved: define source address for proxy-only stub replies
DnsPacket.ifindex=1 (loopback) is normalized to 0 whenever a message is
received on the loopback iface, so for both listeners, 127.0.0.53 and
127.0.0.54, the ifindex will be set to 0 by manager_recv() for queries
that have a local origin.

Replies to such local messages need to set a proper ifindex in any
case, as the supplied source-address would otherwise be ignored in
manager_ipv4_send() (CMSG generation is skipped due to ifindex > 0 check).

Note that this change only forces `ifindex` to loopback if it was actually
normalized to `0` before (due to a loopback detection) in order to keep the
nat-to-127.0.0.54-from-another-interface usecase that was described in
a8d09063447568d87288a8e868fe386c1da7ce09 intact.
Also note that nat is not supported for the main stub 127.0.0.53 which is
why forcing LOOPBACK_IFINDEX was/is fine for that case.

Fixes #23495

(cherry picked from commit dfa14e2859418593b2f9bfae8936d780148c4e6a)
2022-06-02 20:07:11 +02:00
Christian Göttsche
423c60aff1 login: do not issue wall messages on local terminals for suspend and hibernate
Fixes: #23520

[zjs: I added the comment and tweaked the patch a bit.

The call to reset_scheduled_shutdown() is moved down a bit to allow the
callback to have access to information about the operation being cancelled.
This all happens within the same function, so there should be no observable
change in behaviour.]

(cherry picked from commit ea74f39c24344eafc238d1c69155bd5aca5f2e08)
2022-06-02 20:07:11 +02:00
Zbigniew Jędrzejewski-Szmek
befd8769c2 logind: do not print wall messages to local pseudoterminals
Fixes #23520. Replaces #23555.

The problem started with cdf370626f08ed509a5dde9d5618eed29d625032 and
90b1ec03b2ce939f589239133a32f4429f2ad6a6 which together started printing the
wall message in more cases. The motivation for those change was reasonable, but
this clearly causes problems described in #23520: users are getting unexpected
wall messages. Xterm, urxvt, (anything using libutempter?), and tmux (in some
configurations), register local pty sessions in utmp.

So let's try to suppress the message for local pseudo-terminal logins. This
patch based on #23538, but instead of filtering just on /dev/pts, it uses the
.ut_addr_v6 to only filter out local entries.

(cherry picked from commit 51a2b575d751c257f2603f12fe9bb883014c37c1)
2022-06-02 20:07:11 +02:00
Zbigniew Jędrzejewski-Szmek
865b5fb04e shared/utmp-wtmp: pass information if entry is local to filter function
This just adds an unused parameter for future use. No change in
behaviour.

(cherry picked from commit 16618332388442f2f1c3e52b0a9fde00121564a3)
2022-06-02 20:07:11 +02:00
Frantisek Sumsal
f44e534caa seccomp: fix a typo in error message
(cherry picked from commit a52765a5504108fb1d89f3d79b639b0a20efbd5e)
2022-06-02 20:07:11 +02:00
msizanoen1
1961d84ab5 cgroup-util: Properly handle conditions where cgroup.threads is empty after SIGKILL but processes still remain
After sending a SIGKILL to a process, the process might disappear from
`cgroup.threads` but still show up in `cgroup.procs` and still remains in the
cgroup and cause migrating new processes to `Delegate=yes` cgroups to fail with
`-EBUSY`. This is especially likely for heavyweight processes that consume more
kernel CPU time to clean up.

Fix this by only returning 0 when both `cgroup.threads` and
`cgroup.procs` are empty.

(cherry picked from commit 37f0289bf5f2283c187032f83c33ea955b75f119)
2022-06-02 20:07:11 +02:00
наб
e01f55dab5 kernel-install: don't log each initrd on its own line in verbose mode
(cherry picked from commit 2f9f8b96d41bc0787f53dcc01c1488fcdc735e9b)
2022-06-02 20:07:11 +02:00
наб
c6dd6afe02 kernel-install: actually ignore the last two arguments
(cherry picked from commit c60ca42571dec74bdfaf73ceae854cadd247532b)
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 f232c83c7257e08ccbeafc994c90e38515d04c6e)
2022-06-02 20:07:10 +02:00
Yu Watanabe
a5c4e29b2c sd-bus: fix buffer overflow
Fixes #23486.

(cherry picked from commit 89b6a3f13e5f3b8a375dc82cb2a1c2c204a5067e)
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 9745b51c73c78a63003b4cb6e0714829144d297c)
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 3e624bb13b18b241d00c8d375d5774acde25aa3f)
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 4e124425547e243482a1bae43cd20853de13172f)
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 b72308d34440530df3bb8b6b3d272dfc303d1d37)
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 8f2477715691f96b93d277b023f086203f76653f)
2022-06-02 20:04:06 +02:00
Zbigniew Jędrzejewski-Szmek
7c2b2f279c man/shutdown: explain -h more
Fixes #23401

(cherry picked from commit 5ee38adea4d590424fc840cd0e411a3cde73695e)
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 223a359f21af1572a5b98629a3c684f764f3f26e)
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 93dbc22a9533ab4fbf8a4b6c176b95f8cef7a9a6)
2022-06-02 20:04:06 +02:00
Eduard Tolosa
d5be915999 loader.conf: Clarify the default value of timeout.
(cherry picked from commit 815068d3a3bab32df94dff2cfe8e84d0ab973ceb)
2022-06-02 20:04:06 +02:00
Rahil Bhimjiani
4bd2056fbc [sd-boot] improve documentation of beep
(cherry picked from commit 97e7d4945dbf8140b89a92212bcfb8c80c01dd47)
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 7e46a5c093e9e0d2e1ec734058e0caf1725ff37e)
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 4fc69e8a0949c2537019466f839d9b7aee5628c9)
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 cf1ac0cfe44997747b0f857a1d0b67cea1298272)
2022-05-27 11:52:27 +09:00
Frantisek Sumsal
b3781ad821 test: store the key on a separate device
(cherry picked from commit 6b70d3cf81088ee9226cd691bbccc4ebf4764065)
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 b22d90e59438481b421b1eb2449e6efdfb7f2118)
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 1fb7f8e15e19fbe61230b70203b0c35fca54f0a0)
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 011161de615c125e91a27d10decf4b5a3c5fbb99.
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. 742561efbe938c45936f2e4f5d81b3ff6b352882 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 620ecc9c4bb8769b2acb6c1b9b64b330d0f76fc1)
v251.1
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 75d7b5989f99125e52d5c0e5656fa1cd0fae2405.

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 6e9165397faa1b546d367bdfc28dd4377a8f1d0a
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
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 9e82a74cb0f08a288f9db228a0b5bec8a7188cdb, 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 9e82a74cb0f08a288f9db228a0b5bec8a7188cdb, 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 447a822f8ee47b63a4cae00423c4d407bfa5e516 which
removed Default from the list, and a5307e173bf86d695fe85b8e15e91126e8618a14,
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 ]

6637cf9db67237857279262d93ee0e39023c5b85 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