]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
IDS: Introduce ids-functions.pl.
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 14 Feb 2018 07:18:15 +0000 (08:18 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 26 Jul 2018 09:54:25 +0000 (11:54 +0200)
This library will contain a set of functions used by the IDS CGI script
and the planned update script for auto-updating the snort ruleset.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/cfgroot/ids-functions.pl [new file with mode: 0644]
config/rootfiles/common/configroot
html/cgi-bin/ids.cgi
lfs/configroot

diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl
new file mode 100644 (file)
index 0000000..52825ee
--- /dev/null
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2018 IPFire Team <info@ipfire.org>.                        #
+#                                                                          #
+############################################################################
+
+package IDS;
+
+require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/lang.pl";
+
+#
+## Function for checking if at least 300MB of free disk space are available
+## on the "/var" partition.
+#
+sub checkdiskspace () {
+       # Call diskfree to gather the free disk space of /var.
+       my @df = `/bin/df -B M /var`;
+
+       # Loop through the output.
+       foreach my $line (@df) {
+               # Ignore header line.
+               next if $line =~ m/^Filesystem/;
+
+               # Search for a line with the device information.
+               if ($line =~ m/dev/ ) {
+                       # Split the line into single pieces.
+                       my @values = split(' ', $line);
+                       my ($filesystem, $blocks, $used, $available, $used_perenctage, $mounted_on) = @values;
+
+                       # Check if the available disk space is more than 300MB.
+                       if ($available < 300) {
+                               # If there is not enough space, print out an error message.
+                               my $errormessage = "$Lang::tr{'not enough disk space'} < 300MB, /var $available MB";
+
+                               # Exit function and return the error message.
+                               return $errormessage;
+                       }
+               }
+       }
+
+       # Everything okay, return nothing.
+       return;
+}
+
+
+1;
index 87389915e4bf20e12990f19cb651259dc42daeee..8fb66bdb8ba7584b146366b930747137d2ab7d97 100644 (file)
@@ -77,6 +77,7 @@ var/ipfire/general-functions.pl
 var/ipfire/geoip-functions.pl
 var/ipfire/graphs.pl
 var/ipfire/header.pl
+var/ipfire/ids-functions.pl
 var/ipfire/isdn
 #var/ipfire/isdn/settings
 var/ipfire/key
index 656ed2d9b79d06841025d2237935bb1ae7e92b26..40bb820a516d8b516221c341f8e126afffee3f5b 100644 (file)
@@ -28,6 +28,7 @@ use strict;
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
+require "${General::swroot}/ids-functions.pl";
 
 my %color = ();
 my %mainsettings = ();
index c2833fd4a782812aa4c8f21a33e36cdb590a543e..c82a4eabeade61cc8d77526e8d3987269a709b3a 100644 (file)
@@ -80,6 +80,7 @@ $(TARGET) :
        cp $(DIR_SRC)/config/cfgroot/network-functions.pl       $(CONFIG_ROOT)/
        cp $(DIR_SRC)/config/cfgroot/geoip-functions.pl         $(CONFIG_ROOT)/
        cp $(DIR_SRC)/config/cfgroot/aws-functions.pl           $(CONFIG_ROOT)/
+       cp $(DIR_SRC)/config/cfgroot/ids-functions.pl           $(CONFIG_ROOT)/
        cp $(DIR_SRC)/config/cfgroot/lang.pl                    $(CONFIG_ROOT)/
        cp $(DIR_SRC)/config/cfgroot/countries.pl               $(CONFIG_ROOT)/
        cp $(DIR_SRC)/config/cfgroot/graphs.pl                  $(CONFIG_ROOT)/