dovecot-2.2-pigeonhole: Merged changes from Pigeonhole v0.2 tree.

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sun May 20 13:17:09 EEST 2012


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/2841e6b2f973
changeset: 1621:2841e6b2f973
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sun May 20 12:06:25 2012 +0200
description:
Merged changes from Pigeonhole v0.2 tree.

diffstat:

 INSTALL                                                    |   75 +-
 TODO                                                       |   16 +-
 doc/script-location-dict.txt                               |  145 ++
 m4/dovecot.m4                                              |   22 +-
 src/lib-sieve-tool/sieve-tool.c                            |   15 +-
 src/lib-sieve/Makefile.am                                  |    3 +
 src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c         |    2 +-
 src/lib-sieve/plugins/environment/ext-environment-common.c |   12 +-
 src/lib-sieve/plugins/environment/sieve-ext-environment.h  |    3 +-
 src/lib-sieve/plugins/include/cmd-include.c                |   19 +-
 src/lib-sieve/plugins/include/ext-include-binary.c         |   53 +-
 src/lib-sieve/plugins/include/ext-include-common.c         |   22 +-
 src/lib-sieve/plugins/include/ext-include-common.h         |    2 +-
 src/lib-sieve/plugins/notify/cmd-notify.c                  |    2 +-
 src/lib-sieve/plugins/vacation/cmd-vacation.c              |    2 +-
 src/lib-sieve/sieve-actions.c                              |   13 +-
 src/lib-sieve/sieve-binary-file.c                          |   29 +-
 src/lib-sieve/sieve-binary.c                               |   51 +-
 src/lib-sieve/sieve-binary.h                               |   18 +-
 src/lib-sieve/sieve-common.h                               |   13 +-
 src/lib-sieve/sieve-message.c                              |    5 +-
 src/lib-sieve/sieve-message.h                              |    3 +-
 src/lib-sieve/sieve-script-dict.c                          |  285 +++++
 src/lib-sieve/sieve-script-file.c                          |  397 +++++++
 src/lib-sieve/sieve-script-file.h                          |   31 +
 src/lib-sieve/sieve-script-private.h                       |   89 +-
 src/lib-sieve/sieve-script.c                               |  639 +++++++-----
 src/lib-sieve/sieve-script.h                               |   59 +-
 src/lib-sieve/sieve-settings.h                             |   15 +-
 src/lib-sieve/sieve-types.h                                |   37 +-
 src/lib-sieve/sieve.c                                      |   91 +-
 src/lib-sieve/sieve.h                                      |   37 +-
 src/lib-sievestorage/sieve-storage-list.c                  |    5 +
 src/lib-sievestorage/sieve-storage-quota.c                 |    5 +
 src/lib-sievestorage/sieve-storage-save.c                  |    1 +
 src/lib-sievestorage/sieve-storage-script.c                |   40 +-
 src/lib-sievestorage/sieve-storage.c                       |   35 +
 src/managesieve-login/client-authenticate.c                |    9 +-
 src/managesieve/cmd-getscript.c                            |   23 +-
 src/managesieve/main.c                                     |   11 +-
 src/managesieve/managesieve-capabilities.c                 |   16 +-
 src/managesieve/managesieve-client.c                       |   53 +-
 src/managesieve/managesieve-client.h                       |    9 +-
 src/managesieve/managesieve-common.h                       |    4 +
 src/plugins/lda-sieve/lda-sieve-plugin.c                   |  670 ++++++------
 src/sieve-tools/sieve-filter.c                             |    6 +-
 src/sieve-tools/sieve-test.c                               |   24 +-
 src/sieve-tools/sievec.c                                   |    5 +-
 src/testsuite/testsuite-binary.c                           |   11 +-
 src/testsuite/testsuite-script.c                           |    9 +-
 src/testsuite/testsuite-smtp.c                             |    4 +-
 src/testsuite/testsuite-smtp.h                             |    6 +-
 src/testsuite/testsuite.c                                  |    2 -
 stamp.h.in                                                 |    1 +
 tests/extensions/environment/basic.svtest                  |    2 +-
 55 files changed, 2195 insertions(+), 961 deletions(-)

diffs (truncated from 5009 to 300 lines):

diff -r 39730d5f39e4 -r 2841e6b2f973 INSTALL
--- a/INSTALL	Sun May 20 11:33:49 2012 +0200
+++ b/INSTALL	Sun May 20 12:06:25 2012 +0200
@@ -85,23 +85,21 @@
 plugin section of the config file (default values are shown if applicable):
 
  sieve = ~/.dovecot.sieve
-   The path to the user's main active script. 
+   The location of the user's main active script. 
  
  sieve_default = 
-   The path to the default personal sieve script file, which gets executed ONLY
-   if user's private Sieve script does no exist, e.g.
-   /var/lib/dovecot/default.sieve. This is usually a global script, so sure to
-   pre-compile this script manually using the sievec command line tool, as
-   explained in the README file.
-
- sieve_global_path =
-   This is the DEPRECATED former name of the sieve_default setting.
+   The location of the default personal sieve script file, which gets executed
+   ONLY if user's private Sieve script does no exist, e.g.
+   /var/lib/dovecot/default.sieve. This is usually a global script, so be sure
+   to pre-compile this script manually using the sievec command line tool, as
+   explained in the README file. This setting used to be called
+   `sieve_global_path', but that name is now deprecated.
 
  sieve_global_dir =
-   Directory for :global include scripts for the Sieve include extension. 
+   Location for :global include scripts for the Sieve include extension. 
 
- sieve_dir = ~/
-   Directory for :personal include scripts for the Sieve include extension. 
+ sieve_dir = ~/sieve
+   Location for :personal include scripts for the Sieve include extension. 
 
  sieve_extensions =
    Which Sieve language extensions are available to users. By default, all 
@@ -131,6 +129,12 @@
    (wiki2.dovecot.org) or the pigeonhole website (http://pigeonhole.dovecot.org)
    for available plugins. 
 
+ sieve_user_log =
+   The path to the file where the user log file is written. If not configured, a
+   default location is used. If the main user's personal Sieve (as configured
+   with sieve=) is a file, the logfile is set to <filename>.log by default. If
+   it is not a file, the default user log file is ~/.dovecot.sieve.log. 
+
  recipient_delimiter = +
    The separator that is expected between the :user and :detail address parts 
    introduced by the subaddress extension. This may also be a sequence of
@@ -176,7 +180,48 @@
    The maximum number of redirect actions that can be performed during a single
    script execution. If set to 0, no redirect actions are allowed.
 
-Sieve Interpreter - Per-user Sieve script location
+Sieve Interpreter - Script Locations
+------------------------------------
+
+The location of Sieve scripts is not limited to the file system. The Sieve
+interpreter can be extended to retrieve Sieve scripts from other sources as
+well, such as a database. Currently, all settings that are used to obtain the
+location of a single Sieve script, such as sieve=, sieve_default=, sieve_dir=
+and sieve_global_dir= accept the following extended syntax:
+
+location = [<type>:]path[;<option>[=<value>][;...]]
+
+The following script location types are implemented by default:
+
+  file    - The location path is a file system path pointing to the script file
+            or a directory containing script files with names structured as
+            `<script-name>.sieve'.
+	dict    - Dovecot dict lookup. The location path is a dict uri. Read
+            doc/scipt-location-dict.txt for more information and examples. 
+
+If the type prefix is omitted, the script location type is 'file'.
+
+The following options are defined for all location types:
+
+  name=<script-name>
+    Set the name of the Sieve script that this location points to. If the name
+    of the Sieve script is not contained in the location path, this option is
+    required (e.g. for dict locations that must point to a particular script).
+    If the name of the script is contained in the location, the value of the
+    name option overrides the name retrieved from the location. If the Sieve
+    interpreter explicitly queries for a specific name (e.g. to include a script
+    from the sieve_dir= location), this option has no effect.
+
+  bindir=<dirpath>
+		Points to the directory where the compiled binaries for this script location
+    are stored. If this option is omitted, the behavior depends on the location
+    type. For `file' type locations, the binary is then stored in the same
+    directory as where the script file was found if possible. For `dict' type
+    locations, the binary is not stored at all in that case. Don't specify the
+    same directory for different script locations, as this will result in
+    undefined behavior. 
+	
+Sieve Interpreter - Per-user Sieve Script Location
 --------------------------------------------------
 
 By default, the Pigeonhole LDA Sieve plugin looks for the user's Sieve script
@@ -184,8 +229,8 @@
 home directory is set for the user.
 
 If you want to store the script elsewhere, you can override the default using 
-the sieve setting, which specifies the path to the user's script file. This can 
-be done in two ways:
+the sieve= setting, which specifies the location of the user's script file. This
+can be done in two ways:
 
  1. Define the sieve setting in the plugin section of dovecot.conf.
  2. Return sieve extra field from userdb extra fields. 
diff -r 39730d5f39e4 -r 2841e6b2f973 TODO
--- a/TODO	Sun May 20 11:33:49 2012 +0200
+++ b/TODO	Sun May 20 12:06:25 2012 +0200
@@ -1,7 +1,9 @@
 Current activities:
 
-* Update include extension to latest draft (v13 currently):
-	- Implement :optional tag.
+* Implement generic Sieve script object that abstracts from its location and
+  add support for retrieving scripts from dict database.
+	- Implement infrastructure for loading a sequence of global scripts from
+	  a database (for sieve_before/sieve_after).
 
 Parallel plugin-based efforts:
 
@@ -14,6 +16,13 @@
 
 Next (mostly in order of descending priority/precedence):
 
+* Make the sieve storage a base class with (possibly) various implementations, 
+  just like mail-storage. This aims to provide support for alternate types
+  of script storage like LDAP or SQL database.
+	- Implement read/write script storages for using ManageSieve with dict
+	  database
+* Update include extension to latest draft (v13 currently):
+	- Implement :optional tag.
 * Implement index extension
 * Add normalize() method to comparators to normalize the string before matching
   (for efficiency).
@@ -69,9 +78,6 @@
 * Implement extlists extension as a plugin
 * Enotify extension: detect use of variable values extracted from the message 
   that are used in the method argument. RFC reports this as a security issue.
-* Make the sieve storage a base class with (possibly) various implementations, 
-  just like mail-storage. This aims to provide support for alternate types
-  of script storage like LDAP or SQL database.
 * Add support for stream matching for handling large values, e.g. from the body
   extension.
 * Implement message modification and extraction API in order to:
diff -r 39730d5f39e4 -r 2841e6b2f973 doc/script-location-dict.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/script-location-dict.txt	Sun May 20 12:06:25 2012 +0200
@@ -0,0 +1,145 @@
+DICT Sieve Script Location Type
+
+Description
+===========
+
+This location type is used to retrieve Sieve scripts from a Dovecot dict lookup.
+Such dictionaries use a file or an SQL database as backend. Refer to the Dovecot
+dict documentation for more information on dict lookups.
+
+To retrieve a Sieve script from the dict database, two lookups are performed.
+First, the name of the Sieve script is queried from the dict path
+`/priv/sieve/name/<name>'. If the Sieve script exists, this yields a data ID
+which in turn points to the actual script text. The script text is subsequently
+queried from the dict path '/priv/sieve/data/<dict-id>'.
+
+The second query is only necessary when no compiled binary is available or when
+the script has changed and needs to be recompiled. The data ID is used to detect
+changes in the dict's underlying database. Changing a Sieve script in the
+database must be done by first making a new script data item with a new data ID.
+Then, the mapping from name to data ID must be changed to point to the new
+script text, thereby changing the data ID returned from the name lookup, i.e.
+the first query mentioned above. Script binaries compiled from Sieve scripts
+contained in a dict database record the data ID. While the data ID contained in
+the binary is identical to the one returned from the dict lookup, the binary is
+assumed up-to-date. When the returned data ID is different, the new script text
+is retrieved using the second query and compiled into a new binary containing
+the updated data ID.
+
+Note that, by default, compiled binaries are not stored at all for Sieve scripts
+retrieved from a dict database. The bindir= option needs to be specified in the
+location specification. Refer to the INSTALL file for more general information
+about configuration of script locations.
+
+Configuration
+=============
+
+The script location syntax is specialized as follows:
+
+location = dict:<dict-uri>[;<option>[=<value>][;...]]
+
+The following additional options are recognized:
+
+  user=<username>
+    Overrides the user name used for the dict lookup. Normally, the name of the
+    user running the Sieve interpreter is used.
+
+If the name of the Script is left unspecified and not otherwise provided by the
+Sieve interpreter, the name defaults to `default'. 
+
+Examples
+========
+
+Example 1
+---------
+
+This example is mainly useful for performing a quick test of the dict location
+configuration without configuring an actual (SQL) database. For this example, a
+very simple file dict is assumed to be contained in the file
+/etc/dovecot/sieve.dict:
+
+priv/sieve/name/keep
+1
+priv/sieve/name/discard
+2
+priv/sieve/name/spam
+3
+priv/sieve/data/1
+keep;
+priv/sieve/data/2
+discard;
+priv/sieve/data/3
+require ["fileinto", "mailbox"]; fileinto :create "spam";
+
+To use this file dict for the main active script, you can change the
+configuration as follows (e.g. in /etc/dovecot/conf.d/90-sieve.conf):
+
+plugin {
+  sieve = dict:file:/etc/dovecot/sieve.dict;name=keep;bindir=~/.sieve-bin
+}
+
+The Sieve script named "keep" is retrieved from the file dict as the main
+script. Binaries are stored in the ~/.sieve-bin directory. 
+
+Example 2
+---------
+
+This example uses a PostgreSQL database. Our database contains the following
+table:
+
+CREATE TABLE user_sieve_scripts (
+  id integer,
+  username varchar(40),
+  script_name varchar(256),
+  script_data varchar(10240),
+
+  PRIMARY KEY (id),
+  UNIQUE(username, script_name)
+);
+
+We create a file /etc/dovecot/dict-sieve-sql.conf with the following content:
+
+connect = host=localhost dbname=dovecot user=dovecot password=password
+map {
+  pattern = priv/sieve/name/$script_name
+  table = user_sieve_scripts
+  username_field = username
+  value_field = id
+  fields {
+    script_name = $script_name
+  }
+}
+map {
+  pattern = priv/sieve/data/$id
+  table = user_sieve_scripts
+  username_field = username
+  value_field = script_data
+  fields {
+    id = $id
+  }
+}
+
+These are the mappings used by the SQL dict. The first mapping is the name query
+that yields the id of the Sieve script. The second mapping is the query used to
+retrieve the Sieve script itself.
+
+Much like the dict configuration for mailbox quota, it is often not possible to
+directly use an SQL dict because the SQL drivers are not linked to binaries such
+as dovecot-lda and lmtp. You need to use the dict proxy service. Add the dict
+URI to the dict section (typically located in your main dovecot.conf):
+
+dict {
+  sieve = pgsql:/etc/dovecot/dict-sieve-sql.conf.ext
+}
+
+To use this SQL dict for the main active script, you can change the
+configuration as follows (e.g. in /etc/dovecot/conf.d/90-sieve.conf):
+
+plugin {
+  sieve = dict:proxy::sieve;name=active;bindir=~/.sieve-bin
+}
+
+This uses the proxy dict uri `proxy::sieve'. This refers to the `sieve =' entry
+in the dict {...} section above. With this configuration, a Sieve script called
+"main" is retrieved from the SQL dict. Binaries are stored in the ~/.sieve-bin
+directory.
diff -r 39730d5f39e4 -r 2841e6b2f973 m4/dovecot.m4


More information about the dovecot-cvs mailing list