git://git.exim.org
/
users
/
jgh
/
exim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
993e3ef
)
Make success expansion a per-transport option
author
Jeremy Harris
<jgh146exb@wizmail.org>
Sat, 6 Jul 2013 19:56:18 +0000
(20:56 +0100)
committer
Jeremy Harris
<jgh146exb@wizmail.org>
Sat, 6 Jul 2013 19:56:18 +0000
(20:56 +0100)
doc/doc-txt/experimental-spec.txt
patch
|
blob
|
history
src/src/deliver.c
patch
|
blob
|
history
src/src/globals.c
patch
|
blob
|
history
src/src/globals.h
patch
|
blob
|
history
src/src/readconf.c
patch
|
blob
|
history
src/src/structs.h
patch
|
blob
|
history
src/src/transport.c
patch
|
blob
|
history
test/confs/5700
patch
|
blob
|
history
test/scripts/5700-deliv-log/5700
patch
|
blob
|
history
diff --git
a/doc/doc-txt/experimental-spec.txt
b/doc/doc-txt/experimental-spec.txt
index 565c01851a5bc80acbc663117b70c03cf8bfc1c1..a7651f6c0b27665d0c00ab3c7e6e21567a6061bc 100644
(file)
--- a/
doc/doc-txt/experimental-spec.txt
+++ b/
doc/doc-txt/experimental-spec.txt
@@
-847,11
+847,10
@@
b. Configure, somewhere before the DATA ACL, the control option to
DBL (Database Logging)
--------------------------------------------------------------
DBL (Database Logging)
--------------------------------------------------------------
-This feature allows to write exim internal log information
+An arbitrary per-transport string can be expanded on successful delivery,
+and (for SMTP transports) a second string on deferrals caused by a host error.
+This feature allows the writing of exim internal log information
(not available otherwise) into a database.
(not available otherwise) into a database.
-Initially implemented is logging of details about successfully
-completed remote deliveries, which are needed for reputation
-systems, and deferrals caused by a host error.
In order to use DBL, you must set
In order to use DBL, you must set
@@
-859,7
+858,7
@@
EXPERIMENTAL_DBL=yes
in your Local/Makefile
in your Local/Makefile
-and define the
database querie
s in the runtime config file, to
+and define the
expandable string
s in the runtime config file, to
be executed at end of delivery.
Additionally, there are 8 more variables, available at end of
be executed at end of delivery.
Additionally, there are 8 more variables, available at end of
@@
-871,14
+870,17
@@
dbl_delivery_fqdn FQDN of host, which has accepted delivery
dbl_delivery_local_part local part of address being delivered
dbl_delivery_domain domain part of address being delivered
dbl_delivery_confirmation SMTP confirmation message
dbl_delivery_local_part local part of address being delivered
dbl_delivery_domain domain part of address being delivered
dbl_delivery_confirmation SMTP confirmation message
+router_name name of router
+transport_name name of transport
In case of a deferral caused by a host-error:
dbl_defer_errno Error number
dbl_defer_errstr Error string possibly containing more details
In case of a deferral caused by a host-error:
dbl_defer_errno Error number
dbl_defer_errstr Error string possibly containing more details
-To log successful deliveries, set the following option in the main
-option part of runtime config.
+
+To log successful deliveries, set the following option
+on any transport of interest.
dbl_delivery_query
dbl_delivery_query
@@
-894,6
+896,10
@@
${lookup pgsql {SELECT * FROM record_Delivery( \
'${quote_pgsql:${lc:$dbl_delivery_fqdn}}', \
'${quote_pgsql:$message_exim_id}')}}
'${quote_pgsql:${lc:$dbl_delivery_fqdn}}', \
'${quote_pgsql:$message_exim_id}')}}
+The string is expanded after the delivery completes and any
+side-effects will happen. The result is then discarded.
+Note that for complex operations an ACL expansion can be used.
+
In order to log host deferrals, add the following option to an SMTP
transport:
In order to log host deferrals, add the following option to an SMTP
transport:
diff --git
a/src/src/deliver.c
b/src/src/deliver.c
index 29ce056537ca16b693a6fbc755f560b343d63a88..5e4a2a1e17ddde8d719f5e442c070b960eda670c 100644
(file)
--- a/
src/src/deliver.c
+++ b/
src/src/deliver.c
@@
-697,6
+697,11
@@
pointer to a single host item in their host list, for use by the transport. */
#ifdef EXPERIMENTAL_DBL
dbl_delivery_ip = NULL; /* presume no successful remote delivery */
#ifdef EXPERIMENTAL_DBL
dbl_delivery_ip = NULL; /* presume no successful remote delivery */
+ dbl_delivery_port = 0;
+ dbl_delivery_fqdn = NULL;
+ dbl_delivery_local_part = NULL;
+ dbl_delivery_domain = NULL;
+ dbl_delivery_confirmation = NULL;
#endif
s = reset_point = store_get(size);
#endif
s = reset_point = store_get(size);
@@
-745,7
+750,12
@@
if ((log_extra_selector & LX_delivery_size) != 0)
if (addr->transport->info->local)
{
if (addr->host_list != NULL)
if (addr->transport->info->local)
{
if (addr->host_list != NULL)
+ {
s = string_append(s, &size, &ptr, 2, US" H=", addr->host_list->name);
s = string_append(s, &size, &ptr, 2, US" H=", addr->host_list->name);
+ #ifdef EXPERIMENTAL_DBL
+ dbl_delivery_fqdn = addr->host_list->name;
+ #endif
+ }
if (addr->shadow_message != NULL)
s = string_cat(s, &size, &ptr, addr->shadow_message,
Ustrlen(addr->shadow_message));
if (addr->shadow_message != NULL)
s = string_cat(s, &size, &ptr, addr->shadow_message,
Ustrlen(addr->shadow_message));
@@
-766,12
+776,12
@@
else
s = string_cat(s, &size, &ptr, US"*", 1);
#ifdef EXPERIMENTAL_DBL
s = string_cat(s, &size, &ptr, US"*", 1);
#ifdef EXPERIMENTAL_DBL
- dbl_delivery_ip =
string_copy(addr->host_used->address)
;
- dbl_delivery_port = addr->host_used->port;
- dbl_delivery_fqdn =
string_copy(addr->host_used->name)
;
- dbl_delivery_local_part =
string_copy(addr->local_part)
;
- dbl_delivery_domain =
string_copy(addr->domain)
;
- dbl_delivery_confirmation =
string_copy(addr->message)
;
+ dbl_delivery_ip =
addr->host_used->address
;
+ dbl_delivery_port =
addr->host_used->port;
+ dbl_delivery_fqdn =
addr->host_used->name
;
+ dbl_delivery_local_part =
addr->local_part
;
+ dbl_delivery_domain =
addr->domain
;
+ dbl_delivery_confirmation =
addr->message
;
#endif
}
#endif
}
@@
-840,16
+850,18
@@
store we used to build the line after writing it. */
s[ptr] = 0;
log_write(0, flags, "%s", s);
s[ptr] = 0;
log_write(0, flags, "%s", s);
+
#ifdef EXPERIMENTAL_DBL
#ifdef EXPERIMENTAL_DBL
-if (
dbl_delivery_ip != NULL && dbl_delivery_query != NULL
)
+if (
addr->transport->dbl_delivery_query
)
{
DEBUG(D_deliver)
{
{
DEBUG(D_deliver)
{
- debug_printf(" DBL(Delivery): dbl_delivery_query=|%s| dbl_delivery_IP=%s\n", dbl_delivery_query, dbl_delivery_ip);
+ debug_printf(" DBL(Delivery): dbl_delivery_query=|%s| dbl_delivery_IP=%s\n",
+ addr->transport->dbl_delivery_query, dbl_delivery_ip);
}
}
- router_name = addr->router->name;
+ router_name =
addr->router->name;
transport_name = addr->transport->name;
transport_name = addr->transport->name;
- expand_string(dbl_delivery_query);
+ expand_string(
addr->transport->
dbl_delivery_query);
router_name = NULL;
transport_name = NULL;
}
router_name = NULL;
transport_name = NULL;
}
diff --git
a/src/src/globals.c
b/src/src/globals.c
index e9f62666527a129e27794228a9d1198bcc6c061f..2345ac4e18642e086fa975492cb6ff34a0062082 100644
(file)
--- a/
src/src/globals.c
+++ b/
src/src/globals.c
@@
-486,7
+486,6
@@
int daemon_startup_sleep = 30;
#ifdef EXPERIMENTAL_DBL
int dbl_defer_errno = 0;
uschar *dbl_defer_errstr = NULL;
#ifdef EXPERIMENTAL_DBL
int dbl_defer_errno = 0;
uschar *dbl_defer_errstr = NULL;
-uschar *dbl_delivery_query = NULL;
uschar *dbl_delivery_ip = NULL;
int dbl_delivery_port = 0;
uschar *dbl_delivery_fqdn = NULL;
uschar *dbl_delivery_ip = NULL;
int dbl_delivery_port = 0;
uschar *dbl_delivery_fqdn = NULL;
diff --git
a/src/src/globals.h
b/src/src/globals.h
index 4f22832969e09f669bc77e24373200b2fad3378d..ad36bf79fafb5b1c0d077e475b05c47d4d06aaf9 100644
(file)
--- a/
src/src/globals.h
+++ b/
src/src/globals.h
@@
-286,7
+286,6
@@
extern uschar *dccifd_options; /* options for the dccifd daemon */
#ifdef EXPERIMENTAL_DBL
extern int dbl_defer_errno; /* error number set when a remote delivery is deferred with a host error */
extern uschar *dbl_defer_errstr; /* error string set when a remote delivery is deferred with a host error */
#ifdef EXPERIMENTAL_DBL
extern int dbl_defer_errno; /* error number set when a remote delivery is deferred with a host error */
extern uschar *dbl_defer_errstr; /* error string set when a remote delivery is deferred with a host error */
-extern uschar *dbl_delivery_query; /* query string to log delivery info in DB */
extern uschar *dbl_delivery_ip; /* IP of host, which has accepted delivery */
extern int dbl_delivery_port; /* port of host, which has accepted delivery */
extern uschar *dbl_delivery_fqdn; /* FQDN of host, which has accepted delivery */
extern uschar *dbl_delivery_ip; /* IP of host, which has accepted delivery */
extern int dbl_delivery_port; /* port of host, which has accepted delivery */
extern uschar *dbl_delivery_fqdn; /* FQDN of host, which has accepted delivery */
diff --git
a/src/src/readconf.c
b/src/src/readconf.c
index 29ad4e7e063f574b0ebde659007cf93c03d73059..b1b26ff67d9e0fdb8a5d1f53bfe85961e78cd079 100644
(file)
--- a/
src/src/readconf.c
+++ b/
src/src/readconf.c
@@
-195,9
+195,6
@@
static optionlist optionlist_config[] = {
{ "daemon_smtp_ports", opt_stringptr, &daemon_smtp_port },
{ "daemon_startup_retries", opt_int, &daemon_startup_retries },
{ "daemon_startup_sleep", opt_time, &daemon_startup_sleep },
{ "daemon_smtp_ports", opt_stringptr, &daemon_smtp_port },
{ "daemon_startup_retries", opt_int, &daemon_startup_retries },
{ "daemon_startup_sleep", opt_time, &daemon_startup_sleep },
-#ifdef EXPERIMENTAL_DBL
- { "dbl_delivery_query", opt_stringptr, &dbl_delivery_query },
-#endif
#ifdef EXPERIMENTAL_DCC
{ "dcc_direct_add_header", opt_bool, &dcc_direct_add_header },
{ "dccifd_address", opt_stringptr, &dccifd_address },
#ifdef EXPERIMENTAL_DCC
{ "dcc_direct_add_header", opt_bool, &dcc_direct_add_header },
{ "dccifd_address", opt_stringptr, &dccifd_address },
diff --git
a/src/src/structs.h
b/src/src/structs.h
index 53aa2106b7834d2095160b066416b20bcc94e497..d7f01c3b4f76cc10f7497717c5a869705fc4c3c7 100644
(file)
--- a/
src/src/structs.h
+++ b/
src/src/structs.h
@@
-184,6
+184,9
@@
typedef struct transport_instance {
BOOL log_fail_output;
BOOL log_defer_output;
BOOL retry_use_local_part; /* Defaults true for local, false for remote */
BOOL log_fail_output;
BOOL log_defer_output;
BOOL retry_use_local_part; /* Defaults true for local, false for remote */
+#ifdef EXPERIMENTAL_DBL
+ uschar *dbl_delivery_query; /* String to expand on success */
+#endif
} transport_instance;
} transport_instance;
diff --git
a/src/src/transport.c
b/src/src/transport.c
index 7dd1afb85d828f26dad55785feca43fdd661b32b..ef00fe275a5e3b691cc71734e39a636d4ccf04ca 100644
(file)
--- a/
src/src/transport.c
+++ b/
src/src/transport.c
@@
-56,6
+56,10
@@
optionlist optionlist_transports[] = {
(void *)offsetof(transport_instance, body_only) },
{ "current_directory", opt_stringptr|opt_public,
(void *)offsetof(transport_instance, current_dir) },
(void *)offsetof(transport_instance, body_only) },
{ "current_directory", opt_stringptr|opt_public,
(void *)offsetof(transport_instance, current_dir) },
+#ifdef EXPERIMENTAL_DBL
+ { "dbl_delivery_query",opt_stringptr | opt_public,
+ (void *)offsetof(transport_instance, dbl_delivery_query) },
+#endif
{ "debug_print", opt_stringptr | opt_public,
(void *)offsetof(transport_instance, debug_string) },
{ "delivery_date_add", opt_bool|opt_public,
{ "debug_print", opt_stringptr | opt_public,
(void *)offsetof(transport_instance, debug_string) },
{ "delivery_date_add", opt_bool|opt_public,
diff --git
a/test/confs/5700
b/test/confs/5700
index 17241660534955601a1495e08baec2ad5238d525..700b360a8cc6484f310d1788e0531d24722ad769 100644
(file)
--- a/
test/confs/5700
+++ b/
test/confs/5700
@@
-13,8
+13,6
@@
gecos_name = CALLER_NAME
acl_smtp_rcpt = accept
acl_smtp_data = accept
acl_smtp_rcpt = accept
acl_smtp_data = accept
-dbl_delivery_query = ${acl {logger}{delivery}}
-
# ----- ACL -----
# ----- ACL -----
@@
-56,6
+54,7
@@
smtp:
port = PORT_S
command_timeout = 1s
final_timeout = 1s
port = PORT_S
command_timeout = 1s
final_timeout = 1s
+ dbl_delivery_query = ${acl {logger}{delivery}}
dbl_host_defer_query = ${acl {logger}{deferral}}
# End
dbl_host_defer_query = ${acl {logger}{deferral}}
# End
diff --git
a/test/scripts/5700-deliv-log/5700
b/test/scripts/5700-deliv-log/5700
index 2082b14f5de1778f627bb26829fc8fcfab91a19e..dccf02ca563016fd4600fa84540b7c69735e03ae 100644
(file)
--- a/
test/scripts/5700-deliv-log/5700
+++ b/
test/scripts/5700-deliv-log/5700
@@
-22,7
+22,7
@@
DATA
QUIT
220 OK
****
QUIT
220 OK
****
-exim -
d+deliver+expand+acl -
qqf
+exim -qqf
****
#
#
****
#
#
@@
-32,7
+32,7
@@
server PORT_S
EHLO
*sleep 4
****
EHLO
*sleep 4
****
-exim -
d-all+deliver+acl+expand -
odi userx@domain1.com
+exim -odi userx@domain1.com
A message which will hit a timeout
.
****
A message which will hit a timeout
.
****