blob: 86805e19322b7c052ecf8a9ba0c4f75c5a77700b [file] [log] [blame]
dtucker@openbsd.org0d2f8842016-12-16 03:51:19 +00001# Public Domain
2# Zev Weiss, 2016
3
4tid="AllowUsers/DenyUsers"
5
dtucker@openbsd.orgeae735a2016-12-19 03:32:57 +00006me="$LOGNAME"
djm@openbsd.orgc8c60f32016-12-19 22:35:23 +00007if [ "x$me" = "x" ]; then
dtucker@openbsd.orgeae735a2016-12-19 03:32:57 +00008 me=`whoami`
9fi
dtucker@openbsd.org0d2f8842016-12-16 03:51:19 +000010other="nobody"
11
12test_auth()
13{
14 deny="$1"
15 allow="$2"
16 should_succeed="$3"
17 failmsg="$4"
18
19 start_sshd -oDenyUsers="$deny" -oAllowUsers="$allow"
20
21 ${SSH} -F $OBJ/ssh_config "$me@somehost" true
22 status=$?
23
24 if (test $status -eq 0 && ! $should_succeed) \
25 || (test $status -ne 0 && $should_succeed); then
26 fail "$failmsg"
27 fi
28
29 stop_sshd
30}
31
32# DenyUsers AllowUsers should_succeed failure_message
33test_auth "" "" true "user in neither DenyUsers nor AllowUsers denied"
34test_auth "$other $me" "" false "user in DenyUsers allowed"
35test_auth "$me $other" "" false "user in DenyUsers allowed"
36test_auth "" "$other" false "user not in AllowUsers allowed"
37test_auth "" "$other $me" true "user in AllowUsers denied"
38test_auth "" "$me $other" true "user in AllowUsers denied"
39test_auth "$me $other" "$me $other" false "user in both DenyUsers and AllowUsers allowed"
40test_auth "$other $me" "$other $me" false "user in both DenyUsers and AllowUsers allowed"