dovecot-2.2-pigeonhole: lib-sieve: Created sieve LDAP storage dr...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Wed Jul 23 17:36:52 UTC 2014


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/c01b68b0c6b1
changeset: 1884:c01b68b0c6b1
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Wed Jul 23 19:36:00 2014 +0200
description:
lib-sieve: Created sieve LDAP storage driver.

diffstat:

 INSTALL                                                  |   158 +-
 TODO                                                     |     6 +-
 configure.ac                                             |    87 +
 doc/example-config/conf.d/90-sieve.conf                  |    77 +-
 doc/example-config/sieve-ldap.conf                       |    74 +
 doc/script-location-ldap.txt                             |    64 +
 pigeonhole-config.h.in                                   |     3 +
 src/lib-sieve/Makefile.am                                |     1 +
 src/lib-sieve/sieve-storage.c                            |     1 +
 src/lib-sieve/storage/Makefile.am                        |     3 +-
 src/lib-sieve/storage/ldap/Makefile.am                   |    32 +
 src/lib-sieve/storage/ldap/sieve-ldap-db.c               |  1380 ++++++++++++++
 src/lib-sieve/storage/ldap/sieve-ldap-db.h               |   140 +
 src/lib-sieve/storage/ldap/sieve-ldap-script.c           |   314 +++
 src/lib-sieve/storage/ldap/sieve-ldap-storage-settings.c |   155 +
 src/lib-sieve/storage/ldap/sieve-ldap-storage.c          |   215 ++
 src/lib-sieve/storage/ldap/sieve-ldap-storage.h          |   104 +
 17 files changed, 2718 insertions(+), 96 deletions(-)

diffs (truncated from 3023 to 300 lines):

diff -r 8e2832c044a5 -r c01b68b0c6b1 INSTALL
--- a/INSTALL	Wed Jul 23 19:28:07 2014 +0200
+++ b/INSTALL	Wed Jul 23 19:36:00 2014 +0200
@@ -64,6 +64,60 @@
 configuration files are provided in the doc/example-config directory of this
 package.
 
+Sieve Interpreter - Script Locations
+------------------------------------
+
+The Sieve interpreter can retrieve Sieve scripts from several types of
+locations. The default `file' location type is a local filesystem path pointing
+to a Sieve script file or a directory containing multiple Sieve script files.
+More complex setups can use other location types such as `ldap' or `dict' to
+fetch Sieve scripts from remote databases.
+
+All settings that specify the location of one ore more Sieve scripts accept the
+following 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.
+  ldap    - LDAP database lookup. The location path is a configuration file with
+            LDAP options. Read doc/scipt-location-ldap.txt for more information
+            and examples.
+
+If the type prefix is omitted, the script location type is 'file' and the 
+location is interpreted as a local filesystem path pointing to a Sieve script
+file or directory.
+
+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 and the
+    location of a single script is specified, 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 path, 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 let the Sieve
+    "include" extension retrieve a script from the sieve_global= location),
+    this option has no effect.
+
+  bindir=<dirpath>
+    Points to the directory where the compiled binaries for this script location
+    are stored. This directory is created automatically if possible. 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.
+    Multiple mail users can share a single script directory if the script
+    location is the same and all users share the same system credentials (uid,
+    gid).
+
 Sieve Interpreter - Basic Configuration
 ---------------------------------------
 
@@ -85,21 +139,24 @@
 plugin section of the config file (default values are shown if applicable):
 
  sieve = ~/.dovecot.sieve
-   The location of the user's main active script.
+   The location of the user's main Sieve script or script storage. The LDA
+   Sieve plugin uses this to find the active script for Sieve filtering at
+   delivery. The "include" extension uses this location for retrieving
+   :personal" scripts. This is also where the  ManageSieve service will store
+   the user's scripts, if supported by the location type.
 
  sieve_default =
    The location of the default personal sieve script file, which gets executed
-   ONLY if user's private Sieve script does no exist, e.g.
+   ONLY if user's private Sieve script does not 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 =
-   Location for :global include scripts for the Sieve include extension.
-
- sieve_dir = ~/sieve
-   Location for :personal include scripts for the Sieve include extension.
+ sieve_global =
+   Location for :global include scripts for the Sieve include extension. This
+   setting used to be called `sieve_global_dir', but that name is now
+   deprecated.
 
  sieve_extensions =
    Which Sieve language extensions are available to users. By default, all
@@ -148,21 +205,19 @@
 
 plugin {
 ...
-  # The location of the user's active script:
-  sieve = ~/.dovecot.sieve
-
-  # If the user has no personal active script (i.e. if the file
-  # indicated in sieve= does not exist), use this one:
-  sieve_default = /var/lib/dovecot/sieve/default.sieve
-
   # The include extension fetches the :personal scripts from this
   # directory. When ManageSieve is used, this is also where scripts
   # are uploaded.
-  sieve_dir = ~/sieve
+  sieve = file:~/sieve
+
+  # If the user has no personal active script (i.e. if the location
+  # indicated in sieve= settings does have and active script or does not exist),
+  # use this one:
+  sieve_default = /var/lib/dovecot/sieve/default.sieve
 
   # The include extension fetches the :global scripts from this
   # directory.
-  sieve_global_dir = /var/lib/dovecot/sieve/global/
+  sieve_global = /var/lib/dovecot/sieve/global/
 }
 
 Sieve Interpreter - Configurable Limits
@@ -181,47 +236,6 @@
    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 - 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
 --------------------------------------------------
 
@@ -263,15 +277,15 @@
  sieve_before =
  sieve_before2 =
  sieve_before3 = (etc..)
-   Path to a script file or a directory containing script files that need to be
-   executed before the user's personal script. If the path points to a
-   directory, all the Sieve scripts contained therein (with the proper .sieve
-   extension) are executed. The order of execution within that directory is
-   determined by the file names, using a normal 8bit per-character comparison.
+   Location Sieve of scripts that need to be executed before the user's personal
+   script. If a 'file' location path points to a directory, all the Sieve
+   scripts contained therein (with the proper `.sieve' extension) are executed.
+   The order of execution within that directory is determined by the file names,
+   using a normal 8bit per-character comparison.
 
-   Multiple script file or directory paths can be specified by appending an
-   increasing number. The Sieve scripts found from these paths are added to the
-   script execution sequence in the specified order. Reading the numbered
+   Multiple script locations can be specified by appending an increasing number
+   to the setting name. The Sieve scripts found from these locations are added
+   to the script execution sequence in the specified order. Reading the numbered
    sieve_before settings stops at the first missing setting, so no numbers may
    be skipped.
 
@@ -300,7 +314,7 @@
 in the sequence encounters an error, actions from earlier executed scripts are
 not affected. The sequence is broken however, meaning that the script execution
 of the offending script is aborted and no further scripts are executed. An
-implicit keep is executed in stead if necessary, meaning that the interpreter
+implicit keep is executed instead if necessary, meaning that the interpreter
 makes sure that the message is at least stored in the default folder (INBOX).
 
 Just as for executing a single script the normal way, the Pigeonhole LDA Sieve
@@ -317,9 +331,12 @@
    #   E.g. handling messages marked as dangerous
    sieve_before = /var/lib/dovecot/sieve/discard-virusses.sieve
 
+   # Domain-level scripts retrieved from LDAP
+   sieve_before2 = ldap:/etc/dovecot/sieve-ldap.conf;name=ldap-domain
+
    # User-specific scripts executed before the user's personal script.
    #   E.g. a vacation script managed through a non-ManageSieve GUI.
-   sieve_before2 = /var/vmail/%d/%n/sieve-before
+   sieve_before3 = /var/vmail/%d/%n/sieve-before
 
    # User-specific scripts executed after the user's personal script.
    # (if keep is still in effect)
@@ -333,9 +350,9 @@
 }
 
 IMPORTANT: The scripts specified by sieve_before and sieve_after are often
-located in global locations to which the Sieve interpreter has no write access.
-In that case be sure to manually pre-compile those scripts using the sievec
-tool, as explained in the README file.
+located in global locations to which the Sieve interpreter has no write access
+to store the compiled binaries. In that case, be sure to manually pre-compile
+those scripts using the sievec tool, as explained in the README file.
 
 Sieve Interpreter - Extension Configuration
 -------------------------------------------
@@ -496,7 +513,7 @@
      %o - total number of bytes sent to client
 
  managesieve_implementation_string = Dovecot Pigeonhole
-   To fool ManageSieve clients that are focused on CMU's timesieved you can
+   To fool ManageSieve clients that are focused on CMU's timesieved, you can
    specify the IMPLEMENTATION capability that the Dovecot reports to clients
    (e.g. 'Cyrus timsieved v2.2.13').
 
diff -r 8e2832c044a5 -r c01b68b0c6b1 TODO
--- a/TODO	Wed Jul 23 19:28:07 2014 +0200
+++ b/TODO	Wed Jul 23 19:36:00 2014 +0200
@@ -1,6 +1,10 @@
 Current activities:
 
-* Implement LDAP Sieve script storage for read-only access.
+* Finish LDAP Sieve script storage for read-only access.
+	- Consolidate LDAP connections when more than a single Sieve script must be
+	  loaded from different storages linked to the same LDAP server.
+	- Adjust Sieve script API to support asynchronous script retrieval to
+	  retrieve scripts in parallel when possible.
 
 Parallel plugin-based efforts (on hold at the moment):
 
diff -r 8e2832c044a5 -r c01b68b0c6b1 configure.ac
--- a/configure.ac	Wed Jul 23 19:28:07 2014 +0200
+++ b/configure.ac	Wed Jul 23 19:36:00 2014 +0200
@@ -60,6 +60,25 @@
 #
 #
 
+dnl TEST_WITH(name, value, [plugin])
+AC_DEFUN([TEST_WITH], [
+  want=want_`echo $1|sed s/-/_/g`
+  if test $2 = yes || test $2 = no || test $2 = auto; then
+    eval $want=$2
+  elif test $2 = plugin; then
+    if test "$3" = plugin; then
+      eval $want=plugin
+    else
+      AC_ERROR([--with-$1=plugin not supported])
+    fi
+  elif `echo $2|grep '^/' >/dev/null`; then
+    AC_ERROR([--with-$1=path not supported. You may want to use instead:
+CPPFLAGS=-I$2/include LDFLAGS=-L$2/lib ./configure --with-$1])
+  else
+    AC_ERROR([--with-$1: Unknown value: $2])
+  fi
+])
+
 AC_ARG_WITH(docs,
 [  --with-docs             Install documentation (default)],
     if test x$withval = xno; then
@@ -91,6 +110,63 @@
         want_managesieve=yes)
 AM_CONDITIONAL(BUILD_MANAGESIEVE, test "$want_managesieve" = "yes")
 
+AC_ARG_WITH(ldap,
+AS_HELP_STRING([--with-ldap=yes|plugin], [Build with LDAP support]),
+  TEST_WITH(ldap, $withval, plugin),
+  want_ldap=no)
+
+# FIXME: Imported this from Dovecot auth for now. We're working on a proper
+# lib-ldap, but, until then, some code is duplicated.
+have_ldap=no
+if test $want_ldap != no; then
+	AC_CHECK_LIB(ldap, ldap_init, [


More information about the dovecot-cvs mailing list