]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/regress/allow-deny-users.sh
Merge clang trunk r338150, and resolve conflicts.
[FreeBSD/FreeBSD.git] / crypto / openssh / regress / allow-deny-users.sh
1 # Public Domain
2 # Zev Weiss, 2016
3 # $OpenBSD: allow-deny-users.sh,v 1.4 2017/10/20 02:13:41 djm Exp $
4
5 tid="AllowUsers/DenyUsers"
6
7 me="$LOGNAME"
8 if [ "x$me" = "x" ]; then
9         me=`whoami`
10 fi
11 other="nobody"
12
13 test_auth()
14 {
15         deny="$1"
16         allow="$2"
17         should_succeed="$3"
18         failmsg="$4"
19
20         start_sshd -oDenyUsers="$deny" -oAllowUsers="$allow"
21
22         ${SSH} -F $OBJ/ssh_config "$me@somehost" true
23         status=$?
24
25         if (test $status -eq 0 && ! $should_succeed) \
26             || (test $status -ne 0 && $should_succeed); then
27                 fail "$failmsg"
28         fi
29
30         stop_sshd
31 }
32
33 #         DenyUsers     AllowUsers    should_succeed  failure_message
34 test_auth ""            ""            true            "user in neither DenyUsers nor AllowUsers denied"
35 test_auth "$other $me"  ""            false           "user in DenyUsers allowed"
36 test_auth "$me $other"  ""            false           "user in DenyUsers allowed"
37 test_auth ""            "$other"      false           "user not in AllowUsers allowed"
38 test_auth ""            "$other $me"  true            "user in AllowUsers denied"
39 test_auth ""            "$me $other"  true            "user in AllowUsers denied"
40 test_auth "$me $other"  "$me $other"  false           "user in both DenyUsers and AllowUsers allowed"
41 test_auth "$other $me"  "$other $me"  false           "user in both DenyUsers and AllowUsers allowed"