summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-02-11 23:48:02 +0000
committerRuss Allbery <rra@stanford.edu>2008-02-11 23:48:02 +0000
commited075220bbd6515c713a5e53af00d6db66cd1c7c (patch)
treea958c331880ffbf70b6768f3fea4bdbcb8c26372 /perl
parent9feb152a52ec8b28231fdbb2590e0544e683d956 (diff)
Move the remctld handling into the utility library.
Diffstat (limited to 'perl')
-rwxr-xr-xperl/t/keytab.t34
-rw-r--r--perl/t/lib/Util.pm42
-rwxr-xr-xperl/t/verifier.t36
3 files changed, 46 insertions, 66 deletions
diff --git a/perl/t/keytab.t b/perl/t/keytab.t
index 503b5c9..21a53c6 100755
--- a/perl/t/keytab.t
+++ b/perl/t/keytab.t
@@ -158,35 +158,6 @@ sub valid_srvtab {
return ($? == 0) ? 1 : 0;
}
-# Start remctld with the appropriate options to run our fake keytab backend.
-sub spawn_remctld {
- my ($path, $principal, $keytab) = @_;
- unlink 'test-pid';
- my $pid = fork;
- if (not defined $pid) {
- die "cannot fork: $!\n";
- } elsif ($pid == 0) {
- open (STDERR, '>&STDOUT') or die "cannot redirect stderr: $!\n";
- exec ($path, '-m', '-p', 14373, '-s', $principal, '-P', 'test-pid',
- '-f', 't/data/keytab.conf', '-S', '-F', '-k', $keytab) == 0
- or die "cannot exec $path: $!\n";
- } else {
- my $tries = 0;
- while ($tries < 10 && ! -f 'test-pid') {
- select (undef, undef, undef, 0.25);
- }
- }
-}
-
-# Stop the running remctld process.
-sub stop_remctld {
- open (PID, '<', 'test-pid') or return;
- my $pid = <PID>;
- close PID;
- chomp $pid;
- kill 15, $pid;
-}
-
# Use Wallet::Admin to set up the database.
unlink ('krb5cc_temp', 'krb5cc_test', 'test-acl', 'test-pid');
db_setup;
@@ -428,7 +399,8 @@ SKIP: {
is ($two->flag_set ('unchanging', @trace), 1, ' and setting unchanging');
# Now spawn our remctld server and get a ticket cache.
- spawn_remctld ($remctld, $principal, 't/data/test.keytab');
+ remctld_spawn ($remctld, $principal, 't/data/test.keytab',
+ 't/data/keytab.conf');
$ENV{KRB5CCNAME} = 'krb5cc_test';
getcreds ('t/data/test.keytab', $principal);
$ENV{KRB5CCNAME} = 'krb5cc_good';
@@ -460,7 +432,7 @@ SKIP: {
' with the right error');
is ($one->destroy (@trace), 1, 'Destroying wallet/one works');
is ($two->destroy (@trace), 1, ' as does destroying wallet/two');
- stop_remctld;
+ remctld_stop;
# Check that history has been updated correctly.
$history .= <<"EOO";
diff --git a/perl/t/lib/Util.pm b/perl/t/lib/Util.pm
index 6566ca4..8aec1aa 100644
--- a/perl/t/lib/Util.pm
+++ b/perl/t/lib/Util.pm
@@ -2,7 +2,7 @@
# $Id$
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2007 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University
#
# See LICENSE for licensing terms.
@@ -17,11 +17,11 @@ use Wallet::Config;
# This version should be increased on any code change to this module. Always
# use two digits for the minor version with a leading zero if necessary so
# that it will sort properly.
-$VERSION = '0.01';
+$VERSION = '0.02';
use Exporter ();
@ISA = qw(Exporter);
-@EXPORT = qw(contents db_setup);
+@EXPORT = qw(contents db_setup remctld_spawn remctld_stop);
##############################################################################
# General utility functions
@@ -65,3 +65,39 @@ sub db_setup {
unlink 'wallet-db';
}
}
+
+##############################################################################
+# remctld handling
+##############################################################################
+
+# Start remctld with the appropriate options to run our fake keytab backend.
+# Takes the path to remctld, the principal it uses as its server principal,
+# the keytab it uses for authentication, and the configuration file it should
+# load.
+sub remctld_spawn {
+ my ($path, $principal, $keytab, $config) = @_;
+ unlink 'test-pid';
+ my $pid = fork;
+ if (not defined $pid) {
+ die "cannot fork: $!\n";
+ } elsif ($pid == 0) {
+ open (STDERR, '>&STDOUT') or die "cannot redirect stderr: $!\n";
+ exec ($path, '-m', '-p', 14373, '-s', $principal, '-P', 'test-pid',
+ '-f', $config, '-S', '-F', '-k', $keytab) == 0
+ or die "cannot exec $path: $!\n";
+ } else {
+ my $tries = 0;
+ while ($tries < 10 && ! -f 'test-pid') {
+ select (undef, undef, undef, 0.25);
+ }
+ }
+}
+
+# Stop the running remctld process.
+sub remctld_stop {
+ open (PID, '<', 'test-pid') or return;
+ my $pid = <PID>;
+ close PID;
+ chomp $pid;
+ kill 15, $pid;
+}
diff --git a/perl/t/verifier.t b/perl/t/verifier.t
index 65b3923..c1ead6f 100755
--- a/perl/t/verifier.t
+++ b/perl/t/verifier.t
@@ -4,7 +4,7 @@
# t/verifier.t -- Tests for the basic wallet ACL verifiers.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2007 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University
#
# See LICENSE for licensing terms.
@@ -35,35 +35,6 @@ sub getcreds {
return 0;
}
-# Start remctld with the appropriate options to run our fake keytab backend.
-sub spawn_remctld {
- my ($path, $principal, $keytab) = @_;
- unlink 'test-pid';
- my $pid = fork;
- if (not defined $pid) {
- die "cannot fork: $!\n";
- } elsif ($pid == 0) {
- open (STDERR, '>&STDOUT') or die "cannot redirect stderr: $!\n";
- exec ($path, '-m', '-p', 14373, '-s', $principal, '-P', 'test-pid',
- '-f', 't/data/netdb.conf', '-S', '-F', '-k', $keytab) == 0
- or die "cannot exec $path: $!\n";
- } else {
- my $tries = 0;
- while ($tries < 10 && ! -f 'test-pid') {
- select (undef, undef, undef, 0.25);
- }
- }
-}
-
-# Stop the running remctld process.
-sub stop_remctld {
- open (PID, '<', 'test-pid') or return;
- my $pid = <PID>;
- close PID;
- chomp $pid;
- kill 15, $pid;
-}
-
my $verifier = Wallet::ACL::Base->new;
ok (defined $verifier, 'Wallet::ACL::Base creation');
ok ($verifier->isa ('Wallet::ACL::Base'), ' and class verification');
@@ -101,7 +72,8 @@ SKIP: {
# Now spawn our remctld server and get a ticket cache.
unlink ('krb5cc_test', 'test-acl', 'test-pid');
- spawn_remctld ($remctld, $principal, 't/data/test.keytab');
+ remctld_spawn ($remctld, $principal, 't/data/test.keytab',
+ 't/data/netdb.conf');
$ENV{KRB5CCNAME} = 'krb5cc_test';
getcreds ('t/data/test.keytab', $principal);
@@ -178,6 +150,6 @@ SKIP: {
'Undefined principal');
is ($verifier->error, 'no principal specified', ' and right error');
- stop_remctld;
+ remctld_stop;
unlink ('krb5cc_test', 'test-acl', 'test-pid');
}