]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: If quota_over_script is unset, skip the quota_over check.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 7 Feb 2017 13:46:47 +0000 (15:46 +0200)
committerGitLab <gitlab@git.dovecot.net>
Mon, 13 Feb 2017 10:52:05 +0000 (12:52 +0200)
src/plugins/quota/quota.c

index e03a317bbde4103cbd8cff03dcfd109888255d92..f30c3d0fd069f00dc6f6b5289499d41b16f54d2c 100644 (file)
@@ -1026,6 +1026,7 @@ int quota_transaction_commit(struct quota_transaction_context **_ctx)
 }
 
 static bool quota_over_flag_init_root(struct quota_root *root,
+                                     const char **quota_over_script_r,
                                      const char **quota_over_flag_r,
                                      bool *status_r)
 {
@@ -1034,6 +1035,11 @@ static bool quota_over_flag_init_root(struct quota_root *root,
        *quota_over_flag_r = NULL;
        *status_r = FALSE;
 
+       name = t_strconcat(root->set->set_name, "_over_script", NULL);
+       *quota_over_script_r = mail_user_plugin_getenv(root->quota->user, name);
+       if (*quota_over_script_r == NULL)
+               return FALSE;
+
        /* e.g.: quota_over_flag_value=TRUE or quota_over_flag_value=*  */
        name = t_strconcat(root->set->set_name, "_over_flag_value", NULL);
        flag_mask = mail_user_plugin_getenv(root->quota->user, name);
@@ -1051,7 +1057,7 @@ static bool quota_over_flag_init_root(struct quota_root *root,
 
 static void quota_over_flag_check_root(struct quota_root *root)
 {
-       const char *name, *overquota_script, *quota_over_flag;
+       const char *quota_over_script, *quota_over_flag;
        const char *const *resources;
        unsigned int i;
        uint64_t value, limit;
@@ -1073,7 +1079,8 @@ static void quota_over_flag_check_root(struct quota_root *root)
                return;
        }
        root->quota_over_flag_checked = TRUE;
-       if (!quota_over_flag_init_root(root, &quota_over_flag, &quota_over_status))
+       if (!quota_over_flag_init_root(root, &quota_over_script,
+                                      &quota_over_flag, &quota_over_status))
                return;
 
        resources = quota_root_get_resources(root);
@@ -1103,13 +1110,8 @@ static void quota_over_flag_check_root(struct quota_root *root)
                        cur_overquota ? 1 : 0);
        }
        if (cur_overquota != quota_over_status) {
-               name = t_strconcat(root->set->set_name, "_over_script", NULL);
-               overquota_script = mail_user_plugin_getenv(root->quota->user, name);
-               if (overquota_script != NULL) {
-                       quota_warning_execute(root, overquota_script,
-                                             quota_over_flag,
-                                             "quota_over_flag mismatch");
-               }
+               quota_warning_execute(root, quota_over_script, quota_over_flag,
+                                     "quota_over_flag mismatch");
        }
 }