qmail->super.expunge(_mail);
}
+static int
+quota_create_box(struct mailbox *box, const struct mailbox_update *update,
+ bool directory)
+{
+ struct quota_mailbox *qbox = QUOTA_CONTEXT_REQUIRE(box);
+ struct quota_user *quser =
+ QUOTA_USER_CONTEXT_REQUIRE(box->storage->user);
+ struct quota_settings *quota_set = quser->quota->set;
+ unsigned int mailbox_count;
+
+ if (quota_set->max_mailbox_count == 0) {
+ /* no mailbox count limit */
+ } else if (mailbox_is_autocreated(box)) {
+ /* Always allow autocreated mailbox to be created.
+ There shouldn't be many of them */
+ } else if (mailbox_list_get_count(box->list, &mailbox_count) < 0) {
+ mail_storage_copy_list_error(box->storage, box->list);
+ return -1;
+ } else if (mailbox_count >= quota_set->max_mailbox_count) {
+ mail_storage_set_error(box->storage, MAIL_ERROR_LIMIT,
+ "Maximum number of mailboxes reached");
+ return -1;
+ }
+ return qbox->module_ctx.super.create_box(box, update, directory);
+}
+
static int
quota_get_status(struct mailbox *box, enum mailbox_status_items items,
struct mailbox_status *status_r)
qbox->module_ctx.super = *v;
box->vlast = &qbox->module_ctx.super;
+ v->create_box = quota_create_box;
v->get_status = quota_get_status;
v->transaction_begin = quota_mailbox_transaction_begin;
v->transaction_commit = quota_mailbox_transaction_commit;
if (quota_set->quota_exceeded_msg == NULL)
quota_set->quota_exceeded_msg = DEFAULT_QUOTA_EXCEEDED_MSG;
+ const char *mailbox_count =
+ mail_user_plugin_getenv(user, "quota_mailbox_count");
+ if (mailbox_count != NULL) {
+ if (str_to_uint(mailbox_count, "a_set->max_mailbox_count) < 0) {
+ *error_r = "Invalid quota_mailbox_count";
+ return -1;
+ }
+ }
+
const char *max_size = mail_user_plugin_getenv(user,
"quota_max_mail_size");
if (max_size != NULL) {