aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-11-20 18:55:10 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-11-20 18:57:16 +0200
commitc8007b6f1bc449154dcafaf7dc84bba188ef4fed (patch)
tree5e000abe064241b17bc6e5dc0ff7dbb8ce63edba
parent0c1763059c6d2032d7c538cfbdda9d63663165ba (diff)
downloadmailfromd-alpha-7.0.92-mu2.tar.gz
mailfromd-alpha-7.0.92-mu2.tar.bz2
* etc/Makefile.am: Install postfix-macros.sed to pkgdatadir. (install-data-local): Add missing $(DESTDIR) * src/builtin/sa.bi (sa): Check the result of the initial SPAMC command. * src/gram.y (register_macro): Set a comparator that ignores enclosing '{ }'. Always enclose in curly braces macro names longer than 1 character. * tests/miltermacros.at: New testcase. * tests/Makefile.am (TESTSUITE_AT): Add miltermacros.at. * tests/testsuite.at: Include miltermacros.at.
-rw-r--r--etc/Makefile.am4
-rw-r--r--src/builtin/sa.bi5
-rw-r--r--src/gram.y46
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/miltermacros.at40
-rw-r--r--tests/testsuite.at1
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 = \
postfix-macros.sed
noinst_SCRIPTS = rc.mailfromd
-pkglibexec_DATA = postfix-macros.sed
+pkgdata_DATA = postfix-macros.sed
DEFAULT_PIDFILE = $(DEFAULT_STATE_DIR)/mailfromd.pid
CLEANFILES = rc.mailfromd
@@ -48,7 +48,7 @@ SUFFIXES = .mf .lint
check-am: mailfromd.lint
install-data-local:
- @test -z "$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)"
+ @test -z "$(DESTDIR)$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)"
@if [ -r $(DESTDIR)$(sysconfdir)/mailfromd.rc ]; then \
echo >&2 '================================================================='; \
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)
version_str);
}
+ if (result) {
+ spamd_destroy(&ostr);
+ MF_THROW(mfe_failure, "%s", buffer);
+ }
+
spamd_read_line(ostr, buffer, sizeof buffer);
if (sscanf (buffer, "Spam: %5s ; %20s / %20s",
spam_str, score_str, threshold_str) != 3) {
diff --git a/src/gram.y b/src/gram.y
index 8b6815b7..7fafbd74 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -2692,20 +2692,60 @@ smtp_to_gacopyz_stage(enum smtp_state tag)
return gacopyz_stage_none;
}
+static int
+compare_macro_names (const void *item, const void *data)
+{
+ const char *elt;
+ size_t elen;
+ const char *arg;
+ size_t alen;
+
+ elt = item;
+ elen = strlen (elt);
+ if (elt[0] == '{') {
+ elt++;
+ elen -= 2;
+ }
+
+ arg = data;
+ alen = strlen (arg);
+ if (arg[0] == '{') {
+ arg++;
+ alen -= 2;
+ }
+
+ if (alen != elen)
+ return 1;
+ return memcmp (elt, arg, alen);
+}
+
void
register_macro(enum smtp_state state, const char *macro)
{
enum gacopyz_stage ind = smtp_to_gacopyz_stage(state);
+
if (ind == gacopyz_stage_none)
return;
if (!smtp_macro_list[ind]) {
mu_list_create(&smtp_macro_list[ind]);
mu_list_set_comparator(smtp_macro_list[ind],
- mf_list_compare_string);
+ compare_macro_names);
}
/* FIXME: MU: 2nd arg should be const? */
- if (mu_list_locate(smtp_macro_list[ind], (void*) macro, NULL))
- mu_list_append(smtp_macro_list[ind], (void*) strdup (macro));
+ if (mu_list_locate(smtp_macro_list[ind], (void*) macro, NULL)) {
+ char *cmacro;
+ if (macro[1] == 0 || macro[0] == '{')
+ cmacro = xstrdup (macro);
+ else {
+ size_t mlen = strlen (macro);
+ cmacro = xmalloc (mlen + 3);
+ cmacro[0] = '{';
+ memcpy (cmacro + 1, macro, mlen);
+ cmacro[mlen + 1] = '}';
+ cmacro[mlen + 2] = 0;
+ }
+ mu_list_append(smtp_macro_list[ind], cmacro);
+ }
}
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 = \
invcidr2.at\
ismx.at\
macros.at\
+ miltermacros.at\
ml.at\
ml01.at\
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 @@
+# This file is part of Mailfromd testsuite. -*- Autotest -*-
+# Copyright (C) 2010 Sergey Poznyakoff
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([pargma miltermacros])
+AT_KEYWORDS([pargma miltermacros])
+
+# Affected versions: < 7.0.92-20101120
+# Description: #pragma miltermacros did not add curly brackets around
+# macro names longer than 1 character, as the rest of mailfromd code
+# did.
+
+AT_CHECK([
+AT_DATA([prog],[#pragma miltermacros envfrom auth_type
+prog envfrom
+do
+ echo $f
+done
+])
+
+mailfromd MAILFROMD_OPTIONS --dump-macros ./prog
+],
+[EX_OK],
+[envfrom {auth_type}, f
+])
+
+AT_CLEANUP
+
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])
m4_include([eof.at])
m4_include([regopt0.at])
+m4_include([miltermacros.at])

Return to:

Send suggestions and report system problems to the System administrator.