From e29cc91ebf9cf6ea928b9712fb342b857384b5bd Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Thu, 31 Oct 2024 23:43:50 +0100
Subject: [PATCH] lib-sieve: sieve-storage - Properly handle ~ in bin_path

---
 src/lib-sieve/sieve-storage.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/lib-sieve/sieve-storage.c b/src/lib-sieve/sieve-storage.c
index 5f8bca3d1..1020880f3 100644
--- a/src/lib-sieve/sieve-storage.c
+++ b/src/lib-sieve/sieve-storage.c
@@ -296,7 +296,17 @@ int sieve_storage_alloc_with_settings(struct sieve_instance *svinst,
 	if (ret < 0)
 		return -1;
 
-	storage->bin_path = p_strdup_empty(storage->pool, set->script_bin_path);
+	const char *bin_path = set->script_bin_path;
+
+	if (sieve_storage_get_full_path(storage, bin_path, &bin_path) < 0) {
+		sieve_storage_set_critical(
+			storage,
+			"Binary storage path '%s' is relative to home directory, "
+			"but home directory is not available.", bin_path);
+		return -1;
+	}
+
+	storage->bin_path = p_strdup_empty(storage->pool, bin_path);
 	storage->max_storage = set->quota_storage_size;
 	storage->max_scripts = set->quota_script_count;
 
-- 
GitLab