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

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


raeburn		Wed Oct 24 15:11:19 2018 EDT

  Modified files:              
    /loncom	lciptables 
  Log:
  - Sanity checking.
  
  
Index: loncom/lciptables
diff -u loncom/lciptables:1.7 loncom/lciptables:1.8
--- loncom/lciptables:1.7	Wed Oct 24 04:19:27 2018
+++ loncom/lciptables	Wed Oct 24 15:11:19 2018
@@ -2,7 +2,7 @@
 #
 # The Learning Online Network with CAPA
 #
-# $Id: lciptables,v 1.7 2018/10/24 04:19:27 raeburn Exp $
+# $Id: lciptables,v 1.8 2018/10/24 15:11:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -73,18 +73,27 @@
     &Exit(2);
 }
 my $tmpfile = $ARGV[0];
-if (-e $tmpfile) {
-    if (open(my $fh,"<$tmpfile")) {
-        while(<$fh>) {
-            chomp();
-            $iphost{$_} = 1;
+if ($tmpfile =~ m{^\Q/home/httpd/perl/tmp/lciptables_iphost_\E\d+$}) {
+    if (-e $tmpfile) {
+        if (open(my $fh,"<$tmpfile")) {
+            while(<$fh>) {
+                chomp();
+                if (/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) {
+                    if (($1<=255) && ($2<=255) && ($3<=255) && ($4<=255)) {
+                        $iphost{$_} = 1;
+                    }
+                }
+            }
+            close($fh);
+        } else {
+            &Exit(3);  
         }
-        close($fh);
     } else {
-       &Exit(3);  
+        print "Error. File containing IP addresses of hosts in cluster does not exist\n" unless $noprint;
+        &Exit(3);
     }
 } else {
-    print "Error. File containing IP addresses of hosts in cluster does not exist\n" unless $noprint;
+    print "Error. Invalid filename for file containing IP addresses\n" unless $noprint; 
     &Exit(3);
 }
 




More information about the LON-CAPA-cvs mailing list