dovecot-2.2: quota: Improved init() failure error logging.

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 7 16:09:37 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/a07ab0c638d2
changeset: 16677:a07ab0c638d2
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 07 16:09:29 2013 +0300
description:
quota: Improved init() failure error logging.

diffstat:

 src/plugins/quota/quota-dict.c    |  7 ++++---
 src/plugins/quota/quota-fs.c      |  5 +++--
 src/plugins/quota/quota-maildir.c |  5 +++--
 src/plugins/quota/quota-private.h |  3 ++-
 src/plugins/quota/quota.c         |  5 +++--
 5 files changed, 15 insertions(+), 10 deletions(-)

diffs (102 lines):

diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-dict.c
--- a/src/plugins/quota/quota-dict.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-dict.c	Wed Aug 07 16:09:29 2013 +0300
@@ -28,14 +28,15 @@
 	return &root->root;
 }
 
-static int dict_quota_init(struct quota_root *_root, const char *args)
+static int dict_quota_init(struct quota_root *_root, const char *args,
+			   const char **error_r)
 {
 	struct dict_quota_root *root = (struct dict_quota_root *)_root;
 	const char *username, *p, *error;
 
 	p = args == NULL ? NULL : strchr(args, ':');
 	if (p == NULL) {
-		i_error("dict quota: URI missing from parameters");
+		*error_r = "URI missing from parameters";
 		return -1;
 	}
 
@@ -80,7 +81,7 @@
 	if (dict_init(args, DICT_DATA_TYPE_STRING, username,
 		      _root->quota->user->set->base_dir, &root->dict,
 		      &error) < 0) {
-		i_error("dict quota: dict_init(%s) failed: %s", args, error);
+		*error_r = t_strdup_printf("dict_init(%s) failed: %s", args, error);
 		return -1;
 	}
 	return 0;
diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-fs.c
--- a/src/plugins/quota/quota-fs.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-fs.c	Wed Aug 07 16:09:29 2013 +0300
@@ -95,7 +95,8 @@
 	return &root->root;
 }
 
-static int fs_quota_init(struct quota_root *_root, const char *args)
+static int fs_quota_init(struct quota_root *_root, const char *args,
+			 const char **error_r)
 {
 	struct fs_quota_root *root = (struct fs_quota_root *)_root;
 	const char *const *tmp;
@@ -116,7 +117,7 @@
 			i_free(root->storage_mount_path);
 			root->storage_mount_path = i_strdup(*tmp + 6);
 		} else {
-			i_error("fs quota: Invalid parameter: %s", *tmp);
+			*error_r = t_strdup_printf("Invalid parameter: %s", *tmp);
 			return -1;
 		}
 	}
diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-maildir.c	Wed Aug 07 16:09:29 2013 +0300
@@ -753,7 +753,8 @@
 	return &root->root;
 }
 
-static int maildir_quota_init(struct quota_root *_root, const char *args)
+static int maildir_quota_init(struct quota_root *_root, const char *args,
+			      const char **error_r)
 {
 	const char *const *tmp;
 
@@ -768,7 +769,7 @@
 		else if (strncmp(*tmp, "ns=", 3) == 0)
 			_root->ns_prefix = p_strdup(_root->pool, *tmp + 3);
 		else {
-			i_error("maildir quota: Invalid parameter: %s", *tmp);
+			*error_r = t_strdup_printf("Invalid parameter: %s", *tmp);
 			return -1;
 		}
 	}
diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota-private.h	Wed Aug 07 16:09:29 2013 +0300
@@ -48,7 +48,8 @@
 
 struct quota_backend_vfuncs {
 	struct quota_root *(*alloc)(void);
-	int (*init)(struct quota_root *root, const char *args);
+	int (*init)(struct quota_root *root, const char *args,
+		    const char **error_r);
 	void (*deinit)(struct quota_root *root);
 
 	bool (*parse_rule)(struct quota_root_settings *root_set,
diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Tue Aug 06 18:44:37 2013 +0000
+++ b/src/plugins/quota/quota.c	Wed Aug 07 16:09:29 2013 +0300
@@ -270,8 +270,9 @@
 		     sizeof(void *), 10);
 
 	if (root->backend.v.init != NULL) {
-		if (root->backend.v.init(root, root_set->args) < 0) {
-			*error_r = "init() failed";
+		if (root->backend.v.init(root, root_set->args, error_r) < 0) {
+			*error_r = t_strdup_printf("%s quota init failed: %s",
+					root->backend.name, *error_r);
 			return -1;
 		}
 	} else if (root_set->args != NULL) {


More information about the dovecot-cvs mailing list