chiark / gitweb /
Make "list" command suppress rejected addresses by default
authorMatthew Vernon <matthewv@chiark.greenend.org.uk>
Thu, 23 Jan 2014 11:15:03 +0000 (11:15 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 13 Feb 2014 18:29:33 +0000 (18:29 +0000)
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 <matthewv@chiark.greenend.org.uk>
evade-mail-admin

index fb22d3943a8e7e91e66c5e922b572927881673c2..4e5be404f34b863de11d7ea24b49c2c70e7aaf54 100755 (executable)
@@ -22,7 +22,7 @@ actions
   choose [<genopts>] [<redirect>] [#<comment>]  (interactively allocate)
   update <addr> [<redirect>] [#<comment>]
   show <addr>
-  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);
 }