Milter single recipient extension

New in 7.0.5.33. Oracle has implemented a milter extension for per-recipient modification actions. This extension can be implemented in libmilter with the following changes:





Add the following constant and routine declaration to  : /&#x2a; Oracle extension for recipient-specific modification actions &#x2a;/ /&#x2a; &#x2a;&#x2a; Specify a recipient for whom subsequent modification actions &#x2a;&#x2a; apply. Modification actions specified prior to this point will &#x2a;&#x2a; no longer apply to this recipient. &#x2a;&#x2a; &#x2a;&#x2a;     SMFICTX &#x2a;ctx; Opaque context structure &#x2a;&#x2a;     char &#x2a;rcpt; Null terminated list of null terminated envelope &#x2a;&#x2a;             recipient addresses subsequent actions apply to. These should &#x2a;&#x2a;             be in exactly the form passed to xxfi_envrcpt or the address &#x2a;&#x2a;             may not be selected for subsequent modification actions. &#x2a;/ LIBMILTER_API int smfi_specrcpt __P((SMFICTX &#x2a;, char &#x2a;)); 
 * 1) define SMFIF_SPECRCPT   0x1000000   // Recipient-specific modification actions



Add the following constant to include/libmilter/mfdef.h: /&#x2a; Oracle extension for recipient-specific modification actions &#x2a;/ 
 * 1) define SMFIR_SPECRCPT         &#x27;v&#x27;     /&#x2a; Per-recipient modification actions &#x2a;/



Add the following routine to libmilter/smfi.c: /&#x2a; &#x2a;&#x2a; SMFI_SPECRCPT -- Recipient-specific result (Oracle extension) &#x2a;&#x2a; &#x2a;&#x2a;     Parameters: &#x2a;&#x2a;             ctx -- Opaque context structure &#x2a;&#x2a;             rcpt -- null terminated list of null terminated &#x2a;&#x2a;                     recipient addresses &#x2a;&#x2a; &#x2a;&#x2a;     Returns: &#x2a;&#x2a;             MI_SUCCESS/MI_FAILURE &#x2a;/ int smfi_specrcpt(ctx, rcpt) SMFICTX &#x2a;ctx; char &#x2a;rcpt; {        size_t len, l;         struct timeval timeout; char &#x2a;ptr; if (rcpt == NULL &#x7c;&#x7c; &#x2a;rcpt == &#x27;\0&#x27;) return MI_FAILURE; if (!mi_sendok(ctx, SMFIF_SPECRCPT)) return MI_FAILURE; timeout.tv_sec = ctx-&#x3e;ctx_timeout; timeout.tv_usec = 0; len = 0; ptr = rcpt; do        { len += (l = strlen(ptr) + 1); ptr += l;        } while (&#x2a;ptr != &#x27;\0&#x27;); return mi_wr_cmd(ctx-&#x3e;ctx_sd, &timeout, SMFIR_SPECRCPT, rcpt, len); } 



In terms of the milter protocol, this extension consists of a single additional milter response: &#x2a;&#x2a; &#x27;v&#x27;	SMFIR_SPECRCPT	Specify recipient subsequent modification actions apply to. char	rcpt&#x5b;&#x5d;&#x5b;&#x5d;	List of NUL terminated recipients The semantics are straightforward: SMFIR_SPECRCPT specifies a list of message recipients, and subsequent modification actions (SMFIR_ADDHEADER, SMFIR_INSHEADER, SMFIR_CHGHEADER, and SMFIR_QUARANTINE). The modification actions SMFIR_ADDRCPT and SMFIR_DELRCPT may be specified subsequent to an SMFIR_SPECRCPT, but are by nature not recipient-specific. SMFIR_REPLBODY is too expensive to implement on a per-recipient basis; its behavior subsequent to a SMFIR_SPECRCPT is undefined.

Because it&#x27;s possible this extension may conflict with someone else&#x27;s private extension, it must be explicitly enabled by setting the  option to 1 in the  milter plugin options file.

Since extensive code changes were required to implement this extension, it has not been incorporated into the normal   library. A new  library containing the extension has been provided instead.

See also:
 * Milter spamfilterN_config_file
 * Milter implementation