aboutsummaryrefslogtreecommitdiff
path: root/perl/Wallet
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-09-26 18:55:03 +0000
committerRuss Allbery <rra@stanford.edu>2007-09-26 18:55:03 +0000
commit7ec47028dbfe6df70d4c07e9546ae1680cf4e91f (patch)
treea962f796c0ee3b1393d8a6af882d83f498c3a528 /perl/Wallet
parent50d3cd92ea42f76d5a76ec43d869dd8d721ff5f4 (diff)
Include the synchronization configuration in show() output. Provide a
new object method that subclasses can override to add attribute information to show() and remove the documentation about overriding show().
Diffstat (limited to 'perl/Wallet')
-rw-r--r--perl/Wallet/Object/Base.pm36
-rw-r--r--perl/Wallet/Object/Keytab.pm13
2 files changed, 41 insertions, 8 deletions
diff --git a/perl/Wallet/Object/Base.pm b/perl/Wallet/Object/Base.pm
index b4e5939..478382e 100644
--- a/perl/Wallet/Object/Base.pm
+++ b/perl/Wallet/Object/Base.pm
@@ -284,6 +284,13 @@ sub attr {
return;
}
+# Format the object attributes for inclusion in show(). The default
+# implementation just returns the empty string.
+sub attr_show {
+ my ($self) = @_;
+ return '';
+}
+
# Get or set the expires value of an object. Expects an expiration time in
# seconds since epoch. If setting the expiration, trace information must also
# be provided.
@@ -502,6 +509,11 @@ sub show {
if (@flags) {
$output .= sprintf ("%15s: %s\n", 'Flags', "@flags");
}
+ my $attr_output = $self->attr_show;
+ if (not defined $attr_output) {
+ return undef;
+ }
+ $output .= $attr_output;
}
next unless defined $data[$i];
if ($attrs[$i][0] =~ /^ob_(owner|acl_)/) {
@@ -659,6 +671,15 @@ arguments are used for logging and history and should indicate the user and
host from which the change is made and the time of the change. Returns true
on success and false on failure.
+=item attr_show()
+
+Returns a formatted text description of the type-specific attributes of the
+object, or undef on error. The default implementation of this method always
+returns the empty string. If there are any type-specific attributes set,
+this method should return that metadata, formatted as key: value pairs with
+the keys right-aligned in the first 15 characters, followed by a space, a
+colon, and the value.
+
=item destroy(PRINCIPAL, HOSTNAME [, DATETIME])
Destroys the object by removing all record of it from the database. The
@@ -741,14 +762,13 @@ change.
=item show()
Returns a formatted text description of the object suitable for human
-display, or undef on error. The default implementation shows all of the
-base metadata about the object, formatted as key: value pairs with the keys
-aligned in the first 15 characters followed by a space, a colon, and the
-value. If any ACLs or an owner are set, after this data there is a blank
-line and then the information for each unique ACL, separated by blank lines.
-Object implementations with additional data to display can rely on that
-format to add additional settings into the formatted output or at the end
-with a matching format.
+display, or undef on error. All of the base metadata about the object,
+formatted as key: value pairs with the keys aligned in the first 15
+characters followed by a space, a colon, and the value. The attr_show()
+method of the object is also called and any formatted output it returns will
+be included. If any ACLs or an owner are set, after this data there is a
+blank line and then the information for each unique ACL, separated by blank
+lines.
=item store(DATA, PRINCIPAL, HOSTNAME [, DATETIME])
diff --git a/perl/Wallet/Object/Keytab.pm b/perl/Wallet/Object/Keytab.pm
index 5f128b0..c78adc2 100644
--- a/perl/Wallet/Object/Keytab.pm
+++ b/perl/Wallet/Object/Keytab.pm
@@ -475,6 +475,19 @@ sub attr {
}
}
+# Override attr_show to display the sync attribute.
+sub attr_show {
+ my ($self) = @_;
+ my @targets = $self->attr ('sync');
+ if (not @targets and $self->error) {
+ return undef;
+ } elsif (@targets) {
+ return sprintf ("%15s: %s\n", 'Synced with', "@targets");
+ } else {
+ return '';
+ }
+}
+
# Override create to start by creating the principal in Kerberos and only
# create the entry in the database if that succeeds. Error handling isn't
# great here since we don't have a way to communicate the error back to the