From 3dea3434bf2003b757d7ecdb5a8194c8a0c7023f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 20 Oct 2025 20:02:17 +0200 Subject: ExecFork: Simplify closing and make it safe Implement a wrapper around FD_CLOEXEC and use it in place of the raw fcntl(). This wrapper _Exit()s the child if the operation failed. Restructure the close_range() handling to simply mark all fds for closing first and then "reopen" the ones we should keep. --- test/integration/test-close-range | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100755 test/integration/test-close-range (limited to 'test') diff --git a/test/integration/test-close-range b/test/integration/test-close-range deleted file mode 100755 index 108fdea2d..000000000 --- a/test/integration/test-close-range +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -set -e - -TESTDIR="$(readlink -f "$(dirname "$0")")" -. "$TESTDIR/framework" - -setupenvironment -configarchitecture 'amd64' - - -testsuccessequal "close_range(3, 4294967295)" apthelper drop-privs -o Debug::CloseRange=1 true - - -testsuccessequal "close_range(4, 4294967295)" apthelper drop-privs -o APT::Keep-Fds::=3 -o Debug::CloseRange=1 true - - -testsuccessequal "close_range(3, 4) -close_range(6, 4294967295)" apthelper drop-privs -o APT::Keep-Fds::=5 -o Debug::CloseRange=1 true - - -testsuccessequal "close_range(4, 4) -close_range(6, 4294967295)" apthelper drop-privs -o APT::Keep-Fds::=3 -o APT::Keep-Fds::=5 -o Debug::CloseRange=1 true - -testsuccessequal "close_range(4, 4) -close_range(7, 4294967295)" apthelper drop-privs -o APT::Keep-Fds::=3 -o APT::Keep-Fds::=5 -o APT::Keep-Fds::=6 -o Debug::CloseRange=1 true - -# Check with reverse order -testsuccessequal "close_range(4, 5) -close_range(7, 4294967295)" apthelper drop-privs -o APT::Keep-Fds::=6 -o APT::Keep-Fds::=3 -o Debug::CloseRange=1 true - -testsuccessequal "close_range(3, 4) -close_range(7, 4294967295)" apthelper drop-privs -o APT::Keep-Fds::=6 -o APT::Keep-Fds::=5 -o Debug::CloseRange=1 true -- cgit v1.2.3-70-g09d2