1
0
mirror of https://github.com/systemd/systemd synced 2025-12-22 17:04:45 +01:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Daan De Meyer
738bad8f35 mkosi: Use initrd as exitrd
Let's speed up image builds by avoiding building
an exitrd and instead reusing the initrd image for
the same purpose.
2025-12-21 20:31:24 +01:00
Daan De Meyer
64991b2148 repart: Fix --defer-partitions-empty= docs
Fixes #40176
2025-12-21 19:30:06 +00:00
Luca Boccassi
8d1e58f9fd test: fix (again) race condition in TEST-80-NOTIFYACCESS
Even with the previous fix, it can still happen that pid1
sends SIGHUP to the script after 'sdnotify --ready' but before
'wait', so the test can still get stuck:

[ 2444.373448] reload-timeout.sh[158]: + set -o pipefail
[ 2444.373502] reload-timeout.sh[158]: + COUNTER=0
[ 2444.373590] reload-timeout.sh[158]: + trap sighup_handler SIGHUP
[ 2444.373639] reload-timeout.sh[158]: + export SYSTEMD_LOG_LEVEL=debug
[ 2444.373670] reload-timeout.sh[158]: + SYSTEMD_LOG_LEVEL=debug
[ 2444.373790] reload-timeout.sh[158]: + wait_for_signal 1
[ 2444.373871] reload-timeout.sh[158]: + local notify=1
[ 2444.373912] reload-timeout.sh[158]: + local p
[ 2444.374079] reload-timeout.sh[158]: + p=159
[ 2444.374123] reload-timeout.sh[159]: + sleep infinity
[ 2444.375358] systemd[1]: reload-timeout.service: Got notification message from PID 158: READY=1
[ 2444.375363] systemd[1]: reload-timeout.service: Changed start -> running
[ 2444.375368] systemd[1]: reload-timeout.service: Job 294 reload-timeout.service/start finished, result=done
[ 2444.375374] systemd[1]: Started reload-timeout.service.
[ 2444.375766] systemd[1]: reload-timeout.service: Failed to send unit change signal for reload-timeout.service: Connection reset by peer
[ 2444.376464] reload-timeout.sh[158]: + '[' 1 -eq 1 ']'
[ 2444.376464] reload-timeout.sh[158]: + systemd-notify --ready
[ 2444.376518] TEST-80-NOTIFYACCESS.sh[157]: Job for reload-timeout.service finished.
[ 2444.376518] TEST-80-NOTIFYACCESS.sh[157]: Got result done/Success for job reload-timeout.service.
[ 2444.376518] TEST-80-NOTIFYACCESS.sh[157]: Bus n/a: changing state RUNNING → CLOSED
[ 2444.376952] TEST-80-NOTIFYACCESS.sh[92]: + systemctl reload --no-block reload-timeout.service
[ 2444.379548] TEST-80-NOTIFYACCESS.sh[161]: Bus n/a: changing state UNSET → OPENING
[ 2444.379548] TEST-80-NOTIFYACCESS.sh[161]: sd-bus: starting bus by connecting to /run/systemd/private...
[ 2444.379548] TEST-80-NOTIFYACCESS.sh[161]: Bus n/a: changing state OPENING → AUTHENTICATING
[ 2444.379548] TEST-80-NOTIFYACCESS.sh[161]: Executing dbus call org.freedesktop.systemd1.Manager ReloadUnit(reload-timeout.service, replace)
[ 2444.379548] TEST-80-NOTIFYACCESS.sh[161]: Bus n/a: changing state AUTHENTICATING → RUNNING
[ 2444.379910] systemd-notify[160]: Notify message sent to '/run/systemd/notify': "READY=1"
[ 2444.379931] systemd-notify[160]: Notify message sent to '/run/systemd/notify': "BARRIER=1"
[ 2444.382218] systemd[1]: reload-timeout.service: Trying to enqueue job reload-timeout.service/reload/replace
[ 2444.382241] systemd[1]: reload-timeout.service: Installed new job reload-timeout.service/reload as 366
[ 2444.382248] systemd[1]: reload-timeout.service: Enqueued job reload-timeout.service/reload as 366
[ 2444.383905] systemd[1]: reload-timeout.service: Service has no extensions to reload.
[ 2444.384925] systemd[1]: reload-timeout.service: Changed running -> reload-signal
[ 2444.384935] systemd[1]: Reloading reload-timeout.service...
[ 2444.386410] reload-timeout.sh[158]: ++ sighup_handler
[ 2444.386410] reload-timeout.sh[158]: ++ echo hup1
[ 2444.386455] TEST-80-NOTIFYACCESS.sh[161]: Bus n/a: changing state RUNNING → CLOSED
[ 2444.386555] TEST-80-NOTIFYACCESS.sh[92]: + timeout 10 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "reload-signal" ]]; do sleep .5; done'
[ 2444.395566] TEST-80-NOTIFYACCESS.sh[165]: Bus n/a: changing state UNSET → OPENING
[ 2444.395566] TEST-80-NOTIFYACCESS.sh[165]: sd-bus: starting bus by connecting to /run/systemd/private...
[ 2444.396041] TEST-80-NOTIFYACCESS.sh[165]: Bus n/a: changing state OPENING → AUTHENTICATING
[ 2444.396041] TEST-80-NOTIFYACCESS.sh[165]: Showing one /org/freedesktop/systemd1/unit/reload_2dtimeout_2eservice
[ 2444.401911] TEST-80-NOTIFYACCESS.sh[165]: Bus n/a: changing state AUTHENTICATING → RUNNING
[ 2444.401911] TEST-80-NOTIFYACCESS.sh[165]: Bus n/a: changing state RUNNING → CLOSED
[ 2444.403806] TEST-80-NOTIFYACCESS.sh[92]: + sync_in hup1
[ 2444.403806] TEST-80-NOTIFYACCESS.sh[92]: + read -r x
[ 2444.403964] reload-timeout.sh[158]: + wait 159
[ 2444.403988] TEST-80-NOTIFYACCESS.sh[92]: + test hup1 = hup1
[ 2444.403988] TEST-80-NOTIFYACCESS.sh[92]: + timeout 10 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "reload-notify" ]]; do sleep .5; done'

Try to check if the signal handler has ran by checking the counter,
and avoid waiting and immediately return if it has changed

Fixes https://github.com/systemd/systemd/issues/39581

Follow-up for 8fba2ed2588661c91fb3d0ee6c26b034885ee475
2025-12-21 19:29:55 +01:00
Daan De Meyer
5b830eda79 signal-util: Use act instead of __act in comment
The clang-tidy check ignores trailing and
preceeding underscores, so let's just use act
instead of __act.
2025-12-21 19:21:08 +01:00
13 changed files with 18 additions and 121 deletions

View File

@ -504,10 +504,10 @@
<term><option>--defer-partitions-empty=yes</option></term> <term><option>--defer-partitions-empty=yes</option></term>
<listitem><para>This is very similar to <option>--defer-partitions=</option> but automatically <listitem><para>This is very similar to <option>--defer-partitions=</option> but automatically
selects all partitions for deferral that have <option>Format=empty</option> set. It may be used in selects all partitions for deferral that have <option>Format=empty</option> set and do not configure
conjunction with <option>--defer-partitions=</option> or a custom label, or which set <option>Label=_empty</option>. It may be used in conjunction with
<option>--defer-partitions-factory-reset=yes</option>, in which case all matching partitions are <option>--defer-partitions=</option> or <option>--defer-partitions-factory-reset=yes</option>, in
deferred.</para> which case all matching partitions are deferred.</para>
<xi:include href="version-info.xml" xpointer="v259"/></listitem> <xi:include href="version-info.xml" xpointer="v259"/></listitem>
</varlistentry> </varlistentry>

View File

@ -3,7 +3,6 @@
[Config] [Config]
MinimumVersion=commit:9e31235211d975bae25622d6205a8396d104335e MinimumVersion=commit:9e31235211d975bae25622d6205a8396d104335e
Dependencies= Dependencies=
exitrd
initrd initrd
minimal-base minimal-base
minimal-0 minimal-0
@ -57,7 +56,7 @@ ExtraTrees=
%O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity %O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity
%O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig %O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig
%O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template %O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template
%O/exitrd:/exitrd %O/initrd:/exitrd
Initrds=%O/initrd Initrds=%O/initrd
KernelInitrdModules=default KernelInitrdModules=default
@ -94,6 +93,7 @@ Packages=
bash-completion bash-completion
binutils binutils
coreutils coreutils
cpio
curl curl
diffutils diffutils
dnsmasq dnsmasq

View File

@ -1,21 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Output]
Format=directory
[Build]
Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
[Content]
Bootable=no
Locale=C.UTF-8
WithDocs=no
CleanPackageMetadata=yes
MakeInitrd=yes
Packages=
coreutils
bash
[Include]
Include=%D/mkosi/mkosi.sanitizers

View File

@ -1,31 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=arch
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/arch/systemd.prepare
VolatilePackages=
systemd
systemd-libs
RemoveFiles=
# Arch Linux doesn't split their gcc-libs package so we manually remove
# unneeded stuff here to make sure it doesn't end up in the image.
/usr/lib/libgfortran.so*
/usr/lib/libgo.so*
/usr/lib/libgomp.so*
/usr/lib/libgphobos.so*
/usr/lib/libobjc.so*
/usr/lib/libgdruntime.so*
# Remove all files that are only required for development.
/usr/lib/*.a
/usr/include/*
/usr/share/i18n/*
/usr/share/hwdata/*
/usr/share/iana-etc/*
/usr/share/locale/*
/usr/share/terminfo/*
/usr/share/zoneinfo/*

View File

@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# Add a dependency on the build image unless NO_BUILD=1.
[Match]
Environment=!NO_BUILD=1
[Config]
Dependencies=build

View File

@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=|centos
Distribution=|fedora
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/systemd.prepare
VolatilePackages=
systemd-standalone-shutdown

View File

@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=debian
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/systemd.prepare
VolatilePackages=
systemd-standalone-shutdown

View File

@ -1,18 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=opensuse
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/systemd.prepare
Packages=
diffutils
grep
patterns-base-minimal_base
sed
xz
VolatilePackages=
libsystemd0
libudev1
systemd

View File

@ -1,12 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=ubuntu
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/systemd.prepare
VolatilePackages=
libsystemd-shared
libsystemd0
libudev1
systemd

View File

@ -241,7 +241,7 @@ int signal_is_blocked(int sig) {
int autoreaping_enabled(void) { int autoreaping_enabled(void) {
struct sigaction sa; struct sigaction sa;
if (sigaction(SIGCHLD, /* __act= */ NULL, &sa) < 0) if (sigaction(SIGCHLD, /* act= */ NULL, &sa) < 0)
return -errno; return -errno;
return sa.sa_handler == SIG_IGN || FLAGS_SET(sa.sa_flags, SA_NOCLDWAIT); return sa.sa_handler == SIG_IGN || FLAGS_SET(sa.sa_flags, SA_NOCLDWAIT);

View File

@ -14,9 +14,11 @@ sync_in() {
wait_for_signal() { wait_for_signal() {
local notify="${1:?}" local notify="${1:?}"
local p local p
local c
sleep infinity & sleep infinity &
p=$! p=$!
c="${COUNTER:-0}"
# Notify readiness after 'sleep' is running to avoid race # Notify readiness after 'sleep' is running to avoid race
# condition where the SIGHUP is sent before 'sleep' is ready to # condition where the SIGHUP is sent before 'sleep' is ready to
@ -25,7 +27,13 @@ wait_for_signal() {
systemd-notify --ready systemd-notify --ready
fi fi
# ...but even that is not sufficient sometimes, so check if the
# callback has already ran by checking the counter
if [ "$c" -ne "$COUNTER" ]; then
kill -TERM "$p" || :
else
wait "$p" || : wait "$p" || :
fi
} }
sighup_handler() { sighup_handler() {

View File

@ -22,9 +22,8 @@ test -d /run/initrd-mount-target
mountpoint /run/initrd-mount-target mountpoint /run/initrd-mount-target
[[ -e /run/initrd-mount-target/hello-world ]] [[ -e /run/initrd-mount-target/hello-world ]]
# Copy the prepared exitrd to its intended location. Check the respective # Copy the prepared exitrd to its intended location.
# test.sh file for details
mkdir -p /run/initramfs mkdir -p /run/initramfs
cp -r /exitrd/* /run/initramfs/ unzstd --stdout /exitrd | cpio --extract --make-directories --directory /run/initramfs/
touch /testok touch /testok