dovecot-2.1-pigeonhole: LDA Sieve plugin: adjusted script compil...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sat Mar 2 23:38:07 EET 2013


details:   http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/5a440010d1cf
changeset: 1675:5a440010d1cf
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Mar 02 22:36:55 2013 +0100
description:
LDA Sieve plugin: adjusted script compile/load error reporting.
Made normal compile error an info log item in the administrator log.

diffstat:

 src/plugins/lda-sieve/lda-sieve-plugin.c |  55 ++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 20 deletions(-)

diffs (84 lines):

diff -r 994b45b58e91 -r 5a440010d1cf src/plugins/lda-sieve/lda-sieve-plugin.c
--- a/src/plugins/lda-sieve/lda-sieve-plugin.c	Thu Feb 28 23:37:31 2013 +0100
+++ b/src/plugins/lda-sieve/lda-sieve-plugin.c	Sat Mar 02 22:36:55 2013 +0100
@@ -275,25 +275,34 @@
 		ehandler = srctx->master_ehandler;
 
 	if ( debug )
-		sieve_sys_debug(svinst, "opening script %s", sieve_script_location(script));
+		sieve_sys_debug(svinst, "loading script %s", sieve_script_location(script));
 
 	sieve_error_handler_reset(ehandler);
 
-	/* Open the sieve script */
+	/* Load or compile the sieve script */
 	if ( (sbin=sieve_open_script(script, ehandler, cpflags, error_r)) == NULL ) {
-		if ( *error_r == SIEVE_ERROR_NOT_FOUND ) {
+		switch ( *error_r ) {
+		/* Script not found */
+		case SIEVE_ERROR_NOT_FOUND:
 			if ( debug ) {
 				sieve_sys_debug(svinst, "script file %s is missing",
 					sieve_script_location(script));
 			}
-		} else if ( *error_r == SIEVE_ERROR_NOT_VALID &&
-			script == srctx->user_script && srctx->userlog != NULL ) {
-			sieve_sys_error(svinst,	"failed to open script %s "
-				"(view user logfile %s for more information)",
-				sieve_script_location(script), srctx->userlog);
-		} else {
+			break;
+		/* Compile failed */
+		case SIEVE_ERROR_NOT_VALID:
+			if (script == srctx->user_script && srctx->userlog != NULL ) {
+				sieve_sys_info(svinst, "failed to compile script %s "
+					"(view user logfile %s for more information)",
+					sieve_script_location(script), srctx->userlog);
+				break;
+			}
+			/* Fall through */
+		/* Something else */
+		default:
 			sieve_sys_error(svinst,	"failed to open script %s",
 				sieve_script_location(script));
+			break;
 		}
 
 		return NULL;
@@ -328,19 +337,25 @@
 	if ( (sbin=sieve_compile_script(script, ehandler,	cpflags, error_r))
 		== NULL ) {
 
-		if ( *error_r == SIEVE_ERROR_NOT_FOUND ) {
-			if ( debug )
+		switch ( *error_r ) {
+		case SIEVE_ERROR_NOT_FOUND:
+			if ( debug ) {
 				sieve_sys_debug(svinst, "script file %s is missing for re-compile",
 					sieve_script_location(script));
-		} else if ( *error_r == SIEVE_ERROR_NOT_VALID &&
-			script == srctx->user_script && srctx->userlog != NULL ) {
-			sieve_sys_error(svinst,
-				"failed to re-compile script %s "
-				"(view user logfile %s for more information)",
-				sieve_script_location(script), srctx->userlog);
-		} else {
-			sieve_sys_error(svinst,
-				"failed to re-compile script %s", sieve_script_location(script));
+			}
+			break;
+		case SIEVE_ERROR_NOT_VALID:
+			if ( script == srctx->user_script && srctx->userlog != NULL ) {
+				sieve_sys_info(svinst,
+					"failed to re-compile script %s "
+					"(view user logfile %s for more information)",
+					sieve_script_location(script), srctx->userlog);
+				break;
+			}
+			/* Fall through */
+		default:
+			sieve_sys_error(svinst,	"failed to open script %s for re-compile",
+				sieve_script_location(script));
 		}
 
 		return NULL;


More information about the dovecot-cvs mailing list