diff options
author | Jon Robertson <jonrober@stanford.edu> | 2015-06-09 13:06:56 -0700 |
---|---|---|
committer | Jon Robertson <jonrober@stanford.edu> | 2015-11-18 23:47:26 -0800 |
commit | 43f386a6e3d0c141cd732b5ef5c2be8349f51f03 (patch) | |
tree | 0d34c655bf47b6d3078964567539ff239b74719d /perl/lib | |
parent | 0b4201c8a65102227685f5cbe4f81407dce7e0b5 (diff) |
ACL.pm: Destroying a nested ACL will now fail
When destroying an ACL nested in other ACLs, we now fail with an
explanation rather than going through to remove all the places it's
nested. That's more in line with how we handle trying to destroy ACLs
that own things.
Change-Id: I8bc0530e37c54369ec52d9b369f8fabe98def77a
Diffstat (limited to 'perl/lib')
-rw-r--r-- | perl/lib/Wallet/ACL.pm | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/perl/lib/Wallet/ACL.pm b/perl/lib/Wallet/ACL.pm index 6d8005d..f875185 100644 --- a/perl/lib/Wallet/ACL.pm +++ b/perl/lib/Wallet/ACL.pm @@ -273,19 +273,20 @@ sub destroy { die "ACL in use by ".$entry->ob_type.":".$entry->ob_name; } - # Delete any entries (there may or may not be any). - my %search = (ae_id => $self->{id}); - @entries = $self->{schema}->resultset('AclEntry')->search(\%search); - for my $entry (@entries) { - $entry->delete; + # Also make certain the ACL isn't being nested in another. + my %search = (ae_scheme => 'nested', + ae_identifier => $self->{name}); + my %options = (join => 'acls', + prefetch => 'acls'); + @entries = $self->{schema}->resultset('AclEntry')->search(\%search, + \%options); + if (@entries) { + my ($entry) = @entries; + die "ACL is nested in ACL ".$entry->acls->ac_name; } - # Find any references to this being used as a nested verifier and - # remove them. This really breaks out of the normal flow, but it's - # hard to do otherwise. - %search = (ae_scheme => 'nested', - ae_identifier => $self->{name}, - ); + # Delete any entries (there may or may not be any). + %search = (ae_id => $self->{id}); @entries = $self->{schema}->resultset('AclEntry')->search(\%search); for my $entry (@entries) { $entry->delete; |