Fix for guardian-CGI: As a result of fixing BUG11318
Message ID | 20170416221602.15439-1-matthias.fischer@ipfire.org |
---|---|
State | Accepted |
Commit | d68ead3decfdcc4ca4a1413e33f3c47270799836 |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id C264562252 for <patchwork@ipfire.org>; Mon, 17 Apr 2017 00:16:09 +0200 (CEST) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id B4ACF180C; Mon, 17 Apr 2017 00:16:08 +0200 (CEST) Received: from Devel.localdomain (p5DD83151.dip0.t-ipconnect.de [93.216.49.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id BF54ECCA for <development@lists.ipfire.org>; Mon, 17 Apr 2017 00:16:05 +0200 (CEST) From: Matthias Fischer <matthias.fischer@ipfire.org> To: development@lists.ipfire.org Subject: [PATCH] Fix for guardian-CGI: As a result of fixing BUG11318 Date: Mon, 17 Apr 2017 00:16:02 +0200 Message-Id: <20170416221602.15439-1-matthias.fischer@ipfire.org> X-Mailer: git-send-email 2.11.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> List-Unsubscribe: <http://lists.ipfire.org/mailman/options/development>, <mailto:development-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/development/> List-Post: <mailto:development@lists.ipfire.org> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Subscribe: <http://lists.ipfire.org/mailman/listinfo/development>, <mailto:development-request@lists.ipfire.org?subject=subscribe> Errors-To: development-bounces@lists.ipfire.org Sender: "Development" <development-bounces@lists.ipfire.org> |
Message
Matthias Fischer
April 17, 2017, 8:16 a.m. UTC
This is necessary because commit bf1985fae5baca327fcded31264f45638442f02e changes the
place where temporary files from 'iptables' are stored.
Some typos where fixed, too.
Best,
Matthias
Signed-off-by: Matthias Fischer <matthias.fischer@ipfire.org>
---
html/cgi-bin/guardian.cgi | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
Comments
Hi, On Mon, 2017-04-17 at 00:16 +0200, Matthias Fischer wrote: > This is necessary because commit bf1985fae5baca327fcded31264f45638442f02e > changes the > place where temporary files from 'iptables' are stored. To which commit are you referring to? There is no commit like that in the mainline repository: http://git.ipfire.org/?p=ipfire-2.x.git;a=commit;h=bf1985fae5baca327fcded31264f45638442f02e -Michael > > Some typos where fixed, too. > > Best, > Matthias > > Signed-off-by: Matthias Fischer <matthias.fischer@ipfire.org> > --- > html/cgi-bin/guardian.cgi | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/html/cgi-bin/guardian.cgi b/html/cgi-bin/guardian.cgi > index 963a56430..e15501ef5 100644 > --- a/html/cgi-bin/guardian.cgi > +++ b/html/cgi-bin/guardian.cgi > @@ -120,7 +120,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { > $errormessage = "$Lang::tr{'guardian invalid > blocktime'}"; > } > > - # Check if the bloccount is valid. > + # Check if the blockcount is valid. > unless(($settings{'GUARDIAN_BLOCKCOUNT'} =~ /^\d+$/) && > ($settings{'GUARDIAN_BLOCKCOUNT'} ne "0")) { > $errormessage = "$Lang::tr{'guardian invalid > blockcount'}"; > } > @@ -183,7 +183,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { > > # Generate the ID for the new entry. > # > - # Sort the keys by it's ID and store them in an > array. > + # Sort the keys by their ID and store them in an > array. > my @keys = sort { $a <=> $b } keys %ignored; > > # Reverse the key array. > @@ -664,11 +664,11 @@ sub showIgnoreBox() { > <td class='base' colspan='3' > bgcolor='$color{'color20'}'></td> > </tr> > END > - # Check if some hosts have been add to be ignored. > + # Check if some hosts have been added to be ignored. > if (keys (%ignored)) { > my $col = ""; > > - # Loop through all entries of the hash.. > + # Loop through all entries of the hash. > while( (my $key) = each %ignored) { > # Assign data array positions to some > nice variable names. > my $address = $ignored{$key}[0]; > @@ -784,7 +784,7 @@ END > &Header::closebox(); > } > > -# Function to list currently bocked addresses from guardian and unblock them > or add custom entries to block. > +# Function to list currently blocked addresses from guardian and unblock them > or add custom entries to block. > sub showBlockedBox() { > &Header::openbox('100%', 'center', $Lang::tr{'guardian blocked > hosts'}); > > @@ -795,7 +795,7 @@ sub showBlockedBox() { > </tr> > END > > - # Lauch function to get the currently blocked hosts. > + # Launch function to get the currently blocked hosts. > my @blocked_hosts = &GetBlockedHosts(); > > my $id = 0; > @@ -828,7 +828,7 @@ END > END > } > > - # If the loop only has been runs once the id still is "0", which > means there are no > + # If the loop only has been run once the id still is "0", which means > there are no > # additional entries (blocked hosts) in the iptables chain. > if ($id == 0) { > > @@ -890,11 +890,11 @@ sub GetBlockedHosts() { > # Create new, empty array. > my @hosts; > > - # Lauch helper to get chains from iptables. > + # Launch helper to get chains from iptables. > system('/usr/local/bin/getipstat'); > > # Open temporary file which contains the chains and rules. > - open (FILE, '/srv/web/ipfire/html/iptables.txt'); > + open (FILE, '/var/tmp/iptables.txt'); > > # Loop through the entire file. > while (<FILE>) { > @@ -909,7 +909,7 @@ sub GetBlockedHosts() { > next if ($line =~ /^Chain/); > next if ($line =~ /^ pkts/); > > - # Generate array, based on the line content > (seperator is a single or multiple space's) > + # Generate array, based on the line content > (separator is a single or multiple space) > my @comps = split(/\s{1,}/, $line); > my ($lead, $pkts, $bytes, $target, $prot, $opt, $in, > $out, $source, $destination) = @comps; > > @@ -927,9 +927,9 @@ sub GetBlockedHosts() { > close(FILE); > > # Remove recently created temporary files of the "getipstat" binary. > - system(rm -f "/srv/web/ipfire/html/iptables.txt"); > - system(rm -f "/srv/web/ipfire/html/iptablesmangle.txt"); > - system(rm -f "/srv/web/ipfire/html/iptablesnat.txt"); > + system("rm -f /var/tmp/iptables.txt"); > + system("rm -f /var/tmp/iptablesmangle.txt"); > + system("rm -f /var/tmp/iptablesnat.txt"); > > # Convert entries, sort them, write back and store the sorted entries > into new array. > my @sorted = map { $_->[0] } > @@ -947,7 +947,7 @@ sub BuildConfiguration() { > > my $configfile = "${General::swroot}/guardian/guardian.conf"; > > - # Create the configfile if not exist yet. > + # Create the configfile if none exists yet. > unless (-e "$configfile") { system("touch $configfile"); } > > # Open configfile for writing.
On 17.04.2017 13:27, Michael Tremer wrote: > Hi, > > On Mon, 2017-04-17 at 00:16 +0200, Matthias Fischer wrote: >> This is necessary because commit bf1985fae5baca327fcded31264f45638442f02e >> changes the >> place where temporary files from 'iptables' are stored. > > To which commit are you referring to? There is no commit like that in the > mainline repository: > > http://git.ipfire.org/?p=ipfire-2.x.git;a=commit;h=bf1985fae5baca327fcded31264f45638442f02e Ok, try this one: ;-) http://git.ipfire.org/?p=people/mfischer/ipfire-2.x.git;a=commit;h=bf1985fae5baca327fcded31264f45638442f02e Best, Matthias > -Michael > >> >> Some typos where fixed, too. >> >> Best, >> Matthias >> >> Signed-off-by: Matthias Fischer <matthias.fischer@ipfire.org> >> --- >> html/cgi-bin/guardian.cgi | 28 ++++++++++++++-------------- >> 1 file changed, 14 insertions(+), 14 deletions(-) >> >> diff --git a/html/cgi-bin/guardian.cgi b/html/cgi-bin/guardian.cgi >> index 963a56430..e15501ef5 100644 >> --- a/html/cgi-bin/guardian.cgi >> +++ b/html/cgi-bin/guardian.cgi >> @@ -120,7 +120,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { >> $errormessage = "$Lang::tr{'guardian invalid >> blocktime'}"; >> } >> >> - # Check if the bloccount is valid. >> + # Check if the blockcount is valid. >> unless(($settings{'GUARDIAN_BLOCKCOUNT'} =~ /^\d+$/) && >> ($settings{'GUARDIAN_BLOCKCOUNT'} ne "0")) { >> $errormessage = "$Lang::tr{'guardian invalid >> blockcount'}"; >> } >> @@ -183,7 +183,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { >> >> # Generate the ID for the new entry. >> # >> - # Sort the keys by it's ID and store them in an >> array. >> + # Sort the keys by their ID and store them in an >> array. >> my @keys = sort { $a <=> $b } keys %ignored; >> >> # Reverse the key array. >> @@ -664,11 +664,11 @@ sub showIgnoreBox() { >> <td class='base' colspan='3' >> bgcolor='$color{'color20'}'></td> >> </tr> >> END >> - # Check if some hosts have been add to be ignored. >> + # Check if some hosts have been added to be ignored. >> if (keys (%ignored)) { >> my $col = ""; >> >> - # Loop through all entries of the hash.. >> + # Loop through all entries of the hash. >> while( (my $key) = each %ignored) { >> # Assign data array positions to some >> nice variable names. >> my $address = $ignored{$key}[0]; >> @@ -784,7 +784,7 @@ END >> &Header::closebox(); >> } >> >> -# Function to list currently bocked addresses from guardian and unblock them >> or add custom entries to block. >> +# Function to list currently blocked addresses from guardian and unblock them >> or add custom entries to block. >> sub showBlockedBox() { >> &Header::openbox('100%', 'center', $Lang::tr{'guardian blocked >> hosts'}); >> >> @@ -795,7 +795,7 @@ sub showBlockedBox() { >> </tr> >> END >> >> - # Lauch function to get the currently blocked hosts. >> + # Launch function to get the currently blocked hosts. >> my @blocked_hosts = &GetBlockedHosts(); >> >> my $id = 0; >> @@ -828,7 +828,7 @@ END >> END >> } >> >> - # If the loop only has been runs once the id still is "0", which >> means there are no >> + # If the loop only has been run once the id still is "0", which means >> there are no >> # additional entries (blocked hosts) in the iptables chain. >> if ($id == 0) { >> >> @@ -890,11 +890,11 @@ sub GetBlockedHosts() { >> # Create new, empty array. >> my @hosts; >> >> - # Lauch helper to get chains from iptables. >> + # Launch helper to get chains from iptables. >> system('/usr/local/bin/getipstat'); >> >> # Open temporary file which contains the chains and rules. >> - open (FILE, '/srv/web/ipfire/html/iptables.txt'); >> + open (FILE, '/var/tmp/iptables.txt'); >> >> # Loop through the entire file. >> while (<FILE>) { >> @@ -909,7 +909,7 @@ sub GetBlockedHosts() { >> next if ($line =~ /^Chain/); >> next if ($line =~ /^ pkts/); >> >> - # Generate array, based on the line content >> (seperator is a single or multiple space's) >> + # Generate array, based on the line content >> (separator is a single or multiple space) >> my @comps = split(/\s{1,}/, $line); >> my ($lead, $pkts, $bytes, $target, $prot, $opt, $in, >> $out, $source, $destination) = @comps; >> >> @@ -927,9 +927,9 @@ sub GetBlockedHosts() { >> close(FILE); >> >> # Remove recently created temporary files of the "getipstat" binary. >> - system(rm -f "/srv/web/ipfire/html/iptables.txt"); >> - system(rm -f "/srv/web/ipfire/html/iptablesmangle.txt"); >> - system(rm -f "/srv/web/ipfire/html/iptablesnat.txt"); >> + system("rm -f /var/tmp/iptables.txt"); >> + system("rm -f /var/tmp/iptablesmangle.txt"); >> + system("rm -f /var/tmp/iptablesnat.txt"); >> >> # Convert entries, sort them, write back and store the sorted entries >> into new array. >> my @sorted = map { $_->[0] } >> @@ -947,7 +947,7 @@ sub BuildConfiguration() { >> >> my $configfile = "${General::swroot}/guardian/guardian.conf"; >> >> - # Create the configfile if not exist yet. >> + # Create the configfile if none exists yet. >> unless (-e "$configfile") { system("touch $configfile"); } >> >> # Open configfile for writing. >