1 1.1 elric #!/bin/sh 2 1.1 elric # 3 1.1 elric # Copyright (c) 2006 - 2007 Kungliga Tekniska Hgskolan 4 1.1 elric # (Royal Institute of Technology, Stockholm, Sweden). 5 1.1 elric # All rights reserved. 6 1.1 elric # 7 1.1 elric # Redistribution and use in source and binary forms, with or without 8 1.1 elric # modification, are permitted provided that the following conditions 9 1.1 elric # are met: 10 1.1 elric # 11 1.1 elric # 1. Redistributions of source code must retain the above copyright 12 1.1 elric # notice, this list of conditions and the following disclaimer. 13 1.1 elric # 14 1.1 elric # 2. Redistributions in binary form must reproduce the above copyright 15 1.1 elric # notice, this list of conditions and the following disclaimer in the 16 1.1 elric # documentation and/or other materials provided with the distribution. 17 1.1 elric # 18 1.1 elric # 3. Neither the name of the Institute nor the names of its contributors 19 1.1 elric # may be used to endorse or promote products derived from this software 20 1.1 elric # without specific prior written permission. 21 1.1 elric # 22 1.1 elric # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23 1.1 elric # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 1.1 elric # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 1.1 elric # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26 1.1 elric # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 1.1 elric # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 1.1 elric # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 1.1 elric # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 1.1 elric # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 1.1 elric # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 1.1 elric # SUCH DAMAGE. 33 1.1 elric # 34 1.1.1.2 elric # Id 35 1.1 elric # 36 1.1 elric 37 1.1 elric srcdir="@srcdir@" 38 1.1.1.3 christos env_setup="@env_setup@" 39 1.1 elric objdir="@objdir@" 40 1.1 elric EGREP="@EGREP@" 41 1.1 elric 42 1.1.1.3 christos . ${env_setup} 43 1.1.1.3 christos 44 1.1 elric testfailed="echo test failed; cat messages.log; exit 1" 45 1.1 elric 46 1.1.1.4 christos # If there is no useful db support compiled in, disable test 47 1.1 elric ../db/have-db || exit 77 48 1.1 elric 49 1.1 elric R=TEST.H5L.SE 50 1.1 elric 51 1.1 elric port=@port@ 52 1.1 elric 53 1.1 elric kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r ${R}" 54 1.1 elric kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port" 55 1.1 elric 56 1.1 elric server=host/datan.test.h5l.se 57 1.1 elric cache="FILE:${objdir}/cache.krb5" 58 1.1 elric keytabfile=${objdir}/server.keytab 59 1.1 elric keytab="FILE:${keytabfile}" 60 1.1 elric 61 1.1 elric kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache ${afs_no_afslog}" 62 1.1 elric klist="${TESTS_ENVIRONMENT} ../../kuser/klist -c $cache" 63 1.1 elric kgetcred="${TESTS_ENVIRONMENT} ../../kuser/kgetcred -c $cache" 64 1.1 elric kdestroy="${TESTS_ENVIRONMENT} ../../kuser/kdestroy -c $cache ${afs_no_unlog}" 65 1.1 elric test_apreq="${TESTS_ENVIRONMENT} ../../lib/krb5/test_ap-req" 66 1.1 elric 67 1.1 elric KRB5_CONFIG="${objdir}/krb5.conf" 68 1.1 elric export KRB5_CONFIG 69 1.1 elric 70 1.1 elric rm -f ${keytabfile} 71 1.1 elric rm -f current-db* 72 1.1 elric rm -f out-* 73 1.1 elric rm -f mkey.file* 74 1.1 elric 75 1.1 elric > messages.log 76 1.1 elric 77 1.1 elric echo Creating database 78 1.1 elric ${kadmin} \ 79 1.1 elric init \ 80 1.1 elric --realm-max-ticket-life=1day \ 81 1.1 elric --realm-max-renewable-life=1month \ 82 1.1 elric ${R} || exit 1 83 1.1 elric 84 1.1 elric ${kadmin} add -p foo --use-defaults foo@${R} || exit 1 85 1.1 elric ${kadmin} add -p bar --use-defaults ${server}@${R} || exit 1 86 1.1 elric ${kadmin} ext -k ${keytab} ${server}@${R} || exit 1 87 1.1 elric 88 1.1 elric echo "Doing database check" 89 1.1 elric ${kadmin} check ${R} || exit 1 90 1.1 elric ${kadmin} check ${R2} || exit 1 91 1.1 elric 92 1.1 elric echo foo > ${objdir}/foopassword 93 1.1 elric 94 1.1 elric echo "Empty log" 95 1.1 elric > messages.log 96 1.1 elric 97 1.1 elric echo Starting kdc 98 1.1.1.3 christos ${kdc} --detach --testing || { echo "kdc failed to start"; exit 1; } 99 1.1.1.3 christos kdcpid=`getpid kdc` 100 1.1 elric 101 1.1 elric trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT 102 1.1 elric 103 1.1 elric ec=0 104 1.1 elric 105 1.1 elric echo "Check that WINDC module was loaded " 106 1.1 elric grep "windc init" messages.log >/dev/null || \ 107 1.1 elric { ec=1 ; eval "${testfailed}"; } 108 1.1 elric 109 1.1 elric echo "Getting client initial tickets"; > messages.log 110 1.1 elric ${kinit} --password-file=${objdir}/foopassword foo@${R} || \ 111 1.1 elric { ec=1 ; eval "${testfailed}"; } 112 1.1 elric echo "Getting tickets" ; > messages.log 113 1.1 elric ${kgetcred} ${server}@${R} || { ec=1 ; eval "${testfailed}"; } 114 1.1 elric echo "Verify PAC on server"; > messages.log 115 1.1 elric ${test_apreq} --verify-pac ${server}@${R} ${keytab} ${cache} || \ 116 1.1 elric { ec=1 ; eval "${testfailed}"; } 117 1.1 elric ${kdestroy} 118 1.1 elric 119 1.1 elric echo "Getting client initial tickets (pag)"; > messages.log 120 1.1 elric ${kinit} --request-pac --password-file=${objdir}/foopassword foo@${R} || \ 121 1.1 elric { ec=1 ; eval "${testfailed}"; } 122 1.1 elric echo "Getting tickets" ; > messages.log 123 1.1 elric ${kgetcred} ${server}@${R} || { ec=1 ; eval "${testfailed}"; } 124 1.1 elric echo "Verify PAC on server (pag)"; > messages.log 125 1.1 elric ${test_apreq} --verify-pac ${server}@${R} ${keytab} ${cache} || \ 126 1.1 elric { ec=1 ; eval "${testfailed}"; } 127 1.1 elric ${kdestroy} 128 1.1 elric 129 1.1 elric echo "Getting client initial tickets (no pag)"; > messages.log 130 1.1 elric ${kinit} --no-request-pac --password-file=${objdir}/foopassword foo@${R} || \ 131 1.1 elric { ec=1 ; eval "${testfailed}"; } 132 1.1 elric echo "Getting tickets" ; > messages.log 133 1.1 elric ${kgetcred} ${server}@${R} || { ec=1 ; eval "${testfailed}"; } 134 1.1 elric echo "Verify PAC on server (no pag)"; > messages.log 135 1.1 elric ${test_apreq} --verify-pac ${server}@${R} ${keytab} ${cache} 2> /dev/null && \ 136 1.1 elric { ec=1 ; eval "${testfailed}"; } 137 1.1 elric ${kdestroy} 138 1.1 elric 139 1.1 elric 140 1.1 elric echo "killing kdc (${kdcpid})" 141 1.1 elric kill $kdcpid || exit 1 142 1.1 elric 143 1.1 elric trap "" EXIT 144 1.1 elric 145 1.1 elric exit $ec 146