From c6ef90261881b6475beec6b8f72800155281001b Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 13 May 2014 23:35:10 -0700 Subject: [PATCH] Participate in install check and logs export --- fail2ban/fail2ban-lib.pl | 1 - fail2ban/install_check.pl | 18 ++++++++++++++++++ fail2ban/lang/en | 5 +++++ fail2ban/module.info | 1 + fail2ban/syslog_logs.pl | 25 +++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 fail2ban/install_check.pl create mode 100755 fail2ban/syslog_logs.pl diff --git a/fail2ban/fail2ban-lib.pl b/fail2ban/fail2ban-lib.pl index c8db3a20b..1d633adaa 100644 --- a/fail2ban/fail2ban-lib.pl +++ b/fail2ban/fail2ban-lib.pl @@ -1,6 +1,5 @@ # Functions for configuring the fail2ban log analyser # -# XXX other .pl files # XXX include in makedist.pl # XXX main help page # XXX help page for filters with description of / etc diff --git a/fail2ban/install_check.pl b/fail2ban/install_check.pl new file mode 100755 index 000000000..006058e23 --- /dev/null +++ b/fail2ban/install_check.pl @@ -0,0 +1,18 @@ +# install_check.pl + +use strict; +use warnings; +our (%text, %in, %access, %config); +do 'fail2ban-lib.pl'; + +# is_installed(mode) +# For mode 1, returns 2 if the server is installed and configured for use by +# Webmin, 1 if installed but not configured, or 0 otherwise. +# For mode 0, returns 1 if installed, 0 if not +sub is_installed +{ +my ($mode) = @_; +my $err = &check_fail2ban(); +return $err ? 0 : $mode ? 2 : 1; +} + diff --git a/fail2ban/lang/en b/fail2ban/lang/en index 1d19a40c0..0d570ee89 100644 --- a/fail2ban/lang/en +++ b/fail2ban/lang/en @@ -142,3 +142,8 @@ config_logtarget=Write logs to config_syslog=Syslog service config_file=Log file config_default=Default destination + +syslog_logtarget=Fail2Ban action log + +__norefs=1 + diff --git a/fail2ban/module.info b/fail2ban/module.info index 72e3c48df..a3772c094 100644 --- a/fail2ban/module.info +++ b/fail2ban/module.info @@ -6,3 +6,4 @@ desc_de=Fail2Ban Intrusionsdetektor longdesc_de=Fail2ban schützt Ihr System vor Brute-Force-Angriffen, indem Quell-IPs blockiert werden. desc_ms_MY=Fail2Ban Pengesan Pencerobohan longdesc_ms_MY=Fail2ban melindungi sistem anda dari serangan kekerasan dengan mengesan mereka dan menyekat IP sumber mereka. +syslog=1 diff --git a/fail2ban/syslog_logs.pl b/fail2ban/syslog_logs.pl new file mode 100755 index 000000000..59fb05fc6 --- /dev/null +++ b/fail2ban/syslog_logs.pl @@ -0,0 +1,25 @@ +# Contains a function to supply the syslog module with extra logs + +use strict; +use warnings; +our (%text, %in, %access, %config); +do 'fail2ban-lib.pl'; + +# syslog_getlogs() +# Returns the Fail2Ban log +sub syslog_getlogs +{ +my @rv; +my $conf = &get_config(); +my ($def) = grep { $_->{'name'} eq 'Definition' } @$conf; +if ($def) { + my $logtarget = &find_value("logtarget", $def); + if ($logtarget =~ /^\//) { + push(@rv, { 'file' => $logtarget, + 'desc' => $text{'syslog_logtarget'}, + 'active' => 1 }); + } + } +return @rv; +} +