aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-12-20 12:48:16 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-12-20 12:48:16 +0200
commitc2efb9e546db69a6c51532e35831c137d119f5b9 (patch)
treee67810bb8dddb967bd5b3de90229c5523902efea
parent6285eff8645b0b368f0f565caf39b656f5d4403e (diff)
downloadmailfromd-c2efb9e546db69a6c51532e35831c137d119f5b9.tar.gz
mailfromd-c2efb9e546db69a6c51532e35831c137d119f5b9.tar.bz2
Improve Sieve interface
* src/builtin/sieve.bi: Initialize Sieve environment * doc/functions.texi: Document changes.
-rw-r--r--doc/functions.texi23
-rw-r--r--src/builtin/sieve.bi12
2 files changed, 33 insertions, 2 deletions
diff --git a/doc/functions.texi b/doc/functions.texi
index 9da552d6..cb9d600a 100644
--- a/doc/functions.texi
+++ b/doc/functions.texi
@@ -3055,7 +3055,6 @@ Trace execution of @samp{Sieve} tests.
Log every instruction, executed in the compiled @samp{Sieve} code.
This produces huge amounts of output and is rarely useful, unless you
suspect some bug in @samp{Sieve} implementation and wish to trace it.
-
@end table
For example, @code{MF_SIEVE_LOG|MF_SIEVE_DEBUG_TRACE} enables logging
@@ -3066,6 +3065,28 @@ accepted by the @var{script} program, and @code{false} otherwise.
Here, the word @dfn{accepted} means that some form of @samp{KEEP}
action (@pxref{Actions, keep, Actions, mailutils, GNU Mailutils
Manual}) was executed over the message.
+
+While executing the Sieve script, Sieve environment (@cite{RFC 5183})
+is initialized as follows:
+
+@table @asis
+@item domain
+The domain name of the server Sieve is running on.
+@item host
+Host name of the server Sieve is running on.
+@item location
+The string @samp{MTA}.
+@item name
+The string @samp{GNU Mailutils}.
+@item phase
+The string @samp{pre}.
+@item remote-host
+Defined to the value of @samp{client_ptr} macro, if it was required.
+@item remote-ip
+Defined to the value of @samp{client_addr} macro, if it was required.
+@item version
+The version of GNU Mailutils.
+@end table
@end deftypefn
The following example discards each message not accepted by the
diff --git a/src/builtin/sieve.bi b/src/builtin/sieve.bi
index ea531a83..871bbc90 100644
--- a/src/builtin/sieve.bi
+++ b/src/builtin/sieve.bi
@@ -85,7 +85,8 @@ MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags,
int f = MF_OPTVAL(flags);
mu_attribute_t attr;
mu_message_t msg;
-
+ const char *s;
+
rc = mu_sieve_machine_create(&mach);
MF_ASSERT(rc == 0, mfe_failure,
_("failed to initialize sieve machine: %s"),
@@ -97,6 +98,15 @@ MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags,
if (f & MF_SIEVE_DEBUG_INSTR)
modify_debug_flags(MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE9), 0);
+ mu_sieve_set_environ(mach, "location", "MTA");
+ mu_sieve_set_environ(mach, "phase", "pre");
+ s = env_get_macro(env, "client_addr");
+ if (s)
+ mu_sieve_set_environ(mach, "remote-ip", s);
+ s = env_get_macro(env, "client_ptr");
+ if (s)
+ mu_sieve_set_environ(mach, "remote-host", s);
+
mu_sieve_set_data(mach, env);
if (f & MF_SIEVE_TEXT) {

Return to:

Send suggestions and report system problems to the System administrator.