From: Timo Sirainen Date: Wed, 3 Jun 2026 12:25:38 +0000 (+0000) Subject: [PATCH 6/7] lib-sieve: Log a warning when cumulative CPU exceeds the limit X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u7^2~109 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b058ab0668949cb4d8076f6ee70d042d41281aaf;p=dovecot.git [PATCH 6/7] lib-sieve: Log a warning when cumulative CPU exceeds the limit 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 --- diff --git a/pigeonhole/src/lib-sieve/sieve-binary.c b/pigeonhole/src/lib-sieve/sieve-binary.c index 2a239cf..dfc3d08 100644 --- a/pigeonhole/src/lib-sieve/sieve-binary.c +++ b/pigeonhole/src/lib-sieve/sieve-binary.c @@ -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,