diff --git a/src/lib-sieve/sieve-error.c b/src/lib-sieve/sieve-error.c index 5e27f67f7c833f1ba378f8dcdbb3b892938a1c56..971f0719621443ad59c1bc11d2ce6a820e2373aa 100644 --- a/src/lib-sieve/sieve-error.c +++ b/src/lib-sieve/sieve-error.c @@ -64,7 +64,7 @@ void sieve_vcritical tm = localtime(&ioloop_time); - i_error("sieve: %s: %s", location, t_strdup_vprintf(fmt, args)); + i_error("sieve: error: %s: %s", location, t_strdup_vprintf(fmt, args)); if ( ehandler == NULL ) return; diff --git a/src/lib-sieve/sieve-script.c b/src/lib-sieve/sieve-script.c index 0c307edf6902c60ee0760257713e9b115612c919..40a8bf10831866e354eb4a84b81654afc6cf0a10 100644 --- a/src/lib-sieve/sieve-script.c +++ b/src/lib-sieve/sieve-script.c @@ -25,66 +25,68 @@ struct sieve_script *sieve_script_init if ( exists_r != NULL ) *exists_r = FALSE; - T_FRAME( - /* Extract filename from path */ - filename = strrchr(path, '/'); - if ( filename == NULL ) { - dirpath = ""; - filename = path; - } else { - dirpath = t_strdup_until(path, filename); - filename++; - } +// t_push(); + + /* Extract filename from path */ + filename = strrchr(path, '/'); + if ( filename == NULL ) { + dirpath = ""; + filename = path; + } else { + dirpath = t_strdup_until(path, filename); + filename++; + } - if ( name == NULL || *name == '\0' ) { - const char *ext; + if ( name == NULL || *name == '\0' ) { + const char *ext; - /* Extract the script name */ - ext = strrchr(filename, '.'); - if ( ext == NULL || ext == filename || strncmp(ext,".sieve",6) != 0 ) - name = filename; - else - name = t_strdup_until(filename, ext); - } + /* Extract the script name */ + ext = strrchr(filename, '.'); + if ( ext == NULL || ext == filename || strncmp(ext,".sieve",6) != 0 ) + name = filename; + else + name = t_strdup_until(filename, ext); + } - /* First obtain stat data from the system */ + /* First obtain stat data from the system */ - if ( (ret=stat(path, &st)) < 0 && (errno != ENOENT || exists_r == NULL) ) { - if ( errno == ENOENT ) - sieve_error(ehandler, name, "sieve script does not exist"); - else - sieve_critical(ehandler, name, "failed to stat sieve script file '%s': %m", path); + if ( (ret=stat(path, &st)) != 0 && (errno != ENOENT || exists_r == NULL) ) { + if ( errno == ENOENT ) + sieve_error(ehandler, name, "sieve script does not exist"); + else + sieve_critical(ehandler, name, "failed to stat sieve script file '%s': %m", path); + script = NULL; + } else { + /* Only create/init the object if it stat()s without problems */ + + if ( ret == 0 && !S_ISREG(st.st_mode) ) { + sieve_critical(ehandler, name, + "sieve script file '%s' is not a regular file.", path); script = NULL; } else { - /* Only create/init the object if it stat()s without problems */ - - if ( !S_ISREG(st.st_mode) ) { - sieve_critical(ehandler, name, - "sieve script file '%s' is not a regular file.", path); - script = NULL; - } else { - if ( exists_r != NULL ) - *exists_r = ( ret >= 0 ); - - if ( script == NULL ) { - pool = pool_alloconly_create("sieve_script", 1024); - script = p_new(pool, struct sieve_script, 1); - script->pool = pool; - } else - pool = script->pool; + if ( exists_r != NULL ) + *exists_r = ( ret == 0 ); + + if ( script == NULL ) { + pool = pool_alloconly_create("sieve_script", 1024); + script = p_new(pool, struct sieve_script, 1); + script->pool = pool; + } else + pool = script->pool; - script->refcount = 1; - script->ehandler = ehandler; - sieve_error_handler_ref(ehandler); + script->refcount = 1; + script->ehandler = ehandler; + sieve_error_handler_ref(ehandler); - memcpy((void *) &script->st, (void *) &st, sizeof(st)); - script->path = p_strdup(pool, path); - script->filename = p_strdup(pool, filename); - script->dirpath = p_strdup(pool, dirpath); - script->name = p_strdup(pool, name); - } + memcpy((void *) &script->st, (void *) &st, sizeof(st)); + script->path = p_strdup(pool, path); + script->filename = p_strdup(pool, filename); + script->dirpath = p_strdup(pool, dirpath); + script->name = p_strdup(pool, name); } - ); + } + +// t_pop(); return script; }