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)
committerMatthew Vernon <matthewv@chiark.greenend.org.uk>
Thu, 23 Jan 2014 11:15:03 +0000 (11:15 +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.

Signed-off-by: Matthew Vernon <matthewv@chiark.greenend.org.uk>
evade-mail-admin

index fb22d3943a8e7e91e66c5e922b572927881673c2..6a6af061694f349c0bc886a03e1541458dd0d8b9 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)
@@ -408,10 +408,23 @@ 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; }
+    }
     nomoreargs;
-    my $q = $dbh->prepare("SELECT * FROM addrs WHERE user=?".
-                         " ORDER BY localpart");
+    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->execute($user);
     listq($q);
 }
@@ -420,7 +433,7 @@ sub action_list_user {
     die unless $priv;
     $user = nextarg;
     nomoreargs;
-    action_list;
+    action_list "-a";
 }
 
 sub action_list_all {