chiark / gitweb /
Allow users to give away local parts to other users.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 16 Oct 2015 10:05:34 +0000 (11:05 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 16 Oct 2015 10:14:13 +0000 (11:14 +0100)
Keep track of who created things initially so that we can track down
abuse if it occurs.

bin/mailredir.userv
lib/Odin.pm
sql/setup-mail.sql
sql/update-mail-v2.sql [new file with mode: 0644]

index f5acb0688e31e2fc0484fe656d29d08f427cbfa7..fb2d36b968d749632b047b87e61ba8cc6dba98a8 100755 (executable)
@@ -66,6 +66,7 @@ Commands available:
 
        disable LPART ...
        dormant
 
        disable LPART ...
        dormant
+       giveaway LPART OWNER
        help
        list
        new [-n COUNT] [-GENOPTS] [-RECOPTS] [RECIP]
        help
        list
        new [-n COUNT] [-GENOPTS] [-RECOPTS] [RECIP]
@@ -95,6 +96,13 @@ EOF
     my ($lpart, $expire, $recip, $comment) = @$r;
     Odin::print_columns $lpart => 24, $recip => 32, $comment => 0;
   }
     my ($lpart, $expire, $recip, $comment) = @$r;
     Odin::print_columns $lpart => 24, $recip => 32, $comment => 0;
   }
+} elsif ($op eq "giveaway") {
+  @ARGV >= 2 or Odin::fail "usage: giveaway OWNER LPART ...";
+  my $owner = shift @ARGV;
+  my @l = @ARGV;
+  getpwnam $owner or Odin::fail "unknown user `$owner'";
+  my %r = (owner => $owner);
+  Odin::modify_redir $dom, %r, @l;
 } elsif ($op eq "reserved") {
   @ARGV and Odin::fail "usage: reserved";
   for my $r (Odin::redir_query Odin::open_db, $dom, $Odin::WHO,
 } elsif ($op eq "reserved") {
   @ARGV and Odin::fail "usage: reserved";
   for my $r (Odin::redir_query Odin::open_db, $dom, $Odin::WHO,
index 06b5212fcf929c4bc7791c06e5dca2503279f278..154fae0b1c9511cde89593cb42cf4cb0bf34fdb7 100644 (file)
@@ -586,7 +586,8 @@ sub new_redir ($$\%;$) {
     while (@l < $n) {
       my $l = Odin::gen_redir_name $db, $gen;
       insert_record $db, "odin_mailredir",
     while (@l < $n) {
       my $l = Odin::gen_redir_name $db, $gen;
       insert_record $db, "odin_mailredir",
-       lpart => $l, dom => $dom, owner => $WHO, st => 'live',
+       lpart => $l, dom => $dom, st => 'live',
+       owner => $WHO, creator => $WHO,
        recip => $r->{recip} // qualify_recip $Odin::WHO,
        expire => $r->{expire} // -1,
        comment => $r->{comment} // "";
        recip => $r->{recip} // qualify_recip $Odin::WHO,
        expire => $r->{expire} // -1,
        comment => $r->{comment} // "";
index e1b535c2fe6e9836b060e75dc9fcdbd52bdc4ac0..9369cb5b481c40d4d89fa96d0ac3ac0e50848f79 100644 (file)
@@ -16,6 +16,7 @@ create table odin_mailredir
        (lpart varchar(64) not null,
         dom varchar(128) not null,
         owner varchar(64) not null,
        (lpart varchar(64) not null,
         dom varchar(128) not null,
         owner varchar(64) not null,
+        creator varchar(64) not null,
         recip text not null default '',
         expire bigint not null,
         st varchar(16) not null default 'live',
         recip text not null default '',
         expire bigint not null,
         st varchar(16) not null default 'live',
diff --git a/sql/update-mail-v2.sql b/sql/update-mail-v2.sql
new file mode 100644 (file)
index 0000000..d771c7a
--- /dev/null
@@ -0,0 +1,10 @@
+/* -*-sql-*-
+ *
+ * Plain old SQL for setting up the tables for Odin mail redirection.
+ */
+
+begin;
+alter table odin_mailredir add column creator varchar(64);
+update odin_mailredir set creator = owner where creator is null;
+alter table odin_mailredir alter column creator set not null;
+commit;