1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
|
@c This is part of the GNU Mailutils manual.
@c Copyright (C) 1999--2022 Free Software Foundation, Inc.
@c See file mailutils.texi for copying conditions.
@comment *******************************************************************
@pindex sieve
@UNREVISED
Sieve is a language for filtering e-mail messages at time of final
delivery, described in RFC 3028. GNU Mailutils contains
stand-alone @dfn{sieve interpreter}, which is described in detail below.
@menu
* sieve interpreter:: A Sieve Interpreter
@end menu
@node sieve interpreter
@subsection A Sieve Interpreter
The sieve interpreter @command{sieve} allows you to apply Sieve scripts to
arbitrary number of mailboxes. GNU @command{sieve} implements a superset
of the Sieve language as described in RFC 3028. @xref{Sieve Language},
for a description of the Sieve language. @xref{GNU Extensions}, for a
discussion of differences between the GNU implementation of Sieve and
its standard.
@menu
* Invoking Sieve::
* Sieve Configuration::
* Logging and Debugging::
* Extending Sieve::
@end menu
@node Invoking Sieve
@subsubsection Invoking @command{sieve}
The @command{sieve} invocation syntax is:
@example
sieve [@var{options}] @var{script}
@end example
Normally, @var{script} is the name of the disk file with the Sieve
script. If @var{script} is a single dash, the script is read from the
standard input. If the @option{-E} (@option{--expression}) option is
given, @var{script} is taken to be the sieve script text.
@noindent
where @var{script} denotes the filename of the sieve program to parse,
and @var{options} is one or more of the following:
@table @option
@item -c
@itemx --compile-only
Compile script and exit.
@item --clear-library-path
@itemx --clearpath
Clear Sieve library path. See also @ref{Sieve Configuration,
clear-library-path}.
@item --clear-include-path
Clear Sieve include path. See also @ref{Sieve Configuration,
clear-include-path}.
@item -d[@var{flags}]
@itemx --debug[=@var{flags}]
Specify debug flags. The @var{flags} argument is a sequence of one or
more of the following letters:
@multitable @columnfractions .40 .45
@item @samp{g} @tab Enable main parser traces
@item @samp{T} @tab Enable mailutils traces
@item @samp{P} @tab Trace network protocols
@item @samp{t} @tab Enable sieve trace
@item @samp{i} @tab Trace the program instructions
@end multitable
@item -D
@itemx --dump
Compile the script, dump disassembled code on standard output and exit.
@item --environment=@var{name}=@var{value}
Set sieve environment variable @var{name} to the @var{value}.
@item -e @var{address}
@itemx --email @var{address}
Override the user email address. This is useful for @code{reject} and
@code{redirect} actions. By default, the user email address is deduced
from the user name and the full name of the machine where
@command{sieve} is executed. See also @ref{Sieve Configuration,
email}.
@item -E,
@itemx --expression
Treat the @var{script} argument as Sieve program text.
@item -I @var{dir}
@itemx --includedir=@var{dir}
Append directory @var{dir} to the list of directories searched for
include files. See also @ref{Sieve Configuration, include-path}.
@item -f
@itemx --mbox-url=@var{mbox}
Mailbox to sieve (defaults to user's system mailbox). See also
@ref{Sieve Configuration, mbox-url}.
@item -k
@itemx --keep-going
Keep on going if execution fails on a message. See also
@ref{Sieve Configuration, keep-going}.
@item -L @var{dir}
@itemx --libdir=@var{dir}
Append directory @var{dir} to the list of directories searched for
library files. See also @ref{Sieve Configuration, library-path}.
@item --libdir-prefix=@var{dir}
Add @var{dir} to the beginning of the list of directories searched for
library files.
@item --line-info=@var{bool}
Print source location along with action logs (default).
@item -M @var{url}
@itemx --mailer=@var{url}
Define the URL of the default mailer.
@item -n
@itemx --no-actions
@itemx --dry-run
Dry run: do not execute any actions, just print what would be done.
@item --no-program-name
Do not prefix diagnostic messages with the program name.
@item -t @var{ticket}
@itemx --ticket=@var{ticket}
Ticket file for mailbox authentication. See also
@ref{Sieve Configuration, ticket}.
@item --variable=@var{name}=@var{value}
Set Sieve variable @var{name}. This option automatically inserts
@samp{require "variables"} at the top of the script.
@item -v
@itemx --verbose
Log all actions executed. See also @ref{Sieve Configuration, verbose}.
@end table
See also @ref{Common Options}.
@node Sieve Configuration
@subsubsection Sieve Configuration
The behavior of @command{sieve} is affected by the following
configuration statements:
@multitable @columnfractions 0.3 0.6
@headitem Statement @tab Reference
@item debug @tab @xref{debug statement}.
@item tls @tab @xref{tls statement}.
@item mailbox @tab @xref{mailbox statement}.
@item locking @tab @xref{locking statement}.
@item logging @tab @xref{logging statement}.
@item mailer @tab @xref{mailer statement}.
@end multitable
The following statements configure sieve-specific features:
@deffn {Sieve Conf} sieve @{ ... @}
This block statement configures search paths @command{sieve} uses to
locate its loadable modules. @xref{Require Statement}, for a detailed
information about loadable modules.
This statement may contain the following sub-statements:
@deffn {Sieve Conf} clear-library-path @var{bool}
If @var{bool} is @samp{true}, clear library search path.
@end deffn
@deffn {Sieve Conf} clear-include-path @var{bool}
If @var{bool} is @samp{true}, clear include search path.
@end deffn
@deffn {Sieve Conf} library-path @var{path}
Add directories to @command{sieve} library search path. Argument is a
string containing a colon-separated list of directories.
@end deffn
@deffn {Sieve Conf} library-path-prefix @var{path}
Add directories to the beginning if the library search path. Argument
is a string containing a colon-separated list of directories.
@end deffn
@deffn {Sieve Conf} include-path @var{path}
Add directories to the include search path. Argument is a
string containing a colon-separated list of directories.
@end deffn
@end deffn
@deffn {Sieve Conf} keep-going @var{bool}
If @var{bool} is @samp{true}, do not abort if execution of a Sieve
script fails on a particular message.
@end deffn
@deffn {Sieve Conf} mbox-url @var{url}
Sets @acronym{URL} of the mailbox to be processed.
@end deffn
@deffn {Sieve Conf} ticket @var{file}
Sets the name of the ticket file for user authentication.
@end deffn
@deffn {Sieve Conf} debug @var{flags}
Sets Sieve debug flags. @xref{Logging and Debugging}, for a detailed
description.
@end deffn
@deffn {Sieve Conf} verbose @var{bool}
If @var{bool} is @samp{true}, log all executed actions.
@end deffn
@deffn {Sieve Conf} line-info @var{bool}
If @var{bool} is @samp{true}, print source locations along with action
logs. This statement takes effect only if @code{verbose true} is also
set.
@end deffn
@deffn {Sieve Conf} email @var{addr}
Set user e-mail address. This is useful for @code{reject} and
@code{redirect} actions. By default, the user email address is deduced
from the user name and the full name of the machine where @command{sieve} is
executed.
@end deffn
@node Logging and Debugging
@subsubsection Logging and debugging
The default behavior of @command{sieve} is to remain silent about
anything except errors. However, it is sometimes necessary to see
which actions are executed and on which messages. This is particularly
useful when debugging the sieve scripts. The @option{--verbose}
(@option{-v}) option outputs log of every action executed.
Option @option{--debug} allows to produce even more detailed debugging
information. This option takes an argument specifying the
debugging level to be enabled. The argument can consist of the
following letters:
@table @samp
@item t
This flag enables sieve tracing. It means that every test will be logged
when executed.
@item T
This flag enables debugging of underlying @code{mailutils} library.
@item P
Trace network protocols: produces log of network transactions executed
while running the script.
@item g
Enable main parser traces. This is useful for debugging the sieve grammar.
@item i
Trace the program instructions. It is the most extensive debugging
level. It produces the full execution log of a sieve program, showing
each instruction and states of the sieve machine. It is only useful
for debugging the code generator.
@end table
@emph{Note}, that there should be no whitespace
between the short variant of the option (@option{-d}), and its
argument. Similarly, when using long option (@option{--debug}),
its argument must be preceded by equal sign.
If the argument to @option{--debug} is omitted, it defaults to
@samp{TPt}.
Option @option{--dump} produces the disassembled dump of the compiled
sieve program.
By default @command{sieve} outputs all diagnostics on standard error and verbose
logs on standard output. This behaviour is changed when
@option{--log-facility} is given in the command line (@FIXME-pxref{logging}).
This option causes @command{sieve} to output its diagnostics to
the given syslog facility.
@node Extending Sieve
@subsubsection Extending @command{sieve}
The basic set of sieve actions, tests and comparators may be extended
using loadable extensions. The usual @code{require} mechanism is used for
that.
When processing arguments for @code{require} statement, @command{sieve}
uses the following algorithm:
@enumerate 1
@item Look up the name in a symbol table. If the name begins with
@samp{comparator-} it is looked up in the comparator table. If it
begins with @samp{test-}, the test table is searched instead. Otherwise
the name is looked up in the action table.
@item If the name is found, the search is terminated.
@item Otherwise, transform the name. First, any @samp{comparator-} or
@samp{test-} prefix is stripped. Then, any character other than
alphanumeric characters, @samp{.} and @samp{,} is replaced with
dash (@samp{-}). The name thus obtained is used as a file name
of an external loadable module.
@item Try to load the module. The module is searched in the
following search paths (in the order given):
@enumerate 1
@item Mailutils module directory. By default it is
@file{$prefix/lib/mailutils}.
@item The value of the environment variable @env{LTDL_LIBRARY_PATH}.
@item Additional search directories specified with the.
@option{--libdir-prefix} command line option (@pxref{Invoking Sieve,
libdir-prefix}), or the @code{library-path-prefix} configuration
statement (@pxref{Sieve Configuration,library-path-prefix}).
@item Additional search directories specified with the
@code{library-path} statement (@pxref{Sieve Configuration,
library-path}) in Sieve configuration file.
@item Additional search directories specified with the.
@option{--libdir} command line option (@pxref{Invoking Sieve,libdir}).
@item Additional search directories specified with the
@code{#searchpath} Sieve directive (@pxref{#searchpath}).
@item System library search path: The system dependent library
search path (e.g. on Linux it is set by the contents of the file
@file{/etc/ld.so.conf} and the value of the environment variable
@env{LD_LIBRARY_PATH}).
@end enumerate
The value of @env{LTDL_LIBRARY_PATH} and @env{LD_LIBRARY_PATH} must be
a colon-separated list of absolute directories, for example,
@samp{"/usr/lib/mypkg:/lib/foo"}.
In any of these directories, @command{sieve} first attempts to find
and load the given filename. If this fails, it tries to append the
following suffixes to the file name:
@enumerate 1
@item the libtool archive extension @samp{.la}
@item the extension used for native dynamic libraries on the host
platform, e.g., @samp{.so}, @samp{.sl}, etc.
@end enumerate
@item If the module is found, @command{sieve} executes its
initialization function (see below) and again looks up the name
in the symbol table. If found, search terminates successfully.
@item If either the module is not found, or the symbol wasn't
found after execution of the module initialization function,
search is terminated with an error status. @command{sieve} then displays
the following diagnostic message:
@example
source for the required action NAME is not available
@end example
@end enumerate
|