From 807253d6a6035e25d694314d7cd7bac499a02e3d Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Tue, 8 Aug 2000 19:38:44 +0000 Subject: [PATCH] * default.exp: Create krb.conf and krb.realms files for v4 compatibility. Set KRBTKFILE environment variable. Add v4_compatible_enctype() proc to test if krb4 tests are being run and if the current encryption type being tested is compatible with V4. Added v4kinit() proc. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12614 dc483132-0cff-0310-8789-dd5450dbe970 --- src/tests/dejagnu/config/ChangeLog | 8 +++ src/tests/dejagnu/config/default.exp | 84 +++++++++++++++++++++++++++- 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/tests/dejagnu/config/ChangeLog b/src/tests/dejagnu/config/ChangeLog index b839380d8..834b0c968 100644 --- a/src/tests/dejagnu/config/ChangeLog +++ b/src/tests/dejagnu/config/ChangeLog @@ -1,3 +1,11 @@ +2000-08-08 Ezra Peisach + + * default.exp: Create krb.conf and krb.realms files for v4 + compatibility. Set KRBTKFILE environment variable. Add + v4_compatible_enctype() proc to test if krb4 tests are being run + and if the current encryption type being tested is compatible with + V4. Added v4kinit() proc. + 2000-08-07 Ezra Peisach * default.exp: Protect Quote quotation marks in multipass variable diff --git a/src/tests/dejagnu/config/default.exp b/src/tests/dejagnu/config/default.exp index 1f15e97c8..946b32aeb 100644 --- a/src/tests/dejagnu/config/default.exp +++ b/src/tests/dejagnu/config/default.exp @@ -95,7 +95,7 @@ if ![info exists KEY] { # Clear away any files left over from a previous run. # We can't use them now because we don't know the right KEY. # krb5.conf might change if running tests on another host -catch "exec rm -f tmpdir/db.ok tmpdir/srvtab tmpdir/krb5.conf tmpdir/kdc.conf tmpdir/cpw_srvtab" +catch "exec rm -f tmpdir/db.ok tmpdir/srvtab tmpdir/krb5.conf tmpdir/kdc.conf tmpdir/cpw_srvtab tmpdir/krb.realms tmpdir/krb.conf" # Put the installed kerberos directories on PATH. # This needs to be fixed for V5. @@ -380,6 +380,8 @@ proc setup_kerberos_files { } { if [info exists default_tgt_enctypes] { puts $conffile "default_tgs_enctypes = $default_tgs_enctypes" } + puts $conffile " krb4_config = $tmppwd/krb.conf" + puts $conffile " krb4_realms = $tmppwd/krb.realms" puts $conffile "" puts $conffile "\[realms\]" puts $conffile " $REALMNAME = \{" @@ -440,6 +442,22 @@ proc setup_kerberos_files { } { close $aclfile } + # Create krb.conf file + if ![file exists tmpdir/krb.conf] { + set conffile [open tmpdir/krb.conf w] + puts $conffile "$REALMNAME" + puts $conffile "$REALMNAME $hostname:3088 admin server" + close $conffile + } + + # Create krb.realms file + if ![file exists tmpdir/krb.realms] { + set conffile [open tmpdir/krb.realms w] + puts $conffile ".$domain = $REALMNAME" + puts $conffile "$domain = $REALMNAME" + close $conffile + } + set last_passname_conf $multipass_name return 1 } @@ -491,6 +509,10 @@ proc setup_kerberos_env { } { set env(KRB5CCNAME) $tmppwd/tkt verbose "KRB5CCNAME=$env(KRB5CCNAME)" + # Direct the Kerberos programs at a local ticket file. + set env(KRBTKFILE) $tmppwd/tkt + verbose "KRBTKFILE=$env(KRBTKFILE)" + # Direct the Kerberos server at a cache file stored in the # temporary directory. set env(KRB5RCACHEDIR) $tmppwd @@ -1298,6 +1320,66 @@ proc kinit { name pass standalone } { return 1 } + +# v4_compatible_enctype +# Returns 1 if v4 testing is enabled this passes encryption types are compatable with kerberos 4 work +proc v4_compatible_enctype {} { + global supported_enctypes + global KRB4 + + if ![info exists KRB4] { + return 0; + } + + if { $KRB4 && [string first des-cbc-crc:v4 "$supported_enctypes"] >= 0} { + return 1 + } else { + return 0 + } +} + +# kinit +# Use kinit to get a ticket. If the argument is non-zero, call pass +# at relevant points. Returns 1 on success, 0 on failure. + +proc v4kinit { name pass standalone } { + global REALMNAME + global KINIT + global spawn_id + + # Use kinit to get a ticket. + # + # For now always get forwardable tickets. Later when we need to make + # tests that distiguish between forwardable tickets and otherwise + # we should but another option to this proc. --proven + # + spawn $KINIT -4 $name@$REALMNAME + expect { + "Password for $name@$REALMNAME:" { + verbose "v4kinit started" + } + timeout { + fail "v4kinit" + return 0 + } + eof { + fail "v4kinit" + return 0 + } + } + send "$pass\r" + expect eof + if ![check_exit_status kinit] { + return 0 + } + + if {$standalone} { + pass "v4kinit" + } + + return 1 +} + # Set up a root shell using rlogin $hostname -l root. This is used # when testing the daemons that must be run as root, such as telnetd # or rlogind. This sets the global variables rlogin_spawn_id and -- 2.26.2