On Tue, Feb 14, 2017 at 05:54:07PM +0100, Matthias Schneider wrote:

> I just tried to upgrade our postfix instances from 2.11 to 3.1. This broke
> our milter that is expecting macro with name "i" but we got "{i}".
> Could we make this configurable?

It may be simplest to revert to the original (braceless) form of
single-letter macros, I think that's more typically expected.

>From the Sendmail book:

    Macros may have single-character names or multicharacter names.
    Multicharacter names must always be enclosed in curly braces.
    Single-character names may be enclosed in curly braces if you
    desire. Prior to V8.7 you could use single characters only
    without curly braces.

    [ This does suggest that your milter application ought to be
      able to deal with either form, but theory and practice do
      at times differ. ]

Does the patch below resolve your issue?

diff --git a/src/milter/milter.c b/src/milter/milter.c
index 64836d4..bf2760a 100644
--- a/src/milter/milter.c
+++ b/src/milter/milter.c
@@ -333,16 +333,17 @@ static ARGV *milter_macro_lookup(MILTERS *milters, const 
char *macro_names)
     VSTRING *canon_buf = vstring_alloc(20);
     const char *value;
     const char *name;
+    const char *cname;
 
     while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) {
        if (msg_verbose)
            msg_info("%s: \"%s\"", myname, name);
        if (*name != '{')                       /* } */
-           name = STR(vstring_sprintf(canon_buf, "{%s}", name));
-       if ((value = milters->mac_lookup(name, milters->mac_context)) != 0) {
+           cname = STR(vstring_sprintf(canon_buf, "{%s}", name));
+       if ((value = milters->mac_lookup(cname, milters->mac_context)) != 0) {
            if (msg_verbose)
                msg_info("%s: result \"%s\"", myname, value);
-           argv_add(argv, name, value, (char *) 0);
+           argv_add(argv, name[1] == '\0' ? name : cname, value, (char *) 0);
        } else if (milters->macro_defaults != 0
             && (value = htable_find(milters->macro_defaults, name)) != 0) {
            if (msg_verbose)

-- 
        Viktor.

Reply via email to