#!/bin/bash

set -eo pipefail

HERE="$(dirname -- "$0")"
echo "$HERE"
cargo build --release

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
"$@" && echo "SUCCESS!!!" || echo "FAILURE: $?"