dovecot-2.2-pigeonhole: lib-sieve: Implemented support for gener...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Wed Jul 23 17:35:08 UTC 2014
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/8e2832c044a5
changeset: 1883:8e2832c044a5
user: Stephan Bosch <stephan at rename-it.nl>
date: Wed Jul 23 19:28:07 2014 +0200
description:
lib-sieve: Implemented support for generic Sieve storages.
Doveadm-sieve plugin may be broken at this point; not tested so far.
diffstat:
TODO | 32 +-
configure.ac | 4 +-
src/Makefile.am | 1 -
src/lib-sieve/Makefile.am | 19 +-
src/lib-sieve/plugins/include/cmd-include.c | 54 +-
src/lib-sieve/plugins/include/ext-include-binary.c | 18 +-
src/lib-sieve/plugins/include/ext-include-common.c | 81 +-
src/lib-sieve/plugins/include/ext-include-common.h | 12 +-
src/lib-sieve/sieve-binary.h | 2 +-
src/lib-sieve/sieve-common.h | 8 +
src/lib-sieve/sieve-error.c | 43 +-
src/lib-sieve/sieve-error.h | 4 +
src/lib-sieve/sieve-script-dict.c | 3 -
src/lib-sieve/sieve-script-file.h | 31 -
src/lib-sieve/sieve-script-private.h | 80 +-
src/lib-sieve/sieve-script.c | 620 ++++---
src/lib-sieve/sieve-script.h | 101 +-
src/lib-sieve/sieve-storage-private.h | 244 +++
src/lib-sieve/sieve-storage-sync.c | 131 +
src/lib-sieve/sieve-storage.c | 1078 +++++++++++++++
src/lib-sieve/sieve-storage.h | 188 ++
src/lib-sieve/sieve.c | 236 +--
src/lib-sieve/sieve.h | 19 +-
src/lib-sieve/storage/Makefile.am | 3 +
src/lib-sieve/storage/dict/Makefile.am | 13 +
src/lib-sieve/storage/dict/sieve-dict-script.c | 315 ++++
src/lib-sieve/storage/dict/sieve-dict-storage.c | 185 ++
src/lib-sieve/storage/dict/sieve-dict-storage.h | 68 +
src/lib-sieve/storage/file/Makefile.am | 18 +
src/lib-sieve/storage/file/sieve-file-script-sequence.c | 239 +++
src/lib-sieve/storage/file/sieve-file-script.c | 757 ++++++++++
src/lib-sieve/storage/file/sieve-file-storage-active.c | 428 +++++
src/lib-sieve/storage/file/sieve-file-storage-list.c | 125 +
src/lib-sieve/storage/file/sieve-file-storage-quota.c | 123 +
src/lib-sieve/storage/file/sieve-file-storage-save.c | 452 ++++++
src/lib-sieve/storage/file/sieve-file-storage.c | 681 +++++++++
src/lib-sieve/storage/file/sieve-file-storage.h | 177 ++
src/lib-sievestorage/Makefile.am | 21 -
src/lib-sievestorage/sieve-storage-list.c | 115 -
src/lib-sievestorage/sieve-storage-list.h | 29 -
src/lib-sievestorage/sieve-storage-private.h | 69 -
src/lib-sievestorage/sieve-storage-quota.c | 159 --
src/lib-sievestorage/sieve-storage-quota.h | 28 -
src/lib-sievestorage/sieve-storage-save.c | 459 ------
src/lib-sievestorage/sieve-storage-save.h | 39 -
src/lib-sievestorage/sieve-storage-script.c | 740 ----------
src/lib-sievestorage/sieve-storage-script.h | 34 -
src/lib-sievestorage/sieve-storage.c | 744 ----------
src/lib-sievestorage/sieve-storage.h | 58 -
src/managesieve/Makefile.am | 4 +-
src/managesieve/cmd-deletescript.c | 10 +-
src/managesieve/cmd-getscript.c | 6 +-
src/managesieve/cmd-havespace.c | 3 +-
src/managesieve/cmd-listscripts.c | 4 +-
src/managesieve/cmd-putscript.c | 22 +-
src/managesieve/cmd-renamescript.c | 9 +-
src/managesieve/cmd-setactive.c | 22 +-
src/managesieve/managesieve-client.c | 50 +-
src/managesieve/managesieve-quota.c | 2 +-
src/plugins/Makefile.am | 5 +-
src/plugins/doveadm-sieve/Makefile.am | 4 +-
src/plugins/doveadm-sieve/doveadm-sieve-plugin.c | 51 +-
src/plugins/lda-sieve/lda-sieve-plugin.c | 282 ++-
src/sieve-tools/sievec.c | 3 +-
src/testsuite/testsuite-binary.c | 1 -
src/testsuite/testsuite-script.c | 1 -
tests/extensions/include/execute.svtest | 30 +-
67 files changed, 6201 insertions(+), 3396 deletions(-)
diffs (truncated from 11144 to 300 lines):
diff -r 92405f753f6a -r 8e2832c044a5 TODO
--- a/TODO Thu Jun 26 23:25:43 2014 +0200
+++ b/TODO Wed Jul 23 19:28:07 2014 +0200
@@ -1,12 +1,6 @@
Current activities:
-* 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
- - Implement infrastructure for loading a sequence of global scripts from
- a database (for sieve_before/sieve_after).
+* Implement LDAP Sieve script storage for read-only access.
Parallel plugin-based efforts (on hold at the moment):
@@ -17,8 +11,21 @@
Next (mostly in order of descending priority/precedence):
* Implement index extension
+* Implement message modification and extraction API in order to:
+ - Implement replace, enclose, foreverypart, mime and extracttext extensions
* Add normalize() method to comparators to normalize the string before matching
(for efficiency).
+* Properly implement Sieve internationalization support (utf-8 handling),
+ currently it is not complete:
+ - Make this implementation fully conform section 2.7.2 of RFC5228 (Comparisons
+ Across Character Sets).
+ - Verify validity of utf8 where necessary.
+ - Implement comparator-i;unicode-casemap.
+* Add support for stream matching for handling large values, e.g. from the body
+ extension.
+* Clean up doveadm sync implementation:
+ - Mostly comments referring specifically to the file storage type.
+ - API can be polished a lot as well.
* Improve error handling.
- Implement dropping errors in the user's mailbox as a mail message.
* Further develop regex extension and update it to the latest draft:
@@ -50,12 +57,6 @@
fails rather than an implicit keep.
- Add a method to implicitly pass environment variables such as SENDER and
RECIPIENT through the script socket service.
-* Properly implement Sieve internationalization support (utf-8 handling),
- currently it is not complete:
- - Make this implementation fully conform section 2.7.2 of RFC5228 (Comparisons
- Across Character Sets).
- - Verify validity of utf8 where necessary.
- - Implement comparator-i;unicode-casemap.
* Make testsuite much more exhaustive:
- Add support for testing the content of result actions
- Test as many error/warning/info conditions as possible.
@@ -79,10 +80,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.
-* Add support for stream matching for handling large values, e.g. from the body
- extension.
-* Implement message modification and extraction API in order to:
- - Implement replace, enclose, foreverypart, mime and extracttext extensions
* Provide a solution for mail_get_headers_utf8 reparsing the whole message each
time it is called (header and address test; Timo might provide solution from
within Dovecot)
@@ -91,7 +88,6 @@
* Implement IMAP plugin for IMAPSieve support:
- Requires some sort of Sieve transaction support.
- - Requires (IMAP) METADATA support in Dovecot.
- This may include support for manually running a script on a set of messages
through IMAP (no specification for something like this is available; we will
have to provide our own)
diff -r 92405f753f6a -r 8e2832c044a5 configure.ac
--- a/configure.ac Thu Jun 26 23:25:43 2014 +0200
+++ b/configure.ac Wed Jul 23 19:28:07 2014 +0200
@@ -101,6 +101,9 @@
src/Makefile
src/lib-sieve/Makefile
src/lib-sieve/util/Makefile
+src/lib-sieve/storage/Makefile
+src/lib-sieve/storage/file/Makefile
+src/lib-sieve/storage/dict/Makefile
src/lib-sieve/plugins/Makefile
src/lib-sieve/plugins/vacation/Makefile
src/lib-sieve/plugins/subaddress/Makefile
@@ -126,7 +129,6 @@
src/lib-sieve/plugins/vnd.dovecot/Makefile
src/lib-sieve/plugins/vnd.dovecot/debug/Makefile
src/lib-sieve-tool/Makefile
-src/lib-sievestorage/Makefile
src/lib-managesieve/Makefile
src/plugins/Makefile
src/plugins/doveadm-sieve/Makefile
diff -r 92405f753f6a -r 8e2832c044a5 src/Makefile.am
--- a/src/Makefile.am Thu Jun 26 23:25:43 2014 +0200
+++ b/src/Makefile.am Wed Jul 23 19:28:07 2014 +0200
@@ -2,7 +2,6 @@
sieve_subdirs = \
lib-sieve \
- lib-sievestorage \
plugins \
lib-sieve-tool \
sieve-tools \
diff -r 92405f753f6a -r 8e2832c044a5 src/lib-sieve/Makefile.am
--- a/src/lib-sieve/Makefile.am Thu Jun 26 23:25:43 2014 +0200
+++ b/src/lib-sieve/Makefile.am Wed Jul 23 19:28:07 2014 +0200
@@ -1,4 +1,4 @@
-SUBDIRS = util plugins
+SUBDIRS = util storage plugins
dovecot_pkglib_LTLIBRARIES = libdovecot-sieve.la
@@ -43,11 +43,17 @@
cmp-i-ascii-casemap.c
if BUILD_UNFINISHED
+unfinished_storages =
unfinished_plugins = \
$(extdir)/metadata/libsieve_ext_metadata.la
endif
-# These are not actual plugins just yet...
+strgdir = $(top_builddir)/src/lib-sieve/storage
+storages = \
+ $(strgdir)/file/libsieve_storage_file.la \
+ $(strgdir)/dict/libsieve_storage_dict.la \
+ $(unfinished_storages)
+
extdir = $(top_builddir)/src/lib-sieve/plugins
plugins = \
$(extdir)/vacation/libsieve_ext_vacation.la \
@@ -73,12 +79,14 @@
$(unfinished_plugins)
libdovecot_sieve_la_DEPENDENCIES = \
+ $(storages) \
$(plugins) \
$(top_builddir)/src/lib-sieve/util/libsieve_util.la \
$(LIBDOVECOT_LDA_DEPS) \
$(LIBDOVECOT_STORAGE_DEPS) \
$(LIBDOVECOT_DEPS)
libdovecot_sieve_la_LIBADD = \
+ $(storages) \
$(plugins) \
$(top_builddir)/src/lib-sieve/util/libsieve_util.la \
$(LIBDOVECOT_LDA) \
@@ -91,8 +99,8 @@
sieve-smtp.c \
sieve-lexer.c \
sieve-script.c \
- sieve-script-file.c \
- sieve-script-dict.c \
+ sieve-storage.c \
+ sieve-storage-sync.c \
sieve-ast.c \
sieve-binary.c \
sieve-binary-file.c \
@@ -137,7 +145,8 @@
sieve-lexer.h \
sieve-script.h \
sieve-script-private.h \
- sieve-script-file.h \
+ sieve-storage.h \
+ sieve-storage-private.h \
sieve-ast.h \
sieve-binary.h \
sieve-binary-private.h \
diff -r 92405f753f6a -r 8e2832c044a5 src/lib-sieve/plugins/include/cmd-include.c
--- a/src/lib-sieve/plugins/include/cmd-include.c Thu Jun 26 23:25:43 2014 +0200
+++ b/src/lib-sieve/plugins/include/cmd-include.c Wed Jul 23 19:28:07 2014 +0200
@@ -6,6 +6,7 @@
#include "sieve-common.h"
#include "sieve-script.h"
+#include "sieve-storage.h"
#include "sieve-ast.h"
#include "sieve-code.h"
#include "sieve-extensions.h"
@@ -213,8 +214,9 @@
struct sieve_ast_argument *arg = cmd->first_positional;
struct cmd_include_context_data *ctx_data =
(struct cmd_include_context_data *) cmd->data;
+ struct sieve_storage *storage;
struct sieve_script *script;
- const char *script_location, *script_name;
+ const char *script_name;
enum sieve_error error = SIEVE_ERROR_NONE;
int ret;
@@ -247,30 +249,41 @@
return FALSE;
}
- script_location = ext_include_get_script_location
- (this_ext, ctx_data->location, script_name);
- if ( script_location == NULL ) {
- sieve_argument_validate_error(valdtr, arg,
- "include: %s location for included script '%s' is unavailable "
- "(contact system administrator for more information)",
- ext_include_script_location_name(ctx_data->location),
- str_sanitize(script_name, 80));
+ storage = ext_include_get_script_storage
+ (this_ext, ctx_data->location, script_name, &error);
+ if ( storage == NULL ) {
+ // FIXME: handle ':optional' in this case
+ if (error == SIEVE_ERROR_NOT_FOUND) {
+ sieve_argument_validate_error(valdtr, arg,
+ "include: %s location for included script `%s' is unavailable "
+ "(contact system administrator for more information)",
+ ext_include_script_location_name(ctx_data->location),
+ str_sanitize(script_name, 80));
+ } else {
+ sieve_argument_validate_error(valdtr, arg,
+ "include: failed to access %s location for included script `%s' "
+ "(contact system administrator for more information)",
+ ext_include_script_location_name(ctx_data->location),
+ str_sanitize(script_name, 80));
+ }
return FALSE;
}
/* Create script object */
- script = sieve_script_create
- (this_ext->svinst, script_location, script_name,
- sieve_validator_error_handler(valdtr), &error);
+ script = sieve_storage_get_script
+ (storage, script_name, &error);
+ if ( script == NULL )
+ return FALSE;
- ret = 0;
- if ( script != NULL )
- ret = sieve_script_open(script, &error);
-
- if ( script == NULL || ret < 0 ) {
+ ret = sieve_script_open(script, &error);
+ if ( ret < 0 ) {
if ( error != SIEVE_ERROR_NOT_FOUND ) {
- if ( script != NULL )
- sieve_script_unref(&script);
+ sieve_argument_validate_error(valdtr, arg,
+ "failed to access included %s script '%s': %s",
+ ext_include_script_location_name(ctx_data->location),
+ str_sanitize(script_name, 80),
+ sieve_script_get_last_error_lcase(script));
+ sieve_script_unref(&script);
return FALSE;
/* Not found */
@@ -295,8 +308,7 @@
"included %s script '%s' does not exist",
ext_include_script_location_name(ctx_data->location),
str_sanitize(script_name, 80));
- if ( script != NULL )
- sieve_script_unref(&script);
+ sieve_script_unref(&script);
return FALSE;
}
}
diff -r 92405f753f6a -r 8e2832c044a5 src/lib-sieve/plugins/include/ext-include-binary.c
--- a/src/lib-sieve/plugins/include/ext-include-binary.c Thu Jun 26 23:25:43 2014 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-binary.c Wed Jul 23 19:28:07 2014 +0200
@@ -7,6 +7,7 @@
#include "sieve-common.h"
#include "sieve-error.h"
#include "sieve-script.h"
+#include "sieve-storage.h"
#include "sieve-binary.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
@@ -277,7 +278,7 @@
struct sieve_binary_block *inc_block = NULL;
unsigned int location, flags;
string_t *script_name;
- const char *script_location;
+ struct sieve_storage *storage;
struct sieve_script *script;
enum sieve_error error;
int ret;
@@ -314,24 +315,24 @@
}
/* Can we find the script dependency ? */
- script_location = ext_include_get_script_location
- (ext, location, str_c(script_name));
- if ( script_location == NULL ) {
+ storage = ext_include_get_script_storage
+ (ext, location, str_c(script_name), NULL);
+ if ( storage == NULL ) {
/* No, recompile */
+ // FIXME: handle ':optional' in this case
return FALSE;
}
/* Can we open the script dependency ? */
- script = sieve_script_create
- (ext->svinst, script_location, str_c(script_name), NULL, &error);
+ script = sieve_storage_get_script
+ (storage, str_c(script_name), &error);
if ( script == NULL ) {
More information about the dovecot-cvs
mailing list