[LON-CAPA-cvs] cvs: loncom / lciptables

raeburn raeburn at source.lon-capa.org
Wed Oct 24 00:19:27 EDT 2018


raeburn		Wed Oct 24 04:19:27 2018 EDT

  Modified files:              
    /loncom	lciptables 
  Log:
  - Dynamic management of LON-CAPA port 5663 compatible with firewalld.
  
  
Index: loncom/lciptables
diff -u loncom/lciptables:1.6 loncom/lciptables:1.7
--- loncom/lciptables:1.6	Sat May 14 23:38:07 2011
+++ loncom/lciptables	Wed Oct 24 04:19:27 2018
@@ -2,7 +2,7 @@
 #
 # The Learning Online Network with CAPA
 #
-# $Id: lciptables,v 1.6 2011/05/14 23:38:07 raeburn Exp $
+# $Id: lciptables,v 1.7 2018/10/24 04:19:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,29 +88,44 @@
     &Exit(3);
 }
 
+my ($opened,$closed);
 my $lond_port = &LONCAPA::Firewall::get_lond_port();
+if (($lond_port eq '') || ($lond_port =~ /\D/)) {
+    print "Error. Invalid lond port\n" unless $noprint;
+    &Exit(3);
+}
+my $iptables = &LONCAPA::Firewall::get_pathto_iptables();
+if ($iptables eq '') {
+    print "Error. No path to iptables\n" unless $noprint;
+    &Exit(3);
+}
 
+my $firewalld = &LONCAPA::Firewall::uses_firewalld();
 
 &EnableRoot();
-
 my @fw_chains = &LONCAPA::Firewall::get_fw_chains();
-my $iptables = &LONCAPA::Firewall::get_pathto_iptables();
-my $firewall_result = 
-     &LONCAPA::Firewall::firewall_close_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]);
-if ($firewall_result) {
-    print "$firewall_result\n";
-}
-$firewall_result = &LONCAPA::Firewall::firewall_open_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]);
-if ($firewall_result) {
-    print "$firewall_result\n";
+if ($firewalld) {
+    $<=0;
+}
+$opened =
+    &LONCAPA::Firewall::firewall_close_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]);
+$closed =
+    &LONCAPA::Firewall::firewall_open_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]);
+if ($firewalld) {
+    $<=$wwwid;
 }
+&DisableRoot();
 
 # -------------------------------------------------------- Exit script
+if ($opened) {
+    print "$opened\n";
+}
+if ($closed) {
+    print "$closed\n";
+}
 print "lciptables Exiting\n" unless $noprint;
-&DisableRoot;
 &Exit(0);
 
-
 sub EnableRoot {
     if ($wwwid==$>) {
         ($<,$>)=($>,$<);




More information about the LON-CAPA-cvs mailing list