#!/usr/local/bin/perl # edit_portsentry.cgi # Display portsentry configuration menu require './sentry-lib.pl'; $path = &has_command($config{'portsentry'}); if (!$path) { &ui_print_header(undef, $text{'portsentry_title'}, ""); print "

",&text('portsentry_ecommand', "$config{'portsentry'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; &ui_print_footer("", $text{'index_return'}); exit; } if (!-r $config{'portsentry_config'} && -r $config{'portsentry_alt_config'}) { system("cp $config{'portsentry_alt_config'} $config{'portsentry_config'}"); } # Get the version, if needed &read_file("$module_config_directory/portsentry", \%portsentry); @st = stat($path); if ($st[7] != $portsentry{'size'} || $st[9] != $portsentry{'mtime'}) { $out = &backquote_command("$config{'portsentry'} -v 2>&1", 1); if ($out !~ /Version:\s+(\S+)/) { &ui_print_header(undef, $text{'portsentry_title'}, ""); print "

",&text('portsentry_eversion', "$config{'portsentry'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; &ui_print_footer("", $text{'index_return'}); exit; } $portsentry{'version'} = $1; $portsentry{'size'} = $st[7]; $portsentry{'mtime'} = $st[9]; &write_file("$module_config_directory/portsentry", \%portsentry); } &ui_print_header(undef, $text{'portsentry_title'}, "", "portsentry", 0, 0, undef, &help_search_link("portsentry", "man", "doc"), undef, undef, &text('portsentry_version', $portsentry{'version'})); if ($portsentry{'version'} >= 2) { print "

",&text('portsentry_eversion2', "$config{'portsentry'}", $portsentry{'version'}),"

\n"; &ui_print_footer("", $text{'index_return'}); exit; } # Show configuration form $conf = &get_portsentry_config(); print "

\n"; print "\n"; print "\n"; print "
$text{'portsentry_header'}
\n"; $tcp_ports = &find_value("TCP_PORTS", $conf); $udp_ports = &find_value("UDP_PORTS", $conf); $tcp_adv = &find_value("ADVANCED_PORTS_TCP", $conf); $udp_adv = &find_value("ADVANCED_PORTS_UDP", $conf); $tcp_exc = &find_value("ADVANCED_EXCLUDE_TCP", $conf); $udp_exc = &find_value("ADVANCED_EXCLUDE_UDP", $conf); print "\n"; print "\n"; $tblock = &find_value("BLOCK_TCP", $conf); print "\n"; $ublock = &find_value("BLOCK_UDP", $conf); print "\n"; print "\n"; printf "\n", &find_value("PORT_BANNER", $conf); print "\n"; printf "\n", &find_value("SCAN_TRIGGER", $conf); if ($config{'portsentry_ignore'}) { $ign = $config{'portsentry_ignore'}; } else { $ign = &find_value("IGNORE_FILE", $conf); } if ($ign) { print "\n"; print "
$text{'portsentry_tmode'} \n"; printf "%s
\n", $text{'portsentry_mode0'}, join(" ", split(/,/, $tcp_ports)); $tcp_exc = join(" ", split(/,/, $tcp_exc)); print &text('portsentry_mode1', "", ""),"
$text{'portsentry_umode'} \n"; printf "%s
\n", $text{'portsentry_mode0'}, join(" ", split(/,/, $udp_ports)); $udp_exc = join(" ", split(/,/, $udp_exc)); print &text('portsentry_mode1', "", ""),"
$text{'portsentry_tblock'} \n"; printf " $text{'yes'}\n", $tblock == 1 ? "checked" : ""; printf " $text{'no'}\n", $tblock == 0 ? "checked" : ""; printf " $text{'portsentry_kill'}\n", $tblock == 2 ? "checked" : ""; print "
$text{'portsentry_ublock'} \n"; printf " $text{'yes'}\n", $ublock == 1 ? "checked" : ""; printf " $text{'no'}\n", $ublock == 0 ? "checked" : ""; printf " $text{'portsentry_kill'}\n", $ublock == 2 ? "checked" : ""; print "
$text{'portsentry_banner'}
$text{'portsentry_trigger'}
$text{'portsentry_ignore'}
\n"; print "\n" if (defined($editbelow)); } print "
\n"; @pids = &get_portsentry_pids(); if (@pids) { print "
\n"; } else { print "\n"; } # Show start/stop buttons print &ui_hr(); print "\n"; $cmd = &portsentry_start_cmd(); if (@pids) { # Running .. offer to stop print "\n"; print "\n"; print "\n"; print "\n"; } else { # Not running .. offer to start print "\n"; print "\n"; print "\n"; } print "
$text{'portsentry_stopdesc'}
",&text('portsentry_startdesc', "$cmd"), "
\n"; &ui_print_footer("", $text{'index_return'});