From: Franck B. <fra...@us...> - 2007-08-24 15:37:05
|
Update of /cvsroot/ipcop/ipcop/html/cgi-bin In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv30781/html/cgi-bin Modified Files: Tag: IPCOP_v1_4_0 ids.cgi Log Message: Fix snort color indicating the state b adding 'BLUE'when not active. Allow restartsnort to read the name of a config file to use per interface. Also use the config file to read enabled states (kill flag file). Definitly rename ENABLE to ENABLE_RED in cgi code for readability and because it avoids uneeded 'if tests' in the helper. Note: the BLUE color indicating 'disabled' state can be use on all isrunning call by adding the boolean state of the service in the call: isrunning('service', active_service eq 'on'); Index: ids.cgi =================================================================== RCS file: /cvsroot/ipcop/ipcop/html/cgi-bin/ids.cgi,v retrieving revision 1.8.2.36 retrieving revision 1.8.2.37 diff -C2 -d -r1.8.2.36 -r1.8.2.37 *** ids.cgi 13 Jun 2007 20:06:39 -0000 1.8.2.36 --- ids.cgi 24 Aug 2007 15:36:57 -0000 1.8.2.37 *************** *** 36,40 **** &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); ! $snortsettings{'ENABLE_SNORT'} = 'off'; #this is historically for RED $snortsettings{'ENABLE_SNORT_GREEN'} = 'off'; $snortsettings{'ENABLE_SNORT_BLUE'} = 'off'; --- 36,40 ---- &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); ! $snortsettings{'ENABLE_SNORT_RED'} = 'off'; $snortsettings{'ENABLE_SNORT_GREEN'} = 'off'; $snortsettings{'ENABLE_SNORT_BLUE'} = 'off'; *************** *** 43,46 **** --- 43,47 ---- $snortsettings{'RULESTYPE'} = 'nothing'; $snortsettings{'OINKCODE'} = ''; + &Header::getcgihash(\%snortsettings); *************** *** 59,83 **** if ($snortsettings{'ACTION'} eq $Lang::tr{'save'}) { &General::writehash("${General::swroot}/snort/settings", \%snortsettings); - if ($snortsettings{'ENABLE_SNORT'} eq 'on') { - system ('/bin/touch', "${General::swroot}/snort/enable"); - } else { - unlink "${General::swroot}/snort/enable"; - } - if ($snortsettings{'ENABLE_SNORT_GREEN'} eq 'on') { - system ('/bin/touch', "${General::swroot}/snort/enable_green"); - } else { - unlink "${General::swroot}/snort/enable_green"; - } - if ($snortsettings{'ENABLE_SNORT_BLUE'} eq 'on') { - system ('/bin/touch', "${General::swroot}/snort/enable_blue"); - } else { - unlink "${General::swroot}/snort/enable_blue"; - } - if ($snortsettings{'ENABLE_SNORT_ORANGE'} eq 'on') { - system ('/bin/touch', "${General::swroot}/snort/enable_orange"); - } else { - unlink "${General::swroot}/snort/enable_orange"; - } # keep track that settings has been changed until 'apply' is used $snorttags{'APPLY'} = 'NEEDED'; --- 60,82 ---- if ($snortsettings{'ACTION'} eq $Lang::tr{'save'}) { + # The restartsnort helper reads the following variables. + # It defaults to /etc/snort/snort.conf for each variable. + # The cgi don't manage that choice yet, so we just copy values + # Todo: -move the actual config file in /var/ipcop/snort (the standart location) + # -?we can provide two or more predifined config file. The user choose the best with GUI. + # Note:letting the user manage it's configfile per interface is enought. + + my %temp_snortsettings=(); + &General::readhash("${General::swroot}/snort/settings", \%temp_snortsettings); + $snortsettings{'CONFIG_SNORT_RED'} = $temp_snortsettings{'CONFIG_SNORT_RED'} + if defined ($temp_snortsettings{'CONFIG_SNORT_RED'}); + $snortsettings{'CONFIG_SNORT_GREEN'} = $temp_snortsettings{'CONFIG_SNORT_GREEN'} + if defined ($temp_snortsettings{'CONFIG_SNORT_GREEN'}); + $snortsettings{'CONFIG_SNORT_ORANGE'} = $temp_snortsettings{'CONFIG_SNORT_ORANGE'} + if defined ($temp_snortsettings{'CONFIG_SNORT_ORANGE'}); + $snortsettings{'CONFIG_SNORT_BLUE'} = $temp_snortsettings{'CONFIG_SNORT_BLUE'} + if defined ($temp_snortsettings{'CONFIG_SNORT_BLUE'}); + &General::writehash("${General::swroot}/snort/settings", \%snortsettings); # keep track that settings has been changed until 'apply' is used $snorttags{'APPLY'} = 'NEEDED'; *************** *** 164,174 **** close FILE; chomp $iface; ! $red_status=&General::isrunning("snort_$iface"); } ! my $green_status=&General::isrunning("snort_$netsettings{'GREEN_DEV'}"); ! $checked{'ENABLE_SNORT'}{'off'} = ''; ! $checked{'ENABLE_SNORT'}{'on'} = ''; ! $checked{'ENABLE_SNORT'}{$snortsettings{'ENABLE_SNORT'}} = "checked='checked'"; $checked{'ENABLE_SNORT_GREEN'}{'off'} = ''; $checked{'ENABLE_SNORT_GREEN'}{'on'} = ''; --- 163,173 ---- close FILE; chomp $iface; ! $red_status=&General::isrunning("snort_$iface", $snortsettings{'ENABLE_SNORT_RED'} eq 'on'); } ! my $green_status=&General::isrunning("snort_$netsettings{'GREEN_DEV'}", $snortsettings{'ENABLE_SNORT_GREEN'} eq 'on'); ! $checked{'ENABLE_SNORT_RED'}{'off'} = ''; ! $checked{'ENABLE_SNORT_RED'}{'on'} = ''; ! $checked{'ENABLE_SNORT_RED'}{$snortsettings{'ENABLE_SNORT_RED'}} = "checked='checked'"; $checked{'ENABLE_SNORT_GREEN'}{'off'} = ''; $checked{'ENABLE_SNORT_GREEN'}{'on'} = ''; *************** *** 221,225 **** ; if ($netsettings{'BLUE_DEV'} ne '') { ! my $blue_status=&General::isrunning("snort_$netsettings{'BLUE_DEV'}"); print <<END <tr> --- 220,224 ---- ; if ($netsettings{'BLUE_DEV'} ne '') { ! my $blue_status=&General::isrunning("snort_$netsettings{'BLUE_DEV'}", $snortsettings{'ENABLE_SNORT_BLUE'} eq 'on'); print <<END <tr> *************** *** 232,236 **** } if ($netsettings{'ORANGE_DEV'} ne '') { ! my $orange_status=&General::isrunning("snort_$netsettings{'ORANGE_DEV'}"); print <<END <tr> --- 231,235 ---- } if ($netsettings{'ORANGE_DEV'} ne '') { ! my $orange_status=&General::isrunning("snort_$netsettings{'ORANGE_DEV'}", $snortsettings{'ENABLE_SNORT_ORANGE'} eq 'on'); print <<END <tr> *************** *** 244,248 **** print <<END <tr> ! <td class='base'><input type='checkbox' name='ENABLE_SNORT' $checked{'ENABLE_SNORT'}{'on'} /> RED Snort $iface</td> $red_status --- 243,247 ---- print <<END <tr> ! <td class='base'><input type='checkbox' name='ENABLE_SNORT_RED' $checked{'ENABLE_SNORT_RED'}{'on'} /> RED Snort $iface</td> $red_status |