]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/regress/allow-deny-users.sh
stand/powerpc: Only build loader.kboot for powerpc64
[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.5 2018/07/13 02:13:50 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 cp $OBJ/sshd_proxy $OBJ/sshd_proxy.orig
14
15 test_auth()
16 {
17         deny="$1"
18         allow="$2"
19         should_succeed="$3"
20         failmsg="$4"
21
22         cp $OBJ/sshd_proxy.orig $OBJ/sshd_proxy
23         echo DenyUsers="$deny" >> $OBJ/sshd_proxy
24         echo AllowUsers="$allow" >> $OBJ/sshd_proxy
25
26         start_sshd -oDenyUsers="$deny" -oAllowUsers="$allow"
27
28         ${SSH} -F $OBJ/ssh_proxy "$me@somehost" true
29         status=$?
30
31         if (test $status -eq 0 && ! $should_succeed) \
32             || (test $status -ne 0 && $should_succeed); then
33                 fail "$failmsg"
34         fi
35 }
36
37 #         DenyUsers     AllowUsers    should_succeed  failure_message
38 test_auth ""            ""            true            "user in neither DenyUsers nor AllowUsers denied"
39 test_auth "$other $me"  ""            false           "user in DenyUsers allowed"
40 test_auth "$me $other"  ""            false           "user in DenyUsers allowed"
41 test_auth ""            "$other"      false           "user not in AllowUsers allowed"
42 test_auth ""            "$other $me"  true            "user in AllowUsers denied"
43 test_auth ""            "$me $other"  true            "user in AllowUsers denied"
44 test_auth "$me $other"  "$me $other"  false           "user in both DenyUsers and AllowUsers allowed"
45 test_auth "$other $me"  "$other $me"  false           "user in both DenyUsers and AllowUsers allowed"