From af6856afc470656283347c86106c76d4ba3a6f49 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 24 Feb 2016 12:41:12 +0100 Subject: [PATCH] guardian.cgi: Send commands through socket connection. The guardianctrl binary does not longer exists, use the Guardian::Socket module to send various commands by using the provided socket client. Signed-off-by: Stefan Schantl --- html/cgi-bin/guardian.cgi | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/html/cgi-bin/guardian.cgi b/html/cgi-bin/guardian.cgi index 836eabe1ae..5fadc4562d 100644 --- a/html/cgi-bin/guardian.cgi +++ b/html/cgi-bin/guardian.cgi @@ -21,6 +21,7 @@ use strict; use Locale::Codes::Country; +use Guardian::Socket; # enable only the following on debugging purpose #use warnings; @@ -156,8 +157,8 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { # Check if guardian is running. if ($pid > 0) { - # Call guardianctrl to perform a reload. - system("/usr/local/bin/guardianctrl reload &>/dev/null"); + # Send reload command through socket connection. + &Guardian::Socket::Client("reload"); } ## Remove entry from ignore list. @@ -186,8 +187,8 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { # Check if guardian is running. if ($pid > 0) { - # Call guardianctrl to perform a reload. - system("/usr/local/bin/guardianctrl reload &>/dev/null"); + # Send reload command through socket connection. + &Guardian::Socket::Client("reload"); } ## Block a user given address or subnet. @@ -233,8 +234,8 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { if ($errormessage eq '') { my $block = $settings{'ADDRESS_BLOCK'}; - # Call helper to unblock address. - system("/usr/local/bin/guardianctrl block $block &>/dev/null"); + # Send command to block the specified address through socket connection. + &Guardian::Socket::Client("block $block"); } ## Unblock address or subnet. @@ -257,16 +258,16 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) { if ($errormessage eq '') { my $unblock = $settings{'ADDRESS_UNBLOCK'}; - # Call helper to unblock address. - system("/usr/local/bin/guardianctrl unblock $unblock &>/dev/null"); + # Send command to unblock the given address through socket connection. + &Guardian::Socket::Client("unblock $unblock"); } ## Unblock all. # } elsif ($settings{'ACTION'} eq $Lang::tr{'unblock all'}) { - # Call helper to flush iptables chain from guardian. - system("/usr/local/bin/guardianctrl flush-chain &>/dev/null"); + # Send flush command through socket connection. + &Guardian::Socket::Client("flush"); } # Load settings from file. @@ -749,14 +750,14 @@ sub BuildConfiguration() { # Check if guardian should be started or stopped. if($settings{'GUARDIAN_ENABLED'} eq 'on') { if($pid > 0) { - # Call guardianctl to perform a reload. - system("/usr/local/bin/guardianctrl reload &>/dev/null"); + # Send reload command through socket connection. + &Guardian::Socket::Client("reload"); } else { # Launch guardian. - system("/usr/local/bin/guardianctrl start &>/dev/null"); + system("/usr/local/bin/addonctrl guardian start &>/dev/null"); } } else { # Stop the daemon. - system("/usr/local/bin/guardianctrl stop &>/dev/null"); + system("/usr/local/bin/addonctrl guardian stop &>/dev/null"); } } -- 2.39.2