File luser_relay.patch of Package cyrus-imapd.3194
From 197203c01da43939bc815691a2face8f9e072e03 Mon Sep 17 00:00:00 2001
From: Ralf Haferkamp <rhafer@suse.de>
Date: Wed, 13 Jan 2010 11:12:42 +0100
Subject: [PATCH] New option lmtp_luser_relay
Send mail to non-existing mailboxes,to this user. NOTE: This
must be an existing local mailbox name. NOT an email address!
2 files changed, 23 insertions(+), 5 deletions(-)
Index: cyrus-imapd-2.3.16/imap/lmtpengine.c
===================================================================
--- cyrus-imapd-2.3.16.orig/imap/lmtpengine.c
+++ cyrus-imapd-2.3.16/imap/lmtpengine.c
@@ -819,6 +819,8 @@ static int process_recipient(char *addr,
address_data_t *ret = (address_data_t *) xmalloc(sizeof(address_data_t));
int forcedowncase = config_getswitch(IMAPOPT_LMTP_DOWNCASE_RCPT);
int quoted, detail;
+ char *luser_relay = NULL;
+ int has_luser_relay = 0;
assert(addr != NULL && msg != NULL);
@@ -875,6 +877,13 @@ static int process_recipient(char *addr,
}
*dest = '\0';
+ luser_relay = config_getstring(IMAPOPT_LMTP_LUSER_RELAY);
+ if( luser_relay ) {
+ if( !verify_user(luser_relay, NULL, NULL, ignorequota ? -1 : msg->size, msg->authstate) ) {
+ has_luser_relay = 1;
+ }
+ }
+
/* make a working copy of rcpt */
ret->user = ret->rcpt = xstrdup(rcpt);
@@ -900,12 +909,17 @@ static int process_recipient(char *addr,
r = verify_user(ret->user, ret->domain, ret->mailbox,
(quota_t) (ignorequota ? -1 : msg->size), msg->authstate);
if (r) {
- /* we lost */
- free(ret->all);
- free(ret->rcpt);
- free(ret);
- return r;
+ if( r == IMAP_MAILBOX_NONEXISTENT && has_luser_relay ) {
+ ret->user = xstrdup(luser_relay);
+ } else {
+ /* we lost */
+ free(ret->all);
+ free(ret->rcpt);
+ free(ret);
+ return r;
+ }
}
+
ret->ignorequota = ignorequota;
msg->rcpt[msg->rcpt_num] = ret;
Index: cyrus-imapd-2.3.16/lib/imapoptions
===================================================================
--- cyrus-imapd-2.3.16.orig/lib/imapoptions
+++ cyrus-imapd-2.3.16/lib/imapoptions
@@ -1274,6 +1274,10 @@ product version in the capabilities */
interface, otherwise the user is assumed to be in the default
domain (if set). */
+{ "lmtp_luser_relay", NULL, STRING }
+/* Send mail to mailboxes, which do not exists, to this user. NOTE: This must
+ be an existing local mailbox name. NOT an email address! */
+
/*
.SH SEE ALSO
.PP