From 06decef4efd4f69a3b1f35c440ef71dbe45047ab Mon Sep 17 00:00:00 2001 From: Matthew Vernon Date: Thu, 13 Feb 2014 17:39:09 +0000 Subject: [PATCH] Revise patch in line with Ian's comments Ian's feedback on the previous patch has been incorporated: * make whitespace consistent * check argv before shifting * don't repeat any parts of the query * check $priv rather than passing an argument to action_list Signed-off-by: Matthew Vernon --- evade-mail-admin | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/evade-mail-admin b/evade-mail-admin index 6a6af06..6f3fe21 100755 --- a/evade-mail-admin +++ b/evade-mail-admin @@ -408,23 +408,22 @@ sub listq ($) { } } -sub action_list (;$) { +sub action_list { my ($q, $listall); - my ($x) = @_; - if ( defined $x ) { $listall = 1; } - my $v =shift @ARGV; - if ( defined $v ) { - if ($v ne "-a") {die "only legal argument to list is -a";} - else { $listall=1; } + if ($priv) { $listall = 1; } + if (@ARGV) { + my $v = shift @ARGV; + if ($v ne "-a") { + die "only legal argument to list is -a"; + } else { $listall=1; } } nomoreargs; - if($listall){ - $q = $dbh->prepare("SELECT * FROM addrs WHERE user=?". - " ORDER BY localpart"); - }else{ - $q = $dbh->prepare("SELECT * FROM addrs WHERE user=?". - " AND redirect <>'' ORDER BY localpart"); + $q="SELECT * FROM addrs WHERE user=?"; + if (!$listall) { + $q = $q. " AND NOT redirect = ''"; } + $q = $q. " ORDER BY localpart"; + $q = $dbh->prepare($q); $q->execute($user); listq($q); } @@ -433,7 +432,7 @@ sub action_list_user { die unless $priv; $user = nextarg; nomoreargs; - action_list "-a"; + action_list; } sub action_list_all { -- 2.30.2