1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#!/bin/sh
# vim: set filetype=sh :
# file: test.ssh_policy_local-bad-return
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2023)
# license: GNU General Public License, version 3
# description: test 4 policies with return != 0 on local host
# policy-A: --check-mode-c and --policy-stop
# policy-B: --check-mode-c and --policy-continue
# policy-C: --check-mode-C and --policy-stop
# policy-D: --check-mode-C and --policy-continue
# see also: example.ssh_policy and symlink example.ssh_policy_remote
# The following tests are included:
# (1) check ..-c ..-stop ..-local-bad-return
# (2) check ..-c ..-continue ..-local-bad-return
# (3) check ..-C ..-stop ..-local-bad-return
# (4) check ..-C ..-continue ..-local-bad-return
. ./tstlib
if ./sshd2222 should-work; then
sshd2222opts="$(./sshd2222 options)"
fi
export testdir="$(realpath .)"
shell=""
while [ $# -ne 0 ]; do
if [ "$1" = "-s" ]; then
shell="$2"
shift 2
else
echo "ERROR $0: unknown option <$1>" >&2
exit 1
fi
done
[ "$shell" ] && set -- "$@" -s "$shell"
cmd="$(dirname $0)/example.ssh_policy"
ia_logfile="$(mktemp)"
export ia_logfile
exp1e=\
"--- output with ERROR from <example.ssh_policy> running <sh -c \"exit 11\"> ---
e:exit=11
Exit because of ERROR and no interactive question allowed.
11"
exp1l=\
"--- output to LEARN from <example.ssh_policy> running <sh -c \"exit 11\"> ---
l:exit=11
0"
exp2=\
"|example.ssh_policy
|example.ssh_policy: start message
||example.ssh_policy/localhost:example.ssh_policy_remote
||example.ssh_policy_remote: start message
||example.ssh_policy_remote: end message"
exp3e=\
"|--- output with ERROR from <example.ssh_policy> running <sh -c \"exit 11\"> ---
|e:exit=11
|Exit because of ERROR and no interactive question allowed."
exp3l=\
"|--- output to LEARN from <example.ssh_policy> running <sh -c \"exit 11\"> ---
|l:exit=11
|example.ssh_policy: end message"
rm -f $ia_logfile
check "(1) check ..-c ..-stop ..-local-bad-return" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-c --policy-stop --testcase-local-bad-return; echo \$?; cat $ia_logfile" \
"$exp1e
$exp2
$exp3e"
rm -f $ia_logfile
check "(2) check ..-c ..-continue ..-local-bad-return" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-c --policy-continue --testcase-local-bad-return; echo \$?; cat $ia_logfile" \
"$exp1l
$exp2
$exp3l"
rm -f $ia_logfile
check "(3) check ..-C ..-stop ..-local-bad-return" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-C --policy-stop --testcase-local-bad-return; echo \$?; cat $ia_logfile" \
"$exp1e
$exp2
$exp3e"
rm -f $ia_logfile
check "(4) check ..-C ..-continue ..-local-bad-return" --sshd2222-opts "$@" "$cmd -a -s --sshopts \"\" --check-mode-C --policy-continue --testcase-local-bad-return; echo \$?; cat $ia_logfile" \
"$exp1l
$exp2
$exp3l"
rm -f $ia_logfile
|