增加判断配置文件内容是否正确!
This commit is contained in:
parent
bd6793499f
commit
17f06235df
8
conf.c
8
conf.c
@ -204,9 +204,11 @@ static void parse_global_module(char *content, conf * conf)
|
||||
}
|
||||
if (strcasecmp(var, "CLAMAV_ARG") == 0) {
|
||||
val_begin_len = val_end - val_begin;
|
||||
conf->CLAMAV_TIME_LEN = val_begin_len;
|
||||
conf->CLAMAV_ARG_LEN = val_begin_len;
|
||||
if (copy_new_mem(val_begin, val_begin_len, &conf->CLAMAV_ARG) != 0)
|
||||
return;
|
||||
} else {
|
||||
conf->CLAMAV_ARG_LEN = 0;
|
||||
}
|
||||
|
||||
// 磁盘使用率
|
||||
@ -260,8 +262,10 @@ void read_conf(char *filename, conf * configure)
|
||||
int return_val;
|
||||
|
||||
file = fopen(filename, "r");
|
||||
if (file == NULL)
|
||||
if (file == NULL) {
|
||||
perror("cannot open config file.");
|
||||
return ;
|
||||
}
|
||||
fseek(file, 0, SEEK_END);
|
||||
file_size = ftell(file);
|
||||
buff = (char *)alloca(file_size + 1);
|
||||
|
1
conf.h
1
conf.h
@ -23,6 +23,7 @@ typedef struct CONF
|
||||
char *CLAMAV_TIME;
|
||||
int CLAMAV_TIME_LEN;
|
||||
char *CLAMAV_ARG;
|
||||
int CLAMAV_ARG_LEN;
|
||||
|
||||
int IS_BLOCKED;
|
||||
int REFUSE_NUMBER;
|
||||
|
6
rhost.c
6
rhost.c
@ -957,6 +957,12 @@ int main(int argc, char *argv[], char **env)
|
||||
read_conf(path, conf);
|
||||
//ptintf_conf(conf);
|
||||
|
||||
if (0 == conf->CLAMAV_ARG_LEN)
|
||||
{
|
||||
printf("\033[31mError reading configuration file, please check the configuration file!\033[0m\n");
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// 更新病毒库
|
||||
update_freshclam(argc, argv);
|
||||
|
Loading…
Reference in New Issue
Block a user