diff options
-rw-r--r-- | etc/Makefile.am | 4 | ||||
-rw-r--r-- | src/builtin/sa.bi | 5 | ||||
-rw-r--r-- | src/gram.y | 46 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/miltermacros.at | 40 | ||||
-rw-r--r-- | tests/testsuite.at | 1 |
6 files changed, 92 insertions, 5 deletions
diff --git a/etc/Makefile.am b/etc/Makefile.am index 54eca5cd..a99a604a 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am | |||
@@ -22,7 +22,7 @@ EXTRA_DIST = \ | |||
22 | postfix-macros.sed | 22 | postfix-macros.sed |
23 | 23 | ||
24 | noinst_SCRIPTS = rc.mailfromd | 24 | noinst_SCRIPTS = rc.mailfromd |
25 | pkglibexec_DATA = postfix-macros.sed | 25 | pkgdata_DATA = postfix-macros.sed |
26 | 26 | ||
27 | DEFAULT_PIDFILE = $(DEFAULT_STATE_DIR)/mailfromd.pid | 27 | DEFAULT_PIDFILE = $(DEFAULT_STATE_DIR)/mailfromd.pid |
28 | CLEANFILES = rc.mailfromd | 28 | CLEANFILES = rc.mailfromd |
@@ -48,7 +48,7 @@ SUFFIXES = .mf .lint | |||
48 | check-am: mailfromd.lint | 48 | check-am: mailfromd.lint |
49 | 49 | ||
50 | install-data-local: | 50 | install-data-local: |
51 | @test -z "$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)" | 51 | @test -z "$(DESTDIR)$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)" |
52 | @if [ -r $(DESTDIR)$(sysconfdir)/mailfromd.rc ]; then \ | 52 | @if [ -r $(DESTDIR)$(sysconfdir)/mailfromd.rc ]; then \ |
53 | echo >&2 '================================================================='; \ | 53 | echo >&2 '================================================================='; \ |
54 | echo >&2 " Found a legacy script file located in:"; \ | 54 | echo >&2 " Found a legacy script file located in:"; \ |
diff --git a/src/builtin/sa.bi b/src/builtin/sa.bi index 17670c61..e95d9eb6 100644 --- a/src/builtin/sa.bi +++ b/src/builtin/sa.bi | |||
@@ -387,6 +387,11 @@ MF_DEFUN(sa, NUMBER, STRING urlstr, NUMBER prec, OPTIONAL, NUMBER report) | |||
387 | version_str); | 387 | version_str); |
388 | } | 388 | } |
389 | 389 | ||
390 | if (result) { | ||
391 | spamd_destroy(&ostr); | ||
392 | MF_THROW(mfe_failure, "%s", buffer); | ||
393 | } | ||
394 | |||
390 | spamd_read_line(ostr, buffer, sizeof buffer); | 395 | spamd_read_line(ostr, buffer, sizeof buffer); |
391 | if (sscanf (buffer, "Spam: %5s ; %20s / %20s", | 396 | if (sscanf (buffer, "Spam: %5s ; %20s / %20s", |
392 | spam_str, score_str, threshold_str) != 3) { | 397 | spam_str, score_str, threshold_str) != 3) { |
@@ -2692,20 +2692,60 @@ smtp_to_gacopyz_stage(enum smtp_state tag) | |||
2692 | return gacopyz_stage_none; | 2692 | return gacopyz_stage_none; |
2693 | } | 2693 | } |
2694 | 2694 | ||
2695 | static int | ||
2696 | compare_macro_names (const void *item, const void *data) | ||
2697 | { | ||
2698 | const char *elt; | ||
2699 | size_t elen; | ||
2700 | const char *arg; | ||
2701 | size_t alen; | ||
2702 | |||
2703 | elt = item; | ||
2704 | elen = strlen (elt); | ||
2705 | if (elt[0] == '{') { | ||
2706 | elt++; | ||
2707 | elen -= 2; | ||
2708 | } | ||
2709 | |||
2710 | arg = data; | ||
2711 | alen = strlen (arg); | ||
2712 | if (arg[0] == '{') { | ||
2713 | arg++; | ||
2714 | alen -= 2; | ||
2715 | } | ||
2716 | |||
2717 | if (alen != elen) | ||
2718 | return 1; | ||
2719 | return memcmp (elt, arg, alen); | ||
2720 | } | ||
2721 | |||
2695 | void | 2722 | void |
2696 | register_macro(enum smtp_state state, const char *macro) | 2723 | register_macro(enum smtp_state state, const char *macro) |
2697 | { | 2724 | { |
2698 | enum gacopyz_stage ind = smtp_to_gacopyz_stage(state); | 2725 | enum gacopyz_stage ind = smtp_to_gacopyz_stage(state); |
2726 | |||
2699 | if (ind == gacopyz_stage_none) | 2727 | if (ind == gacopyz_stage_none) |
2700 | return; | 2728 | return; |
2701 | if (!smtp_macro_list[ind]) { | 2729 | if (!smtp_macro_list[ind]) { |
2702 | mu_list_create(&smtp_macro_list[ind]); | 2730 | mu_list_create(&smtp_macro_list[ind]); |
2703 | mu_list_set_comparator(smtp_macro_list[ind], | 2731 | mu_list_set_comparator(smtp_macro_list[ind], |
2704 | mf_list_compare_string); | 2732 | compare_macro_names); |
2705 | } | 2733 | } |
2706 | /* FIXME: MU: 2nd arg should be const? */ | 2734 | /* FIXME: MU: 2nd arg should be const? */ |
2707 | if (mu_list_locate(smtp_macro_list[ind], (void*) macro, NULL)) | 2735 | if (mu_list_locate(smtp_macro_list[ind], (void*) macro, NULL)) { |
2708 | mu_list_append(smtp_macro_list[ind], (void*) strdup (macro)); | 2736 | char *cmacro; |
2737 | if (macro[1] == 0 || macro[0] == '{') | ||
2738 | cmacro = xstrdup (macro); | ||
2739 | else { | ||
2740 | size_t mlen = strlen (macro); | ||
2741 | cmacro = xmalloc (mlen + 3); | ||
2742 | cmacro[0] = '{'; | ||
2743 | memcpy (cmacro + 1, macro, mlen); | ||
2744 | cmacro[mlen + 1] = '}'; | ||
2745 | cmacro[mlen + 2] = 0; | ||
2746 | } | ||
2747 | mu_list_append(smtp_macro_list[ind], cmacro); | ||
2748 | } | ||
2709 | } | 2749 | } |
2710 | 2750 | ||
2711 | static int | 2751 | static int |
diff --git a/tests/Makefile.am b/tests/Makefile.am index 9dca569c..31279a1a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am | |||
@@ -82,6 +82,7 @@ TESTSUITE_AT = \ | |||
82 | invcidr2.at\ | 82 | invcidr2.at\ |
83 | ismx.at\ | 83 | ismx.at\ |
84 | macros.at\ | 84 | macros.at\ |
85 | miltermacros.at\ | ||
85 | ml.at\ | 86 | ml.at\ |
86 | ml01.at\ | 87 | ml01.at\ |
87 | module01.at\ | 88 | module01.at\ |
diff --git a/tests/miltermacros.at b/tests/miltermacros.at new file mode 100644 index 00000000..613d4a80 --- /dev/null +++ b/tests/miltermacros.at | |||
@@ -0,0 +1,40 @@ | |||
1 | # This file is part of Mailfromd testsuite. -*- Autotest -*- | ||
2 | # Copyright (C) 2010 Sergey Poznyakoff | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([pargma miltermacros]) | ||
18 | AT_KEYWORDS([pargma miltermacros]) | ||
19 | |||
20 | # Affected versions: < 7.0.92-20101120 | ||
21 | # Description: #pragma miltermacros did not add curly brackets around | ||
22 | # macro names longer than 1 character, as the rest of mailfromd code | ||
23 | # did. | ||
24 | |||
25 | AT_CHECK([ | ||
26 | AT_DATA([prog],[#pragma miltermacros envfrom auth_type | ||
27 | prog envfrom | ||
28 | do | ||
29 | echo $f | ||
30 | done | ||
31 | ]) | ||
32 | |||
33 | mailfromd MAILFROMD_OPTIONS --dump-macros ./prog | ||
34 | ], | ||
35 | [EX_OK], | ||
36 | [envfrom {auth_type}, f | ||
37 | ]) | ||
38 | |||
39 | AT_CLEANUP | ||
40 | |||
diff --git a/tests/testsuite.at b/tests/testsuite.at index d1b9b99a..e9667846 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at | |||
@@ -258,4 +258,5 @@ m4_include([hdr-mul.at]) | |||
258 | m4_include([eof.at]) | 258 | m4_include([eof.at]) |
259 | 259 | ||
260 | m4_include([regopt0.at]) | 260 | m4_include([regopt0.at]) |
261 | m4_include([miltermacros.at]) | ||
261 | 262 | ||