/[smecontribs]/rpms/smeserver-fail2ban/contribs10/smeserver-fail2ban-0.1.18-bz10819-whitelisthostfix.patch
ViewVC logotype

Contents of /rpms/smeserver-fail2ban/contribs10/smeserver-fail2ban-0.1.18-bz10819-whitelisthostfix.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Thu Dec 9 05:40:57 2021 UTC (2 years, 11 months ago) by jpp
Branch: MAIN
CVS Tags: smeserver-fail2ban-0_1_18-27_el7_sme, smeserver-fail2ban-0_1_18-31_el7_sme, smeserver-fail2ban-0_1_18-24_el7_sme, smeserver-fail2ban-0_1_18-30_el7_sme, smeserver-fail2ban-0_1_18-25_el7_sme, smeserver-fail2ban-0_1_18-32_el7_sme, smeserver-fail2ban-0_1_18-28_el7_sme, smeserver-fail2ban-0_1_18-29_el7_sme, smeserver-fail2ban-0_1_18-23_el7_sme, smeserver-fail2ban-0_1_18-26_el7_sme, HEAD
* Thu Dec 09 2021 Jean-Philippe Pialasse <tests@pialasse.com> 0.1.18-23.sme
- fix adding removing whitelisted hosts [SME: 10819]
  moved config options to dedicated page
- removed apache-badbots.local, lot of false positives [SME: 10857]

1 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
2 --- 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
3 +++ 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
4 @@ -187,4 +187,18 @@
5 <base>ERROR_UPDATING_WHITE</base>
6 <trans>Unable to unban and whitelist</trans>
7 </entry>
8 + <entry>
9 + <base>ERR_EXISTS</base>
10 + <trans>Error: IP already in whitelist</trans>
11 + </entry>
12 + <entry>
13 + <base>SEND_MAIL_STATUS</base>
14 + <trans>Send mail on ban</trans>
15 + </entry>
16 + <entry>
17 + <base>EMAIL</base>
18 + <trans>Alert Email</trans>
19 + </entry>
20 +
21 +
22 </lexicon>
23 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
24 --- smeserver-fail2ban-0.1.18.old/root/etc/e-smith/web/functions/fail2ban 2021-12-09 00:02:36.570000000 -0500
25 +++ smeserver-fail2ban-0.1.18/root/etc/e-smith/web/functions/fail2ban 2021-12-09 00:26:20.847000000 -0500
26 @@ -14,15 +14,47 @@
27 __DATA__
28 <form title="Fail2Ban" header="/etc/e-smith/web/common/head.tmpl"
29 footer="/etc/e-smith/web/common/foot.tmpl">
30 - <page name="First" post-event="change_settings()"
31 + <page name="First" post-event="change_whitelist()"
32 pre-event="print_status_message()">
33
34 - <field type="select" id="status"
35 - options=" 'enabled' => 'ENABLED', 'disabled' => 'DISABLED'"
36 - value="get_prop('fail2ban', 'status')">
37 - <label>STATUS</label>
38 - <description>SERVICE_STATUS</description>
39 + <subroutine src="show_config_link()"/>
40 +
41 +
42 + <subroutine src="show_valid_from_list()"/>
43 + <field type="text" id="ip" value=""
44 + validation="ip_number_or_blank">
45 + <description>DESC_ADD_IP</description>
46 + <label>ADD_IP</label>
47 </field>
48 + <field type="text" id="bits" value=""
49 + validation="subnet_mask_bit, validate_network_and_mask">
50 + <description>DESC_ADD_BITS</description>
51 + <label>ADD_BITS</label>
52 + </field>
53 +
54 +
55 + <subroutine src="print_button('SAVE')" />
56 +
57 + <subroutine src="show_current_deny()"/>
58 + </page>
59 + <page name="Second"
60 + pre-event="RemoveIP()">
61 + <subroutine src="print_status_message()" />
62 + <subroutine src="back()" />
63 + </page>
64 +
65 +
66 +
67 +
68 + <page name="Config"
69 + post-event="change_settings()" >
70 + <subroutine src="print_status_message()" />
71 + <field type="select" id="status"
72 + options=" 'enabled' => 'ENABLED', 'disabled' => 'DISABLED'"
73 + value="get_prop('fail2ban', 'status')">
74 + <label>STATUS</label>
75 + <description>SERVICE_STATUS</description>
76 + </field>
77 <field type="select" id="FilterLocalNetworks"
78 options=" 'enabled' => 'ENABLED', 'disabled' => 'DISABLED'"
79 value="get_prop('fail2ban', 'FilterLocalNetworks')">
80 @@ -72,7 +104,7 @@
81 <label>QPSMTPD</label>
82 <description>QPSMTPD_STATUS</description>
83 </field>
84 - <field type="select" id="dovecot"
85 + <field type="select" id="dovecot"
86 options=" 'enabled' => 'ENABLED', 'disabled' => 'DISABLED'"
87 value="get_prop('dovecot', 'Fail2Ban')">
88 <label>IMAP</label>
89 @@ -115,29 +147,8 @@
90 <description>WORDPRESS_STATUS</description>
91 </field>
92
93 + <subroutine src="print_button('SAVE')" />
94
95 -
96 - <subroutine src="show_valid_from_list()"/>
97 - <field type="text" id="ip" value=""
98 - validation="ip_number_or_blank">
99 - <description>DESC_ADD_IP</description>
100 - <label>ADD_IP</label>
101 - </field>
102 - <field type="text" id="bits" value=""
103 - validation="subnet_mask_bit, validate_network_and_mask">
104 - <description>DESC_ADD_BITS</description>
105 - <label>ADD_BITS</label>
106 - </field>
107 -
108 -
109 - <subroutine src="print_button('SAVE')" />
110 -
111 - <subroutine src="show_current_deny()"/>
112 - </page>
113 - <page name="Second"
114 - pre-event="RemoveIP()">
115 - <subroutine src="print_status_message()" />
116 - <subroutine src="back()" />
117 </page>
118 </form>
119
120 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
121 --- 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
122 +++ smeserver-fail2ban-0.1.18/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/fail2ban.pm 2021-12-09 00:29:28.253000000 -0500
123 @@ -14,7 +14,7 @@
124
125 our @ISA = qw(esmith::FormMagick Exporter);
126
127 -our @EXPORT = qw(get_value get_prop change_settings RemoveIP);
128 +our @EXPORT = qw(get_value get_prop change_settings RemoveIP add_new_valid_from);
129
130 our $VERSION = sprintf '%d.%03d', q$Revision: 1.1 $ =~ /: (\d+).(\d+)/;
131 our $db = esmith::ConfigDB->open
132 @@ -128,6 +128,16 @@
133 return esmith::util::IPquadToAddr($a) <=> esmith::util::IPquadToAddr($b);
134 }
135
136 +sub show_config_link
137 +{
138 + my $self = shift;
139 + my $q = $self->{cgi};
140 +
141 + print '<tr><td colspan=2>',"<a href=\"$scriptname?page=0&page_stack=&Next=Next&wherenext=Config\">",
142 + $q->p($self->localise('CONFIG')),'</a></td></tr>';
143 + return '';
144 +}
145 +
146 sub show_valid_from_list
147 {
148 my $self = shift;
149 @@ -226,7 +236,7 @@
150 my $prop = $rec->prop('IgnoreIP') || '';
151
152 my @vals = split /,/, $prop;
153 - return '' if (grep /^$ip\/$bits$/, @vals); # already have this entry
154 + return $self->error('ERR_EXISTS') if (grep /^$ip\/$bits$/, @vals); # already have this entry
155
156 if ($prop ne '')
157 {
158 @@ -239,7 +249,7 @@
159 $rec->set_prop('IgnoreIP', $prop);
160 $q->delete('ip');
161 $q->delete('bits');
162 - return 1;
163 + return 1
164 }
165
166 sub remove_valid_from
167 @@ -278,6 +288,28 @@
168 return 1;
169 }
170
171 +sub change_whitelist {
172 + my ($fm) = @_;
173 + my $q = $fm->{'cgi'};
174 +
175 + my %conf;
176 +
177 + # Don't process the form unless we clicked the Save button. The event is
178 + # called even if we chose the Remove link or the Add link.
179 + return unless($q->param('Next') eq $fm->localise('SAVE'));
180 + my $ip = ($q->param ('ip') || '');
181 + return '' unless $fm->add_new_valid_from;
182 + return '' unless $fm->remove_valid_from;
183 +
184 + unless ( system( "/sbin/e-smith/signal-event", "fail2ban-conf" ) == 0 )
185 + {
186 + $fm->error('ERROR_UPDATING');
187 + return undef;
188 + }
189 +
190 + $fm->success('SUCCESS');
191 +}
192 +
193 sub change_settings {
194 my ($fm) = @_;
195 my $q = $fm->{'cgi'};
196 @@ -359,7 +391,7 @@
197
198 if ( $rec->prop('status') eq 'disabled' )
199 {
200 - unless ( `/etc/init.d/fail2ban stop` )
201 + unless ( `/usr/bin/systemctl stop fail2ban` )
202 {
203 $fm->error('ERROR_STOPPING');
204 return undef;

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed