|
|
@ -362,76 +362,74 @@ f2b_jail_init(f2b_jail_t *jail, f2b_config_t *config) { |
|
|
|
|
|
|
|
|
|
|
|
if (!jail->source) { |
|
|
|
if (!jail->source) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': missing 'source' option", jail->name); |
|
|
|
f2b_log_msg(log_error, "jail '%s': missing 'source' option", jail->name); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!jail->filter) { |
|
|
|
|
|
|
|
f2b_log_msg(log_error, "jail '%s': missing 'filter' option", jail->name); |
|
|
|
|
|
|
|
goto cleanup; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!jail->backend) { |
|
|
|
|
|
|
|
f2b_log_msg(log_error, "jail '%s': missing 'backend' option", jail->name); |
|
|
|
|
|
|
|
goto cleanup; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((section = f2b_config_section_find(config->sources, jail->source->name)) == NULL) { |
|
|
|
if ((section = f2b_config_section_find(config->sources, jail->source->name)) == NULL) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': no source with name '%s'", jail->name, jail->source->name); |
|
|
|
f2b_log_msg(log_error, "jail '%s': no source with name '%s'", jail->name, jail->source->name); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!f2b_source_init(jail->source, section)) { |
|
|
|
if (!f2b_source_init(jail->source, section)) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': can't init source '%s' with %s", jail->name, jail->source->name, jail->source->init); |
|
|
|
f2b_log_msg(log_error, "jail '%s': can't init source '%s' with %s", jail->name, jail->source->name, jail->source->init); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (jail->source->flags & MOD_NEED_FILTER && !(jail->flags & JAIL_HAS_FILTER)) { |
|
|
|
if (jail->source->flags & MOD_NEED_FILTER) { |
|
|
|
|
|
|
|
if (!jail->filter) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': source '%s' needs filter, but jail has no one", jail->name, jail->source->name); |
|
|
|
f2b_log_msg(log_error, "jail '%s': source '%s' needs filter, but jail has no one", jail->name, jail->source->name); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((section = f2b_config_section_find(config->filters, jail->filter->name)) == NULL) { |
|
|
|
if ((section = f2b_config_section_find(config->filters, jail->filter->name)) == NULL) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': no filter with name '%s'", jail->name, jail->filter->name); |
|
|
|
f2b_log_msg(log_error, "jail '%s': no filter with name '%s'", jail->name, jail->filter->name); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup2; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!f2b_filter_init(jail->filter, section)) { |
|
|
|
if (!f2b_filter_init(jail->filter, section)) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': no regexps loaded from '%s'", jail->name, jail->filter->init); |
|
|
|
f2b_log_msg(log_error, "jail '%s': no regexps loaded from '%s'", jail->name, jail->filter->init); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup2; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!jail->backend) { |
|
|
|
|
|
|
|
f2b_log_msg(log_error, "jail '%s': missing 'backend' option", jail->name); |
|
|
|
|
|
|
|
goto cleanup3; |
|
|
|
|
|
|
|
} |
|
|
|
if ((section = f2b_config_section_find(config->backends, jail->backend->name)) == NULL) { |
|
|
|
if ((section = f2b_config_section_find(config->backends, jail->backend->name)) == NULL) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': no backend with name '%s'", jail->name, jail->backend->name); |
|
|
|
f2b_log_msg(log_error, "jail '%s': no backend with name '%s'", jail->name, jail->backend->name); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup3; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!f2b_backend_init(jail->backend, section)) { |
|
|
|
if (!f2b_backend_init(jail->backend, section)) { |
|
|
|
f2b_log_msg(log_error, "jail '%s': can't init backend '%s' with %s", |
|
|
|
f2b_log_msg(log_error, "jail '%s': can't init backend '%s' with %s", |
|
|
|
jail->name, jail->backend->name, jail->backend->init); |
|
|
|
jail->name, jail->backend->name, jail->backend->init); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup3; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* start all */ |
|
|
|
/* start all */ |
|
|
|
if (!f2b_source_start(jail->source)) { |
|
|
|
if (!f2b_source_start(jail->source)) { |
|
|
|
f2b_log_msg(log_warn, "jail '%s': source action 'start' failed", jail->name); |
|
|
|
f2b_log_msg(log_warn, "jail '%s': source action 'start' failed", jail->name); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup3; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!f2b_backend_start(jail->backend)) { |
|
|
|
if (!f2b_backend_start(jail->backend)) { |
|
|
|
f2b_log_msg(log_warn, "jail '%s': backend action 'start' failed", jail->name); |
|
|
|
f2b_log_msg(log_warn, "jail '%s': backend action 'start' failed", jail->name); |
|
|
|
goto cleanup; |
|
|
|
goto cleanup3; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
f2b_log_msg(log_debug, "jail '%s' init complete", jail->name); |
|
|
|
f2b_log_msg(log_debug, "jail '%s' init complete", jail->name); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
cleanup: |
|
|
|
cleanup3: |
|
|
|
if (jail->source) { |
|
|
|
if (jail->backend) { |
|
|
|
f2b_source_destroy(jail->source); |
|
|
|
f2b_backend_destroy(jail->backend); |
|
|
|
jail->source = NULL; |
|
|
|
jail->backend = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
cleanup2: |
|
|
|
if (jail->filter) { |
|
|
|
if (jail->filter) { |
|
|
|
f2b_filter_destroy(jail->filter); |
|
|
|
f2b_filter_destroy(jail->filter); |
|
|
|
jail->filter = NULL; |
|
|
|
jail->filter = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
if (jail->backend) { |
|
|
|
cleanup1: |
|
|
|
f2b_backend_destroy(jail->backend); |
|
|
|
if (jail->source) { |
|
|
|
jail->backend = NULL; |
|
|
|
f2b_source_destroy(jail->source); |
|
|
|
|
|
|
|
jail->source = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|