From: Ian Jackson Date: Wed, 4 Sep 2013 17:31:28 +0000 (+0100) Subject: allow specifying ADDR as full address X-Git-Tag: test~37 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?p=d.git;a=commitdiff_plain;h=9d5df20621dd1e77936522860cc0ec39f81330c8 allow specifying ADDR as full address --- diff --git a/service b/service index c5dbfe4..7e8eed9 100755 --- a/service +++ b/service @@ -12,8 +12,8 @@ END our $usage2 = <<'END'; actions create [REDIRECT] [#COMMENT] (default for REDIRECT is your username) - update LOCAL-PART [REDIRECT] [#COMMENT] - show LOCAL-PART + update ADDR [REDIRECT] [#COMMENT] + show ADDR list list-actions empty string for REDIRECT means reject @@ -21,8 +21,8 @@ END our $usage3 = <<'END'; privileged actions list-user USER - insert-exact LOCAL-PART USER REDIRECT COMMENT - donate LOCAL-PART USER + insert-exact ADDR USER REDIRECT COMMENT + donate ADDR USER enable-user|disable-user USER END @@ -47,6 +47,13 @@ sub nextarg () { return $v; } +sub nextarg_addr () { + my $addr = nextarg; + return $addr if $addr !~ m/\@/; + die "address not in correct domain (\@$dom)\n" unless $' eq $dom; #'; + return $`; #`; +} + sub nomoreargs () { die "too many arguments\n" if @ARGV; } @@ -182,7 +189,7 @@ sub begin_row ($) { } sub action_update { - my $localpart = nextarg; + my $localpart = nextarg_addr; my $updrow = rhsargs({}); nomoreargs; begin_row($localpart); @@ -198,7 +205,7 @@ sub action_update { } sub action_show { - my $localpart = nextarg; + my $localpart = nextarg_addr; nomoreargs; my $row = begin_row($localpart); prow($row); @@ -238,7 +245,7 @@ sub action_list_all { sub action_insert_exact { die unless $priv; my $row = { }; - $row->{'localpart'} = nextarg; + $row->{'localpart'} = nextarg_addr; $row->{'user'} = $user = nextarg; $row->{'redirect'} = nextarg; $row->{'comment'} = nextarg; @@ -249,7 +256,7 @@ sub action_insert_exact { sub action_donate { die unless $priv; - my $localpart = nextarg; + my $localpart = nextarg_addr; my $newuser = nextarg; nomoreargs; begin_row($localpart); @@ -313,7 +320,7 @@ if (defined $ENV{'USERV_USER'}) { $user = ((getpwuid $<)[0]) or die; } -$usage2 .= "LOCAL-PART is implicitly qualified with \@$dom\n" +$usage2 .= "ADDR may be a local part, implicitly qualified with \@$dom\n" if defined $qualdom; $usage2 .= "REDIRECT is implicitly qualified with \@$qualdom if it has no \@\n" if defined $qualdom;