From 62f4dc22e3d9739c93c2b29acfdefb34afc448a2 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sat, 1 Dec 2007 02:24:14 +0000 Subject: Don't use die when forking kasetkey fails and similarly don't close the database connection on a failed fork. --- perl/Wallet/Object/Keytab.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'perl') diff --git a/perl/Wallet/Object/Keytab.pm b/perl/Wallet/Object/Keytab.pm index 6254d6f..1189150 100644 --- a/perl/Wallet/Object/Keytab.pm +++ b/perl/Wallet/Object/Keytab.pm @@ -65,14 +65,13 @@ sub kadmin { # Don't use die here; it will get trapped as an exception. Also be # careful about our database handles. (We still lose if there's some # other database handle open we don't know about.) + $self->{dbh}->{InactiveDestroy} = 0 if ref $self; unless (open (STDERR, '>&STDOUT')) { warn "wallet: cannot dup stdout: $!\n"; - $self->{dbh}->{InactiveDestroy} = 0 if ref $self; exit 1; } unless (exec ($Wallet::Config::KEYTAB_KADMIN, @args)) { warn "wallet: cannot run $Wallet::Config::KEYTAB_KADMIN: $!\n"; - $self->{dbh}->{InactiveDestroy} = 0 if ref $self; exit 1; } } @@ -227,9 +226,18 @@ sub kaserver_kasetkey { $self->error ("cannot fork: $!"); return undef; } elsif ($pid == 0) { - open (STDERR, '>&STDOUT') or die "cannot redirect stderr: $!\n"; - exec ($kasetkey, '-k', $admin_srvtab, '-a', $admin, @args) - or die "cannot exec $kasetkey: $!\n"; + # Don't use die here; it will get trapped as an exception. Also be + # careful about our database handles. (We still lose if there's some + # other database handle open we don't know about.) + $self->{dbh}->{InactiveDestroy} = 0; + unless (open (STDERR, '>&STDOUT')) { + warn "cannot redirect stderr: $!\n"; + exit 1; + } + unless (exec ($kasetkey, '-k', $admin_srvtab, '-a', $admin, @args)) { + warn "cannot exec $kasetkey: $!\n"; + exit 1; + } } else { local $/; my $output = ; -- cgit v1.2.3