dovecot-2.2-pigeonhole: lib-sieve: Improved debug messages about...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sat Mar 14 14:52:23 UTC 2015


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/0226882e55e1
changeset: 2011:0226882e55e1
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Mar 14 15:52:15 2015 +0100
description:
lib-sieve: Improved debug messages about up-to-date status of a loaded binary.

diffstat:

 src/lib-sieve/sieve-script.c                    |  36 +++++++++++----------
 src/lib-sieve/storage/dict/sieve-dict-script.c  |   8 ++++-
 src/lib-sieve/storage/file/sieve-file-script.c  |   6 ++-
 src/lib-sieve/storage/ldap/sieve-ldap-script.c  |  40 +++++++++++++++++++++---
 src/lib-sieve/storage/ldap/sieve-ldap-storage.c |   1 +
 src/lib-sieve/storage/ldap/sieve-ldap-storage.h |   1 +
 6 files changed, 67 insertions(+), 25 deletions(-)

diffs (227 lines):

diff -r adbd9fc695d1 -r 0226882e55e1 src/lib-sieve/sieve-script.c
--- a/src/lib-sieve/sieve-script.c	Sat Mar 14 15:31:53 2015 +0100
+++ b/src/lib-sieve/sieve-script.c	Sat Mar 14 15:52:15 2015 +0100
@@ -337,7 +337,6 @@
 {
 	struct sieve_binary *sbin = sieve_binary_block_get_binary(sblock);
 	string_t *storage_class, *location;
-	const char *script_location;
 	unsigned int version;
 
 	if ( sieve_binary_block_get_size(sblock) - *offset == 0 )
@@ -346,15 +345,16 @@
 	/* storage class */
 	if ( !sieve_binary_read_string(sblock, offset, &storage_class) ) {
 		sieve_script_sys_error(script,
-			"Binary %s has invalid metadata for script %s: "
+			"Binary `%s' has invalid metadata for script `%s': "
 			"Invalid storage class",
-			sieve_binary_path(sbin), sieve_script_location(script));
+			sieve_binary_path(sbin), script->location);
 		return -1;
 	}
 	if ( strcmp(str_c(storage_class), script->driver_name) != 0 ) {
 		sieve_script_sys_debug(script,
-			"Binary reports unexpected driver name "
+			"Binary `%s' reports unexpected driver name for script `%s' "
 			"(`%s' rather than `%s')",
+			sieve_binary_path(sbin), script->location,
 			str_c(storage_class), script->driver_name);
 		return 0;
 	}
@@ -362,34 +362,36 @@
 	/* version */
 	if ( !sieve_binary_read_unsigned(sblock, offset, &version) ) {
 		sieve_script_sys_error(script,
-			"Binary %s has invalid metadata for script %s: "
+			"Binary `%s' has invalid metadata for script `%s': "
 			"Invalid version",
-			sieve_binary_path(sbin), sieve_script_location(script));
+			sieve_binary_path(sbin), script->location);
 		return -1;
 	}
 	if ( script->storage->version != version ) {
 		sieve_script_sys_debug(script,
-			"Binary %s was compiled with different version "
-			"of the `%s' script storage class (compiled v%d, expected v%d;"
-			"automatically fixed when re-compiled)", sieve_binary_path(sbin),
-			script->driver_name, version, script->storage->version);
+			"Binary `%s' was compiled with "
+			"a different version of the `%s' script storage class "
+			"(compiled v%d, expected v%d; "
+				"automatically fixed when re-compiled)",
+			sieve_binary_path(sbin), script->driver_name,
+		 	version, script->storage->version);
 		return 0;
 	}
 
 	/* location */
 	if ( !sieve_binary_read_string(sblock, offset, &location) ) {
 		sieve_script_sys_error(script,
-			"Binary %s has invalid metadata for script %s: "
+			"Binary `%s' has invalid metadata for script `%s': "
 			"Invalid location",
-			sieve_binary_path(sbin), sieve_script_location(script));
+			sieve_binary_path(sbin), script->location);
 		return -1;
 	}
-	script_location = ( script->location == NULL ? "" : script->location);
-	if ( strcmp(str_c(location), script_location) != 0 ) {
+	i_assert( script->location != NULL );
+	if ( strcmp(str_c(location), script->location) != 0 ) {
 		sieve_script_sys_debug(script,
-			"Binary reports different script location "
-			"(`%s' rather than `%s')",
-			str_c(location), script_location);
+			"Binary `%s' reports different location "
+			"for script `%s' (binary points to `%s')",
+			sieve_binary_path(sbin), script->location, str_c(location));
 		return 0;
 	}
 	
diff -r adbd9fc695d1 -r 0226882e55e1 src/lib-sieve/storage/dict/sieve-dict-script.c
--- a/src/lib-sieve/storage/dict/sieve-dict-script.c	Sat Mar 14 15:31:53 2015 +0100
+++ b/src/lib-sieve/storage/dict/sieve-dict-script.c	Sat Mar 14 15:52:15 2015 +0100
@@ -161,8 +161,14 @@
 		return -1;
 	}
 	i_assert( dscript->data_id != NULL );
-	if ( strcmp(str_c(data_id), dscript->data_id) != 0 )
+	if ( strcmp(str_c(data_id), dscript->data_id) != 0 ) {
+		sieve_script_sys_debug(script,
+			"Binary `%s' reports different data ID for script `%s' "
+			"(`%s' rather than `%s')",
+			sieve_binary_path(sbin), sieve_script_location(script),
+			str_c(data_id), dscript->data_id);
 		return 0;
+	}
 	return 1;
 }
 
diff -r adbd9fc695d1 -r 0226882e55e1 src/lib-sieve/storage/file/sieve-file-script.c
--- a/src/lib-sieve/storage/file/sieve-file-script.c	Sat Mar 14 15:31:53 2015 +0100
+++ b/src/lib-sieve/storage/file/sieve-file-script.c	Sat Mar 14 15:52:15 2015 +0100
@@ -483,9 +483,11 @@
 		fscript->st.st_mtime : fscript->lnk_st.st_mtime );
 
 	if ( bmtime <= smtime ) {
-		if (svinst->debug) {
+		if ( svinst->debug ) {
 			sieve_script_sys_debug(script,
-				"Sieve binary is not newer than the Sieve script (%s <= %s)",
+				"Sieve binary `%s' is not newer "
+				"than the Sieve script `%s' (%s <= %s)",
+				sieve_binary_path(sbin), sieve_script_location(script),
 				t_strflocaltime("%Y-%m-%d %H:%M:%S", bmtime),
 				t_strflocaltime("%Y-%m-%d %H:%M:%S", smtime));
 		}
diff -r adbd9fc695d1 -r 0226882e55e1 src/lib-sieve/storage/ldap/sieve-ldap-script.c
--- a/src/lib-sieve/storage/ldap/sieve-ldap-script.c	Sat Mar 14 15:31:53 2015 +0100
+++ b/src/lib-sieve/storage/ldap/sieve-ldap-script.c	Sat Mar 14 15:52:15 2015 +0100
@@ -2,6 +2,7 @@
  */
 
 #include "lib.h"
+#include "time-util.h"
 #include "istream.h"
 
 #include "sieve-ldap-storage.h"
@@ -121,24 +122,41 @@
 {
 	struct sieve_ldap_script *lscript =
 		(struct sieve_ldap_script *)script;
+	struct sieve_instance *svinst = script->storage->svinst;
 	struct sieve_ldap_storage *lstorage =
 		(struct sieve_ldap_storage *)script->storage;		
 	struct sieve_binary *sbin =
 		sieve_binary_block_get_binary(sblock);
+	time_t bmtime = sieve_binary_mtime(sbin);
 	string_t *dn, *modattr;
 
 	/* config file changed? */
-	if ( sieve_binary_mtime(sbin) <= lstorage->set_mtime )
+	if ( bmtime <= lstorage->set_mtime ) {
+		if ( svinst->debug ) {
+			sieve_script_sys_debug(script,
+				"Sieve binary `%s' is not newer "
+				"than the LDAP configuration `%s' (%s <= %s)",
+				sieve_binary_path(sbin), lstorage->config_file,
+				t_strflocaltime("%Y-%m-%d %H:%M:%S", bmtime),
+				t_strflocaltime("%Y-%m-%d %H:%M:%S", lstorage->set_mtime));
+		}
 		return 0;
+	}
 
 	/* open script if not open already */
 	if ( lscript->dn == NULL &&
 		sieve_script_open(script, NULL) < 0 )
 		return 0;
 
-	/* if modattr not found recompile always */
-	if ( lscript->modattr == NULL || *lscript->modattr == '\0' )
+	/* if modattr not found, recompile always */
+	if ( lscript->modattr == NULL || *lscript->modattr == '\0' ) {
+		sieve_script_sys_error(script,
+			"LDAP entry for script `%s' "
+			"has no modified attribute `%s'",
+			sieve_script_location(script),
+			lstorage->set.sieve_ldap_mod_attr);
 		return 0;
+	}
 
 	/* compare DN in binary and from search result */
 	if ( !sieve_binary_read_string(sblock, offset, &dn) ) {
@@ -149,8 +167,14 @@
 		return -1;
 	}
 	i_assert( lscript->dn != NULL );
-	if ( strcmp(str_c(dn), lscript->dn) != 0 )
+	if ( strcmp(str_c(dn), lscript->dn) != 0 ) {
+		sieve_script_sys_debug(script,
+			"Binary `%s' reports different LDAP DN for script `%s' "
+			"(`%s' rather than `%s')",
+			sieve_binary_path(sbin), sieve_script_location(script),
+			str_c(dn), lscript->dn);
 		return 0;
+	}
 
 	/* compare modattr in binary and from search result */
 	if ( !sieve_binary_read_string(sblock, offset, &modattr) ) {
@@ -160,8 +184,14 @@
 			sieve_binary_path(sbin), sieve_script_location(script));
 		return -1;
 	}
-	if ( strcmp(str_c(modattr), lscript->modattr) != 0 )
+	if ( strcmp(str_c(modattr), lscript->modattr) != 0 ) {
+		sieve_script_sys_debug(script,
+			"Binary `%s' reports different modified attribute content "
+			"for script `%s' (`%s' rather than `%s')",
+			sieve_binary_path(sbin), sieve_script_location(script),
+			str_c(modattr), lscript->modattr);
 		return 0;
+	}
 	return 1;
 }
 
diff -r adbd9fc695d1 -r 0226882e55e1 src/lib-sieve/storage/ldap/sieve-ldap-storage.c
--- a/src/lib-sieve/storage/ldap/sieve-ldap-storage.c	Sat Mar 14 15:31:53 2015 +0100
+++ b/src/lib-sieve/storage/ldap/sieve-ldap-storage.c	Sat Mar 14 15:52:15 2015 +0100
@@ -82,6 +82,7 @@
 		return -1;
 
 	lstorage->username = p_strdup(storage->pool, username);
+	lstorage->config_file = p_strdup(storage->pool, storage->location);
 	lstorage->conn = sieve_ldap_db_init(lstorage);
 
 	storage->location = p_strconcat(storage->pool,
diff -r adbd9fc695d1 -r 0226882e55e1 src/lib-sieve/storage/ldap/sieve-ldap-storage.h
--- a/src/lib-sieve/storage/ldap/sieve-ldap-storage.h	Sat Mar 14 15:31:53 2015 +0100
+++ b/src/lib-sieve/storage/ldap/sieve-ldap-storage.h	Sat Mar 14 15:52:15 2015 +0100
@@ -68,6 +68,7 @@
 	struct sieve_ldap_storage_settings set;
 	time_t set_mtime;
 
+	const char *config_file;
 	const char *username; // FIXME: needed?
 
 	struct ldap_connection *conn;


More information about the dovecot-cvs mailing list