diff options
Diffstat (limited to 'perl/t/lib')
| -rw-r--r-- | perl/t/lib/Util.pm | 21 | 
1 files changed, 19 insertions, 2 deletions
diff --git a/perl/t/lib/Util.pm b/perl/t/lib/Util.pm index ac0f530..ab88b39 100644 --- a/perl/t/lib/Util.pm +++ b/perl/t/lib/Util.pm @@ -20,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 @@ -66,7 +67,7 @@ sub db_setup {  }  ############################################################################## -# Local ticket cache +# Kerberos utility functions  ##############################################################################  # Given a keytab file and a principal, try authenticating with kinit. @@ -85,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  ##############################################################################  | 
