END
our $usage2 = <<'END';
actions
- create [REDIRECT] [#COMMENT]
+ create [REDIRECT] [#COMMENT] (default for REDIRECT is your username)
update LOCAL-PART [REDIRECT] [#COMMENT]
show LOCAL-PART
list
list-actions
-empty value for REDIRECT means reject
+empty string for REDIRECT means reject
END
our $usage3 = <<'END';
privileged actions
}
sub rhsargs ($) {
- my ($row) = @_;
+ my ($defrow) = @_;
+ my $row = { };
while (@ARGV) {
$_ = shift @ARGV;
my $f = (s/^\#// ? 'comment' : 'redirect');
die "$f supplied twice\n" if exists $row->{$f};
$row->{$f} = $_;
}
+ foreach my $f (keys %$defrow) {
+ next if defined $row->{$f};
+ $row->{$f} = $defrow->{$f};
+ }
qualify $row->{'redirect'};
return $row;
}
prow($row);
}
+sub listq ($) {
+ my ($q) = @_;
+ while (my $row = $q->fetchrow_hashref()) {
+ prow($row);
+ }
+}
+
sub action_list {
nomoreargs;
my $q = $dbh->prepare("SELECT * FROM addrs WHERE user=?".
" ORDER BY localpart");
$q->execute($user);
- while (my $row = $q->fetchrow_hashref()) {
- prow($row);
- }
+ listq($q);
}
sub action_list_user {
action_list;
}
+sub action_list_all {
+ die unless $priv;
+ nomoreargs;
+ my $q = $dbh->prepare("SELECT * FROM addrs".
+ " ORDER BY user, localpart");
+ $q->execute();
+ listq($q)
+}
+
sub action_insert_exact {
die unless $priv;
my $row = { };