]> dgit.raspbian.org Git - dovecot.git/commitdiff
[PATCH 5/7] lib-sieve: file storage: Remove orphan compiled binaries on delete and...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 5 May 2026 16:51:27 +0000 (16:51 +0000)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
DELETESCRIPT and RENAMESCRIPT only operated on the .sieve file and
left the matching compiled binary (.svbin) on disk. The orphan was
never referenced again under that name, so it accumulated as wasted
disk space until something else (manual cleanup, account removal)
removed it.

Unlink fscript->bin_path alongside the .sieve operation. The unlink is
best-effort: failures other than ENOENT are logged but do not fail the
DELETE/RENAME.

Gbp-Pq: Name 0005-lib-sieve-file-storage-Remove-orphan-compiled-binari.patch

pigeonhole/src/lib-sieve/storage/file/sieve-file-script.c

index 6cc1dc9387b4e3104b6b6ee15ffe6d8660ac0565..05f8ea376bfa37d6b36f61dca6f415f200ffafe4 100644 (file)
@@ -659,6 +659,14 @@ static int sieve_file_storage_script_delete(struct sieve_script *script)
                                fscript->path);
                }
        }
+
+       /* Best-effort: drop the compiled binary as well so it does not
+          linger as a stale orphan. */
+       if (fscript->bin_path != NULL &&
+           unlink(fscript->bin_path) < 0 && errno != ENOENT) {
+               e_error(script->event,
+                       "unlink(%s) failed: %m", fscript->bin_path);
+       }
        return ret;
 }
 
@@ -791,6 +799,16 @@ sieve_file_storage_script_rename(struct sieve_script *script,
                                                fscript->path);
                                }
 
+                               /* Drop the old compiled binary; the renamed
+                                  script will recompile under its new name. */
+                               if (fscript->bin_path != NULL &&
+                                   unlink(fscript->bin_path) < 0 &&
+                                   errno != ENOENT) {
+                                       e_error(script->event,
+                                               "unlink(%s) failed: %m",
+                                               fscript->bin_path);
+                               }
+
                                if (script->name != NULL && *script->name != '\0')
                                        script->name = p_strdup(script->pool, newname);
                                fscript->path = p_strdup(script->pool, newpath);