From 3543456f84ec2e83e07b6c9bf2b3a1c5d30241d8 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Mon, 30 Sep 2024 09:58:34 -0700 Subject: Add ExtraFileDescriptor property to StartTransientUnit dbus API This adds the ExtraFileDescriptor property to StartTransient dbus API with format "a(hs)" - array of (file descriptor, name) pairs. The FD will be passed to the unit via sd_notify like Socket and OpenFile. systemctl show also shows ExtraFileDescriptorName for these transient units. We only show the name passed to dbus as the FD numbers will change once passed over the unix socket and are duplicated, so its confusing to display the numbers. We do not add this functionality for systemd-run or general systemd service units as it is not useful for general systemd services. Arguably, it could be useful for systemd-run in bash scripts but we prefer to be cautious and not expose the API yet. Fixes: #34396 --- .../TEST-23-UNIT-FILE.ExtraFileDescriptors.sh | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 test/units/TEST-23-UNIT-FILE.ExtraFileDescriptors.sh (limited to 'test') diff --git a/test/units/TEST-23-UNIT-FILE.ExtraFileDescriptors.sh b/test/units/TEST-23-UNIT-FILE.ExtraFileDescriptors.sh new file mode 100755 index 0000000000..cf5c240908 --- /dev/null +++ b/test/units/TEST-23-UNIT-FILE.ExtraFileDescriptors.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux +set -o pipefail + +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + +at_exit() { + set +e + + rm -rf /tmp/test-extra-fd/ +} + +trap at_exit EXIT + +mkdir /tmp/test-extra-fd +echo "Hello" > /tmp/test-extra-fd/1.txt +echo "Extra" > /tmp/test-extra-fd/2.txt + +systemd-analyze log-level debug + +# Open files and assign FD to variables +exec {TEST_FD1}