about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-06-12 17:36:52 +0200
committerEric Wong <e@80x24.org>2018-06-12 23:07:43 +0000
commit599bf0b3c198ab207e3c7baacafa513fd0d6393d (patch)
treee2ce257c116646085b37347b4c55c744137c8416 /script
parenta2c1d7943f9145dc4b7f84e081b67dc9d0425736 (diff)
downloadpublic-inbox-599bf0b3c198ab207e3c7baacafa513fd0d6393d.tar.gz
public-inbox-mda: use <sysexits.h> status codes where applicable
Many MTA understand these and map them to sensible SMTP error messages.

Inability to find an inbox results in "5.1.1 user unknown".
Misformatted messages are rejected with "5.6.0 data format error".
Unsupported inbox versions are reported as "5.3.5 local configuration error".

All of these are interpreted as permanent failures.
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-mda7
1 files changed, 4 insertions, 3 deletions
diff --git a/script/public-inbox-mda b/script/public-inbox-mda
index 766d58a6..1f1252a7 100755
--- a/script/public-inbox-mda
+++ b/script/public-inbox-mda
@@ -38,8 +38,8 @@ my $config = PublicInbox::Config->new;
 my $recipient = $ENV{ORIGINAL_RECIPIENT};
 defined $recipient or die "ORIGINAL_RECIPIENT not defined in ENV\n";
 my $dst = $config->lookup($recipient); # first check
-defined $dst or do_exit(1);
-my $main_repo = $dst->{mainrepo} or do_exit(1);
+defined $dst or do_exit(67); # EX_NOUSER 5.1.1 user unknown
+my $main_repo = $dst->{mainrepo} or do_exit(67);
 
 # pre-check, MDA has stricter rules than an importer might;
 do_exit(0) unless PublicInbox::MDA->precheck($simple, $dst->{address});
@@ -73,7 +73,7 @@ if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message
 } elsif ($ret == PublicInbox::Filter::Base::IGNORE) {
         do_exit(0); # chuck it to emergency
 } elsif ($ret == PublicInbox::Filter::Base::REJECT) {
-        $! = $ret;
+        $! = 65; # EX_DATAERR 5.6.0 data format error
         die $filter->err, "\n";
 } # else { accept
 
@@ -88,6 +88,7 @@ if ($v == 2) {
         my $git = $dst->git;
         $im = PublicInbox::Import->new($git, $dst->{name}, $recipient, $dst);
 } else {
+        $! = 78; # EX_CONFIG 5.3.5 local configuration error
         die "Unsupported inbox version: $v\n";
 }
 if (defined $im->add($mime)) {