diff -Nur --no-dereference smeserver-fail2ban-0.1.18.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/fail2ban smeserver-fail2ban-0.1.18/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/fail2ban
--- smeserver-fail2ban-0.1.18.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/fail2ban 2021-12-09 00:02:36.570000000 -0500
+++ smeserver-fail2ban-0.1.18/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/fail2ban 2021-12-09 00:35:05.242000000 -0500
@@ -187,4 +187,18 @@
ERROR_UPDATING_WHITE
Unable to unban and whitelist
+
+ ERR_EXISTS
+ Error: IP already in whitelist
+
+
+ SEND_MAIL_STATUS
+ Send mail on ban
+
+
+ EMAIL
+ Alert Email
+
+
+
diff -Nur --no-dereference smeserver-fail2ban-0.1.18.old/root/etc/e-smith/web/functions/fail2ban smeserver-fail2ban-0.1.18/root/etc/e-smith/web/functions/fail2ban
--- smeserver-fail2ban-0.1.18.old/root/etc/e-smith/web/functions/fail2ban 2021-12-09 00:02:36.570000000 -0500
+++ smeserver-fail2ban-0.1.18/root/etc/e-smith/web/functions/fail2ban 2021-12-09 00:26:20.847000000 -0500
@@ -14,15 +14,47 @@
__DATA__
diff -Nur --no-dereference smeserver-fail2ban-0.1.18.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/fail2ban.pm smeserver-fail2ban-0.1.18/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/fail2ban.pm
--- smeserver-fail2ban-0.1.18.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/fail2ban.pm 2021-12-09 00:02:36.664000000 -0500
+++ smeserver-fail2ban-0.1.18/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/fail2ban.pm 2021-12-09 00:29:28.253000000 -0500
@@ -14,7 +14,7 @@
our @ISA = qw(esmith::FormMagick Exporter);
-our @EXPORT = qw(get_value get_prop change_settings RemoveIP);
+our @EXPORT = qw(get_value get_prop change_settings RemoveIP add_new_valid_from);
our $VERSION = sprintf '%d.%03d', q$Revision: 1.1 $ =~ /: (\d+).(\d+)/;
our $db = esmith::ConfigDB->open
@@ -128,6 +128,16 @@
return esmith::util::IPquadToAddr($a) <=> esmith::util::IPquadToAddr($b);
}
+sub show_config_link
+{
+ my $self = shift;
+ my $q = $self->{cgi};
+
+ print '',"",
+ $q->p($self->localise('CONFIG')),' |
';
+ return '';
+}
+
sub show_valid_from_list
{
my $self = shift;
@@ -226,7 +236,7 @@
my $prop = $rec->prop('IgnoreIP') || '';
my @vals = split /,/, $prop;
- return '' if (grep /^$ip\/$bits$/, @vals); # already have this entry
+ return $self->error('ERR_EXISTS') if (grep /^$ip\/$bits$/, @vals); # already have this entry
if ($prop ne '')
{
@@ -239,7 +249,7 @@
$rec->set_prop('IgnoreIP', $prop);
$q->delete('ip');
$q->delete('bits');
- return 1;
+ return 1
}
sub remove_valid_from
@@ -278,6 +288,28 @@
return 1;
}
+sub change_whitelist {
+ my ($fm) = @_;
+ my $q = $fm->{'cgi'};
+
+ my %conf;
+
+ # Don't process the form unless we clicked the Save button. The event is
+ # called even if we chose the Remove link or the Add link.
+ return unless($q->param('Next') eq $fm->localise('SAVE'));
+ my $ip = ($q->param ('ip') || '');
+ return '' unless $fm->add_new_valid_from;
+ return '' unless $fm->remove_valid_from;
+
+ unless ( system( "/sbin/e-smith/signal-event", "fail2ban-conf" ) == 0 )
+ {
+ $fm->error('ERROR_UPDATING');
+ return undef;
+ }
+
+ $fm->success('SUCCESS');
+}
+
sub change_settings {
my ($fm) = @_;
my $q = $fm->{'cgi'};
@@ -359,7 +391,7 @@
if ( $rec->prop('status') eq 'disabled' )
{
- unless ( `/etc/init.d/fail2ban stop` )
+ unless ( `/usr/bin/systemctl stop fail2ban` )
{
$fm->error('ERROR_STOPPING');
return undef;