dovecot-sieve-1.0: If sieve script is a symlink, recompile also ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 25 18:57:23 EEST 2008
details: http://hg.dovecot.org/dovecot-sieve-1.0/rev/3d78296cf763
changeset: 38:3d78296cf763
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 aa6896701baf -r 3d78296cf763 src/sieve-cmu.c
--- a/src/sieve-cmu.c Fri Jun 06 16:56:38 2008 +0300
+++ b/src/sieve-cmu.c Mon Jul 21 16:42:42 2008 +0300
@@ -570,14 +570,14 @@ dovecot_sieve_compile(sieve_interp_t *in
dovecot_sieve_compile(sieve_interp_t *interp, 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",
@@ -585,12 +585,19 @@ dovecot_sieve_compile(sieve_interp_t *in
}
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) {
@@ -598,7 +605,8 @@ dovecot_sieve_compile(sieve_interp_t *in
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