aboutsummaryrefslogtreecommitdiff
path: root/perl/t/lib
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-02-12 00:07:59 +0000
committerRuss Allbery <rra@stanford.edu>2008-02-12 00:07:59 +0000
commit247366355b63b3f6804d591dde9d5b48895a8fdf (patch)
tree5598f9b6c530ba048b361038cb786ca6ad25177f /perl/t/lib
parented075220bbd6515c713a5e53af00d6db66cd1c7c (diff)
Move getcreds into the utility library as well.
Diffstat (limited to 'perl/t/lib')
-rw-r--r--perl/t/lib/Util.pm22
1 files changed, 21 insertions, 1 deletions
diff --git a/perl/t/lib/Util.pm b/perl/t/lib/Util.pm
index 8aec1aa..481b7d9 100644
--- a/perl/t/lib/Util.pm
+++ b/perl/t/lib/Util.pm
@@ -21,7 +21,7 @@ $VERSION = '0.02';
use Exporter ();
@ISA = qw(Exporter);
-@EXPORT = qw(contents db_setup remctld_spawn remctld_stop);
+@EXPORT = qw(contents db_setup getcreds remctld_spawn remctld_stop);
##############################################################################
# General utility functions
@@ -67,6 +67,26 @@ sub db_setup {
}
##############################################################################
+# Local ticket cache
+##############################################################################
+
+# Given a keytab file and a principal, try authenticating with kinit.
+sub getcreds {
+ my ($file, $principal) = @_;
+ my @commands = (
+ "kinit -k -t $file $principal >/dev/null 2>&1 </dev/null",
+ "kinit -t $file $principal >/dev/null 2>&1 </dev/null",
+ "kinit -k -K $file $principal >/dev/null 2>&1 </dev/null",
+ );
+ for my $command (@commands) {
+ if (system ($command) == 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+##############################################################################
# remctld handling
##############################################################################