[Exim] AUTH= support for lmtp transport

Pàgina inicial
Delete this message
Reply to this message
Autor: Claas Hilbrecht
Data:  
A: Exim users list
Assumpte: [Exim] AUTH= support for lmtp transport
The attached patch adds the AUTH= support to exim for LMTP transports (eg.
MAIL FROM=<> AUTH=<user>). This is very useful for cyrus if you use plus
adressing. The following transport can put messages directly to a users
mailbox. So a message directed to
"cyrus_mailbox_name+subfolder_in_cyrus@???" goes directly to the
"subfolder_in_cyrus" mailbox instead of the INBOX. I use the following
transport for LMTP with auth support:

cyrus_lmtp:
  rcpt_include_affixes = yes
  driver = lmtp
  auth = ${lookup mysql{select auth from mailcfg_email_mailboxes where \
                mailbox='${quote_mysql:$local_part}' limit 1}}
  socket = /var/run/cyrus/socket/lmtp



diff -u transports.org/lmtp.c transports/lmtp.c
--- transports.org/lmtp.c    Mon Sep 22 10:30:00 2003
+++ transports/lmtp.c    Sat Oct 11 12:41:23 2003
@@ -20,6 +20,8 @@
 */


 optionlist lmtp_transport_options[] = {
+  { "auth",              opt_stringptr,
+      (void *)offsetof(lmtp_transport_options_block, auth) },
   { "batch_id",          opt_stringptr | opt_public,
       (void *)offsetof(transport_instance, batch_id) },
   { "batch_max",         opt_int | opt_public,
@@ -41,6 +43,7 @@
 /* Default private options block for the lmtp transport. */


 lmtp_transport_options_block lmtp_transport_option_defaults = {
+  NULL,           /* auth */
   NULL,           /* cmd */
   NULL,           /* skt */
   5*60,           /* timeout */
@@ -453,6 +456,9 @@
 BOOL yield = FALSE;
 address_item *addr;
 uschar *sockname = NULL;
+uschar *auth = NULL;
+uschar *authstr = NULL;
+uschar *mailfrom = NULL;
 uschar **argv;
 uschar buffer[256];


@@ -556,10 +562,42 @@
 if (!lmtp_read_response(out, buffer, sizeof(buffer), '2',
      timeout)) goto RESPONSE_FAILED;


-/* Now the envelope sender */
+/* check too see if we need to supply AUTH=cred to the enveloper sender */

-if (!lmtp_write_command(fd_in, "MAIL FROM:<%s>\r\n", return_path))
+ if(ob->auth == NULL)
+   {
+     authstr = "";
+   }
+ else
+   {
+     auth = expand_string(ob->auth);
+     if (auth == NULL)
+       {
+     addrlist->message =
+       string_sprintf("Expansion of \"%s\" (auth setting "
+              "for %s transport) failed: %s",
+              ob->auth, tblock->name,
+              expand_string_message);
+     return FALSE;
+       }
+    authstr = string_sprintf(" AUTH=%s", auth);
+   }
+
+  DEBUG(D_transport|D_v)
+    debug_printf("auth expand result=%s\n",authstr);
+
+  /* Now the envelope sender */
+  mailfrom = string_sprintf("<%s>%s", return_path, authstr);
+
+if (!lmtp_write_command(fd_in, "MAIL FROM:%s\r\n", mailfrom))
   goto WRITE_FAILED;
+//if (!lmtp_write_command(fd_in, "MAIL FROM:<%s>%s\r\n", return_path,
authstr))
+//  goto WRITE_FAILED;
+
+/*
+  DEBUG(D_transport|D_v)
+    debug_printf("   LMTP>>MAIL FROM:<%s>%s\r\n", return_path, authstr);
+*/


 if (!lmtp_read_response(out, buffer, sizeof(buffer), '2', timeout))
   goto RESPONSE_FAILED;
diff -u transports.org/lmtp.h transports/lmtp.h
--- transports.org/lmtp.h    Mon Sep 22 10:30:00 2003
+++ transports/lmtp.h    Sat Oct 11 12:45:45 2003
@@ -8,6 +8,7 @@
 /* Private structure for the private options. */


typedef struct {
+ uschar *auth;
uschar *cmd;
uschar *skt;
int timeout;

---
Claas Hilbrecht
http://www.jucs-kramkiste.de