diff options
author | Jon Robertson <jonrober@stanford.edu> | 2010-01-07 08:02:26 -0800 |
---|---|---|
committer | Jon Robertson <jonrober@stanford.edu> | 2010-01-07 08:02:26 -0800 |
commit | 17b515f76c5774e3bc45906d3e679edcfe2b529b (patch) | |
tree | 8c966a3c5adbbd25e87fa5e632a7943812457a0b /perl | |
parent | 4ad367b4269811dd0b9abfa9c0e69a1a7490e4e9 (diff) |
Added ability to list only ACLs with no members
Added new option to the 'wallet-admin list acls' command, 'empty', which
will only return those ACLs which have no members. This will help
maintenance in the long term by pointing out ACLs in error or no longer
needed.
Diffstat (limited to 'perl')
-rw-r--r-- | perl/Wallet/Admin.pm | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/perl/Wallet/Admin.pm b/perl/Wallet/Admin.pm index 91f1bfb..0e437ec 100644 --- a/perl/Wallet/Admin.pm +++ b/perl/Wallet/Admin.pm @@ -261,6 +261,15 @@ sub list_acls_all { return ($sql); } +# Returns the SQL statement required to find and returned all empty ACLs in +# the db. +sub list_acls_empty { + my ($self) = @_; + my $sql = 'select ac_id, ac_name from acls left join acl_entries ' + .'on (acls.ac_id=acl_entries.ae_id) where ae_id is null;'; + return ($sql); +} + # Returns the SQL statement and the field required to search the ACLs and # return only those entries which contain a entries with identifiers # matching a particular given string. @@ -289,10 +298,14 @@ sub list_acls { if (!defined $type || $type eq '') { ($sql) = $self->list_acls_all (); } else { - if (@args == 0) { - $self->error ("acl searches require an argument to search"); - } elsif ($type eq 'entry') { - ($sql, @search) = $self->list_acls_entry (@args); + if ($type eq 'entry') { + if (@args == 0) { + $self->error ("acl searches require an argument to search"); + } else { + ($sql, @search) = $self->list_acls_entry (@args); + } + } elsif ($type eq 'empty') { + ($sql) = $self->list_acls_empty (); } else { $self->error ("do not know search type: $type"); } |