From c5323d174210c1bae7050a626a4f60583157e33d Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 1 Nov 2024 20:55:07 +0000 Subject: [PATCH] testsuite: test that IMP lingers with `imp run` Problem: There is no test that ensures the privileged IMP lingers to handle signal delivery with `flux-imp run`. Add a test to t2002-imp-run.t. --- t/t2002-imp-run.t | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/t/t2002-imp-run.t b/t/t2002-imp-run.t index 01e739b9..ace927fc 100755 --- a/t/t2002-imp-run.t +++ b/t/t2002-imp-run.t @@ -49,6 +49,8 @@ test_expect_success 'create configs for flux-imp exec and signer' ' path = "$TESTDIR/test.sh" [run.allowednotset] path = "$TESTDIR/test.sh" + [run.sleep] + path = "$TESTDIR/sleep.sh" EOF ' test_expect_success 'create test shell scripts' ' @@ -61,6 +63,12 @@ test_expect_success 'create test shell scripts' ' env EOF chmod +x $TESTDIR/test.sh && + cat <<-EOF >$TESTDIR/sleep.sh && + #!/bin/sh + echo \$\$ >sleep.pid + exec sleep 30 + EOF + chmod +x $TESTDIR/sleep.sh && touch $TESTDIR/noexec.sh && chmod 600 $TESTDIR/noexec.sh ' @@ -158,6 +166,26 @@ test_expect_success SUDO 'flux-imp run allows FLUX_JOB_ID and FLUX_JOB_USERID' ' grep ^FLUX_JOB_ID=1234 sudo-run-test-uid-jobid.out && grep ^FLUX_JOB_USERID=$(id -u) sudo-run-test-uid-jobid.out ' + +wait_for_file() { + count=0 && + while ! test -f $1; do + sleep 0.1 + count=$((count+1)) + test $count -gt 20 && break + test_debug "echo retrying count=${count}" + done +} +test_expect_success SUDO,NO_CHAIN_LINT 'flux-imp run: setuid IMP lingers' ' + $SUDO $flux_imp run sleep & + imp_pid=$! && + test_when_finished "rm -f sleep.pid" && + wait_for_file sleep.pid && + pid=$(cat sleep.pid) && + test $(ps --no-header -o comm -p ${pid}) = "flux-imp" && + kill -TERM $imp_pid && + test_expect_code 143 wait $imp_pid +' test_expect_success SUDO 'flux-imp run will not run file with bad ownership' ' $SUDO chown $USER $TESTDIR/test.sh && test_must_fail $SUDO $flux_imp run test &&