dovecot-2.2: quota-status: If size parameter is given, use it to...

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 5 00:13:33 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/2493ec20df8c
changeset: 16192:2493ec20df8c
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 02 11:52:36 2013 +0300
description:
quota-status: If size parameter is given, use it to check quota.

diffstat:

 src/plugins/quota/quota-status.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (50 lines):

diff -r b2fad9b21e60 -r 2493ec20df8c src/plugins/quota/quota-status.c
--- a/src/plugins/quota/quota-status.c	Tue Apr 02 11:32:24 2013 +0300
+++ b/src/plugins/quota/quota-status.c	Tue Apr 02 11:52:36 2013 +0300
@@ -21,6 +21,7 @@
 	struct connection conn;
 
 	char *recipient;
+	uoff_t size;
 };
 
 static enum quota_protocol protocol;
@@ -42,7 +43,8 @@
 	i_free_and_null(client->recipient);
 }
 
-static int quota_check(struct mail_user *user, const char **error_r)
+static int
+quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r)
 {
 	struct quota_user *quser = QUOTA_USER_CONTEXT(user);
 	struct mail_namespace *ns;
@@ -60,7 +62,7 @@
 	box = mailbox_alloc(ns->list, "INBOX", 0);
 
 	ctx = quota_transaction_begin(box);
-	ret = quota_test_alloc(ctx, 1, &too_large);
+	ret = quota_test_alloc(ctx, I_MAX(1, mail_size), &too_large);
 	quota_transaction_rollback(&ctx);
 
 	mailbox_free(&box);
@@ -95,7 +97,7 @@
 		o_stream_send_str(client->conn.output,
 				  "action=REJECT Unknown user\n\n");
 	} else if (ret > 0) {
-		if ((ret = quota_check(user, &error)) > 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(
@@ -124,6 +126,10 @@
 	if (client->recipient == NULL &&
 	    strncmp(line, "recipient=", 10) == 0)
 		client->recipient = i_strdup(line + 10);
+	else if (strncmp(line, "size=", 5) == 0) {
+		if (str_to_uoff(line+5, &client->size) < 0)
+			client->size = 0;
+	}
 	return 1;
 }
 


More information about the dovecot-cvs mailing list