diff --git a/tests/kdc/Makefile.am b/tests/kdc/Makefile.am index 24960aeb1..393212117 100644 --- a/tests/kdc/Makefile.am +++ b/tests/kdc/Makefile.am @@ -16,6 +16,7 @@ SCRIPT_TESTS = \ check-kadmin \ check-kdc \ check-keys \ + check-kpasswd \ check-pkinit \ check-iprop \ check-referral \ @@ -25,6 +26,7 @@ TESTS = $(SCRIPT_TESTS) port = 49188 admport = 49189 +pwport = 49190 if HAVE_DLOPEN do_dlopen = -e 's,[@]DLOPEN[@],true,g' @@ -36,6 +38,7 @@ do_subst = sed $(do_dlopen) \ -e 's,[@]srcdir[@],$(srcdir),g' \ -e 's,[@]port[@],$(port),g' \ -e 's,[@]admport[@],$(admport),g' \ + -e 's,[@]pwport[@],$(pwport),g' \ -e 's,[@]objdir[@],$(top_builddir)/tests/kdc,g' \ -e 's,[@]EGREP[@],$(EGREP),g' @@ -81,6 +84,11 @@ check-referral: check-referral.in Makefile chmod +x check-referral.tmp mv check-referral.tmp check-referral +check-kpasswdd: check-kpasswdd.in Makefile + $(do_subst) < $(srcdir)/check-kpasswdd.in > check-kpasswdd.tmp + chmod +x check-kpasswdd.tmp + mv check-kpasswdd.tmp check-kpasswdd + krb5.conf: krb5.conf.in Makefile $(do_subst) \ -e 's,[@]kdc[@],,g' < $(srcdir)/krb5.conf.in > krb5.conf.tmp @@ -141,6 +149,7 @@ CLEANFILES= \ EXTRA_DIST = \ check-kadmin.in \ check-kdc.in \ + check-kpasswd.in \ check-keys.in \ check-referral.in \ check-uu.in \ diff --git a/tests/kdc/check-kpasswdd.in b/tests/kdc/check-kpasswdd.in new file mode 100644 index 000000000..3d458f9b3 --- /dev/null +++ b/tests/kdc/check-kpasswdd.in @@ -0,0 +1,161 @@ +#!/bin/sh +# +# Copyright (c) 2006 - 2008 Kungliga Tekniska Högskolan +# (Royal Institute of Technology, Stockholm, Sweden). +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Institute nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $Id$ +# + +srcdir="@srcdir@" +objdir="@objdir@" +EGREP="@EGREP@" + +testfailed="echo test failed; cat messages.log; exit 1" + +# If there is no useful db support compile in, disable test +../db/have-db || exit 77 + +R=TEST.H5L.SE + +port=@port@ +pwport=@pwport@ + +kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R" +kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port" +kpasswdd="${TESTS_ENVIRONMENT} ../../kpasswd/kpasswdd --addresses=localhost -p $pwport" + +server=host/datan.test.h5l.se +cache="FILE:${objdir}/cache.krb5" +keytabfile=${objdir}/server.keytab +keytab="FILE:${keytabfile}" + +kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog" +klist="${TESTS_ENVIRONMENT} ../../kuser/klist -c $cache" +kgetcred="${TESTS_ENVIRONMENT} ../../kuser/kgetcred -c $cache" +kdestroy="${TESTS_ENVIRONMENT} ../../kuser/kdestroy -c $cache --no-unlog" + +KRB5_CONFIG="${objdir}/krb5.conf" +export KRB5_CONFIG + +rm -f ${keytabfile} +rm -f current-db* +rm -f out-* +rm -f mkey.file* + +> messages.log + +echo Creating database +${kadmin} \ + init \ + --realm-max-ticket-life=1day \ + --realm-max-renewable-life=1month \ + ${R} || exit 1 + +${kadmin} add -p foo --use-defaults foo@${R} || exit 1 +${kadmin} add -p kaka --use-defaults ${server}@${R} || exit 1 +${kadmin} ext -k ${keytab} ${server}@${R} || exit 1 + +echo "Doing database check" +${kadmin} check ${R} || exit 1 + +echo foo > ${objdir}/foopassword + +echo Starting kdc +${kdc} & +kdcpid=$! + +sh ${srcdir}/wait-kdc.sh +if [ "$?" != 0 ] ; then + kill ${kdcpid} + exit 1 +fi + +echo Starting kpasswdd +${kpasswdd} & +kpasswddpid=$! + +trap "kill ${kdcpid} ${kpasswddpid}; echo signal killing kdc; exit 1;" EXIT + +ec=0 + +echo "Getting client initial tickets"; > messages.log +${kinit} --password-file=${objdir}/foopassword foo@$R || \ + { ec=1 ; eval "${testfailed}"; } +echo "Getting tickets"; > messages.log +${kgetcred} ${server}@${R} || { ec=1 ; eval "${testfailed}"; } +echo "Listing tickets"; > messages.log +${klist} > /dev/null || { ec=1 ; eval "${testfailed}"; } +./ap-req ${server}@${R} ${keytab} ${cache} || \ + { ec=1 ; eval "${testfailed}"; } +${kdestroy} + + +pw=ak4unandsop39NuJ + +echo "Changing password" +cat > cpw.tmp < ${objdir}/foopassword + + +echo "Getting client initial tickets"; > messages.log +${kinit} --password-file=${objdir}/foopassword foo@$R || \ + { ec=1 ; eval "${testfailed}"; } +echo "Getting tickets"; > messages.log +${kgetcred} ${server}@${R} || { ec=1 ; eval "${testfailed}"; } +echo "Listing tickets"; > messages.log +${klist} > /dev/null || { ec=1 ; eval "${testfailed}"; } +./ap-req ${server}@${R} ${keytab} ${cache} || \ + { ec=1 ; eval "${testfailed}"; } +${kdestroy} + + + + + +echo "killing kdc (${kdcpid} ${kpasswddpid})" +kill $kdcpid $kpasswddpid || exit 1 + +trap "" EXIT + +exit $ec diff --git a/tests/kdc/krb5.conf.in b/tests/kdc/krb5.conf.in index 82b672afd..1612234a4 100644 --- a/tests/kdc/krb5.conf.in +++ b/tests/kdc/krb5.conf.in @@ -11,6 +11,7 @@ TEST.H5L.SE = { kdc = localhost:@port@ admin_server = localhost:@admport@ + kpasswd_server = localhost:@pwport@ } SUB.TEST.H5L.SE = { kdc = localhost:@port@