annotate testharness/install-test-harness.sh @ 189:b2456d274576 default tip

Add line breaks that rustfmt ate back to documentation.
author Paul Fisher <paul@pfish.zone>
date Thu, 31 Jul 2025 15:42:12 -0400
parents 77470e45e397
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
1 #!/bin/sh
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
2
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
3 set -ex
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
4
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
5 LINUX_BSD_CONF="/etc/pam.d/nonstick-testharness"
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
6
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
7 patch_pam_conf() {
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
8 SRC="$1"
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
9 DST="$2"
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
10 LIB="$3"
169
77470e45e397 Set up stuff to work the way Sun expects it to.
Paul Fisher <paul@pfish.zone>
parents: 165
diff changeset
11 SUN_PATCH=""
77470e45e397 Set up stuff to work the way Sun expects it to.
Paul Fisher <paul@pfish.zone>
parents: 165
diff changeset
12 if [ "$(uname -s)" = "SunOS" ]; then
77470e45e397 Set up stuff to work the way Sun expects it to.
Paul Fisher <paul@pfish.zone>
parents: 165
diff changeset
13 SUN_PATCH="s/^#Sun#//"
77470e45e397 Set up stuff to work the way Sun expects it to.
Paul Fisher <paul@pfish.zone>
parents: 165
diff changeset
14 fi
77470e45e397 Set up stuff to work the way Sun expects it to.
Paul Fisher <paul@pfish.zone>
parents: 165
diff changeset
15 sed -e "s#pam_testharness\.so#$LIB#" -e "$SUN_PATCH" <"$SRC" >"$DST"
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
16 }
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
17
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
18 setup_pam_conf() {
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
19 SRC="$1"
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
20 case "$(uname -s)" in
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
21 "Linux" | *BSD)
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
22 # For Linux-PAM and OpenPAM, PAM is configured with the per-service files
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
23 # in /etc/pam.d/...
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
24 sudo cp "$SRC" "$LINUX_BSD_CONF"
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
25 ;;
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
26 "SunOS")
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
27 # On SunOS, PAM has just the one configuration file,
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
28 # with the service prepended to each line.
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
29 sudo cp /etc/pam.conf /etc/pam.conf.bak
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
30 sed 's/^\([^#]\)/nonstick-testharness \1/' <"$SRC" \
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
31 | sudo tee -a /etc/pam.conf >/dev/null
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
32 ;;
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
33 *)
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
34 echo "UNKNOWN OS!!!"
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
35 return 1
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
36 ;;
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
37 esac
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
38 }
163
a75a66cb4181 Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
39
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
40 cleanup_pam_conf() {
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
41 case "$(uname -s)" in
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
42 "Linux" | *BSD)
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
43 sudo rm "$LINUX_BSD_CONF"
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
44 ;;
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
45 "SunOS")
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
46 sudo mv /etc/pam.conf.bak /etc/pam.conf
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
47 ;;
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
48 esac
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
49 }
163
a75a66cb4181 Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
50
a75a66cb4181 Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
51 HERE="$(dirname -- "$0")"
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
52 cd "$HERE"
163
a75a66cb4181 Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
53 cargo build --release
a75a66cb4181 Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
54
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
55 cleanup() {
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
56 rm -r "$MY_TEMP"
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
57 sudo rm -r "$ROOT_TEMP"
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
58 cleanup_pam_conf
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
59 }
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
60
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
61 MY_TEMP="$(mktemp -d -t nonstick-user-XXXXXX)"
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
62 ROOT_TEMP="$(sudo mktemp -d -t nonstick-root-XXXXXX)"
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
63 sudo chmod a+rx "$ROOT_TEMP"
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
64 PAM_LIBRARY="$ROOT_TEMP/pam_nonstick.so"
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
65 sudo cp ../target/release/libnonstick_testharness.so "$PAM_LIBRARY"
165
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
66 patch_pam_conf ./nonstick_testharness.conf "$MY_TEMP/nonstick-testharness" "$PAM_LIBRARY"
c4b1e280463c Make test script really work across platforms (?).
Paul Fisher <paul@pfish.zone>
parents: 164
diff changeset
67 setup_pam_conf "$MY_TEMP/nonstick-testharness"
164
d0bba0117456 make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents: 163
diff changeset
68 trap cleanup EXIT
163
a75a66cb4181 Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
69 "$@" && echo "SUCCESS!!!" || echo "FAILURE: $?"