[LON-CAPA-cvs] cvs: loncom / lond /lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Sat, 14 May 2011 15:47:04 -0000
raeburn Sat May 14 15:47:04 2011 EDT
Modified files:
/loncom lond
/loncom/lonnet/perl lonnet.pm
Log:
- Replace &loncapa_dns_server() in lond with &is_LC_dns() in lonnet.pm
- Sender address not relevant for e-mail sent when dns_*.tab updated
- lonHostID and IP for client which called PushFile in lond.log and e-mail.
Index: loncom/lond
diff -u loncom/lond:1.472 loncom/lond:1.473
--- loncom/lond:1.472 Fri May 13 02:58:02 2011
+++ loncom/lond Sat May 14 15:47:01 2011
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.472 2011/05/13 02:58:02 raeburn Exp $
+# $Id: lond,v 1.473 2011/05/14 15:47:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.472 $'; #' stupid emacs
+my $VERSION='$Revision: 1.473 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -421,7 +421,8 @@
my $tablename = $perlvar{'lonTabDir'}."/managers.tab";
if (!open (MANAGERS, $tablename)) {
- if (&loncapa_dns_server()) {
+ my $hostname = &Apache::lonnet::hostname($perlvar{'lonHostID'});
+ if (&Apache::lonnet::is_LC_dns($hostname)) {
&logthis('<font color="red">No manager table. Nobody can manage!!</font>');
}
return;
@@ -677,7 +678,7 @@
return "error:$!";
} else {
&logthis('<font color="green"> Installed new '.$tablefile
- ."</font>");
+ ." - transaction by: $clientname ($clientip)</font>");
my $adminmail = $perlvar{'lonAdmEMail'};
my $admindom = &Apache::lonnet::host_domain($perlvar{'lonHostID'});
if ($admindom ne '') {
@@ -691,16 +692,12 @@
}
if ($adminmail =~ /^[^\@]+\@[^\@]+$/) {
my $msg = new Mail::Send;
- my $senderaddress = $perlvar{'lonSysEMail'};
$msg->to($adminmail);
$msg->subject('LON-CAPA DNS update on '.$perlvar{'lonHostID'});
- if ($senderaddress) {
- $msg->add('From',$senderaddress);
- }
$msg->add('Content-type','text/plain; charset=UTF-8');
if (my $fh = $msg->open()) {
print $fh 'Update to '.$tablefile.' from Cluster Manager '.
- $client."\n";
+ "$clientname ($clientip)\n";
$fh->close;
}
}
@@ -712,25 +709,6 @@
}
-sub loncapa_dns_server {
- my $lonhost = &Apache::lonnet::get_host_ip($perlvar{'lonHostID'});
- my $hoststable = "$perlvar{'lonTabDir'}/hosts.tab";
- my $is_dns_server;
- if (!open(HOSTS,"<$hoststable")) {
- &logthis('<font color="yellow">Could not open hosts.tab to check for LON-CAPA DNS servers.</font>');
- while (my $host = <HOSTS>) {
- chomp($host);
- $host =~ s/(^\s+|\s+$)//g;
- if ($host =~ /^\Q^$lonhost\E/) {
- $is_dns_server = 1;
- last;
- }
- }
- close(HOSTS);
- }
- return $is_dns_server;
-}
-
#
# Called to re-init either lonc or lond.
#
@@ -6114,6 +6092,7 @@
# a setuid perl script that can be root for us to do this job.
#
sub ReloadApache {
+# --------------------------- Handle case of another apachereload process (locking)
my $execdir = $perlvar{'lonDaemons'};
my $script = $execdir."/apachereload";
system($script);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1106 loncom/lonnet/perl/lonnet.pm:1.1107
--- loncom/lonnet/perl/lonnet.pm:1.1106 Fri May 13 02:26:21 2011
+++ loncom/lonnet/perl/lonnet.pm Sat May 14 15:47:04 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1106 2011/05/13 02:26:21 raeburn Exp $
+# $Id: lonnet.pm,v 1.1107 2011/05/14 15:47:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -10084,13 +10084,19 @@
my $loaded;
my %name_to_host;
my %internetdom;
+ my %LC_dns_serv;
sub parse_hosts_tab {
my ($file) = @_;
foreach my $configline (@$file) {
next if ($configline =~ /^(\#|\s*$ )/x);
- next if ($configline =~ /^\^/);
- chomp($configline);
+ chomp($configline);
+ if ($configline =~ /^\^/) {
+ if ($configline =~ /^\^([\w.\-]+)/) {
+ $LC_dns_serv{$1} = 1;
+ }
+ next;
+ }
my ($id,$domain,$role,$name,$protocol,$intdom)=split(/:/,$configline);
$name=~s/\s//g;
if ($id && $domain && $role && $name) {
@@ -10226,6 +10232,14 @@
my ($lonid) = @_;
return $internetdom{$lonid};
}
+
+ sub is_LC_dns {
+ &load_hosts_tab() if (!$loaded);
+
+ my ($hostname) = @_;
+ return exists($LC_dns_serv{$hostname});
+ }
+
}
{