]> dgit.raspbian.org Git - dovecot.git/commitdiff
[PATCH 6/7] lib-sieve: Log a warning when cumulative CPU exceeds the limit
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 3 Jun 2026 12:25:38 +0000 (12:25 +0000)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
sieve_binary_record_resource_usage() returned FALSE when the script's
cumulative CPU time crossed sieve_max_cpu_time, but the only log line
on that path was a debug-level "Updated cumulative resource usage"
emitted on every recording, with no signal at the actual disable
transition. Operators had to infer the disable from later "Failed to
open script ... (cumulative resource limit exceeded)" errors on
subsequent deliveries.

Emit a warning at the transition point, including the cumulative CPU
usage that triggered it.

Gbp-Pq: Name 0006-lib-sieve-Log-a-warning-when-cumulative-CPU-exceeds-.patch

pigeonhole/src/lib-sieve/sieve-binary.c

index 2a239cfa5e1f4a072b49fbfd7a976441f685a484..dfc3d0883b094efcfee95164c5808628ef2cac1f 100644 (file)
@@ -248,6 +248,7 @@ bool sieve_binary_record_resource_usage(
        struct sieve_binary *sbin, const struct sieve_resource_usage *rusage)
 {
        struct sieve_resource_usage rusage_total;
+       struct sieve_script *script;
 
        if (sbin == NULL)
                return TRUE;
@@ -262,7 +263,21 @@ bool sieve_binary_record_resource_usage(
        e_debug(sbin->event, "Updated cumulative resource usage: %s",
                sieve_resource_usage_get_summary(&rusage_total));
 
-       return sieve_binary_check_resource_usage(sbin);
+       if (!sieve_resource_usage_is_excessive(sbin->svinst, &rusage_total))
+               return TRUE;
+
+       /* Cumulative resource usage is only tracked for personal scripts;
+          all callers gate this on the user's own script. */
+       script = sbin->script;
+       i_assert(script != NULL);
+       i_assert(sieve_storage_is_personal(script->storage));
+
+       e_warning(sbin->event,
+                 "Personal sieve processing disabled for script '%s': "
+                 "cumulative resource usage limit exceeded (%s)",
+                 sieve_script_label(script),
+                 sieve_resource_usage_get_summary(&rusage_total));
+       return FALSE;
 }
 
 void sieve_binary_set_resource_usage(struct sieve_binary *sbin,