dovecot-2.1: quota-status: Added quota_status_(success|nouser|ov...

dovecot at dovecot.org dovecot at dovecot.org
Thu Apr 4 23:57:05 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.1/rev/c7da636a09c4
changeset: 14947:c7da636a09c4
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 04 23:56:55 2013 +0300
description:
quota-status: Added quota_status_(success|nouser|overquota) settings.

diffstat:

 src/plugins/quota/quota-status.c |  26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diffs (51 lines):

diff -r 2493ec20df8c -r c7da636a09c4 src/plugins/quota/quota-status.c
--- a/src/plugins/quota/quota-status.c	Tue Apr 02 11:52:36 2013 +0300
+++ b/src/plugins/quota/quota-status.c	Thu Apr 04 23:56:55 2013 +0300
@@ -79,7 +79,7 @@
 	struct mail_storage_service_input input;
 	struct mail_storage_service_user *service_user;
 	struct mail_user *user;
-	const char *error;
+	const char *value = NULL, *error;
 	int ret;
 
 	if (client->recipient == NULL) {
@@ -94,21 +94,31 @@
 					       &service_user, &user, &error);
 	restrict_access_allow_coredumps(TRUE);
 	if (ret == 0) {
-		o_stream_send_str(client->conn.output,
-				  "action=REJECT Unknown user\n\n");
+		value = mail_user_plugin_getenv(user, "quota_status_nouser");
+		if (value == NULL)
+			value = "REJECT Unknown user";
 	} else if (ret > 0) {
-		if ((ret = quota_check(user, client->size, &error)) > 0)
-			o_stream_send_str(client->conn.output, "action=OK\n\n");
-		else if (ret == 0) {
-			o_stream_send_str(client->conn.output, t_strdup_printf(
-					  "action=552 5.2.2 %s\n\n", error));
+		if ((ret = quota_check(user, client->size, &error)) > 0) {
+			/* under quota */
+			value = mail_user_plugin_getenv(user, "quota_status_success");
+			if (value == NULL)
+				value = "OK";
+		} else if (ret == 0) {
+			/* over quota */
+			value = mail_user_plugin_getenv(user, "quota_status_overquota");
+			if (value == NULL)
+				value = t_strdup_printf("action=552 5.2.2 %s\n\n", error);
 		}
 		mail_user_unref(&user);
 		mail_storage_service_user_free(&service_user);
 	}
 	if (ret < 0) {
+		/* temporary failure */
 		o_stream_send_str(client->conn.output, t_strdup_printf(
 			"action=DEFER_IF_PERMIT %s\n\n", error));
+	} else {
+		o_stream_send_str(client->conn.output,
+				  t_strdup_printf("action=%s\n\n", value));
 	}
 }
 


More information about the dovecot-cvs mailing list