[Dovecot] PATCH: sendmail-like DSNs in Dovecot deliver (EX_TEMPFAIL always)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello,
I've put together an always tempfail & sendmail-like DSN report back patch.
Because I don't know how to transform the rejection reason into sysexit.h codes, it always tempfails.
The hooks are so that:
a) config file setting:
lda_mode = mode
b) command line:
deliver --mode mode
where mode is default or sendmail.
When no mode is specified, it defaults to "default", which is the current behaviour.
In sendmail mode, mail_send_rejection() simply prints the rejection reason to stdout, logs it and returns EX_TEMPFAIL. Ideally, the return value would be specific to the reason. I haven't poked into this deeply, but it doesn't look straight forward.
Bye,
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBRkHNQS9SORjhbDpvAQIhdggAq79RHKa1gIUTFwAu7Gd2maIUkDTgbNu6 8+MEQHujOPkV6wcF+5ih/hkht5BnuBUiIbnp2dvKGaUcHY8avzYD6BEc6gIAyJjM YIKDANI5+BVnQWUdiQMlQrSrRIZBqFziL8v/LvICJUsiOqCKT7se37KuUOK14gXO FSghuPta0rorogJ8kh+VGdmnqNVzKb6eKrnFQUggiezTmTcHY6/DRsLbsKV//fyW cybualj+THF9cj+EajwCMsYypc9KOdVg6lhcCD87oskDmMqcG5lwF2HU9nclnMxE 6pOnaLGNfKmWyeAKOLgvMimjhkU74+NBwQ+b4h61JzZ6lbiZKWX7wA== =gE8Z -----END PGP SIGNATURE-----
Steffen Kaiser schrieb:
Hello,
I've put together an always tempfail & sendmail-like DSN report back patch.
Because I don't know how to transform the rejection reason into sysexit.h codes, it always tempfails.
Just read /usr/include/sysexits.h and pick the best fit, such as EX_NOPERM. 8-)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Wed, 9 May 2007, Matthias Andree wrote:
Steffen Kaiser schrieb:
I've put together an always tempfail & sendmail-like DSN report back patch.
Because I don't know how to transform the rejection reason into sysexit.h codes, it always tempfails.
Just read /usr/include/sysexits.h and pick the best fit, such as EX_NOPERM. 8-)
Well, it's not that easy:
a) there are approx 90 calls to mail_storage_set_error() b) there is one call to mail_storage_set_syntax_error() c) calls to mail_storage_set_internal_error() or mail_storage_set_critical() -- they set tempfail, but otherwise add a "INTERNAL FAILURE" message string.
Some use a fixed string error description, some use a generic one: "%s".
I do not find myself able to wead out the proper sysexit code for them, at least not currently.
Actually, it would be cool, if mail_storage_set_error() would differ between temp and permanent failures, e.g. for:
static int quota_check(struct mailbox_transaction_context *t, struct mail *mail) { ret = quota_try_alloc(qt, mail, &too_large); if (ret > 0) return 0; else if (ret == 0) { mail_storage_set_error(t->box->storage, "Quota exceeded");
and to pass the appropriate sysexit code.
Probably, if the MTA delivers a mail to a local user, there is just one _permanent_ error possible at all:
the Sieve script discards the mail.
This is the only permanent error, I can think of, the MTA may not foresee, all others could be thought of as temporary, because there must be some misconfiguration and the problem needs treatment. After that the message can be delivered successfully or get bounced, e.g. initiated by the admin. Some conditions, e.g. out of quota, no treatment by the admin is possible / doable, hence, the queue return timeout kicks in or the user perform the treatment self.
If this assumption helds. it would be as simple as have mail_storage_clear_error(storage); sets temporary_failure always and add a new function mail_storage_set_perm_error() that resets the flag - and adds a sysexit value ;-) Maybe, change temporary_error into sysexit value, which is EX_TEMPFAIL by default.
Bye,
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBRkMb5y9SORjhbDpvAQKQrQf9FO2rFZbz2LVpNzuYZArvEaqv0ZMyggUM 5VaIowin5nGeHw9bgJrOANNcOJgyDqccEvQGNxhRY0c/nDn2qwvok4Widt8Lug7M DBtSxyNOSC8dgmp+F6JDVrMG9Vwhk/48NRYwQNbb11eci4A1vpU49vak2L86ABBB aeBt0Q7DfTgrGeWu79AKewlmJI/RbdjbwxcpravPet3QzEbcoT7TVVP8j4vTcW9r xSVjdcn5YdBiBVoCk4WA4wJFUQ4RqsTwU5Dnw41MuzbwhT6SHVKk/psEZzpGGQDU FuFqbNrcUba3SQMG/2a3bnfhAMmFKnhpvUFvXCfkjNMWaakVLGmN4Q== =mt6P -----END PGP SIGNATURE-----
On Wed, 2007-05-09 at 15:31 +0200, Steffen Kaiser wrote:
The hooks are so that:
a) config file setting:
lda_mode = mode
b) command line:
deliver --mode mode
where mode is default or sendmail.
When no mode is specified, it defaults to "default", which is the current behaviour.
Since I can't think of any other modes, how about just a simple -e parameter which means that rejections are done by writing the error to stderr and exiting with EX_NOPERM.
In sendmail mode, mail_send_rejection() simply prints the rejection reason to stdout, logs it and returns EX_TEMPFAIL.
Shouldn't it be stderr, not stdout? Although I guess both might work.
Ideally, the return value would be specific to the reason. I haven't poked into this deeply, but it doesn't look straight forward.
I don't think there are any useful exit codes in sysexits.h. Hmm. Deliver fallbacks always trying to write mail to INBOX if it couldn't write it elsewhere. So INBOX writes can fail only with:
- permission problems
- out of quota
In INBOX cause 1. is probably a configuration problem. In this case it should be treated as temporary problem.
- should probably be configurable, as some people want it to be a temporary failure and others want it to be a permanent failure.
I guess I'll have to go and fix Dovecot's error handling a bit.
For now I added the -e parameter. Currently it only works if the delivery actually fails. I'm not sure how I should handle rejections in Sieve scripts. http://dovecot.org/list/dovecot-cvs/2007-May/008761.html
On Sun, 2007-05-13 at 18:16 +0300, Timo Sirainen wrote:
I don't think there are any useful exit codes in sysexits.h. Hmm. Deliver fallbacks always trying to write mail to INBOX if it couldn't write it elsewhere. So INBOX writes can fail only with:
- permission problems
- out of quota
In INBOX cause 1. is probably a configuration problem. In this case it should be treated as temporary problem.
- should probably be configurable, as some people want it to be a temporary failure and others want it to be a permanent failure.
I guess I'll have to go and fix Dovecot's error handling a bit.
Dovecot can now internally report these failures:
/* Temporary internal error */
MAIL_ERROR_TEMP,
/* It's not possible to do the wanted operation */
MAIL_ERROR_NOTPOSSIBLE,
/* Invalid parameters (eg. mailbox name not valid) */
MAIL_ERROR_PARAMS,
/* No permission to do the request */
MAIL_ERROR_PERM,
/* Out of disk space or quota */
MAIL_ERROR_NOSPACE,
/* Item (eg. mailbox) doesn't exist or it's not visible to us */
MAIL_ERROR_NOTFOUND,
/* Tried to access an expunged message */
MAIL_ERROR_EXPUNGED
I also added quota_full_tempfail setting to control if it should return EX_TEMPFAIL or bounce the mail. All other errors are treated as EX_TEMPFAIL.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Sun, 13 May 2007, Timo Sirainen wrote:
Since I can't think of any other modes,
I'm going to look into adding LMTP to deliver ;-) sendmail supports LMTP even for a spawned LDA rather than a LMTP deamon. However, I don't know what to prefer.
Shouldn't it be stderr, not stdout? Although I guess both might work.
Well, I'm not sure. But as far as I know sendmail communicates primarily with stdin/stdout with the LDA (as inetd). However, for permanent failures both stdout and stderr are joint together. I haven't read the sendmail sources well enough to find the actual piece of code, though.
For now I added the -e parameter. Currently it only works if the delivery actually fails. I'm not sure how I should handle rejections in Sieve scripts. http://dovecot.org/list/dovecot-cvs/2007-May/008761.html
I think Dovecot should.
Bye,
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBRkgiTy9SORjhbDpvAQJQXwgAvqA59iy/9iIbbyq5QxK+or0aslb1oBvf oLmnEsafskweYr0zUMnyKmV3UEWFn5Oh/oX/5azLA8TFeDfqf8lFwu1VfByngIW0 zzkDmA3+ldWgjqLVRegNMF94dChCdktMy7q1CWo0hBnLAtVIM+4X0u+OKZqKqEM0 F2bd2LYbeSeBGnTp6LkMi5y28r4u8+T6xJXrmn0TzDSiW3BAlLIgp11rlnn6UgoB 1LC0amTV9uaTzJTU0HB2u9p+DbCnfyLVeK3AQt7bNpIsVfE4AHMe6MClrt8W7ZBB AiU3P1h/p29oWT9EDsaclDTJMCJEmn995Eg/+jq6YTDFnk3WfbscLw== =hL0g -----END PGP SIGNATURE-----
participants (3)
-
Matthias Andree
-
Steffen Kaiser
-
Timo Sirainen