Re: [exim] EXIM 'Completed' hook'

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Jasen Betts
Date:  
À: exim-users
Sujet: Re: [exim] EXIM 'Completed' hook'
On 2015-11-01, Jeremy Harris <jgh@???> wrote:
> On 30/10/15 20:37, Brent Jones wrote:
>> Was the experimental_events slated to be called 'stable', I thought I
>> recalled something to that effect :)
>
> I've not been thinking of moving it to mainline yet, but if there's
> enough interest in its use I will. Please speak up.
>
> Also, are there any additional event types needed?


I wanted one for message deferred per RCPT.


here's a diff against the debian source version 4.62-4


diff --recursive -U5 /tmp/exim4-4.86/src/deliver.c src/deliver.c
--- /tmp/exim4-4.86/src/deliver.c       2015-11-04 09:00:15.000000000 +1300
+++ src/deliver.c       2015-11-04 14:55:51.144390011 +1300
@@ -750,30 +750,37 @@
     }
   }
 return NULL;
 }


-static void
+void
 msg_event_raise(const uschar * event, const address_item * addr)
 {
 const uschar * save_domain = deliver_domain;
 uschar * save_local =  deliver_localpart;
 const uschar * save_host = deliver_host;
+const uschar * save_address = deliver_host_address;
+const int      save_port =   deliver_host_port;


if (!addr->transport)
return;

 router_name =    addr->router ? addr->router->name : NULL;
 transport_name = addr->transport->name;
 deliver_domain = addr->domain;
 deliver_localpart = addr->local_part;
 deliver_host =   addr->host_used ? addr->host_used->name : NULL;
+deliver_host_address = addr->host_used ? addr->host_used->address : NULL;
+deliver_host_port =    addr->host_used ? addr->host_used->port : -1;


 (void) event_raise(addr->transport->event_action, event,
          addr->host_used || Ustrcmp(addr->transport->driver_name, "lmtp") == 0
-         ? addr->message : NULL);
+          || Ustrcmp(addr->transport->driver_name, "smtp") == 0
+         ? addr->message : NULL); 


+deliver_host_port =      save_port;
+deliver_host_address =   save_address;
 deliver_host =      save_host;
 deliver_localpart = save_local;
 deliver_domain =    save_domain;
 router_name = transport_name = NULL;
 }
diff --recursive -U5 /tmp/exim4-4.86/src/functions.h src/functions.h
--- /tmp/exim4-4.86/src/functions.h     2015-11-04 09:00:15.000000000 +1300
+++ src/functions.h     2015-11-04 14:55:51.148389933 +1300
@@ -161,10 +161,11 @@


 extern void    enq_end(uschar *);
 extern BOOL    enq_start(uschar *);
 #ifdef EXPERIMENTAL_EVENT
 extern uschar *event_raise(uschar *, const uschar *, uschar *);
+extern void msg_event_raise( const uschar * event, const address_item * addr);
 #endif
 extern void    exim_exit(int);
 extern void    exim_nullstd(void);
 extern void    exim_setugid(uid_t, gid_t, BOOL, uschar *);
 extern int     exim_tvcmp(struct timeval *, struct timeval *);
diff --recursive -U5 /tmp/exim4-4.86/src/transports/smtp.c src/transports/smtp.c
--- /tmp/exim4-4.86/src/transports/smtp.c       2015-11-04 09:00:15.000000000 +1300
+++ src/transports/smtp.c       2015-11-04 14:55:51.160389694 +1300
@@ -683,10 +683,12 @@


save_domain = deliver_domain;
save_local = deliver_localpart;

 /*XXX would ip & port already be set up? */
+/*XXX this seems to be the case #JB# */
+
 deliver_host_address = string_copy(host->address);
 deliver_host_port =    host->port == PORT_NONE ? 25 : host->port;
 event_defer_errno =    addr->basic_errno;


 router_name =    addr->router->name;
@@ -892,14 +894,18 @@
       addr->basic_errno = ERRNO_RCPT4XX;
       addr->more_errno |= ((buffer[1] - '0')*10 + buffer[2] - '0') << 8;


       /* Log temporary errors if there are more hosts to be tried.
       If not, log this last one in the == line. */
+      /* this log_write mimics code in post_process_one in deliver.c */


       if (host->next)
        log_write(0, LOG_MAIN, "H=%s [%s]: %s", host->name, host->address, addr->message);
-
+#ifdef EXPERIMENTAL_EVENT
+  event_defer_errno=addr->basic_errno;
+  msg_event_raise(US"msg:smtp:defer", addr);
+#endif
       /* Do not put this message on the list of those waiting for specific
       hosts, as otherwise it is likely to be tried too often. */


       update_waiting = FALSE;



--
\_(ツ)_