aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-11-04 20:53:27 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-11-04 20:53:27 +0200
commit3852eab595ac34d9f6add6e4c30a824c6c0e1e69 (patch)
tree5b948252db4eb37b1687884e2d4370921e6545c0
parent8bce3b2feef4a14de10b3c4cb0f24582c59433c0 (diff)
downloadmailfromd-3852eab595ac34d9f6add6e4c30a824c6c0e1e69.tar.gz
mailfromd-3852eab595ac34d9f6add6e4c30a824c6c0e1e69.tar.bz2
Fix handling of 5.x filter files.
* mfd/lex.l (INCTX_IGNORE_BYE): New flag. (string_beg): New static. (compose_start): Initialize string_beg. (compose_finish): Assign string_beg to yylloc.beg. (module rule): Fix warning message. Eat everything up to and including '.', if the module file is included. Raise INCTX_IGNORE_BYE flag in this case. (bye rule): If INCTX_IGNORE_BYE is set return EOF. * mflib/heloarg_test.mf, mflib/match_cidr.mf, mflib/match_dnsbl.mf, mflib/match_rhsbl.mf, mflib/sockmap.mf, mflib/spf.mf: Quote arguments of the `require' statements. * doc/upgrade.texi: Update.
-rw-r--r--doc/upgrade.texi13
-rw-r--r--mfd/lex.l47
-rw-r--r--mflib/heloarg_test.mf4
-rw-r--r--mflib/match_cidr.mf2
-rw-r--r--mflib/match_dnsbl.mf6
-rw-r--r--mflib/match_rhsbl.mf6
-rw-r--r--mflib/sockmap.mf2
-rw-r--r--mflib/spf.mf2
-rw-r--r--mflib/valid_domain.mf2
9 files changed, 65 insertions, 19 deletions
diff --git a/doc/upgrade.texi b/doc/upgrade.texi
index 0d4637e7..1bcc2da7 100644
--- a/doc/upgrade.texi
+++ b/doc/upgrade.texi
@@ -123,6 +123,19 @@ $ rm /tmp/mailfromd-newconf.sh
@end smallexample
@end itemize
+ Notice, that the conversions script attempts to fix only deprecation
+warnings. It will not try to correct any other type of warnings or
+errors. For example, you may get warning messages similar to:
+
+@smallexample
+mailfromd: /etc/mailfromd.mf:7: warning: including a module file is unreliable and may cause subtle errors
+mailfromd: /etc/mailfromd.mf:7: warning: use `require dns' instead
+@end smallexample
+
+This means that you use @samp{#include} where you should have used
+@samp{require}. You will have to fix such warnings manually, as
+suggested in the warning message.
+
If, for some reason, you cannot upgrade your scripts right now, you
may suppress deprecation warnings by setting the environment variable
@env{MAILFROMD_DEPRECATION} to @samp{no} before starting
diff --git a/mfd/lex.l b/mfd/lex.l
index a5b4a5da..a6fea9f8 100644
--- a/mfd/lex.l
+++ b/mfd/lex.l
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "mailfromd.h"
+#include "dirname.h"
#include "gram.h"
#include "prog.h"
@@ -72,8 +73,10 @@ get_locus()
/* Input context flags */
-#define INCTX_MODULE 0x1 /* current input is a MFL module */
-#define INCTX_HADINPUT 0x2 /* some statements has already been processed */
+#define INCTX_MODULE 0x1 /* current input is a MFL module */
+#define INCTX_HADINPUT 0x2 /* some statements has already been processed */
+#define INCTX_IGNORE_BYE 0x4 /* ignore eventual `bye' statement, because
+ this is an #included module */
/* Input context stack */
struct inctx { /* input context structure */
@@ -314,6 +317,7 @@ advance_line()
/* String composer */
+static struct locus string_beg;
static NODE *string_head, *string_tail;
static void
@@ -334,6 +338,8 @@ compose_start(int state)
"finished when a new one started");
abort();
}
+ string_beg = locus;
+ string_beg.point -= string_beg.leng;
BEGIN_X(state);
}
@@ -354,6 +360,7 @@ compose_finish()
}
}
yylval.node = string_head;
+ yylloc.beg = string_beg;
string_head = string_tail = NULL;
return T_COMPOSE;
}
@@ -562,18 +569,44 @@ from return T_FROM;
static return T_STATIC;
public return T_PUBLIC;
module { if (inctx_tos && inctx_flags == 0) {
+ int c;
+ char *fname = base_name(locus.file);
+ size_t flen = strlen(fname);
+
+ if (flen > 3
+ && strcmp(fname + flen - 3, ".mf") == 0)
+ fname[flen - 3] = 0;
parse_warning_locus(&inctx_tos->locus,
_("including a module file is unreliable and may cause subtle errors"));
/* TRANSLATORS: Do not translate `require %s' */
parse_warning_locus(&inctx_tos->locus,
_("use `require %s' instead"),
- locus.file);
- } else if (inctx_flags & INCTX_HADINPUT)
+ fname);
+ free (fname);
+ inctx_flags |= INCTX_IGNORE_BYE;
+ start_locus = locus;
+ while ((c = input()) != '.') {
+ if (c == 0) {
+ parse_error_locus(&start_locus,
+ _("unexpected end of file"));
+ return 0;
+ } else if (c == '\n')
+ advance_line();
+ }
+ } else {
+ if (inctx_flags & INCTX_HADINPUT)
parse_error(_("misplaced `module'"));
- return T_MODULE;
+ return T_MODULE;
+ }
}
-bye return T_BYE;
-
+bye {
+ if (inctx_flags & INCTX_IGNORE_BYE) {
+ /* It is an included module. Return EOF immediately.
+ A warning message has already been issued. */
+ return 0;
+ } else
+ return T_BYE;
+ }
{ICONST} { return builtin_const(yytext, yyleng); }
<ONBLOCK>poll return T_POLL;
<ONBLOCK>host return T_HOST;
diff --git a/mflib/heloarg_test.mf b/mflib/heloarg_test.mf
index bf1a1da4..b7609fb8 100644
--- a/mflib/heloarg_test.mf
+++ b/mflib/heloarg_test.mf
@@ -15,8 +15,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
module 'heloarg_test'.
-require is_ip
-require dns
+require 'is_ip'
+require 'dns'
const HELO_SUCCESS 0
const HELO_MYIP 1 # ARG is our IP address.
diff --git a/mflib/match_cidr.mf b/mflib/match_cidr.mf
index 3cf88e01..1867998f 100644
--- a/mflib/match_cidr.mf
+++ b/mflib/match_cidr.mf
@@ -16,7 +16,7 @@
module 'match_cidr'.
-require status
+require 'status'
#pragma regex push +extended
diff --git a/mflib/match_dnsbl.mf b/mflib/match_dnsbl.mf
index acd10189..ca01aa3d 100644
--- a/mflib/match_dnsbl.mf
+++ b/mflib/match_dnsbl.mf
@@ -17,9 +17,9 @@
module 'match_dnsbl'.
-require status
-require dns
-require match_cidr
+require 'status'
+require 'dns'
+require 'match_cidr'
#pragma regex push +extended
diff --git a/mflib/match_rhsbl.mf b/mflib/match_rhsbl.mf
index 3c602f11..91a32859 100644
--- a/mflib/match_rhsbl.mf
+++ b/mflib/match_rhsbl.mf
@@ -17,9 +17,9 @@
module 'match_rhsbl'.
-require status
-require dns
-require match_cidr
+require 'status'
+require 'dns'
+require 'match_cidr'
#pragma regex push +extended
func match_rhsbl(string email, string zone, string iprange)
diff --git a/mflib/sockmap.mf b/mflib/sockmap.mf
index 3d4c2459..7bad4ef3 100644
--- a/mflib/sockmap.mf
+++ b/mflib/sockmap.mf
@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
module 'sockmap'.
-require status
+require 'status'
static func __sockmap_send(number fd, string query)
do
diff --git a/mflib/spf.mf b/mflib/spf.mf
index 889d09da..2a0e0414 100644
--- a/mflib/spf.mf
+++ b/mflib/spf.mf
@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
module 'spf'.
-require safedb
+require 'safedb'
#pragma regex push +extended +icase
set spf_database "%__statedir__/spf.db"
diff --git a/mflib/valid_domain.mf b/mflib/valid_domain.mf
index 03d31f46..3b6ea613 100644
--- a/mflib/valid_domain.mf
+++ b/mflib/valid_domain.mf
@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
module 'valid_domain'.
-require dns
+require 'dns'
# boolean valid_domain (string DOMAIN)
#

Return to:

Send suggestions and report system problems to the System administrator.