From 0d8cc90f4dead04de7181634377fe11115678f34 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Fri, 15 Feb 2019 12:18:45 +0100 Subject: [PATCH] services.cgi: Show status of suricata instead of snort Signed-off-by: Stefan Schantl --- html/cgi-bin/services.cgi | 43 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index 64fdbba05a..26ab4f3143 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -56,6 +56,7 @@ my %servicenames =( $Lang::tr{'secure shell server'} => 'sshd', $Lang::tr{'vpn'} => 'charon', $Lang::tr{'web proxy'} => 'squid', + $Lang::tr{'intrusion detection system'} => 'suricata', 'OpenVPN' => 'openvpn' ); @@ -71,30 +72,15 @@ my %link =( $Lang::tr{'vpn'} => "$Lang::tr{'vpn'}", $Lang::tr{'web proxy'} => "$Lang::tr{'web proxy'}", 'OpenVPN' => "OpenVPN", - "$Lang::tr{'intrusion detection system'} (GREEN)" => "$Lang::tr{'intrusion detection system'} (GREEN)", - "$Lang::tr{'intrusion detection system'} (RED)" => "$Lang::tr{'intrusion detection system'} (RED)", - "$Lang::tr{'intrusion detection system'} (ORANGE)" => "$Lang::tr{'intrusion detection system'} (ORANGE)", - "$Lang::tr{'intrusion detection system'} (BLUE)" => "$Lang::tr{'intrusion detection system'} (BLUE)" + "$Lang::tr{'intrusion detection system'}" => "$Lang::tr{'intrusion detection system'}", ); -my $lines=0; # Used to count the outputlines to make different bgcolor - -my $iface = ''; -if (open(FILE, "${General::swroot}/red/iface")){ - $iface = ; - close FILE; - chomp $iface; -} - -$servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}"; -$servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}"; +# Hash to overwrite the process name of a process if it differs fromt the launch command. +my %overwrite_exename_hash = ( + "suricata" => "Suricata-Main" +); -if ($netsettings{'ORANGE_DEV'} ne ''){ - $servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}"; -} -if ($netsettings{'BLUE_DEV'} ne ''){ - $servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}"; -} +my $lines=0; # Used to count the outputlines to make different bgcolor my @querry = split(/\?/,$ENV{'QUERY_STRING'}); $querry[0] = '' unless defined $querry[0]; @@ -258,7 +244,20 @@ sub isrunning{ my $memory; $cmd =~ /(^[a-z]+)/; - $exename = $1; + + # Check if the exename needs to be overwritten. + # This happens if the expected process name string + # differs from the real one. This may happened if + # a service uses multiple processes or threads. + if (exists($overwrite_exename_hash{$1})) { + # Grab the string which will be reported by + # the process from the corresponding hash. + $exename = $overwrite_exename_hash{$1}; + } else { + # Directly expect the launched command as + # process name. + $exename = $1; + } if (open(FILE, "/var/run/${cmd}.pid")){ $pid = ; chomp $pid; -- 2.39.2