[LON-CAPA-cvs] cvs: loncom(version_2_11_X) / lond

raeburn raeburn at source.lon-capa.org
Mon Jun 9 15:47:52 EDT 2014


raeburn		Mon Jun  9 19:47:52 2014 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom	lond 
  Log:
  - For 2.11
    - Backport 1.510
  
  
Index: loncom/lond
diff -u loncom/lond:1.489.2.14 loncom/lond:1.489.2.15
--- loncom/lond:1.489.2.14	Wed Apr 30 23:16:03 2014
+++ loncom/lond	Mon Jun  9 19:47:51 2014
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.489.2.14 2014/04/30 23:16:03 raeburn Exp $
+# $Id: lond,v 1.489.2.15 2014/06/09 19:47:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,7 +61,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.489.2.14 $'; #' stupid emacs
+my $VERSION='$Revision: 1.489.2.15 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -621,7 +621,7 @@
 #     String to send to client ("ok" or "refused" if bad file).
 #
 sub PushFile {
-    my $request = shift;    
+    my $request = shift;
     my ($command, $filename, $contents) = split(":", $request, 3);
     &Debug("PushFile");
     
@@ -651,6 +651,44 @@
 
     if($filename eq "host") {
 	$contents = AdjustHostContents($contents);
+    } elsif ($filename eq 'dns_host' || $filename eq 'dns_domain') {
+        if ($contents eq '') {
+            &logthis('<font color="red"> Pushfile: unable to install '
+                    .$tablefile." - no data received from push. </font>");
+            return 'error: push had no data';
+        }
+        if (&Apache::lonnet::get_host_ip($clientname)) {
+            my $clienthost = &Apache::lonnet::hostname($clientname);
+            if ($managers{$clientip} eq $clientname) {
+                my $clientprotocol = $Apache::lonnet::protocol{$clientname};
+                $clientprotocol = 'http' if ($clientprotocol ne 'https');
+                my $url = '/adm/'.$filename;
+                $url =~ s{_}{/};
+                my $ua=new LWP::UserAgent;
+                $ua->timeout(60);
+                my $request=new HTTP::Request('GET',"$clientprotocol://$clienthost$url");
+                my $response=$ua->request($request);
+                if ($response->is_error()) {
+                    &logthis('<font color="red"> Pushfile: unable to install '
+                            .$tablefile." - error attempting to pull data. </font>");
+                    return 'error: pull failed';
+                } else {
+                    my $result = $response->content;
+                    chomp($result);
+                    unless ($result eq $contents) {
+                        &logthis('<font color="red"> Pushfile: unable to install '
+                                .$tablefile." - pushed data and pulled data differ. </font>");
+                        my $pushleng = length($contents);
+                        my $pullleng = length($result);
+                        if ($pushleng != $pullleng) {
+                            return "error: $pushleng vs $pullleng bytes";
+                        } else {
+                            return "error: mismatch push and pull";
+                        }
+                    }
+                }
+            }
+        }
     }
 
     #  Install the new file:




More information about the LON-CAPA-cvs mailing list