[LON-CAPA-cvs] cvs: loncom /configuration Firewall.pm

raeburn raeburn@source.lon-capa.org
Tue, 26 Apr 2011 03:43:17 -0000


raeburn		Tue Apr 26 03:43:17 2011 EDT

  Modified files:              
    /loncom/configuration	Firewall.pm 
  Log:
  - &get_fw_chains() uses distprobe when getting names of chains in iptables.
  
  
Index: loncom/configuration/Firewall.pm
diff -u loncom/configuration/Firewall.pm:1.8 loncom/configuration/Firewall.pm:1.9
--- loncom/configuration/Firewall.pm:1.8	Fri Feb 25 19:41:59 2011
+++ loncom/configuration/Firewall.pm	Tue Apr 26 03:43:17 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Firewall configuration to allow internal LON-CAPA communication between servers   
 #
-# $Id: Firewall.pm,v 1.8 2011/02/25 19:41:59 raeburn Exp $
+# $Id: Firewall.pm,v 1.9 2011/04/26 03:43:17 raeburn Exp $
 #
 # The LearningOnline Network with CAPA
 #
@@ -369,6 +369,17 @@
 
 sub get_fw_chains {
     my ($iptables) = @_;
+    my $perlvarref=&LONCAPA::Configuration::read_conf();
+    my $distro;
+    if (ref($perlvarref) eq 'HASH') {
+        my $path = $perlvarref->{'lonDaemons'};
+        if ($path) {
+            if (open(PIPE,"$path/distprobe|")) {
+                $distro = <PIPE>;
+                close(PIPE);
+            }
+        }
+    }
     my @fw_chains;
     my $suse_config = "/etc/sysconfig/SuSEfirewall2";
     my $ubuntu_config = "/etc/ufw/ufw.conf";
@@ -379,12 +390,20 @@
         if (-e $ubuntu_config) {
             @posschains = ('ufw-user-input','INPUT');
         } else {
-            @posschains = ('RH-Firewall-1-INPUT','INPUT');
+            if ($distro =~ /^(debian|ubuntu|suse|sles)/) {
+                @posschains = ('INPUT'); 
+            } else {
+                @posschains = ('RH-Firewall-1-INPUT','INPUT');
+            }
             if (!-e '/etc/sysconfig/iptables') {
                 if (!-e '/var/lib/iptables') {
-                    print("Unable to find iptables file containing static definitions\n");
+                    unless ($distro =~ /^(debian|ubuntu)/) {
+                        print("Unable to find iptables file containing static definitions\n");
+                    }
+                }
+                if ($distro =~ /^(fedora|rhes|centos|scientific)/) {
+                    push(@fw_chains,'RH-Firewall-1-INPUT');
                 }
-                push(@fw_chains,'RH-Firewall-1-INPUT'); 
             }
         }
         if ($iptables eq '') {