summaryrefslogtreecommitdiff
path: root/perl/lib/Wallet
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2014-07-15 22:57:31 -0700
committerRuss Allbery <rra@stanford.edu>2014-07-15 22:58:47 -0700
commit5d0038202d82c71119fefa9c5bd0f816ae55991c (patch)
treeeabcd4396bfd1e41ca11eb0a107cf12609f8a414 /perl/lib/Wallet
parentee79913831be70fc51c193ea4118a15abb038a67 (diff)
Return the name of the ACL instead of the numeric ID
The owner and getacl commands now return the current name of the ACL instead of its numeric ID, matching the documentation of owner. Change-Id: Ic47aad48bd1454ed4bffff7030b0492d74eee4fa Reviewed-on: https://gerrit.stanford.edu/1559 Reviewed-by: Russ Allbery <rra@stanford.edu> Tested-by: Russ Allbery <rra@stanford.edu>
Diffstat (limited to 'perl/lib/Wallet')
-rw-r--r--perl/lib/Wallet/Object/Base.pm20
-rw-r--r--perl/lib/Wallet/Server.pm8
2 files changed, 21 insertions, 7 deletions
diff --git a/perl/lib/Wallet/Object/Base.pm b/perl/lib/Wallet/Object/Base.pm
index 4939bf5..a6a78bf 100644
--- a/perl/lib/Wallet/Object/Base.pm
+++ b/perl/lib/Wallet/Object/Base.pm
@@ -26,7 +26,7 @@ use Wallet::ACL;
# 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.07';
+$VERSION = '0.08';
##############################################################################
# Constructors
@@ -302,7 +302,14 @@ sub acl {
} elsif (defined $id) {
return $self->_set_internal ($attr, undef, $user, $host, $time);
} else {
- return $self->_get_internal ($attr);
+ my $id = $self->_get_internal ($attr);
+ return unless defined $id;
+ my $acl = eval { Wallet::ACL->new ($id, $self->{schema}) };
+ if ($@) {
+ $self->error ($@);
+ return;
+ }
+ return $acl->name;
}
}
@@ -380,7 +387,14 @@ sub owner {
} elsif (defined $owner) {
return $self->_set_internal ('owner', undef, $user, $host, $time);
} else {
- return $self->_get_internal ('owner');
+ my $id = $self->_get_internal ('owner');
+ return unless defined $id;
+ my $acl = eval { Wallet::ACL->new ($id, $self->{schema}) };
+ if ($@) {
+ $self->error ($@);
+ return;
+ }
+ return $acl->name;
}
}
diff --git a/perl/lib/Wallet/Server.pm b/perl/lib/Wallet/Server.pm
index e278489..95fd4e6 100644
--- a/perl/lib/Wallet/Server.pm
+++ b/perl/lib/Wallet/Server.pm
@@ -831,7 +831,7 @@ failure to get the error message.
Gets or sets the ACL type ACL to ID for the object identified by TYPE and
NAME. ACL should be one of C<get>, C<store>, C<show>, C<destroy>, or
C<flags>. If ID is not given, returns the current setting of that ACL as
-a numeric ACL ID or undef if that ACL isn't set or on failure. To
+the name of the ACL or undef if that ACL isn't set or on failure. To
distinguish between an ACL that isn't set and a failure to retrieve the
ACL, the caller should call error() after an undef return. If error()
also returns undef, that ACL wasn't set; otherwise, error() will return
@@ -1041,9 +1041,9 @@ owner ACL will not be checked.
=item owner(TYPE, NAME [, OWNER])
Gets or sets the owner for the object identified by TYPE and NAME. If
-OWNER is not given, returns the current owner as a numeric ACL ID or undef
-if no owner is set or on an error. To distinguish between an owner that
-isn't set and a failure to retrieve the owner, the caller should call
+OWNER is not given, returns the current owner as the name of the ACL or
+undef if no owner is set or on an error. To distinguish between an owner
+that isn't set and a failure to retrieve the owner, the caller should call
error() after an undef return. If error() also returns undef, that ACL
wasn't set; otherwise, error() will return the error message.