mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 03:33:25 +02:00
IDS: Introduce ids-functions.pl.
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>
This commit is contained in:
64
config/cfgroot/ids-functions.pl
Normal file
64
config/cfgroot/ids-functions.pl
Normal file
@@ -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;
|
||||||
@@ -77,6 +77,7 @@ var/ipfire/general-functions.pl
|
|||||||
var/ipfire/geoip-functions.pl
|
var/ipfire/geoip-functions.pl
|
||||||
var/ipfire/graphs.pl
|
var/ipfire/graphs.pl
|
||||||
var/ipfire/header.pl
|
var/ipfire/header.pl
|
||||||
|
var/ipfire/ids-functions.pl
|
||||||
var/ipfire/isdn
|
var/ipfire/isdn
|
||||||
#var/ipfire/isdn/settings
|
#var/ipfire/isdn/settings
|
||||||
var/ipfire/key
|
var/ipfire/key
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use strict;
|
|||||||
require '/var/ipfire/general-functions.pl';
|
require '/var/ipfire/general-functions.pl';
|
||||||
require "${General::swroot}/lang.pl";
|
require "${General::swroot}/lang.pl";
|
||||||
require "${General::swroot}/header.pl";
|
require "${General::swroot}/header.pl";
|
||||||
|
require "${General::swroot}/ids-functions.pl";
|
||||||
|
|
||||||
my %color = ();
|
my %color = ();
|
||||||
my %mainsettings = ();
|
my %mainsettings = ();
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ $(TARGET) :
|
|||||||
cp $(DIR_SRC)/config/cfgroot/network-functions.pl $(CONFIG_ROOT)/
|
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/geoip-functions.pl $(CONFIG_ROOT)/
|
||||||
cp $(DIR_SRC)/config/cfgroot/aws-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/lang.pl $(CONFIG_ROOT)/
|
||||||
cp $(DIR_SRC)/config/cfgroot/countries.pl $(CONFIG_ROOT)/
|
cp $(DIR_SRC)/config/cfgroot/countries.pl $(CONFIG_ROOT)/
|
||||||
cp $(DIR_SRC)/config/cfgroot/graphs.pl $(CONFIG_ROOT)/
|
cp $(DIR_SRC)/config/cfgroot/graphs.pl $(CONFIG_ROOT)/
|
||||||
|
|||||||
Reference in New Issue
Block a user