user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Leah Neukirchen <leah@vuxu.org>
To: meta@public-inbox.org
Cc: Leah Neukirchen <leah@vuxu.org>
Subject: [PATCH] public-inbox-mda: use <sysexits.h> status codes where applicable
Date: Tue, 12 Jun 2018 17:36:52 +0200	[thread overview]
Message-ID: <20180612153652.29719-1-leah@vuxu.org> (raw)

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.
---
 script/public-inbox-mda | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/script/public-inbox-mda b/script/public-inbox-mda
index 766d58a..1f1252a 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)) {
-- 
2.17.1


             reply	other threads:[~2018-06-12 15:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 15:36 Leah Neukirchen [this message]
2018-06-13  1:18 ` [PATCH] public-inbox-mda: use <sysexits.h> status codes where applicable Eric Wong
2023-11-10 18:43 ` Eric Wong
2023-11-10 21:32   ` Leah Neukirchen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180612153652.29719-1-leah@vuxu.org \
    --to=leah@vuxu.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).