diff options
author | Russ Allbery <rra@stanford.edu> | 2007-08-31 16:55:23 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-08-31 16:55:23 +0000 |
commit | 0ce8e1f8cf98c34b1d6990473a33f77fc04cac04 (patch) | |
tree | 3cbe7b4e39bc23b88c38143db1dd088e7623c7d2 /perl/Wallet/Object/Keytab.pm | |
parent | d67458b024098556511c7cfdc38a94351ed570d4 (diff) |
Use a better method of setting the internal error that automatically
adjusts for trailing newlines and exception detritus, saving duplicate
code. Standardize the documentation of the error() method and document
using this in child classes of the generic ACL and Object classes.
Disable printing of errors during connect in Wallet::Server since we're
going to throw our own exception.
Diffstat (limited to 'perl/Wallet/Object/Keytab.pm')
-rw-r--r-- | perl/Wallet/Object/Keytab.pm | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/perl/Wallet/Object/Keytab.pm b/perl/Wallet/Object/Keytab.pm index 313a439..38e0938 100644 --- a/perl/Wallet/Object/Keytab.pm +++ b/perl/Wallet/Object/Keytab.pm @@ -123,7 +123,7 @@ sub _kadmin_addprinc { sub _kadmin_ktadd { my ($self, $principal, $file) = @_; unless ($self->_valid_principal ($principal)) { - $self->{error} = "invalid principal name: $principal"; + $self->error ("invalid principal name: $principal"); return undef; } if ($Wallet::Config::KEYTAB_REALM) { @@ -131,11 +131,10 @@ sub _kadmin_ktadd { } my $output = eval { $self->_kadmin ("ktadd -q -k $file $principal") }; if ($@) { - $self->{error} = $@; - chomp $self->{error}; + $self->error ($@); return undef; } elsif ($output =~ /^(?:kadmin|ktadd): (.*)/m) { - $self->{error} = "error creating keytab for $principal: $1"; + $self->error ("error creating keytab for $principal: $1"); return undef; } return 1; @@ -147,13 +146,12 @@ sub _kadmin_ktadd { sub _kadmin_delprinc { my ($self, $principal) = @_; unless ($self->_valid_principal ($principal)) { - $self->{error} = "invalid principal name: $principal"; + $self->error ("invalid principal name: $principal"); return undef; } my $exists = eval { $self->_kadmin_exists ($principal) }; if ($@) { - $self->{error} = $@; - chomp $self->{error}; + $self->error ($@); return undef; } elsif (not $exists) { return 1; @@ -163,11 +161,10 @@ sub _kadmin_delprinc { } my $output = eval { $self->_kadmin ("delprinc -force $principal") }; if ($@) { - $self->{error} = $@; - chomp $self->{error}; + $self->error ($@); return undef; } elsif ($output =~ /^delete_principal: (.*)/m) { - $self->{error} = "error deleting $principal: $1"; + $self->error ("error deleting $principal: $1"); return undef; } return 1; @@ -200,7 +197,7 @@ sub get { my ($self, $user, $host, $time) = @_; $time ||= time; unless (defined ($Wallet::Config::KEYTAB_TMP)) { - $self->{error} = 'KEYTAB_TMP configuration variable not set'; + $self->error ('KEYTAB_TMP configuration variable not set'); return undef; } my $file = $Wallet::Config::KEYTAB_TMP . "/keytab.$$"; @@ -208,7 +205,7 @@ sub get { local *KEYTAB; unless (open (KEYTAB, '<', $file)) { my $princ = $self->{name}; - $self->{error} = "error opening keytab for principal $princ: $!"; + $self->error ("error opening keytab for principal $princ: $!"); return undef; } local $/; @@ -216,7 +213,7 @@ sub get { my $data = <KEYTAB>; if ($!) { my $princ = $self->{name}; - $self->{error} = "error reading keytab for principal $princ: $!"; + $self->error ("error reading keytab for principal $princ: $!"); return undef; } close KEYTAB; |