From 21651a03eee3a174c657515fc75ecd1857500c10 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sun, 17 May 2020 22:19:39 -0700 Subject: Sort the ACL membership report 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/perl/lib/Wallet/Report.pm b/perl/lib/Wallet/Report.pm index d4add04..a6aebb9 100644 --- a/perl/lib/Wallet/Report.pm +++ b/perl/lib/Wallet/Report.pm @@ -1,7 +1,7 @@ # Wallet::Report -- Wallet system reporting interface # # Written by Russ Allbery -# Copyright 2016 Russ Allbery +# Copyright 2016, 2020 Russ Allbery # 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; -- cgit v1.2.3