dovecot-2.1: quota-status: Unknown recipients caused a crash.

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 5 13:21:47 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.1/rev/c6b4a639cae1
changeset: 14952:c6b4a639cae1
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 05 13:21:40 2013 +0300
description:
quota-status: Unknown recipients caused a crash.

diffstat:

 src/plugins/quota/Makefile.am    |   1 +
 src/plugins/quota/quota-status.c |  31 ++++++++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diffs (84 lines):

diff -r c42846219939 -r c6b4a639cae1 src/plugins/quota/Makefile.am
--- a/src/plugins/quota/Makefile.am	Fri Apr 05 00:08:40 2013 +0300
+++ b/src/plugins/quota/Makefile.am	Fri Apr 05 13:21:40 2013 +0300
@@ -5,6 +5,7 @@
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/lib \
+	-I$(top_srcdir)/src/lib-settings \
 	-I$(top_srcdir)/src/lib-master \
 	-I$(top_srcdir)/src/lib-dict \
 	-I$(top_srcdir)/src/lib-index \
diff -r c42846219939 -r c6b4a639cae1 src/plugins/quota/quota-status.c
--- a/src/plugins/quota/quota-status.c	Fri Apr 05 00:08:40 2013 +0300
+++ b/src/plugins/quota/quota-status.c	Fri Apr 05 13:21:40 2013 +0300
@@ -4,7 +4,9 @@
 #include "ostream.h"
 #include "connection.h"
 #include "restrict-access.h"
+#include "settings-parser.h"
 #include "master-service.h"
+#include "master-service-settings.h"
 #include "mail-namespace.h"
 #include "mail-storage.h"
 #include "mail-storage-settings.h"
@@ -27,6 +29,7 @@
 static enum quota_protocol protocol;
 static struct mail_storage_service_ctx *storage_service;
 static struct connection_list *clients;
+static char *nouser_reply;
 
 static void client_connected(struct master_service_connection *conn)
 {
@@ -94,9 +97,7 @@
 					       &service_user, &user, &error);
 	restrict_access_allow_coredumps(TRUE);
 	if (ret == 0) {
-		value = mail_user_plugin_getenv(user, "quota_status_nouser");
-		if (value == NULL)
-			value = "REJECT Unknown user";
+		value = nouser_reply;
 	} else if (ret > 0) {
 		if ((ret = quota_check(user, client->size, &error)) > 0) {
 			/* under quota */
@@ -173,16 +174,40 @@
 
 static void main_init(void)
 {
+	struct mail_storage_service_input input;
+	const struct setting_parser_info *user_info;
+	const struct setting_parser_context *set_parser;
+	const struct mail_user_settings *user_set;
+	const char *value, *error;
+	pool_t pool;
+
 	clients = connection_list_init(&client_set, &client_vfuncs);
 	storage_service = mail_storage_service_init(master_service, NULL,
 		MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP |
 		MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP |
 		MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS |
 		MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR);
+
+	memset(&input, 0, sizeof(input));
+	input.service = "quota-status";
+	input.module = "mail";
+	input.username = "";
+
+	pool = pool_alloconly_create("service all settings", 4096);
+	if (mail_storage_service_read_settings(storage_service, &input, pool,
+					       &user_info, &set_parser,
+					       &error) < 0)
+		i_fatal("%s", error);
+	user_set = settings_parser_get_list(set_parser)[1];
+	value = mail_user_set_plugin_getenv(user_set, "quota_status_nouser");
+	nouser_reply = value != NULL ? i_strdup(value) :
+		i_strdup("REJECT Unknown user");
+	pool_unref(&pool);
 }
 
 static void main_deinit(void)
 {
+	i_free(nouser_reply);
 	connection_list_deinit(&clients);
 	mail_storage_service_deinit(&storage_service);
 }


More information about the dovecot-cvs mailing list