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 port="@port@" 41 1.1 elric 42 1.1.1.3 christos . ${env_setup} 43 1.1.1.3 christos 44 1.1 elric # Disable test if: no data, no java, or socket wrapper 45 1.1 elric ../db/have-db || exit 77 46 1.1 elric sh ${srcdir}/have-java.sh || exit 77 47 1.1 elric [ X"$SOCKET_WRAPPER_DIR" != X ] && exit 77 48 1.1 elric 49 1.1 elric R=TEST.H5L.SE 50 1.1.1.3 christos server=host/localhost 51 1.1.1.3 christos keytabfile="${objdir}/server.keytab" 52 1.1.1.3 christos keytab="FILE:${keytabfile}" 53 1.1.1.3 christos cache="FILE:${objdir}/cache.krb5" 54 1.1 elric 55 1.1.1.3 christos kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache ${afs_no_afslog}" 56 1.1 elric kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R" 57 1.1 elric kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=127.0.0.1 -P $port" 58 1.1.1.3 christos gssclient="${TESTS_ENVIRONMENT} ../../appl/test/gssapi_client" 59 1.1 elric 60 1.1 elric KRB5_CONFIG="${objdir}/krb5.conf" 61 1.1 elric export KRB5_CONFIG 62 1.1 elric 63 1.1 elric rm -f ${keytabfile} messages.log 64 1.1 elric rm -f current-db* 65 1.1 elric rm -f out-* 66 1.1 elric rm -f mkey.file* 67 1.1 elric 68 1.1 elric echo "Compile" 69 1.1 elric javac -d "${objdir}" "${srcdir}/KerberosInit.java" || \ 70 1.1 elric { echo "Failed to compile java program: $?" ; exit 77; } 71 1.1 elric 72 1.1.1.3 christos echo "Compile" 73 1.1.1.3 christos javac -d "${objdir}" "${srcdir}/../../appl/test/jgssapi_server.java" || \ 74 1.1.1.3 christos { echo "Failed to compile java program: $?" ; exit 77; } 75 1.1.1.3 christos 76 1.1 elric > messages.log 77 1.1 elric 78 1.1.1.3 christos echo foo > ${objdir}/foopassword 79 1.1.1.3 christos 80 1.1 elric echo Creating database 81 1.1 elric ${kadmin} \ 82 1.1 elric init \ 83 1.1 elric --realm-max-ticket-life=1day \ 84 1.1 elric --realm-max-renewable-life=1month \ 85 1.1 elric ${R} || exit 1 86 1.1 elric 87 1.1 elric ${kadmin} add -p foo --use-defaults lha@${R} || exit 1 88 1.1 elric ${kadmin} modify --attributes=+requires-pre-auth lha@${R} || exit 1 89 1.1.1.3 christos ${kadmin} add -p kaka --use-defaults ${server}@${R} || exit 1 90 1.1.1.3 christos ${kadmin} ext -k ${keytab} ${server}@${R} || exit 1 91 1.1 elric 92 1.1 elric echo Starting kdc 93 1.1.1.3 christos ${kdc} --detach --testing || { echo "kdc failed to start"; exit 1; } 94 1.1.1.3 christos kdcpid=`getpid kdc` 95 1.1 elric 96 1.1.1.3 christos trap "kill -9 ${kdcpid}; echo signal killing kdc; exit 1;" EXIT 97 1.1 elric 98 1.1 elric echo "Run init" 99 1.1 elric java \ 100 1.1.1.3 christos -Dsun.security.krb5.debug=true \ 101 1.1.1.3 christos -Djava.security.krb5.conf="${objdir}"/krb5.conf \ 102 1.1.1.3 christos -Djava.security.auth.login.config="${srcdir}/jaas.conf" \ 103 1.1.1.3 christos KerberosInit > output.tmp 2>&1 || { cat output.tmp ; exit 1; } 104 1.1.1.3 christos 105 1.1.1.3 christos 106 1.1.1.3 christos # Disabled because of: 107 1.1.1.3 christos # 108 1.1.1.3 christos # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077646 109 1.1.1.3 christos # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077640 110 1.1.1.3 christos # 111 1.1.1.3 christos 112 1.1.1.3 christos if false ; then 113 1.1.1.3 christos 114 1.1.1.3 christos echo "start server" 115 1.1.1.3 christos java \ 116 1.1.1.3 christos -Dsun.security.krb5.debug=true \ 117 1.1.1.3 christos -Djava.security.krb5.conf="${objdir}"/krb5.conf \ 118 1.1.1.3 christos -Djavax.security.auth.useSubjectCredsOnly=false \ 119 1.1.1.3 christos -Djava.security.auth.login.config="${srcdir}/jaas.conf" \ 120 1.1.1.3 christos jgssapi_server > output.tmp 2>&1 & 121 1.1.1.3 christos javapid=$! 122 1.1.1.3 christos sleep 5 123 1.1.1.3 christos 124 1.1.1.3 christos trap "kill -9 ${kdcpid} ${javapid}; echo signal killing kdc java; exit 1;" EXIT 125 1.1.1.3 christos 126 1.1.1.3 christos echo "Getting client initial tickets"; > messages.log 127 1.1.1.3 christos ${kinit} --password-file=${objdir}/foopassword lha@$R || \ 128 1.1.1.3 christos { echo "kinit failed" ; exit 1; } 129 1.1.1.3 christos 130 1.1.1.3 christos env KRB5CCNAME=${cache} \ 131 1.1.1.3 christos ${gssclient} --port=4717 --service=host localhost || exit 1 132 1.1.1.3 christos 133 1.1.1.3 christos sleep 5 134 1.1.1.3 christos 135 1.1.1.3 christos kill ${javapid} 136 1.1.1.3 christos 137 1.1.1.3 christos grep 'Exception in thread' output.tmp && exit 1 138 1.1.1.3 christos fi 139 1.1 elric 140 1.1 elric echo "Done" 141 1.1 elric 142 1.1.1.3 christos echo "killing kdc (${kdcpid} ${javapid})" 143 1.1.1.3 christos kill $kdcpid $javapid || exit 1 144 1.1 elric 145 1.1 elric trap "" EXIT 146 1.1 elric 147 1.1 elric exit 0 148