From: Tony Finch Date: Fri, 12 Oct 2012 13:54:07 +0000 (+0100) Subject: The udpsend ACL modifier. X-Git-Tag: exim-4_82_RC1~26 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b0019c78b011504b32f054eac95bf3b27b8e8367;p=exim.git The udpsend ACL modifier. This is for reporting mailer activity without going via the log files. --- diff --git a/src/src/acl.c b/src/src/acl.c index 4f64e0a53..11626709d 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -107,6 +107,7 @@ enum { ACLC_ACL, ACLC_SPF, ACLC_SPF_GUESS, #endif + ACLC_UDPSEND, ACLC_VERIFY }; /* ACL conditions/modifiers: "delay", "control", "continue", "endpass", @@ -171,6 +172,7 @@ static uschar *conditions[] = { US"spf", US"spf_guess", #endif + US"udpsend", US"verify" }; @@ -315,6 +317,7 @@ static uschar cond_expand_at_top[] = { TRUE, /* spf */ TRUE, /* spf_guess */ #endif + TRUE, /* udpsend */ TRUE /* verify */ }; @@ -379,6 +382,7 @@ static uschar cond_modifiers[] = { FALSE, /* spf */ FALSE, /* spf_guess */ #endif + TRUE, /* udpsend */ FALSE /* verify */ }; @@ -579,6 +583,8 @@ static unsigned int cond_forbids[] = { (1<name = hostname; +h->port = portnum; +h->mx = MX_NONE; + +if (string_is_ip_address(hostname, NULL)) + h->address = hostname, r = HOST_FOUND; +else + r = host_find_byname(h, NULL, 0, NULL, FALSE); +if (r == HOST_FIND_FAILED || r == HOST_FIND_AGAIN) + { + *log_msgptr = "DNS lookup failed in \"udpsend\" modifier"; + return DEFER; + } + +HDEBUG(D_acl) + debug_printf("udpsend [%s]:%d %s\n", h->address, portnum, arg); + +host_af = (Ustrchr(h->address, ':') == NULL)? AF_INET:AF_INET6; +r = s = ip_socket(SOCK_DGRAM, host_af); +if (r < 0) goto defer; +r = ip_connect(s, host_af, h->address, portnum, 1); +if (r < 0) goto defer; +len = strlen(arg); +r = send(s, arg, len, MSG_NOSIGNAL); +if (r < 0) goto defer; +if (r < len) + { + *log_msgptr = + string_sprintf("\"udpsend\" truncated from %d to %d octets", len, r); + return DEFER; + } + +HDEBUG(D_acl) + debug_printf("udpsend %d bytes\n", r); + +return OK; + +defer: +*log_msgptr = string_sprintf("\"udpsend\" failed: %s", strerror(errno)); +return DEFER; +} + + + /************************************************* * Handle conditions/modifiers on an ACL item * *************************************************/ @@ -3546,6 +3652,10 @@ for (; cb != NULL; cb = cb->next) break; #endif + case ACLC_UDPSEND: + rc = acl_udpsend(arg, log_msgptr); + break; + /* If the verb is WARN, discard any user message from verification, because such messages are SMTP responses, not header additions. The latter come only from explicit "message" modifiers. However, put the user message into