diff --git a/src/lib-sieve/sieve-script-file.c b/src/lib-sieve/sieve-script-file.c index 3808750a9f951958a553dbe1f59dfdb6d2843e3c..8708878c6419f24acc3c2afdc05ab84f1305da7e 100644 --- a/src/lib-sieve/sieve-script-file.c +++ b/src/lib-sieve/sieve-script-file.c @@ -122,7 +122,7 @@ static int sieve_file_script_open struct sieve_error_handler *ehandler = _script->ehandler; pool_t pool = _script->pool; const char *name = _script->name; - const char *filename, *dirpath, *basename, *binpath; + const char *filename, *dirpath, *basename, *binpath, *binprefix; struct stat st; struct stat lnk_st; bool success = TRUE; @@ -220,10 +220,15 @@ static int sieve_file_script_open if ( _script->bin_dir != NULL ) { binpath = sieve_binfile_from_name(name); binpath = t_strconcat(_script->bin_dir, "/", binpath, NULL); + binprefix = t_strconcat(_script->bin_dir, "/", name, NULL); } else { binpath = sieve_binfile_from_name(basename); - if ( *dirpath != '\0' ) + if ( *dirpath != '\0' ) { binpath = t_strconcat(dirpath, "/", binpath, NULL); + binprefix = t_strconcat(dirpath, "/", basename, NULL); + } else { + binprefix = basename; + } } script->st = st; @@ -232,6 +237,7 @@ static int sieve_file_script_open script->filename = p_strdup(pool, filename); script->dirpath = p_strdup(pool, dirpath); script->binpath = p_strdup(pool, binpath); + script->binprefix = p_strdup(pool, binprefix); if ( script->script.name == NULL || strcmp(script->script.name, basename) == 0 ) @@ -354,12 +360,12 @@ static int sieve_file_script_binary_save script->st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO), error_r); } -static const char *sieve_file_script_binary_get_directory +static const char *sieve_file_script_binary_get_prefix (struct sieve_script *_script) { struct sieve_file_script *script = (struct sieve_file_script *)_script; - return script-> dirpath; + return script-> binprefix; } const struct sieve_script sieve_file_script = { @@ -376,7 +382,7 @@ const struct sieve_script sieve_file_script = { NULL, sieve_file_script_binary_load, sieve_file_script_binary_save, - sieve_file_script_binary_get_directory, + sieve_file_script_binary_get_prefix, sieve_file_script_get_size, diff --git a/src/lib-sieve/sieve-script-private.h b/src/lib-sieve/sieve-script-private.h index 3a0797b7885e4fffe34e2ef8bbc13c89451227a0..174cff3cd885fe8f751cf7c4e39c14872f48cebe 100644 --- a/src/lib-sieve/sieve-script-private.h +++ b/src/lib-sieve/sieve-script-private.h @@ -32,7 +32,7 @@ struct sieve_script_vfuncs { int (*binary_save) (struct sieve_script *script, struct sieve_binary *sbin, bool update, enum sieve_error *error_r); - const char *(*binary_get_directory) + const char *(*binary_get_prefix) (struct sieve_script *script); int (*get_size) @@ -88,6 +88,7 @@ struct sieve_file_script { const char *dirpath; const char *filename; const char *binpath; + const char *binprefix; int fd; }; diff --git a/src/lib-sieve/sieve-script.c b/src/lib-sieve/sieve-script.c index 9afc073aff4e79556940d2f93553576736e7e2c0..9e56951e08c06b710eb9cefd843884a18030be79 100644 --- a/src/lib-sieve/sieve-script.c +++ b/src/lib-sieve/sieve-script.c @@ -542,18 +542,18 @@ int sieve_script_binary_save return script->v.binary_save(script, sbin, update, error_r); } -const char *sieve_script_binary_get_directory +const char *sieve_script_binary_get_prefix (struct sieve_script *script) { if ( script->bin_dir != NULL && sieve_script_setup_bindir(script, 0700) >= 0 ) { - return script->bin_dir; + return t_strconcat(script->bin_dir, "/", script->name, NULL); } - if ( script->v.binary_get_directory == NULL ) + if ( script->v.binary_get_prefix == NULL ) return NULL; - return script->v.binary_get_directory(script); + return script->v.binary_get_prefix(script); } int sieve_script_setup_bindir diff --git a/src/lib-sieve/sieve-script.h b/src/lib-sieve/sieve-script.h index 9889aa0c1772efc7a86a200f0044770e19595d05..b5cbc5482039ff154d1ded1cdb118b549b61b42f 100644 --- a/src/lib-sieve/sieve-script.h +++ b/src/lib-sieve/sieve-script.h @@ -68,7 +68,7 @@ int sieve_script_binary_save (struct sieve_script *script, struct sieve_binary *sbin, bool update, enum sieve_error *error_r); -const char *sieve_script_binary_get_directory +const char *sieve_script_binary_get_prefix (struct sieve_script *script); /*