diff options
author | Russ Allbery <rra@stanford.edu> | 2010-02-21 17:45:56 -0800 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2010-02-21 17:45:56 -0800 |
commit | ae14bea1375dd5923d4a73e167b27bee13feb7b7 (patch) | |
tree | c1222395732cf8ce2cca32f013f080d19736f474 /perl/t/lib | |
parent | 57aba51dc26ebf0bdd034f6cb418a9ea5f1fc0be (diff) | |
parent | 60210334fa3dbd5dd168199063c6ee850d750d0c (diff) |
Merge commit 'upstream/0.10' into debian
Diffstat (limited to 'perl/t/lib')
-rw-r--r-- | perl/t/lib/Util.pm | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/perl/t/lib/Util.pm b/perl/t/lib/Util.pm index a1bacbd..ab88b39 100644 --- a/perl/t/lib/Util.pm +++ b/perl/t/lib/Util.pm @@ -1,5 +1,4 @@ # Util -- Utility class for wallet tests. -# $Id$ # # Written by Russ Allbery <rra@stanford.edu> # Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University @@ -21,7 +20,8 @@ $VERSION = '0.02'; use Exporter (); @ISA = qw(Exporter); -@EXPORT = qw(contents db_setup getcreds remctld_spawn remctld_stop); +@EXPORT = qw(contents db_setup getcreds keytab_valid remctld_spawn + remctld_stop); ############################################################################## # General utility functions @@ -67,7 +67,7 @@ sub db_setup { } ############################################################################## -# Local ticket cache +# Kerberos utility functions ############################################################################## # Given a keytab file and a principal, try authenticating with kinit. @@ -86,6 +86,22 @@ sub getcreds { return 0; } +# Given keytab data and the principal, write it to a file and try +# authenticating using kinit. +sub keytab_valid { + my ($keytab, $principal) = @_; + open (KEYTAB, '>', 'keytab') or die "cannot create keytab: $!\n"; + print KEYTAB $keytab; + close KEYTAB; + $principal .= '@' . $Wallet::Config::KEYTAB_REALM + unless $principal =~ /\@/; + my $result = getcreds ('keytab', $principal); + if ($result) { + unlink 'keytab'; + } + return $result; +} + ############################################################################## # remctld handling ############################################################################## |