]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/scripts/update-ids-ruleset
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2018 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 require '/var/ipfire/general-functions.pl';
26 require "${General::swroot}/ids-functions.pl";
27 require "${General::swroot}/lang.pl";
29 # The user and group name as which this script should be run.
30 my $run_as = 'nobody';
32 # Get user and group id of the user.
33 my ( $uid, $gid ) = ( getpwnam $run_as )[ 2, 3 ];
35 # Check if the script currently runs as root.
37 # Drop privileges and switch to the specified user and group.
38 POSIX
::setgid
( $gid );
39 POSIX
::setuid
( $uid );
42 # Check if the red device is active.
43 unless (-e
"${General::swroot}/red/active") {
44 # Store notice in the syslog.
45 &IDS
::_log_to_syslog
("The system is offline.");
47 # Store error message for displaying in the WUI.
48 &IDS
::_store_error_message
("$Lang::tr{'could not download latest updates'} - $Lang::tr{'system is offline'}");
54 # Check if enought free disk space is availabe.
55 if(&IDS
::checkdiskspace
()) {
56 # Store the error message for displaying in the WUI.
57 &IDS
::_store_error_message
("$Lang::tr{'not enough disk space'}");
64 &IDS
::lock_ids_page
();
66 # Call the download function and gather the new ruleset.
67 if(&IDS
::downloadruleset
()) {
68 # Store error message for displaying in the WUI.
69 &IDS
::_store_error_message
("$Lang::tr{'could not download latest updates'}");
71 # Unlock the IDS page.
72 &IDS
::unlock_ids_page
();
78 # Set correct ownership for the downloaded tarball.
79 &IDS
::set_ownership
("$IDS::rulestarball");
81 # Call oinkmaster to alter the ruleset.
84 # Set correct ownership for the rulesdir and files.
85 &IDS
::set_ownership
("$IDS::rulespath");
87 # Unlock the IDS page.
88 &IDS
::unlock_ids_page
();
90 # Check if the IDS is running.
91 if(&IDS
::ids_is_running
()) {
92 # Call suricatactrl to perform a reload.
93 &IDS
::call_suricatactrl
("reload");