]> eyrie.org Git - kerberos/wallet.git/commitdiff
Sort the ACL membership report
authorRuss Allbery <eagle@eyrie.org>
Mon, 18 May 2020 05:19:39 +0000 (22:19 -0700)
committerRuss Allbery <eagle@eyrie.org>
Mon, 18 May 2020 05:19:39 +0000 (22:19 -0700)
In Wallet::Report, sort the results of acl_membership().  This is
only used for the duplicate ACLs report currently, but it may help
external callers as well as produce reliable results for testing.
Patch from macrotex.

perl/lib/Wallet/Report.pm

index d4add04412a15dca4d658467bf7a797b2822549e..a6aebb9d8b81d21a1c913f1b11f968c97a0b48c9 100644 (file)
@@ -1,7 +1,7 @@
 # Wallet::Report -- Wallet system reporting interface
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2016 Russ Allbery <eagle@eyrie.org>
+# Copyright 2016, 2020 Russ Allbery <eagle@eyrie.org>
 # Copyright 2008-2010, 2013-2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
@@ -504,7 +504,8 @@ sub acls_unused {
 }
 
 # Obtain a textual representation of the membership of an ACL, returning undef
-# on error and setting the internal error.
+# on error and setting the internal error.  Make sure the membership is sorted
+# so that comparisons are possible.
 sub acl_membership {
     my ($self, $id) = @_;
     my $acl = eval { Wallet::ACL->new ($id, $self->{schema}) };
@@ -512,7 +513,9 @@ sub acl_membership {
         $self->error ($@);
         return;
     }
-    my @members = map { "$_->[0] $_->[1]" } $acl->list;
+    my @entries = $acl->list;
+    @entries = sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } $acl->list;
+    my @members = map { "$_->[0] $_->[1]" } @entries;
     if (!@members && $acl->error) {
         $self->error ($acl->error);
         return;