From: Matthew Vernon Date: Thu, 23 Jan 2014 11:15:03 +0000 (+0000) Subject: Make "list" command suppress rejected addresses by default X-Git-Tag: A~2 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?p=d.git;a=commitdiff_plain;h=0a3a970bcc7364e3bc72a2c722511aa57521c438 Make "list" command suppress rejected addresses by default The "list" command now suppresses addresses that reject incoming mail by default. If the -a command is specified, then they are listed as before. The administrator's "list-user" command always shows all aliases for a user, regardless of whether or not they are delivered. [v3, squashed from c9f544da6fba by iwj] Signed-off-by: Matthew Vernon --- diff --git a/evade-mail-admin b/evade-mail-admin index fb22d39..4e5be40 100755 --- a/evade-mail-admin +++ b/evade-mail-admin @@ -22,7 +22,7 @@ actions choose [] [] [#] (interactively allocate) update [] [#] show - list + list [-a] (-a also lists aliases set to reject) list-actions empty string for redirect means reject remember to quote comments (to protect # from your shell) @@ -409,9 +409,23 @@ sub listq ($) { } sub action_list { + my $listall = 0; + $listall ||= $priv; + while (@ARGV) { + last unless $ARGV[0] =~ m/^-/; + $_ = shift @ARGV; + last if m/^--?$/; + if (m/^-a$/) { + $listall=1; + } else { + die "unknown option to list \`$_'\n"; + } + } nomoreargs; - my $q = $dbh->prepare("SELECT * FROM addrs WHERE user=?". - " ORDER BY localpart"); + my $q = "SELECT * FROM addrs WHERE user=?"; + $q .= " AND NOT redirect = ''" unless $listall; + $q .= " ORDER BY localpart"; + $q = $dbh->prepare($q); $q->execute($user); listq($q); }