From 88c8511a6b32dbcc66ef665e2a30a13ad5210846 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sun, 13 Mar 2016 14:59:43 +1000 Subject: [PATCH] + jail.[ch]: add f2b_jail_stop() --- src/jail.c | 25 +++++++++++++++++++++++++ src/jail.h | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/jail.c b/src/jail.c index a1fe3a1..32374dc 100644 --- a/src/jail.c +++ b/src/jail.c @@ -283,3 +283,28 @@ f2b_jail_init(f2b_jail_t *jail, f2b_config_t *config) { f2b_backend_destroy(jail->backend); return false; } + +bool +f2b_jail_stop(f2b_jail_t *jail) { + bool errors = false; + + f2b_filelist_destroy(jail->logfiles); + f2b_filter_destroy(jail->filter); + + for (f2b_ipaddr_t *addr = jail->ipaddrs; addr != NULL; addr = addr->next) { + if (!addr->banned) + continue; + if (f2b_jail_unban(jail, addr)) + continue; + errors = true; + } + f2b_addrlist_destroy(jail->ipaddrs); + + if (!f2b_backend_stop(jail->backend)) { + f2b_log_msg(log_error, "jail '%s': action 'stop' failed: %s", + jail->name, f2b_backend_error(jail->backend)); + errors = true; + } + + return errors; +} diff --git a/src/jail.h b/src/jail.h index c964433..53f023f 100644 --- a/src/jail.h +++ b/src/jail.h @@ -33,6 +33,7 @@ void f2b_jail_parse_compound_value(const char *value, char *name, char *init); f2b_jail_t *f2b_jail_create (f2b_config_section_t *section); void f2b_jail_set_defaults(f2b_config_section_t *section); -size_t f2b_jail_process (f2b_jail_t *jail); bool f2b_jail_init (f2b_jail_t *jail, f2b_config_t *config); +size_t f2b_jail_process (f2b_jail_t *jail); +bool f2b_jail_stop (f2b_jail_t *jail); #endif /* F2B_JAIL_H_ */