From f90ea439b5796ce4a60450d024b0474d14702c3f Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@open-xchange.com> Date: Thu, 31 Oct 2024 13:00:30 +0100 Subject: [PATCH] lib-sieve: storage: file: sieve-file-storage - Omit symlink operations when storage is just a file --- src/lib-sieve/storage/file/sieve-file-storage-active.c | 6 ++++++ src/lib-sieve/storage/file/sieve-file-storage.c | 6 +++--- src/lib-sieve/storage/file/sieve-file-storage.h | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib-sieve/storage/file/sieve-file-storage-active.c b/src/lib-sieve/storage/file/sieve-file-storage-active.c index 9893c35e8..491d97981 100644 --- a/src/lib-sieve/storage/file/sieve-file-storage-active.c +++ b/src/lib-sieve/storage/file/sieve-file-storage-active.c @@ -24,6 +24,12 @@ sieve_file_storage_active_read_link(struct sieve_file_storage *fstorage, const char *error = NULL; int ret; + if (fstorage->is_file) { + /* The storage is in fact a single script file. There is no + concept of an active script in this storage. */ + return 0; + } + ret = t_readlink(fstorage->active_path, link_r, &error); if (ret < 0) { *link_r = NULL; diff --git a/src/lib-sieve/storage/file/sieve-file-storage.c b/src/lib-sieve/storage/file/sieve-file-storage.c index be3d7d4a8..c6fa4773a 100644 --- a/src/lib-sieve/storage/file/sieve-file-storage.c +++ b/src/lib-sieve/storage/file/sieve-file-storage.c @@ -294,7 +294,6 @@ sieve_file_storage_init_common(struct sieve_file_storage *fstorage, { struct sieve_storage *storage = &fstorage->storage; const char *tmp_dir, *link_path, *active_fname, *storage_dir, *error; - bool have_link = FALSE; int ret; i_assert(storage_path != NULL || active_path != NULL); @@ -360,7 +359,7 @@ sieve_file_storage_init_common(struct sieve_file_storage *fstorage, if (storage_path != NULL && *storage_path != '\0') { e_debug(storage->event, "Using script storage path: %s", storage_path); - have_link = TRUE; + fstorage->is_file = FALSE; } else { if ((storage->flags & SIEVE_STORAGE_FLAG_READWRITE) != 0) { sieve_storage_set_critical(storage, @@ -369,6 +368,7 @@ sieve_file_storage_init_common(struct sieve_file_storage *fstorage, } storage_path = active_path; + fstorage->is_file = TRUE; } i_assert(storage_path != NULL); @@ -449,7 +449,7 @@ sieve_file_storage_init_common(struct sieve_file_storage *fstorage, if (!exists && sieve_file_storage_stat(fstorage, storage_path) < 0) return -1; - if (have_link) { + if (!fstorage->is_file) { if (t_realpath(storage_path, &storage_path, &error) < 0) { sieve_storage_set_critical(storage, "Failed to normalize storage path (path=%s): %s", diff --git a/src/lib-sieve/storage/file/sieve-file-storage.h b/src/lib-sieve/storage/file/sieve-file-storage.h index d73a1911e..e07d8bff9 100644 --- a/src/lib-sieve/storage/file/sieve-file-storage.h +++ b/src/lib-sieve/storage/file/sieve-file-storage.h @@ -40,6 +40,8 @@ struct sieve_file_storage { gid_t file_create_gid; time_t prev_mtime; + + bool is_file:1; }; const char * -- GitLab