# HG changeset patch # User Paul Fisher # Date 1752531134 14400 # Node ID d0bba011745610ba73f780e468fec76bcd672810 # Parent a75a66cb418136566ba96933876b20db4d539750 make test script more cross platform? diff -r a75a66cb4181 -r d0bba0117456 testharness/install-test-harness.sh --- a/testharness/install-test-harness.sh Mon Jul 14 17:40:11 2025 -0400 +++ b/testharness/install-test-harness.sh Mon Jul 14 18:12:14 2025 -0400 @@ -1,13 +1,62 @@ -#!/bin/bash +#!/bin/sh + +set -exo pipefail + +LINUX_BSD_CONF="/etc/pam.d/nonstick-testharness" + +pam_library_path() { + case "$(uname -s)" in + "Linux" | "SunOS") + echo "/usr/lib/security" + ;; + *BSD) + echo "/usr/lib" + ;; + *) + echo "UNKNOWN OS!!!" + return 1 + ;; + esac +} -set -eo pipefail +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) + sudo rm "$LINUX_BSD_CONF" + ;; + "SunOS") + sudo mv /etc/pam.conf.bak /etc/pam.conf + ;; + esac +} HERE="$(dirname -- "$0")" -echo "$HERE" +cd "$HERE" cargo build --release +PAM_LIBRARY="$(pam_library_path)/pam_testharness.so" -sudo mkdir -p /lib/security -sudo cp ../target/release/libnonstick_testharness.so /lib/security/pam_testharness.so -sudo cp nonstick_testharness.conf /etc/pam.d/nonstick-testharness -trap 'sudo rm /etc/pam.d/nonstick-testharness; sudo rm /lib/security/pam_testharness.so' EXIT +cleanup() { + sudo rm "$PAM_LIBRARY" + cleanup_pam_conf +} + +sudo cp ../target/release/libnonstick_testharness.so "$PAM_LIBRARY" +setup_pam_conf +trap cleanup EXIT "$@" && echo "SUCCESS!!!" || echo "FAILURE: $?" \ No newline at end of file