rm -rf /var/tmp/mangletest
rm -f /var/tmp/mangletest.tar.gz
rm -f /shouldnotwork
+ loginctl disable-linger testuser
}
trap at_exit EXIT
# Then restart the nspawn service and verify the inner payload actually
# receives the preserved fds back via LISTEN_FDS, with their original content.
create_dummy_container /home/testuser/.local/state/machines/fdstore
+if [[ ! -x /home/testuser/.local/state/machines/fdstore/usr/bin/test-fdstore ]]; then
+ echo >&2 "test-fdstore not available in the minimal container, skipping fdstore tests"
+ exit 0
+fi
# The container init execs the helper directly so the FDSTORE notification is
# sent from PID 1 (nspawn rejects notify messages from anyone but the inner
# payload's init). The helper itself execs sleep on success to keep the
run0 -u testuser systemctl --user reset-failed systemd-nspawn@fdstore.service
machinectl terminate fdstore 2>/dev/null || true
-
-loginctl disable-linger testuser
# then forwards the preserved fds via LISTEN_FDS to a fresh nspawn payload,
# which verifies the content is intact.
create_dummy_container /var/lib/machines/fdstore
- cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
+ if [[ -x /var/lib/machines/fdstore/usr/bin/test-fdstore ]]; then
+ cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
#!/usr/bin/env bash
set -e
exec /usr/bin/test-fdstore check
EOF
- chmod +x /var/lib/machines/fdstore/sbin/init
- mkdir -p /run/systemd/nspawn
- cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
+ chmod +x /var/lib/machines/fdstore/sbin/init
+ mkdir -p /run/systemd/nspawn
+ cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
[Exec]
KillSignal=SIGTERM
EOF
- n_nspawn_fds=$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)
- test "${n_nspawn_fds}" -ge 2
- systemctl start systemd-nspawn@fdstore.service
- systemctl is-active systemd-nspawn@fdstore.service
+ n_nspawn_fds=$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)
+ test "${n_nspawn_fds}" -ge 2
+ systemctl start systemd-nspawn@fdstore.service
+ systemctl is-active systemd-nspawn@fdstore.service
+ else
+ echo >&2 "test-fdstore not available in the minimal container, skipping fdstore tests"
+ fi
# late.service: rewrite the fragment with the second-boot ExecStart and
# exercise the daemon-reload + daemon-reexec preservation paths.
# → LUO → after kexec PID 1 restores the fdstore → systemd-nspawn →
# payload verifies content matches.
create_dummy_container /var/lib/machines/fdstore
- cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
+ if [[ -x /var/lib/machines/fdstore/usr/bin/test-fdstore ]]; then
+ cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
#!/usr/bin/env bash
set -e
exec /usr/bin/test-fdstore store
EOF
- chmod +x /var/lib/machines/fdstore/sbin/init
+ chmod +x /var/lib/machines/fdstore/sbin/init
- mkdir -p /run/systemd/nspawn
- cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
+ mkdir -p /run/systemd/nspawn
+ cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
[Exec]
KillSignal=SIGTERM
EOF
- systemctl start systemd-nspawn@fdstore.service
- timeout 30s bash -c \
- "until [[ \"\$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)\" -ge 2 ]]; do sleep 0.5; done"
+ systemctl start systemd-nspawn@fdstore.service
+ timeout 30s bash -c \
+ "until [[ \"\$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)\" -ge 2 ]]; do sleep 0.5; done"
+ else
+ echo >&2 "test-fdstore not available in the minimal container, skipping fdstore tests"
+ fi
# Negative path: store a fd store entry that holds a child LUO session named
# like PID 1's own ("systemd"). On kexec PID 1 must refuse to serialize it