Mercurial > crates > nonstick
changeset 165:c4b1e280463c
Make test script really work across platforms (?).
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 14 Jul 2025 18:56:55 -0400 |
parents | d0bba0117456 |
children | 2f5913131295 |
files | testharness/install-test-harness.sh |
diffstat | 1 files changed, 28 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/testharness/install-test-harness.sh Mon Jul 14 18:12:14 2025 -0400 +++ b/testharness/install-test-harness.sh Mon Jul 14 18:56:55 2025 -0400 @@ -1,16 +1,30 @@ #!/bin/sh -set -exo pipefail +set -ex LINUX_BSD_CONF="/etc/pam.d/nonstick-testharness" -pam_library_path() { +patch_pam_conf() { + SRC="$1" + DST="$2" + LIB="$3" + sed "s#pam_testharness\.so#$LIB#" <"$SRC" >"$DST" +} + +setup_pam_conf() { + SRC="$1" case "$(uname -s)" in - "Linux" | "SunOS") - echo "/usr/lib/security" + "Linux" | *BSD) + # For Linux-PAM and OpenPAM, PAM is configured with the per-service files + # in /etc/pam.d/... + sudo cp "$SRC" "$LINUX_BSD_CONF" ;; - *BSD) - echo "/usr/lib" + "SunOS") + # On SunOS, PAM has just the one configuration file, + # with the service prepended to each line. + sudo cp /etc/pam.conf /etc/pam.conf.bak + sed 's/^\([^#]\)/nonstick-testharness \1/' <"$SRC" \ + | sudo tee -a /etc/pam.conf >/dev/null ;; *) echo "UNKNOWN OS!!!" @@ -19,22 +33,6 @@ esac } -setup_pam_conf() { - case "$(uname -s)" in - "Linux" | *BSD) - sudo cp nonstick_testharness.conf "$LINUX_BSD_CONF" - ;; - "SunOS") - sudo cp /etc/pam.conf /etc/pam.conf.bak - sed 's/^\([^#]\)/nonstick-testharness \1/' <./nonstick_testharness.conf \ - | sudo tee -a /etc/pam.conf >/dev/null - ;; - *) - echo "UNKNOWN OS!!!" - return 1 - ;; - esac -} cleanup_pam_conf() { case "$(uname -s)" in "Linux" | *BSD) @@ -49,14 +47,19 @@ HERE="$(dirname -- "$0")" cd "$HERE" cargo build --release -PAM_LIBRARY="$(pam_library_path)/pam_testharness.so" cleanup() { - sudo rm "$PAM_LIBRARY" + rm -r "$MY_TEMP" + sudo rm -r "$ROOT_TEMP" cleanup_pam_conf } +MY_TEMP="$(mktemp -d -t nonstick-user-XXXXXX)" +ROOT_TEMP="$(sudo mktemp -d -t nonstick-root-XXXXXX)" +sudo chmod a+rx "$ROOT_TEMP" +PAM_LIBRARY="$ROOT_TEMP/pam_nonstick.so" sudo cp ../target/release/libnonstick_testharness.so "$PAM_LIBRARY" -setup_pam_conf +patch_pam_conf ./nonstick_testharness.conf "$MY_TEMP/nonstick-testharness" "$PAM_LIBRARY" +setup_pam_conf "$MY_TEMP/nonstick-testharness" trap cleanup EXIT "$@" && echo "SUCCESS!!!" || echo "FAILURE: $?" \ No newline at end of file