diff options
| author | Russ Allbery <rra@stanford.edu> | 2010-02-08 19:59:26 -0800 | 
|---|---|---|
| committer | Russ Allbery <rra@stanford.edu> | 2010-02-08 19:59:26 -0800 | 
| commit | c2422d4f762b5db774c6e0fef2cb2de916904f0e (patch) | |
| tree | aa5f1e5663dee832569cda13a7ab935f013f3f57 /perl | |
| parent | ab7df231106dc67ba96b4ff7b5483370bfcba969 (diff) | |
Redo how we find enctypes in the keytab test suite
We may have a different userspace than the Kerberos type, so always
try klist -ke first and then fall back on ktutil if it fails.
Also display the error message in a few more places if things fail,
discovered as useful when debugging other problems.
Diffstat (limited to 'perl')
| -rwxr-xr-x | perl/t/keytab.t | 36 | 
1 files changed, 22 insertions, 14 deletions
| diff --git a/perl/t/keytab.t b/perl/t/keytab.t index 25e946c..c3e89d5 100755 --- a/perl/t/keytab.t +++ b/perl/t/keytab.t @@ -116,19 +116,22 @@ sub enctypes {      close KEYTAB;      my @enctypes; -    if ($Wallet::Config::KEYTAB_KRBTYPE eq 'MIT') { -        open (KLIST, '-|', 'klist', '-ke', 'keytab') -            or die "cannot run klist: $!\n"; -        local $_; -        while (<KLIST>) { -            next unless /^ *\d+ /; -            my ($string) = /\((.*)\)\s*$/; -            next unless $string; -            $enctype = $enctype{lc $string} || 'UNKNOWN'; -            push (@enctypes, $enctype); -        } -        close KLIST; -    } elsif ($Wallet::Config::KEYTAB_KRBTYPE eq 'Heimdal') { +    open (KLIST, '-|', 'klist', '-ke', 'keytab') +        or die "cannot run klist: $!\n"; +    local $_; +    while (<KLIST>) { +        next unless /^ *\d+ /; +        my ($string) = /\((.*)\)\s*$/; +        next unless $string; +        $enctype = $enctype{lc $string} || 'UNKNOWN'; +        push (@enctypes, $enctype); +    } +    close KLIST; + +    # If that failed, we may have a Heimdal user space instead, so try ktutil. +    # If we try this directly, it will just hang with MIT ktutil. +    if ($? != 0) { +        @enctypes = ();          open (KTUTIL, '-|', 'ktutil', '-k', 'keytab', 'list')              or die "cannot run ktutil: $!\n";          local $_; @@ -227,9 +230,14 @@ SKIP: {      $object = eval {          Wallet::Object::Keytab->create ('keytab', 'wallet/two', $dbh, @trace)        }; -    ok (defined ($object), 'Creating an existing principal succeeds'); +    if (defined ($object)) { +        ok (defined ($object), 'Creating an existing principal succeeds'); +    } else { +        is ($@, '', 'Creating an existing principal succeeds'); +    }      ok ($object->isa ('Wallet::Object::Keytab'), ' and is the right class');      is ($object->destroy (@trace), 1, ' and destroying it succeeds'); +    is ($object->error, undef, ' with no error message');      ok (! created ('wallet/two'), ' and now it does not exist');      my @name = qw(keytab wallet-test/one);      $object = eval { Wallet::Object::Keytab->create (@name, $dbh, @trace) }; | 
