3 # Copyright (c) 2007 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden).
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # 3. Neither the name of the Institute nor the names of its contributors
19 # may be used to endorse or promote products derived from this software
20 # without specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 top_builddir
="@top_builddir@"
35 env_setup
="@env_setup@"
40 srcdir
="${top_srcdir}/tests/kdc"
41 test_alname
="${test_alname} --simple"
47 if test "$2" -ne 0; then
50 eval ${test_alname} "'$1'" > localname
$stderr
52 if test $status -ne "$2"; then
53 echo "Unexpected exit code from test_alname $1: $status"
56 if test $status -ne 0; then
59 read lname
< localname
60 if test "X$lname" != "X$3"; then
61 echo "Unexpected mapping of $1: $lname"
72 KRB5_CONFIG
="${objdir}/krb5-authz.conf"
75 echo "Checking 1-component principal names in default realms"
76 check_localname mapped1@
${R} 0 foo ||
exit 1
77 check_localname mapped2@
${R} 0 bar ||
exit 1
78 check_localname mapped1@
${R2} 0 m1 ||
exit 1
79 check_localname mapped2@
${R2} 0 m2 ||
exit 1
80 check_localname mapped1@
${R3} 0 mapped1 ||
exit 1
81 check_localname mapped2@
${R3} 0 mapped2 ||
exit 1
82 check_localname notmapped1@
${R} 0 notmapped1 ||
exit 1
83 check_localname notmapped1@
${R2} 0 notmapped1 ||
exit 1
84 check_localname notmapped1@
${R3} 0 notmapped1 ||
exit 1
86 echo "Checking 1-component principal names in non-default realm"
87 check_localname mapped1@
${R4} 1 ||
exit 1
88 check_localname notmapped1@
${R4} 1 ||
exit 1
90 echo "Checking 2-component principal names"
91 check_localname foo
/mapped1@
${R} 0 foo ||
exit 1
92 check_localname foo
/mapped2@
${R} 0 bar ||
exit 1
93 check_localname bar
/mapped1@
${R2} 0 foobar ||
exit 1
94 check_localname bar
/mapped2@
${R2} 0 foobaz ||
exit 1
95 check_localname foo
/mapped1@
${R3} 1 ||
exit 1
96 check_localname bar
/mapped1@
${R3} 1 ||
exit 1
97 check_localname foo
/notmapped1@
${R} 1 ||
exit 1
98 check_localname bar
/notmapped1@
${R2} 1 ||
exit 1
100 echo "Checking 2-component principal names in non-default realm"
101 check_localname foo
/mapped1@
${R4} 1 ||
exit 1
102 check_localname bar
/mapped1@
${R4} 1 ||
exit 1
103 check_localname foo
/notmapped1@
${R4} 1 ||
exit 1
104 check_localname bar
/notmapped1@
${R4} 1 ||
exit 1
106 echo "Checking for overflow"
107 test_alname
="${test_alname} --simple --lname-size=1"
108 check_localname mapped1@
${R} 3 ||
exit 1
109 check_localname mapped2@
${R} 3 ||
exit 1
110 check_localname mapped1@
${R2} 3 ||
exit 1
111 check_localname mapped2@
${R2} 3 ||
exit 1
112 check_localname mapped1@
${R3} 3 ||
exit 1
113 check_localname mapped2@
${R3} 3 ||
exit 1
115 echo "Checking krb5_kuserok()"
116 ${test_kuserok} random-princ@RANDOM-REALM foo
> /dev
/null ||
exit 1
117 ${test_kuserok} mapped1@
${R} foo
> /dev
/null ||
exit 1
118 ${test_kuserok} mapped1@
${R2} m1
> /dev
/null ||
exit 1
119 ${test_kuserok} notmapped1@
${R3} notmapped1
> /dev
/null ||
exit 1
120 ${test_kuserok} this-better-not-exist@NOR-THIS foo
> /dev
/null
&& exit 1
122 # If the user running this test has a ~/.k5login or .k5logind, test
123 # based on their content
124 if test -n "${HOME}" -a -n "${USER:-${LOGNAME}}" -a -s "${HOME}/.k5login"; then
125 echo "Checking ~/.k5login"
127 ${test_kuserok} "${princ}" "${USER:-${LOGNAME}}" > /dev/null || exit 1
128 done < "${HOME}/.k5login
" || exit 1
130 if test -n "${HOME}" -a -n "${USER:-${LOGNAME}}" -a -d "${HOME}/.k5login.d
"; then
131 echo "Checking ~
/.k5login.d
"
132 ls -f "${HOME}/.k5login.d
" | egrep -v '^(\.|\.\.|#.*|.*~|\.*.sw.)$' | while read f; do
133 f="${HOME}/.k5login.d
/$f"
134 test -d "${f}" && continue
136 ${test_kuserok} "${princ}" "${USER:-${LOGNAME}}" > /dev
/null ||
exit 1
137 done < "${f}" ||
exit 1
141 KRB5_CONFIG
="${objdir}/krb5-authz2.conf"
144 echo "Checking krb5_kuserok() (with authoritative k5login files)"
145 ${test_kuserok} random-princ@RANDOM-REALM foo
> /dev
/null ||
exit 1
146 ${test_kuserok} mapped1@
${R} foo
> /dev
/null
&& exit 1
147 ${test_kuserok} mapped1@
${R2} m1
> /dev
/null ||
exit 1
148 ${test_kuserok} notmapped1@
${R3} notmapped1
> /dev
/null ||
exit 1
149 ${test_kuserok} this-better-not-exist@NOR-THIS foo
> /dev
/null
&& exit 1