diff --git a/src/conf.c b/src/conf.c index 83b1620..011d9ea 100644 --- a/src/conf.c +++ b/src/conf.c @@ -37,12 +37,6 @@ #include "rotater.h" #include "zc_defs.h" -#ifdef _WIN32 -#define STATS_FILE stat -#else -#define STATS_FILE lstat -#endif - /*******************************************************************************/ #define ZLOG_CONF_DEFAULT_FORMAT "default = \"%D %V [%p:%F:%L] %m%n\"" #define ZLOG_CONF_DEFAULT_RULE "*.* >stdout" @@ -471,11 +465,17 @@ static int zlog_conf_build_with_file(zlog_conf_t * a_conf) int section = 0; /* [global:1] [levels:2] [formats:3] [rules:4] */ - if (STATS_FILE(a_conf->file, &a_stat)) { + if (stat(a_conf->file, &a_stat)) { zc_error("lstat conf file[%s] fail, errno[%d]", a_conf->file, errno); return -1; } + + if (!S_ISREG(a_stat.st_mode)) { + zc_error("conf file[%s] is not a regular file", a_conf->file); + return -1; + } + localtime_r(&(a_stat.st_mtime), &local_time); strftime(a_conf->mtime, sizeof(a_conf->mtime), "%Y-%m-%d %H:%M:%S", &local_time);