Log port openings properly
authorJamie Cameron <jcameron@webmin.com>
Sat, 13 Aug 2011 19:52:16 +0000 (12:52 -0700)
committerJamie Cameron <jcameron@webmin.com>
Sat, 13 Aug 2011 19:52:16 +0000 (12:52 -0700)
firewall/log_parser.pl
firewall/open-ports.pl

index 4385e62..645daf7 100755 (executable)
@@ -20,6 +20,9 @@ elsif ($type eq "chain") {
 elsif ($type eq "host" || $type eq "group") {
        return &text("log_${action}_${type}", "<tt>$object</tt>");
        }
+elsif ($action eq "openports") {
+       return &text('log_openports', join(" ", split(/\0/, $p->{'ports'})));
+       }
 else {
        return $text{"log_$action"};
        }
index 58964f2..bd03689 100755 (executable)
@@ -114,9 +114,9 @@ PORT: foreach $p (@ARGV) {
 if (@added) {
        # Added some rules .. save them
        &run_before_command();
-       &unlock_file($iptables_save_file);
-       &save_table($filter);
        &lock_file($iptables_save_file);
+       &save_table($filter);
+       &unlock_file($iptables_save_file);
        &run_after_command();
        &copy_to_cluster();
        print STDERR "Opened ports ",join(" ", @added),"\n";
@@ -133,10 +133,10 @@ if (@added) {
                        print "Applied configuration successfully\n";
                        }
                }
-       &webmin_log("openports");
+       &webmin_log("openports", undef, undef, { 'ports' => \@added });
        exit($ex);
        }
 else {
-       print STDERR "Add ports are already open\n";
+       print STDERR "All ports are already open\n";
        exit(0);
        }