Discussion:
[PATCH] make autocreate_quota:0 work as documented
Donald Buczek
10 years ago
Permalink
Hello,

with cyrus-imapd-2.5.3 the autocreate_quota parameter doesn't work as documented
by imapd.conf(5) when set to the value 0. This should enable autocreation with
unlimited quota, but it doesn't.

This patch fixed it for me.

Regards
Donald Buczek


---
imap/autocreate.c | 4 ++--
imap/imapd.c | 2 +-
imap/lmtpd.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/imap/autocreate.c b/imap/autocreate.c
index f4c78fd..2ddd6d7 100644
--- a/imap/autocreate.c
+++ b/imap/autocreate.c
@@ -698,14 +698,14 @@ int autocreate_user(struct namespace *namespace,
goto done;
}

- if (autocreatequota >= 0 || autocreatequotamessage >= 0) {
+ if (autocreatequota > 0 || autocreatequotamessage >= 0) {
quota_t newquotas[QUOTA_NUMRESOURCES];
int res;

for (res = 0 ; res < QUOTA_NUMRESOURCES ; res++)
newquotas[res] = QUOTA_UNLIMITED;

- newquotas[QUOTA_STORAGE] = autocreatequota;
+ newquotas[QUOTA_STORAGE] = autocreatequota !=0 ? autocreatequota : QUOTA_UNLIMITED;
newquotas[QUOTA_MESSAGE] = autocreatequotamessage;

r = mboxlist_setquotas(inboxname, newquotas, 0);
diff --git a/imap/imapd.c b/imap/imapd.c
index 1a553b4..838eacd 100644
--- a/imap/imapd.c
+++ b/imap/imapd.c
@@ -2277,7 +2277,7 @@ static void autocreate_inbox(void)
if (imapd_userisadmin) return;
if (imapd_userisproxyadmin) return;

- if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)>=0) {
char *inboxname = mboxname_user_mbox(imapd_userid, NULL);
int r = mboxlist_lookup(inboxname, NULL, NULL);
free(inboxname);
diff --git a/imap/lmtpd.c b/imap/lmtpd.c
index 4d55ae1..f97a052 100644
--- a/imap/lmtpd.c
+++ b/imap/lmtpd.c
@@ -1111,7 +1111,7 @@ int autocreate_inbox(const char *user, const char *domain)
/*
* Check for autocreatequota and createonpost
*/
- if (!config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)<0) {
free(username);
return IMAP_MAILBOX_NONEXISTENT;
}
--
2.3.4
Donald Buczek
10 years ago
Permalink
Anything wrong with this?

D.


-------- Forwarded Message --------
Subject: [PATCH] make autocreate_quota:0 work as documented
Date: Wed, 27 May 2015 13:57:59 +0200
From: Donald Buczek <***@molgen.mpg.de>
To: cyrus-***@lists.andrew.cmu.edu
CC: Donald Buczek <***@molgen.mpg.de>



Hello,

with cyrus-imapd-2.5.3 the autocreate_quota parameter doesn't work as documented
by imapd.conf(5) when set to the value 0. This should enable autocreation with
unlimited quota, but it doesn't.

This patch fixed it for me.

Regards
Donald Buczek


---
imap/autocreate.c | 4 ++--
imap/imapd.c | 2 +-
imap/lmtpd.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/imap/autocreate.c b/imap/autocreate.c
index f4c78fd..2ddd6d7 100644
--- a/imap/autocreate.c
+++ b/imap/autocreate.c
@@ -698,14 +698,14 @@ int autocreate_user(struct namespace *namespace,
goto done;
}

- if (autocreatequota >= 0 || autocreatequotamessage >= 0) {
+ if (autocreatequota > 0 || autocreatequotamessage >= 0) {
quota_t newquotas[QUOTA_NUMRESOURCES];
int res;

for (res = 0 ; res < QUOTA_NUMRESOURCES ; res++)
newquotas[res] = QUOTA_UNLIMITED;

- newquotas[QUOTA_STORAGE] = autocreatequota;
+ newquotas[QUOTA_STORAGE] = autocreatequota !=0 ? autocreatequota : QUOTA_UNLIMITED;
newquotas[QUOTA_MESSAGE] = autocreatequotamessage;

r = mboxlist_setquotas(inboxname, newquotas, 0);
diff --git a/imap/imapd.c b/imap/imapd.c
index 1a553b4..838eacd 100644
--- a/imap/imapd.c
+++ b/imap/imapd.c
@@ -2277,7 +2277,7 @@ static void autocreate_inbox(void)
if (imapd_userisadmin) return;
if (imapd_userisproxyadmin) return;

- if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)>=0) {
char *inboxname = mboxname_user_mbox(imapd_userid, NULL);
int r = mboxlist_lookup(inboxname, NULL, NULL);
free(inboxname);
diff --git a/imap/lmtpd.c b/imap/lmtpd.c
index 4d55ae1..f97a052 100644
--- a/imap/lmtpd.c
+++ b/imap/lmtpd.c
@@ -1111,7 +1111,7 @@ int autocreate_inbox(const char *user, const char *domain)
/*
* Check for autocreatequota and createonpost
*/
- if (!config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)<0) {
free(username);
return IMAP_MAILBOX_NONEXISTENT;
}
--
2.3.4
ellie timoney
10 years ago
Permalink
Hi Donald,

I'm currently maintaining the 2.5 series.� Your patch looks okay at a
glance, it just had the misfortune of being sent through the day after
I'd gone on leave for a few weeks.

But I'm back now, and hope to look this over more closely and get it
merged sometime this week.� Thanks for the contribution!

Regards,

Ellie
Post by Donald Buczek
Anything wrong with this?
D.
-------- Forwarded Message --------
Post by Donald Buczek
Subject: [PATCH] make autocreate_quota:0 work as documented Date: Wed,
Hello,
with cyrus-imapd-2.5.3 the autocreate_quota parameter doesn't work as
documented by imapd.conf(5) when set to the value 0. This should enable
autocreation with unlimited quota, but it doesn't.

This patch fixed it for me.

Regards
Donald Buczek


---
imap/autocreate.c | 4 ++-- imap/imapd.c | 2 +- imap/lmtpd.c |
2 +- 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/imap/autocreate.c b/imap/autocreate.c index
f4c78fd..2ddd6d7 100644 --- a/imap/autocreate.c +++ b/imap/autocreate.c
@@ -698,14 +698,14 @@ int autocreate_user(struct namespace *namespace,
goto done; }

- if (autocreatequota >= 0 || autocreatequotamessage >= 0) {
+ if (autocreatequota > 0 || autocreatequotamessage >= 0) { quota_t
newquotas[QUOTA_NUMRESOURCES]; int res;

for (res = 0 ; res < QUOTA_NUMRESOURCES ; res++)
newquotas[res] = QUOTA_UNLIMITED;

- newquotas[QUOTA_STORAGE] = autocreatequota;
+ newquotas[QUOTA_STORAGE] = autocreatequota !=0 ? autocreatequota
: QUOTA_UNLIMITED; newquotas[QUOTA_MESSAGE] =
autocreatequotamessage;

r = mboxlist_setquotas(inboxname, newquotas, 0); diff --git
a/imap/imapd.c b/imap/imapd.c index 1a553b4..838eacd 100644 ---
a/imap/imapd.c +++ b/imap/imapd.c @@ -2277,7 +2277,7 @@ static
void autocreate_inbox(void) if (imapd_userisadmin) return; if
(imapd_userisproxyadmin) return;

- if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)>=0) { char *inboxname
= mboxname_user_mbox(imapd_userid, NULL); int r =
mboxlist_lookup(inboxname, NULL, NULL); free(inboxname); diff --
git a/imap/lmtpd.c b/imap/lmtpd.c index 4d55ae1..f97a052 100644 ---
a/imap/lmtpd.c +++ b/imap/lmtpd.c @@ -1111,7 +1111,7 @@ int
autocreate_inbox(const char *user, const char *domain) /*
* Check for autocreatequota and createonpost */
- if (!config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)<0) { free(username);
return IMAP_MAILBOX_NONEXISTENT; }
--
2.3.4
ellie timoney
10 years ago
Permalink
Hi Donald,

I've made a few cleanups and merged your patch.� It will be included in
the next release.

Thanks!

Ellie
...
with cyrus-imapd-2.5.3 the autocreate_quota parameter doesn't work as
documented by imapd.conf(5) when set to the value 0. This should enable
autocreation with unlimited quota, but it doesn't.

This patch fixed it for me.

Regards
Donald Buczek


---
imap/autocreate.c | 4 ++-- imap/imapd.c | 2 +- imap/lmtpd.c |
2 +- 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/imap/autocreate.c b/imap/autocreate.c index
f4c78fd..2ddd6d7 100644 --- a/imap/autocreate.c +++ b/imap/autocreate.c
@@ -698,14 +698,14 @@ int autocreate_user(struct namespace *namespace,
goto done; }

- if (autocreatequota >= 0 || autocreatequotamessage >= 0) {
+ if (autocreatequota > 0 || autocreatequotamessage >= 0) { quota_t
newquotas[QUOTA_NUMRESOURCES]; int res;

for (res = 0 ; res < QUOTA_NUMRESOURCES ; res++)
newquotas[res] = QUOTA_UNLIMITED;

- newquotas[QUOTA_STORAGE] = autocreatequota;
+ newquotas[QUOTA_STORAGE] = autocreatequota !=0 ? autocreatequota
: QUOTA_UNLIMITED; newquotas[QUOTA_MESSAGE] =
autocreatequotamessage;

r = mboxlist_setquotas(inboxname, newquotas, 0); diff --git
a/imap/imapd.c b/imap/imapd.c index 1a553b4..838eacd 100644 ---
a/imap/imapd.c +++ b/imap/imapd.c @@ -2277,7 +2277,7 @@ static
void autocreate_inbox(void) if (imapd_userisadmin) return; if
(imapd_userisproxyadmin) return;

- if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)>=0) { char *inboxname
= mboxname_user_mbox(imapd_userid, NULL); int r =
mboxlist_lookup(inboxname, NULL, NULL); free(inboxname); diff --
git a/imap/lmtpd.c b/imap/lmtpd.c index 4d55ae1..f97a052 100644 ---
a/imap/lmtpd.c +++ b/imap/lmtpd.c @@ -1111,7 +1111,7 @@ int
autocreate_inbox(const char *user, const char *domain) /*
* Check for autocreatequota and createonpost */
- if (!config_getint(IMAPOPT_AUTOCREATE_QUOTA)) {
+ if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)<0) { free(username);
return IMAP_MAILBOX_NONEXISTENT; }
--
2.3.4
Loading...