[dovecot-cvs] dovecot-1.0: Added -e parameter to write rejection error to stde...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 12 20:17:32 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/0d3d7083b582
changeset: 5303:0d3d7083b582
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 12 20:17:29 2007 +0300
description:
Added -e parameter to write rejection error to stderr and exit with
EX_NOPERM instead of sending the rejection by executing sendmail.

diffstat:

1 file changed, 14 insertions(+), 2 deletions(-)
src/deliver/deliver.c |   16 ++++++++++++++--

diffs (55 lines):

diff -r bdd45370eb26 -r 0d3d7083b582 src/deliver/deliver.c
--- a/src/deliver/deliver.c	Tue Jun 12 20:14:59 2007 +0300
+++ b/src/deliver/deliver.c	Tue Jun 12 20:17:29 2007 +0300
@@ -459,7 +459,7 @@ static void print_help(void)
 {
 	printf(
 "Usage: deliver [-c <config file>] [-d <destination user>] [-m <mailbox>]\n"
-"               [-n] [-f <envelope sender>]\n");
+"               [-n] [-e] [-f <envelope sender>]\n");
 }
 
 int main(int argc, char *argv[])
@@ -478,6 +478,7 @@ int main(int argc, char *argv[])
 	struct mailbox_transaction_context *t;
 	struct mail *mail;
 	uid_t process_euid;
+	bool stderr_rejection = FALSE;
 	int i, ret;
 
 	i_set_failure_exit_callback(failure_exit_callback);
@@ -513,6 +514,8 @@ int main(int argc, char *argv[])
 					       "Missing destination argument");
 			}
 			destination = argv[i];
+		} else if (strcmp(argv[i], "-e") == 0) {
+			stderr_rejection = TRUE;
 		} else if (strcmp(argv[i], "-c") == 0) {
 			/* config file path */
 			i++;
@@ -702,7 +705,7 @@ int main(int argc, char *argv[])
 	}
 
 	if (ret < 0) {
-		const char *error;
+		const char *error, *msgid;
 		bool syntax, temporary_error;
 		int ret;
 
@@ -711,7 +714,16 @@ int main(int argc, char *argv[])
 		if (temporary_error)
 			return EX_TEMPFAIL;
 
+		msgid = mail_get_first_header(mail, "Message-ID");
+		i_info("msgid=%s: Rejected: %s",
+		       msgid == NULL ? "" : str_sanitize(msgid, 80),
+		       str_sanitize(error, 512));
+
 		/* we'll have to reply with permanent failure */
+		if (stderr_rejection) {
+			fprintf(stderr, "%s\n", error);
+			return EX_NOPERM;
+		}
 		ret = mail_send_rejection(mail, destination, error);
 		if (ret != 0)
 			return ret < 0 ? EX_TEMPFAIL : ret;


More information about the dovecot-cvs mailing list