|
|
|
@ -45,52 +45,61 @@ f2b_jail_parse_compound_value(const char *value, char *name, char *init) {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
f2b_jail_apply_config(f2b_jail_t *jail, f2b_config_section_t *section) { |
|
|
|
|
f2b_config_param_t *param = NULL; |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
f2b_jail_set_param(f2b_jail_t *jail, const char *param, const char *value) { |
|
|
|
|
assert(jail != NULL); |
|
|
|
|
assert(section != NULL); |
|
|
|
|
assert(section->type == t_jail || section->type == t_defaults); |
|
|
|
|
assert(param != NULL); |
|
|
|
|
assert(value != NULL); |
|
|
|
|
|
|
|
|
|
for (param = section->param; param != NULL; param = param->next) { |
|
|
|
|
if (strcmp(param->name, "enabled") == 0) { |
|
|
|
|
if (strcmp(param->value, "yes") == 0) |
|
|
|
|
if (strcmp(param, "enabled") == 0) { |
|
|
|
|
if (strcmp(value, "yes") == 0) |
|
|
|
|
jail->enabled = true; |
|
|
|
|
continue; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (strcmp(param->name, "bantime") == 0) { |
|
|
|
|
jail->bantime = atoi(param->value); |
|
|
|
|
if (strcmp(param, "bantime") == 0) { |
|
|
|
|
jail->bantime = atoi(value); |
|
|
|
|
if (jail->bantime <= 0) |
|
|
|
|
jail->bantime = DEFAULT_BANTIME; |
|
|
|
|
continue; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (strcmp(param->name, "findtime") == 0) { |
|
|
|
|
jail->findtime = atoi(param->value); |
|
|
|
|
if (strcmp(param, "findtime") == 0) { |
|
|
|
|
jail->findtime = atoi(value); |
|
|
|
|
if (jail->findtime <= 0) |
|
|
|
|
jail->findtime = DEFAULT_FINDTIME; |
|
|
|
|
continue; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (strcmp(param->name, "expiretime") == 0) { |
|
|
|
|
jail->expiretime = atoi(param->value); |
|
|
|
|
if (strcmp(param, "expiretime") == 0) { |
|
|
|
|
jail->expiretime = atoi(value); |
|
|
|
|
if (jail->expiretime <= 0) |
|
|
|
|
jail->expiretime = DEFAULT_EXPIRETIME; |
|
|
|
|
continue; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (strcmp(param->name, "maxretry") == 0) { |
|
|
|
|
jail->maxretry = atoi(param->value); |
|
|
|
|
if (strcmp(param, "maxretry") == 0) { |
|
|
|
|
jail->maxretry = atoi(value); |
|
|
|
|
if (jail->maxretry == 0) |
|
|
|
|
jail->maxretry = DEFAULT_MAXRETRY; |
|
|
|
|
continue; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (strcmp(param->name, "incr_bantime") == 0) { |
|
|
|
|
jail->incr_bantime = atof(param->value); |
|
|
|
|
continue; |
|
|
|
|
if (strcmp(param, "incr_bantime") == 0) { |
|
|
|
|
jail->incr_bantime = atof(value); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (strcmp(param->name, "incr_findtime") == 0) { |
|
|
|
|
jail->incr_findtime = atof(param->value); |
|
|
|
|
continue; |
|
|
|
|
if (strcmp(param, "incr_findtime") == 0) { |
|
|
|
|
jail->incr_findtime = atof(value); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
f2b_jail_apply_config(f2b_jail_t *jail, f2b_config_section_t *section) { |
|
|
|
|
f2b_config_param_t *param = NULL; |
|
|
|
|
|
|
|
|
|
assert(jail != NULL); |
|
|
|
|
assert(section != NULL); |
|
|
|
|
assert(section->type == t_jail || section->type == t_defaults); |
|
|
|
|
|
|
|
|
|
for (param = section->param; param != NULL; param = param->next) { |
|
|
|
|
if (strcmp(param->name, "source") == 0) { |
|
|
|
|
f2b_jail_parse_compound_value(param->value, jail->source_name, jail->source_init); |
|
|
|
|
continue; |
|
|
|
@ -103,6 +112,9 @@ f2b_jail_apply_config(f2b_jail_t *jail, f2b_config_section_t *section) {
|
|
|
|
|
f2b_jail_parse_compound_value(param->value, jail->backend_name, jail->backend_init); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (f2b_jail_set_param(jail, param->name, param->value)) |
|
|
|
|
continue; |
|
|
|
|
f2b_log_msg(log_warn, "jail '%s': unrecognized parameter: %s", jail->name, param->name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|