From 47a65d1f8061371697365fd0dd75d7ceec8746a5 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Wed, 9 Oct 2024 21:18:18 +0200
Subject: [PATCH] lib-sieve: sieve-storage - Use sieve_script_label() rather
 than sieve_script_location()

For now, these yield the same result.
---
 src/lib-sieve/plugins/include/cmd-include.c   |  5 +-
 .../plugins/include/ext-include-binary.c      |  4 +-
 src/lib-sieve/sieve-binary.c                  |  4 +-
 src/lib-sieve/sieve-script.c                  | 13 +++--
 src/lib-sieve/sieve-script.h                  |  1 +
 src/lib-sieve/sieve-storage.h                 |  1 +
 src/lib-sieve/sieve.c                         |  9 ++--
 .../storage/dict/sieve-dict-script.c          |  6 +--
 .../storage/file/sieve-file-script.c          |  6 +--
 .../storage/ldap/sieve-ldap-script.c          | 10 ++--
 src/managesieve/cmd-getscript.c               | 17 +++---
 .../imap-filter-sieve/imap-filter-sieve.c     | 40 +++++++-------
 src/plugins/imapsieve/imap-sieve.c            | 40 +++++++-------
 src/plugins/lda-sieve/lda-sieve-plugin.c      | 52 +++++++++----------
 14 files changed, 105 insertions(+), 103 deletions(-)

diff --git a/src/lib-sieve/plugins/include/cmd-include.c b/src/lib-sieve/plugins/include/cmd-include.c
index d5d9af38a..f83e4d925 100644
--- a/src/lib-sieve/plugins/include/cmd-include.c
+++ b/src/lib-sieve/plugins/include/cmd-include.c
@@ -360,9 +360,8 @@ static bool opc_include_dump(const struct sieve_dumptime_env *denv,
 
 	sieve_code_descend(denv);
 	sieve_code_dumpf(
-		denv, "script: '%s' from %s %s%s[ID: %d, BLOCK: %d]",
-		sieve_script_name(included->script),
-		sieve_script_location(included->script),
+		denv, "script: '%s' %s%s[ID: %d, BLOCK: %d]",
+		sieve_script_label(included->script),
 		((flags & EXT_INCLUDE_FLAG_ONCE) != 0 ? "(once) " : ""),
 		((flags & EXT_INCLUDE_FLAG_OPTIONAL) != 0 ? "(optional) " : ""),
 		include_id, sieve_binary_block_get_id(included->block));
diff --git a/src/lib-sieve/plugins/include/ext-include-binary.c b/src/lib-sieve/plugins/include/ext-include-binary.c
index d79b569d4..0988424f2 100644
--- a/src/lib-sieve/plugins/include/ext-include-binary.c
+++ b/src/lib-sieve/plugins/include/ext-include-binary.c
@@ -408,9 +408,9 @@ ext_include_binary_open(const struct sieve_extension *ext,
 			/* Binary is corrupt, recompile */
 			e_error(svinst->event, "include: "
 				"dependency block %d of binary %s "
-				"contains invalid script metadata for script %s",
+				"contains invalid script metadata for script '%s'",
 				block_id, sieve_binary_path(sbin),
-				sieve_script_location(script));
+				sieve_script_label(script));
 			sieve_script_unref(&script);
 			return FALSE;
 		}
diff --git a/src/lib-sieve/sieve-binary.c b/src/lib-sieve/sieve-binary.c
index 774ce7059..45247579a 100644
--- a/src/lib-sieve/sieve-binary.c
+++ b/src/lib-sieve/sieve-binary.c
@@ -284,7 +284,7 @@ bool sieve_binary_loaded(struct sieve_binary *sbin)
 const char *sieve_binary_source(struct sieve_binary *sbin)
 {
 	if (sbin->script != NULL && (sbin->path == NULL || sbin->file == NULL))
-		return sieve_script_location(sbin->script);
+		return sieve_script_label(sbin->script);
 
 	return sbin->path;
 }
@@ -315,7 +315,7 @@ const char *sieve_binary_script_name(struct sieve_binary *sbin)
 const char *sieve_binary_script_location(struct sieve_binary *sbin)
 {
 	return (sbin->script == NULL ?
-		NULL : sieve_script_location(sbin->script));
+		NULL : sieve_script_label(sbin->script));
 }
 
 /*
diff --git a/src/lib-sieve/sieve-script.c b/src/lib-sieve/sieve-script.c
index be5bdc820..efdde6369 100644
--- a/src/lib-sieve/sieve-script.c
+++ b/src/lib-sieve/sieve-script.c
@@ -306,6 +306,11 @@ const char *sieve_script_location(const struct sieve_script *script)
 	return script->location;
 }
 
+const char *sieve_script_label(const struct sieve_script *script)
+{
+	return script->location;
+}
+
 struct sieve_instance *sieve_script_svinst(const struct sieve_script *script)
 {
 	return script->storage->svinst;
@@ -447,14 +452,14 @@ int sieve_script_binary_read_metadata(struct sieve_script *script,
 		e_error(script->event,
 			"Binary '%s' has invalid metadata for script '%s': "
 			"Invalid storage class",
-			sieve_binary_path(sbin), script->location);
+			sieve_binary_path(sbin), sieve_script_label(script));
 		return -1;
 	}
 	if (strcmp(str_c(storage_class), script->driver_name) != 0) {
 		e_debug(script->event,
 			"Binary '%s' reports unexpected driver name for script '%s' "
 			"('%s' rather than '%s')",
-			sieve_binary_path(sbin), script->location,
+			sieve_binary_path(sbin), sieve_script_label(script),
 			str_c(storage_class), script->driver_name);
 		return 0;
 	}
@@ -464,7 +469,7 @@ int sieve_script_binary_read_metadata(struct sieve_script *script,
 		e_error(script->event,
 			"Binary '%s' has invalid metadata for script '%s': "
 			"Invalid version",
-			sieve_binary_path(sbin), script->location);
+			sieve_binary_path(sbin), sieve_script_label(script));
 		return -1;
 	}
 	if (script->storage->version != version) {
@@ -483,7 +488,7 @@ int sieve_script_binary_read_metadata(struct sieve_script *script,
 		e_error(script->event,
 			"Binary '%s' has invalid metadata for script '%s': "
 			"Invalid location",
-			sieve_binary_path(sbin), script->location);
+			sieve_binary_path(sbin), sieve_script_label(script));
 		return -1;
 	}
 	i_assert(script->location != NULL);
diff --git a/src/lib-sieve/sieve-script.h b/src/lib-sieve/sieve-script.h
index a409eb1a2..1d6be3f3d 100644
--- a/src/lib-sieve/sieve-script.h
+++ b/src/lib-sieve/sieve-script.h
@@ -110,6 +110,7 @@ int sieve_script_delete(struct sieve_script *script, bool ignore_active);
  */
 
 const char *sieve_script_name(const struct sieve_script *script) ATTR_PURE;
+const char *sieve_script_label(const struct sieve_script *script) ATTR_PURE;
 const char *sieve_script_location(const struct sieve_script *script) ATTR_PURE;
 struct sieve_instance *
 sieve_script_svinst(const struct sieve_script *script) ATTR_PURE;
diff --git a/src/lib-sieve/sieve-storage.h b/src/lib-sieve/sieve-storage.h
index 0fe2a3c1b..9ba836f5f 100644
--- a/src/lib-sieve/sieve-storage.h
+++ b/src/lib-sieve/sieve-storage.h
@@ -151,6 +151,7 @@ int sieve_storage_quota_havespace(struct sieve_storage *storage,
  * Properties
  */
 
+const char *sieve_storage_name(const struct sieve_storage *storage) ATTR_PURE;
 const char *sieve_storage_location(const struct sieve_storage *storage)
 	ATTR_PURE;
 bool sieve_storage_is_default(const struct sieve_storage *storage) ATTR_PURE;
diff --git a/src/lib-sieve/sieve.c b/src/lib-sieve/sieve.c
index 6319d5395..e0dcdf245 100644
--- a/src/lib-sieve/sieve.c
+++ b/src/lib-sieve/sieve.c
@@ -358,8 +358,8 @@ int sieve_compile(struct sieve_instance *svinst, const char *script_location,
 		return -1;
 	}
 
-	e_debug(svinst->event, "Script '%s' from %s successfully compiled",
-		sieve_script_name(script), sieve_script_location(script));
+	e_debug(svinst->event, "Script '%s' successfully compiled",
+		sieve_script_label(script));
 
 	sieve_script_unref(&script);
 	return 0;
@@ -443,9 +443,8 @@ sieve_open_script_real(struct sieve_script *script,
 			return -1;
 
 		e_debug(svinst->event,
-			"Script '%s' from %s successfully compiled",
-			sieve_script_name(script),
-			sieve_script_location(script));
+			"Script '%s' successfully compiled",
+			sieve_script_label(script));
 
 		sieve_binary_set_resource_usage(sbin, &rusage);
 	}
diff --git a/src/lib-sieve/storage/dict/sieve-dict-script.c b/src/lib-sieve/storage/dict/sieve-dict-script.c
index 791a6ac27..8e8b83653 100644
--- a/src/lib-sieve/storage/dict/sieve-dict-script.c
+++ b/src/lib-sieve/storage/dict/sieve-dict-script.c
@@ -158,15 +158,15 @@ sieve_dict_script_binary_read_metadata(struct sieve_script *script,
 	if (!sieve_binary_read_string(sblock, offset, &data_id)) {
 		e_error(script->event,
 			"Binary '%s' has invalid metadata for script '%s'",
-			sieve_binary_path(sbin), sieve_script_location(script));
+			sieve_binary_path(sbin), sieve_script_label(script));
 		return -1;
 	}
 	i_assert(dscript->data_id != NULL);
 	if (strcmp(str_c(data_id), dscript->data_id) != 0) {
 		e_debug(script->event,
 			"Binary '%s' reports different data ID for script '%s' "
-			"('%s' rather than '%s')",
-			sieve_binary_path(sbin), sieve_script_location(script),
+			"(`%s' rather than `%s')",
+			sieve_binary_path(sbin), sieve_script_label(script),
 			str_c(data_id), dscript->data_id);
 		return 0;
 	}
diff --git a/src/lib-sieve/storage/file/sieve-file-script.c b/src/lib-sieve/storage/file/sieve-file-script.c
index 8285a7061..59b22eb02 100644
--- a/src/lib-sieve/storage/file/sieve-file-script.c
+++ b/src/lib-sieve/storage/file/sieve-file-script.c
@@ -500,9 +500,9 @@ sieve_file_script_binary_read_metadata(struct sieve_script *script,
 		if (svinst->debug) {
 			e_debug(script->event,
 				"Sieve binary '%s' is not newer "
-				"than the Sieve script '%s' (%s.%lu <= %s.%lu)",
-				sieve_binary_path(sbin),
-				sieve_script_location(script),
+				"than the Sieve script '%s' (path=%s, %s.%lu <= %s.%lu)",
+				sieve_binary_path(sbin), sieve_script_label(script),
+				fscript->path,
 				t_strflocaltime("%Y-%m-%d %H:%M:%S",
 						bstat->st_mtime),
 				ST_MTIME_NSEC(*bstat),
diff --git a/src/lib-sieve/storage/ldap/sieve-ldap-script.c b/src/lib-sieve/storage/ldap/sieve-ldap-script.c
index f1d7b177a..c372cf69a 100644
--- a/src/lib-sieve/storage/ldap/sieve-ldap-script.c
+++ b/src/lib-sieve/storage/ldap/sieve-ldap-script.c
@@ -148,7 +148,7 @@ sieve_ldap_script_binary_read_metadata(struct sieve_script *script,
 		e_error(script->event,
 			"LDAP entry for script '%s' "
 			"has no modified attribute '%s'",
-			sieve_script_location(script),
+			sieve_script_label(script),
 			lstorage->set->sieve_ldap_mod_attr);
 		return 0;
 	}
@@ -158,7 +158,7 @@ sieve_ldap_script_binary_read_metadata(struct sieve_script *script,
 		e_error(script->event,
 			"Binary '%s' has invalid metadata for script '%s': "
 			"Invalid DN",
-			sieve_binary_path(sbin), sieve_script_location(script));
+			sieve_binary_path(sbin), sieve_script_label(script));
 		return -1;
 	}
 	i_assert(lscript->dn != NULL);
@@ -166,7 +166,7 @@ sieve_ldap_script_binary_read_metadata(struct sieve_script *script,
 		e_debug(script->event,
 			"Binary '%s' reports different LDAP DN for script '%s' "
 			"('%s' rather than '%s')",
-			sieve_binary_path(sbin), sieve_script_location(script),
+			sieve_binary_path(sbin), sieve_script_label(script),
 			str_c(dn), lscript->dn);
 		return 0;
 	}
@@ -176,14 +176,14 @@ sieve_ldap_script_binary_read_metadata(struct sieve_script *script,
 		e_error(script->event,
 			"Binary '%s' has invalid metadata for script '%s': "
 			"Invalid modified attribute",
-			sieve_binary_path(sbin), sieve_script_location(script));
+			sieve_binary_path(sbin), sieve_script_label(script));
 		return -1;
 	}
 	if (strcmp(str_c(modattr), lscript->modattr) != 0) {
 		e_debug(script->event,
 			"Binary '%s' reports different modified attribute content "
 			"for script '%s' ('%s' rather than '%s')",
-			sieve_binary_path(sbin), sieve_script_location(script),
+			sieve_binary_path(sbin), sieve_script_label(script),
 			str_c(modattr), lscript->modattr);
 		return 0;
 	}
diff --git a/src/managesieve/cmd-getscript.c b/src/managesieve/cmd-getscript.c
index 106ce5bfa..3a9e39f2f 100644
--- a/src/managesieve/cmd-getscript.c
+++ b/src/managesieve/cmd-getscript.c
@@ -68,10 +68,9 @@ static bool cmd_getscript_continue(struct client_command_context *cmd)
 			/* Input stream gave less data than expected */
 			sieve_storage_set_critical(
 				ctx->storage, "GETSCRIPT for script '%s' "
-				"from %s got too little data: "
+				"got too little data: "
 				"%"PRIuUOFF_T" vs %"PRIuUOFF_T,
-				sieve_script_name(ctx->script),
-				sieve_script_location(ctx->script),
+				sieve_script_label(ctx->script),
 				ctx->script_stream->v_offset, ctx->script_size);
 			client_disconnect(ctx->client, "GETSCRIPT failed");
 			ctx->failed = TRUE;
@@ -83,10 +82,9 @@ static bool cmd_getscript_continue(struct client_command_context *cmd)
 		return FALSE;
 	case OSTREAM_SEND_ISTREAM_RESULT_ERROR_INPUT:
 		sieve_storage_set_critical(ctx->storage,
-			"o_stream_send_istream() failed for script '%s' "
-			"from %s: %s",
-			sieve_script_name(ctx->script),
-			sieve_script_location(ctx->script),
+			"o_stream_send_istream() failed for script '%s': "
+			"%s",
+			sieve_script_label(ctx->script),
 			i_stream_get_error(ctx->script_stream));
 		ctx->failed = TRUE;
 		break;
@@ -136,9 +134,8 @@ bool cmd_getscript(struct client_command_context *cmd)
 
 	if (sieve_script_get_size(ctx->script, &ctx->script_size) <= 0) {
 		sieve_storage_set_critical(ctx->storage,
-			"failed to obtain script size for script '%s' from %s",
-			sieve_script_name(ctx->script),
-			sieve_script_location(ctx->script));
+			"failed to obtain script size for script '%s'",
+			sieve_script_label(ctx->script));
 		ctx->failed = TRUE;
 		return cmd_getscript_finish(ctx);
 	}
diff --git a/src/plugins/imap-filter-sieve/imap-filter-sieve.c b/src/plugins/imap-filter-sieve/imap-filter-sieve.c
index 35bd6f615..abace63b1 100644
--- a/src/plugins/imap-filter-sieve/imap-filter-sieve.c
+++ b/src/plugins/imap-filter-sieve/imap-filter-sieve.c
@@ -367,12 +367,12 @@ imap_sieve_filter_open_script(struct imap_filter_sieve_context *sctx,
 	if (recompile) {
 		/* Warn */
 		e_warning(sieve_get_event(svinst),
-			  "Encountered corrupt binary: re-compiling script %s",
-			  sieve_script_location(script));
+			  "Encountered corrupt binary: re-compiling script '%s'",
+			  sieve_script_label(script));
 		compile_name = "re-compile";
 	} else {
-		e_debug(sieve_get_event(svinst), "Loading script %s",
-			sieve_script_location(script));
+		e_debug(sieve_get_event(svinst), "Loading script '%s'",
+			sieve_script_label(script));
 	}
 
 	if (script == sctx->user_script)
@@ -397,14 +397,14 @@ imap_sieve_filter_open_script(struct imap_filter_sieve_context *sctx,
 		case SIEVE_ERROR_NOT_FOUND:
 			e_debug(sieve_get_event(svinst),
 				"Script '%s' is missing for %s",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Temporary failure */
 		case SIEVE_ERROR_TEMP_FAILURE:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s "
 				"(temporary failure)",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Compile failed */
 		case SIEVE_ERROR_NOT_VALID:
@@ -412,20 +412,20 @@ imap_sieve_filter_open_script(struct imap_filter_sieve_context *sctx,
 				break;
 			e_error(sieve_get_event(svinst),
 				"Failed to %s script '%s'",
-				compile_name, sieve_script_location(script));
+				compile_name, sieve_script_label(script));
 			break;
 		/* Cumulative resource limit exceeded */
 		case SIEVE_ERROR_RESOURCE_LIMIT:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s "
 				"(cumulative resource limit exceeded)",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Something else */
 		default:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		}
 
@@ -765,39 +765,39 @@ imap_sieve_filter_handle_exec_status(struct imap_filter_sieve_context *sctx,
 	switch (status) {
 	case SIEVE_EXEC_FAILURE:
 		e_log(sieve_get_event(svinst), user_log_level,
-		      "Execution of script %s failed",
-		      sieve_script_location(script));
+		      "Execution of script '%s' failed",
+		      sieve_script_label(script));
 		ret = -1;
 		break;
 	case SIEVE_EXEC_TEMP_FAILURE:
 		e_log(sieve_get_event(svinst), log_level,
-		      "Execution of script %s was aborted "
+		      "Execution of script '%s' was aborted "
 		      "due to temporary failure",
-		      sieve_script_location(script));
+		      sieve_script_label(script));
 		*fatal_r = TRUE;
 		ret = -1;
 		break;
 	case SIEVE_EXEC_BIN_CORRUPT:
 		e_error(sieve_get_event(svinst),
-			"!!BUG!!: Binary compiled from %s is still corrupt; "
+			"!!BUG!!: Binary compiled from '%s' is still corrupt; "
 			"bailing out and reverting to default action",
-			sieve_script_location(script));
+			sieve_script_label(script));
 		*fatal_r = TRUE;
 		ret = -1;
 		break;
 	case SIEVE_EXEC_RESOURCE_LIMIT:
 		e_error(sieve_get_event(svinst),
-			"Execution of script %s was aborted "
+			"Execution of script '%s' was aborted "
 			"due to excessive resource usage",
-			sieve_script_location(script));
+			sieve_script_label(script));
 		*fatal_r = TRUE;
 		ret = -1;
 		break;
 	case SIEVE_EXEC_KEEP_FAILED:
 		e_log(sieve_get_event(svinst), log_level,
-		      "Execution of script %s failed "
+		      "Execution of script '%s' failed "
 		      "with unsuccessful implicit keep",
-		      sieve_script_location(script));
+		      sieve_script_label(script));
 		ret = -1;
 		break;
 	case SIEVE_EXEC_OK:
@@ -847,7 +847,7 @@ imap_sieve_filter_run_scripts(struct imap_filter_sieve_context *sctx,
 		if (sbin == NULL) {
 			e_debug(sieve_get_event(svinst),
 				"Skipping script from '%s'",
-				sieve_script_location(script));
+				sieve_script_label(script));
 			continue;
 		}
 
diff --git a/src/plugins/imapsieve/imap-sieve.c b/src/plugins/imapsieve/imap-sieve.c
index 25d2cf20e..cb7d34218 100644
--- a/src/plugins/imapsieve/imap-sieve.c
+++ b/src/plugins/imapsieve/imap-sieve.c
@@ -582,12 +582,12 @@ imap_sieve_run_open_script(struct imap_sieve_run *isrun,
 	if (recompile) {
 		/* Warn */
 		e_warning(sieve_get_event(svinst),
-			  "Encountered corrupt binary: re-compiling script %s",
-			  sieve_script_location(script));
+			  "Encountered corrupt binary: re-compiling script '%s'",
+			  sieve_script_label(script));
 		compile_name = "re-compile";
 	} else {
 		e_debug(sieve_get_event(svinst),
-			"Loading script %s", sieve_script_location(script));
+			"Loading script '%s'", sieve_script_label(script));
 	}
 
 	if (rscript->user_script)
@@ -612,14 +612,14 @@ imap_sieve_run_open_script(struct imap_sieve_run *isrun,
 		case SIEVE_ERROR_NOT_FOUND:
 			e_debug(sieve_get_event(svinst),
 				"Script '%s' is missing for %s",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Temporary failure */
 		case SIEVE_ERROR_TEMP_FAILURE:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s "
 				"(temporary failure)",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Compile failed */
 		case SIEVE_ERROR_NOT_VALID:
@@ -628,26 +628,26 @@ imap_sieve_run_open_script(struct imap_sieve_run *isrun,
 				e_info(sieve_get_event(svinst),
 				       "Failed to %s script '%s' "
 				       "(view user logfile '%s' for more information)",
-				       compile_name, sieve_script_location(script),
+				       compile_name, sieve_script_label(script),
 				       isrun->userlog);
 				break;
 			}
 			e_error(sieve_get_event(svinst),
 				"Failed to %s script '%s'",
-				compile_name, sieve_script_location(script));
+				compile_name, sieve_script_label(script));
 			break;
 		/* Cumulative resource limit exceeded */
 		case SIEVE_ERROR_RESOURCE_LIMIT:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s "
 				"(cumulative resource limit exceeded)",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Something else */
 		default:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		}
 
@@ -697,39 +697,39 @@ imap_sieve_handle_exec_status(struct imap_sieve_run *isrun,
 	switch (status) {
 	case SIEVE_EXEC_FAILURE:
 		e_log(sieve_get_event(svinst), user_log_level,
-			"Execution of script %s failed%s",
-			sieve_script_location(script), userlog_notice);
+			"Execution of script '%s' failed%s",
+			sieve_script_label(script), userlog_notice);
 		ret = 0;
 		break;
 	case SIEVE_EXEC_TEMP_FAILURE:
 		e_log(sieve_get_event(svinst), log_level,
-		      "Execution of script %s was aborted "
+		      "Execution of script '%s' was aborted "
 		      "due to temporary failure%s",
-		      sieve_script_location(script), userlog_notice);
+		      sieve_script_label(script), userlog_notice);
 		*fatal_r = TRUE;
 		ret = -1;
 		break;
 	case SIEVE_EXEC_BIN_CORRUPT:
 		e_error(sieve_get_event(svinst),
-			"!!BUG!!: Binary compiled from %s is still corrupt; "
+			"!!BUG!!: Binary compiled from '%s' is still corrupt; "
 			"bailing out and reverting to default action",
-			sieve_script_location(script));
+			sieve_script_label(script));
 		*fatal_r = TRUE;
 		ret = -1;
 		break;
 	case SIEVE_EXEC_RESOURCE_LIMIT:
 		e_error(sieve_get_event(svinst),
-			"Execution of script %s was aborted "
+			"Execution of script '%s' was aborted "
 			"due to excessive resource usage",
-			sieve_script_location(script));
+			sieve_script_label(script));
 		*fatal_r = TRUE;
 		ret = -1;
 		break;
 	case SIEVE_EXEC_KEEP_FAILED:
 		e_log(sieve_get_event(svinst), log_level,
-		      "Execution of script %s failed "
+		      "Execution of script '%s' failed "
 		      "with unsuccessful implicit keep%s",
-		      sieve_script_location(script), userlog_notice);
+		      sieve_script_label(script), userlog_notice);
 		ret = 0;
 		break;
 	case SIEVE_EXEC_OK:
@@ -798,7 +798,7 @@ imap_sieve_run_scripts(struct imap_sieve_run *isrun,
 		if (sbin == NULL) {
 			e_debug(sieve_get_event(svinst),
 				"Opening script %d of %d from '%s'",
-				i+1, count, sieve_script_location(script));
+				i+1, count, sieve_script_label(script));
 
 			/* Already known to fail */
 			if (scripts[i].compile_error != SIEVE_ERROR_NONE) {
diff --git a/src/plugins/lda-sieve/lda-sieve-plugin.c b/src/plugins/lda-sieve/lda-sieve-plugin.c
index 0868badee..2b3eda70c 100644
--- a/src/plugins/lda-sieve/lda-sieve-plugin.c
+++ b/src/plugins/lda-sieve/lda-sieve-plugin.c
@@ -345,7 +345,7 @@ lda_sieve_binary_save(struct lda_sieve_run_context *srctx,
 			"to save global Sieve script binaries; "
 			"global Sieve scripts like '%s' need to be "
 			"pre-compiled using the sievec tool",
-			sieve_script_location(script));
+			sieve_script_label(script));
 	}
 }
 
@@ -365,11 +365,11 @@ sieve_binary *lda_sieve_open(struct lda_sieve_run_context *srctx,
 		/* Warn */
 		e_warning(sieve_get_event(svinst),
 			  "Encountered corrupt binary: re-compiling script %s",
-			  sieve_script_location(script));
+			  sieve_script_label(script));
 		compile_name = "re-compile";
 	} else {
 		e_debug(sieve_get_event(svinst),
-			"Loading script %s", sieve_script_location(script));
+			"Loading script %s", sieve_script_label(script));
 	}
 
 	if (script == srctx->user_script)
@@ -394,7 +394,7 @@ sieve_binary *lda_sieve_open(struct lda_sieve_run_context *srctx,
 		case SIEVE_ERROR_NOT_FOUND:
 			e_debug(sieve_get_event(svinst),
 				"Script '%s' is missing for %s",
-				sieve_script_location(script),
+				sieve_script_label(script),
 				compile_name);
 			break;
 		/* Temporary failure */
@@ -402,7 +402,7 @@ sieve_binary *lda_sieve_open(struct lda_sieve_run_context *srctx,
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s "
 				"(temporary failure)",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Compile failed */
 		case SIEVE_ERROR_NOT_VALID:
@@ -412,26 +412,26 @@ sieve_binary *lda_sieve_open(struct lda_sieve_run_context *srctx,
 				       "Failed to %s script '%s' "
 				       "(view user logfile '%s' for more information)",
 				       compile_name,
-				       sieve_script_location(script),
+				       sieve_script_label(script),
 				       srctx->userlog);
 				break;
 			}
 			e_error(sieve_get_event(svinst),
 				"Failed to %s script '%s'",
-				compile_name, sieve_script_location(script));
+				compile_name, sieve_script_label(script));
 			break;
 		/* Cumulative resource limit exceeded */
 		case SIEVE_ERROR_RESOURCE_LIMIT:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s "
 				"(cumulative resource limit exceeded)",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		/* Something else */
 		default:
 			e_error(sieve_get_event(svinst),
 				"Failed to open script '%s' for %s",
-				sieve_script_location(script), compile_name);
+				sieve_script_label(script), compile_name);
 			break;
 		}
 
@@ -478,15 +478,15 @@ lda_sieve_handle_exec_status(struct lda_sieve_run_context *srctx,
 	switch (status) {
 	case SIEVE_EXEC_FAILURE:
 		e_log(sieve_get_event(svinst), user_log_level,
-		      "Execution of script %s failed, "
+		      "Execution of script '%s' failed, "
 		      "but implicit keep was successful%s",
-		      sieve_script_location(script), userlog_notice);
+		      sieve_script_label(script), userlog_notice);
 		ret = 1;
 		break;
 	case SIEVE_EXEC_TEMP_FAILURE:
 		e_log(sieve_get_event(svinst), log_level,
-		      "Execution of script %s was aborted due to temporary failure%s",
-		      sieve_script_location(script), userlog_notice);
+		      "Execution of script '%s' was aborted due to temporary failure%s",
+		      sieve_script_label(script), userlog_notice);
 		if (mail_error != MAIL_ERROR_TEMP &&
 		    mdctx->tempfail_error == NULL) {
 			mdctx->tempfail_error =
@@ -496,22 +496,22 @@ lda_sieve_handle_exec_status(struct lda_sieve_run_context *srctx,
 		break;
 	case SIEVE_EXEC_BIN_CORRUPT:
 		e_error(sieve_get_event(svinst),
-			"!!BUG!!: Binary compiled from %s is still corrupt; "
+			"!!BUG!!: Binary compiled from '%s' is still corrupt; "
 			"bailing out and reverting to default delivery",
-			sieve_script_location(script));
+			sieve_script_label(script));
 		ret = -1;
 		break;
 	case SIEVE_EXEC_RESOURCE_LIMIT:
 		e_error(sieve_get_event(svinst),
-			"Execution of script %s was aborted "
+			"Execution of script '%s' was aborted "
 			"due to excessive resource usage",
-			sieve_script_location(script));
+			sieve_script_label(script));
 		ret = -1;
 		break;
 	case SIEVE_EXEC_KEEP_FAILED:
 		e_log(sieve_get_event(svinst), log_level,
-		      "Execution of script %s failed with unsuccessful implicit keep%s",
-		      sieve_script_location(script), userlog_notice);
+		      "Execution of script '%s' failed with unsuccessful implicit keep%s",
+		      sieve_script_label(script), userlog_notice);
 		ret = -1;
 		break;
 	default:
@@ -558,11 +558,11 @@ lda_sieve_execute_script(struct lda_sieve_run_context *srctx,
 		e_debug(sieve_get_event(svinst),
 			"Opening script %d of %d from '%s'",
 			index, srctx->script_count,
-			sieve_script_location(script));
+			sieve_script_label(script));
 	} else {
 		e_debug(sieve_get_event(svinst),
 			"Opening discard script from '%s'",
-			sieve_script_location(script));
+			sieve_script_label(script));
 	}
 
 	sbin = lda_sieve_open(srctx, script, cpflags, FALSE, error_code_r);
@@ -800,7 +800,7 @@ static int lda_sieve_find_scripts(struct lda_sieve_run_context *srctx)
 			for (i = 0; i < count; i ++) {
 				e_debug(sieve_get_event(svinst),
 					"Executed before user's personal Sieve script(%d): %s",
-					i+1, sieve_script_location(scripts[i]));
+					i+1, sieve_script_label(scripts[i]));
 			}
 		}
 	}
@@ -811,8 +811,8 @@ static int lda_sieve_find_scripts(struct lda_sieve_run_context *srctx)
 
 		if (ret >= 0) {
 			e_debug(sieve_get_event(svinst),
-				"Using the following location for user's Sieve script: %s",
-				sieve_script_location(srctx->main_script));
+				"Using the following personal Sieve script: %s",
+				sieve_script_label(srctx->main_script));
 		}
 	}
 
@@ -845,8 +845,8 @@ static int lda_sieve_find_scripts(struct lda_sieve_run_context *srctx)
 			scripts = array_get(&script_sequence, &count);
 			for ( i = after_index; i < count; i ++ ) {
 				e_debug(sieve_get_event(svinst),
-					"executed after user's Sieve script(%d): %s",
-					i+1, sieve_script_location(scripts[i]));
+					"Executed after user's Sieve script(%d): %s",
+					i+1, sieve_script_label(scripts[i]));
 			}
 		}
 	}
-- 
GitLab