dovecot-sieve-1.1: If sieve script is a symlink, recompile also ...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jul 21 16:42:45 EEST 2008
details: http://hg.dovecot.org/dovecot-sieve-1.1/rev/f4560fb9b8c1
changeset: 61:f4560fb9b8c1
user: Timo Sirainen <tss at iki.fi>
date: Mon Jul 21 16:42:42 2008 +0300
description:
If sieve script is a symlink, recompile also if the symlink changes.
Patch by Frank Behrens.
diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
src/sieve-cmu.c | 16 ++++++++++++----
diffs (51 lines):
diff -r d7fdee930d07 -r f4560fb9b8c1 src/sieve-cmu.c
--- a/src/sieve-cmu.c Thu Jun 12 09:11:45 2008 +0300
+++ b/src/sieve-cmu.c Mon Jul 21 16:42:42 2008 +0300
@@ -900,14 +900,14 @@ dovecot_sieve_compile(script_data_t *sda
dovecot_sieve_compile(script_data_t *sdata, const char *script_path,
const char *compiled_path)
{
- struct stat st, st2;
+ struct stat st, st2, stlnk;
sieve_script_t *script;
bytecode_info_t *bc;
const char *temp_path;
FILE *f;
int fd, ret;
- if (stat(script_path, &st) < 0) {
+ if (lstat(script_path, &st) < 0) {
if (errno == ENOENT) {
if (getenv("DEBUG") != NULL) {
i_info("cmusieve: Script not found: %s",
@@ -915,12 +915,19 @@ dovecot_sieve_compile(script_data_t *sda
}
return 0;
}
- i_error("stat(%s) failed: %m", script_path);
+ i_error("lstat(%s) failed: %m", script_path);
return -1;
}
if (S_ISDIR(st.st_mode)) {
i_error("%s should be a file, not a directory", script_path);
return -1;
+ }
+ /* in case of symbolic link compare linked files date, too */
+ if (S_ISLNK(st.st_mode)) {
+ if (stat(script_path, &stlnk) < 0) {
+ i_error("stat(%s) failed: %m", script_path);
+ return -1;
+ }
}
if (stat(compiled_path, &st2) < 0) {
if (errno != ENOENT) {
@@ -928,7 +935,8 @@ dovecot_sieve_compile(script_data_t *sda
return -1;
}
} else {
- if (st.st_mtime <= st2.st_mtime)
+ if (st.st_mtime <= st2.st_mtime &&
+ (!S_ISLNK(st.st_mode) || stlnk.st_mtime <= st2.st_mtime))
return 1;
}
More information about the dovecot-cvs
mailing list