dovecot-2.0-pigeonhole: Fixed runtime error logging not to repor...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sat Sep 4 15:54:48 EEST 2010


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/081a2c9babc0
changeset: 1407:081a2c9babc0
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Sep 04 14:53:35 2010 +0200
description:
Fixed runtime error logging not to report user-caused errors to the master log.

diffstat:

 TODO                                     |    1 -
 src/lib-sieve/cmd-redirect.c             |   10 +-
 src/lib-sieve/ext-reject.c               |    2 +-
 src/lib-sieve/sieve-actions.c            |   33 +++++---
 src/lib-sieve/sieve-commands.h           |    4 -
 src/lib-sieve/sieve-error.c              |  121 +++++++++++++++++++++++++++---
 src/lib-sieve/sieve-error.h              |   41 +++++++++-
 src/lib-sieve/sieve-interpreter.c        |   33 +++----
 src/lib-sieve/sieve-result.c             |   27 ++++++-
 src/lib-sieve/sieve-result.h             |    6 +
 src/lib-sieve/sieve-script.c             |   10 +-
 src/lib-sieve/sieve-validator.c          |   13 ---
 src/plugins/lda-sieve/lda-sieve-plugin.c |   26 ++++--
 13 files changed, 239 insertions(+), 88 deletions(-)

diffs (truncated from 687 to 300 lines):

diff -r cda3b3fe04b0 -r 081a2c9babc0 TODO
--- a/TODO	Sat Sep 04 14:51:35 2010 +0200
+++ b/TODO	Sat Sep 04 14:53:35 2010 +0200
@@ -1,7 +1,6 @@
 Current activities:
 
 * Improve error handling and logging
-	- Avoid reporting user-caused errors to the master log.
 	- Review logging and error handling; add more warning/info/debug messages
 	  where useful.
 
diff -r cda3b3fe04b0 -r 081a2c9babc0 src/lib-sieve/cmd-redirect.c
--- a/src/lib-sieve/cmd-redirect.c	Sat Sep 04 14:51:35 2010 +0200
+++ b/src/lib-sieve/cmd-redirect.c	Sat Sep 04 14:53:35 2010 +0200
@@ -361,7 +361,7 @@
 	const struct sieve_message_data *msgdata = aenv->msgdata;
 	const struct sieve_script_env *senv = aenv->scriptenv;
 	const char *dupeid;
-	
+
 	/* Prevent mail loops if possible */
 	dupeid = msgdata->id == NULL ? 
 		NULL : t_strdup_printf("%s-%s", msgdata->id, ctx->to_address);
@@ -373,16 +373,16 @@
 			return TRUE;
 		}
 	}
-	
+
 	/* Try to forward the message */
 	if ( act_redirect_send(aenv, ctx) ) {
-	
+
 		/* Mark this message id as forwarded to the specified destination */
 		if (dupeid != NULL) {
 			sieve_action_duplicate_mark(senv, dupeid, strlen(dupeid),
 				ioloop_time + CMD_REDIRECT_DUPLICATE_KEEP);
 		}
-	
+
 		sieve_result_log(aenv, "forwarded to <%s>", 
 			str_sanitize(ctx->to_address, 128));	
 
@@ -394,7 +394,7 @@
 
 		return TRUE;
 	}
-  
+ 
 	return FALSE;
 }
 
diff -r cda3b3fe04b0 -r 081a2c9babc0 src/lib-sieve/ext-reject.c
--- a/src/lib-sieve/ext-reject.c	Sat Sep 04 14:51:35 2010 +0200
+++ b/src/lib-sieve/ext-reject.c	Sat Sep 04 14:53:35 2010 +0200
@@ -485,7 +485,7 @@
 	fprintf(f, "\r\n\r\n--%s--\r\n", boundary);
 
 	if ( !sieve_smtp_close(senv, smtp_handle) ) {
-		sieve_result_error(aenv, 
+		sieve_result_error(aenv,
 			"failed to send rejection message to <%s> "
 			"(refer to server log for more information)",
 			str_sanitize(sender, 80));
diff -r cda3b3fe04b0 -r 081a2c9babc0 src/lib-sieve/sieve-actions.c
--- a/src/lib-sieve/sieve-actions.c	Sat Sep 04 14:51:35 2010 +0200
+++ b/src/lib-sieve/sieve-actions.c	Sat Sep 04 14:53:35 2010 +0200
@@ -500,14 +500,14 @@
 	 * succeeded. 
 	 */
 	aenv->exec_status->last_storage = mailbox_get_storage(trans->box);
-	
+
 	/* Start mail transaction */
 	trans->mail_trans = mailbox_transaction_begin
 		(trans->box, MAILBOX_TRANSACTION_FLAG_EXTERNAL);
 
 	/* Create mail object for stored message */
 	trans->dest_mail = mail_alloc(trans->mail_trans, 0, NULL);
- 
+
 	/* Store the message */
 	save_ctx = mailbox_save_alloc(trans->mail_trans);
 	mailbox_save_set_dest_mail(save_ctx, trans->dest_mail);
@@ -515,7 +515,7 @@
 	/* Apply keywords and flags that side-effects may have added */
 	if ( trans->flags_altered ) {
 		keywords = act_store_keywords_create(aenv, &trans->keywords, trans->box);
-		
+
 		mailbox_save_set_flags(save_ctx, trans->flags, keywords);
 	}
 
@@ -523,12 +523,12 @@
 		sieve_act_store_get_storage_error(aenv, trans);
  		result = FALSE;
 	}
- 	
+
 	/* Deallocate keywords */
  	if ( keywords != NULL ) {
  		mailbox_keywords_unref(trans->box, &keywords);
  	}
- 		 	
+ 
 	return result;
 }
 
@@ -555,7 +555,7 @@
 	/* Store disabled? */
 	if ( trans->disabled ) {
 		sieve_result_log(aenv, "store into mailbox %s skipped", mailbox_name);
-	
+
 	/* Store redundant? */
 	} else if ( trans->redundant ) {
 		sieve_result_log(aenv, "left message in mailbox %s", mailbox_name);
@@ -563,16 +563,23 @@
 	/* Store failed? */
 	} else if ( !status ) {
 		const char *errstr;
-		enum mail_error error;
+		enum mail_error error_code;
 
-		if ( trans->error != NULL )
+		if ( trans->error != NULL ) {
 			errstr = trans->error;
-		else
+			error_code = trans->error_code;
+		} else {
 			errstr = mail_storage_get_last_error
-				(mailbox_get_storage(trans->box), &error);
-	
-		sieve_result_error(aenv, "failed to store into mailbox %s: %s", 
-			mailbox_name, errstr);
+				(mailbox_get_storage(trans->box), &error_code);
+		}
+
+		if ( error_code != MAIL_ERROR_NOTFOUND || error_code != MAIL_ERROR_PARAMS ) {
+			sieve_result_error(aenv, "failed to store into mailbox %s: %s",
+				mailbox_name, errstr);
+		} else {
+			sieve_result_user_error(aenv, "failed to store into mailbox %s: %s",
+				mailbox_name, errstr);
+		}
 
 	/* Store aborted? */
 	} else if ( rolled_back ) {
diff -r cda3b3fe04b0 -r 081a2c9babc0 src/lib-sieve/sieve-commands.h
--- a/src/lib-sieve/sieve-commands.h	Sat Sep 04 14:51:35 2010 +0200
+++ b/src/lib-sieve/sieve-commands.h	Sat Sep 04 14:53:35 2010 +0200
@@ -192,13 +192,9 @@
 	sieve_validator_error(validator, (context)->ast_node->source_line, __VA_ARGS__)
 #define sieve_command_validate_warning(validator, context, ...) \
 	sieve_validator_warning(validator, (context)->ast_node->source_line, __VA_ARGS__)
-#define sieve_command_validate_critical(validator, context, ...) \
-	sieve_validator_critical(validator, (context)->ast_node->source_line, __VA_ARGS__)
 
 #define sieve_command_generate_error(gentr, context, ...) \
 	sieve_generator_error(gentr, (context)->ast_node->source_line, __VA_ARGS__)
-#define sieve_command_generate_critical(gentr, context, ...) \
-	sieve_generator_critical(gentr, (context)->ast_node->source_line, __VA_ARGS__)
 
 /* Utility macros */
 
diff -r cda3b3fe04b0 -r 081a2c9babc0 src/lib-sieve/sieve-error.c
--- a/src/lib-sieve/sieve-error.c	Sat Sep 04 14:51:35 2010 +0200
+++ b/src/lib-sieve/sieve-error.c	Sat Sep 04 14:53:35 2010 +0200
@@ -65,6 +65,38 @@
  * System errors
  */
 
+void sieve_sys_verror
+(struct sieve_instance *svinst, const char *fmt, va_list args)
+{	
+	T_BEGIN { 
+		sieve_verror(svinst->system_ehandler, NULL, fmt, args);
+	} T_END;
+}
+
+void sieve_sys_vwarning
+(struct sieve_instance *svinst, const char *fmt, va_list args)
+{	
+	T_BEGIN { 
+		sieve_vwarning(svinst->system_ehandler, NULL, fmt, args);
+	} T_END;
+}
+
+void sieve_sys_vinfo
+(struct sieve_instance *svinst, const char *fmt, va_list args)
+{	
+	T_BEGIN { 
+		sieve_vinfo(svinst->system_ehandler, NULL, fmt, args);
+	} T_END;
+}
+
+void sieve_sys_vdebug
+(struct sieve_instance *svinst, const char *fmt, va_list args)
+{	
+	T_BEGIN { 
+		sieve_vdebug(svinst->system_ehandler, NULL, fmt, args);
+	} T_END;
+}
+
 void sieve_sys_error(struct sieve_instance *svinst, const char *fmt, ...)
 {
 	va_list args;
@@ -124,6 +156,73 @@
 }
 
 /*
+ * User errors
+ */
+
+void sieve_user_verror
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, va_list args)
+{
+	if ( ehandler == NULL ) return;
+	
+	sieve_direct_verror(ehandler, location, fmt, args);
+}
+
+void sieve_user_vwarning
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, va_list args)
+{
+	if ( ehandler == NULL ) return;
+
+	sieve_direct_vwarning(ehandler, location, fmt, args);
+}
+
+void sieve_user_vinfo
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, va_list args)
+{
+	if ( ehandler == NULL ) return;
+
+	sieve_direct_vinfo(ehandler, location, fmt, args);
+}
+
+void sieve_user_error
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, ...)
+{
+	va_list args;
+	va_start(args, fmt);
+	
+	T_BEGIN { sieve_user_verror(ehandler, location, fmt, args); } T_END;
+	
+	va_end(args);
+}
+
+void sieve_user_warning
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, ...)
+{
+	va_list args;
+	va_start(args, fmt);
+	
+	T_BEGIN { sieve_user_vwarning(ehandler, location, fmt, args); } T_END;
+
+	va_end(args);
+}
+
+void sieve_user_info
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, ...)
+{
+	va_list args;
+	va_start(args, fmt);
+	
+	T_BEGIN { sieve_user_vinfo(ehandler, location, fmt, args); } T_END;
+	
+	va_end(args);
+}
+
+/*
  * Main error functions
  */
 
@@ -187,23 +286,21 @@
 }
 
 void sieve_vcritical
-	(struct sieve_error_handler *ehandler, const char *location, 
-		const char *fmt, va_list args)
+(struct sieve_instance *svinst, struct sieve_error_handler *ehandler,
+	const char *location, const char *fmt, va_list args)
 {
 	char str[256];
 	struct tm *tm; 
-	
-	tm = localtime(&ioloop_time);
-	
+		
 	if ( location == NULL || *location == '\0' ) {
-		sieve_sys_error
-			(ehandler->svinst, "%s", t_strdup_vprintf(fmt, args));
+		sieve_verror(svinst->system_ehandler, NULL, fmt, args);


More information about the dovecot-cvs mailing list