--- loncom/lond 2011/05/14 17:14:29 1.467.2.3 +++ loncom/lond 2011/01/20 10:55:02 1.469 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.467.2.3 2011/05/14 17:14:29 raeburn Exp $ +# $Id: lond,v 1.469 2011/01/20 10:55:02 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -15,6 +15,7 @@ # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # @@ -52,14 +53,13 @@ use LONCAPA::lonlocal; use LONCAPA::lonssl; use Fcntl qw(:flock); use Apache::lonnet; -use Mail::Send; my $DEBUG = 0; # Non zero to enable debug log entries. my $status=''; my $lastlog=''; -my $VERSION='$Revision: 1.467.2.3 $'; #' stupid emacs +my $VERSION='$Revision: 1.469 $'; #' stupid emacs my $remoteVERSION; my $currenthostid="default"; my $currentdomainid; @@ -420,11 +420,8 @@ sub ReadManagerTable { my $tablename = $perlvar{'lonTabDir'}."/managers.tab"; if (!open (MANAGERS, $tablename)) { - my $hostname = &Apache::lonnet::hostname($perlvar{'lonHostID'}); - if (&Apache::lonnet::is_LC_dns($hostname)) { - &logthis('No manager table. Nobody can manage!!'); - } - return; + logthis('No manager table. Nobody can manage!!'); + return; } while(my $host = ) { chomp($host); @@ -449,7 +446,7 @@ sub ReadManagerTable { } } else { logthis(' existing host'." $host\n"); - $managers{&Apache::lonnet::get_host_ip($host)} = $host; # Use info from cluster tab if cluster memeber + $managers{&Apache::lonnet::get_host_ip($host)} = $host; # Use info from cluster tab if clumemeber } } } @@ -511,8 +508,7 @@ sub AdjustHostContents { my $me = $perlvar{'lonHostID'}; foreach my $line (split(/\n/,$contents)) { - if(!(($line eq "") || ($line =~ /^ *\#/) || ($line =~ /^ *$/) || - ($line =~ /^\s*\^/))) { + if(!(($line eq "") || ($line =~ /^ *\#/) || ($line =~ /^ *$/))) { chomp($line); my ($id,$domain,$role,$name,$ip,$maxcon,$idleto,$mincon)=split(/:/,$line); if ($id eq $me) { @@ -600,8 +596,11 @@ sub InstallFile { # # ConfigFileFromSelector: converts a configuration file selector # into a configuration file pathname. -# Supports the following file selectors: -# hosts, domain, dns_hosts, dns_domain +# It's probably no longer necessary to preserve +# special handling of hosts or domain as those +# files have been superceded by dns_hosts, dns_domain. +# The default action is just to prepend the directory +# and append .tab # # # Parameters: @@ -614,9 +613,12 @@ sub ConfigFileFromSelector { my $tablefile; my $tabledir = $perlvar{'lonTabDir'}.'/'; - if (($selector eq "hosts") || ($selector eq "domain") || - ($selector eq "dns_hosts") || ($selector eq "dns_domain")) { - $tablefile = $tabledir.$selector.'.tab'; + if ($selector eq "hosts") { + $tablefile = $tabledir."hosts.tab"; + } elsif ($selector eq "domain") { + $tablefile = $tabledir."domain.tab"; + } else { + $tablefile = $tabledir.$selector.'.tab'; } return $tablefile; @@ -645,8 +647,6 @@ sub PushFile { # supported: # hosts.tab ($filename eq host). # domain.tab ($filename eq domain). - # dns_hosts.tab ($filename eq dns_host). - # dns_domain.tab ($filename eq dns_domain). # Construct the destination filename or reject the request. # # lonManage is supposed to ensure this, however this session could be @@ -677,32 +677,12 @@ sub PushFile { .$tablefile." $! "); return "error:$!"; } else { - &logthis(' Installed new '.$tablefile - ." - transaction by: $clientname ($clientip)"); - my $adminmail = $perlvar{'lonAdmEMail'}; - my $admindom = &Apache::lonnet::host_domain($perlvar{'lonHostID'}); - if ($admindom ne '') { - my %domconfig = - &Apache::lonnet::get_dom('configuration',['contacts'],$admindom); - if (ref($domconfig{'contacts'}) eq 'HASH') { - if ($domconfig{'contacts'}{'adminemail'} ne '') { - $adminmail = $domconfig{'contacts'}{'adminemail'}; - } - } - } - if ($adminmail =~ /^[^\@]+\@[^\@]+$/) { - my $msg = new Mail::Send; - $msg->to($adminmail); - $msg->subject('LON-CAPA DNS update on '.$perlvar{'lonHostID'}); - $msg->add('Content-type','text/plain; charset=UTF-8'); - if (my $fh = $msg->open()) { - print $fh 'Update to '.$tablefile.' from Cluster Manager '. - "$clientname ($clientip)\n"; - $fh->close; - } - } + &logthis(' Installed new '.$tablefile + .""); + } + # Indicate success: return "ok"; @@ -1689,15 +1669,6 @@ sub server_homeID_handler { } ®ister_handler("serverhomeID", \&server_homeID_handler, 0, 1, 0); -sub server_distarch_handler { - my ($cmd,$tail,$client) = @_; - my $userinput = "$cmd:$tail"; - my $reply = &distro_and_arch(); - &Reply($client,\$reply,$userinput); - return 1; -} -®ister_handler("serverdistarch", \&server_distarch_handler, 0, 1, 0); - # Process a reinit request. Reinit requests that either # lonc or lond be reinitialized so that an updated # host.tab or domain.tab can be processed. @@ -5037,11 +5008,10 @@ sub get_sections_handler { sub validate_course_owner_handler { my ($cmd, $tail, $client) = @_; my $userinput = "$cmd:$tail"; - my ($inst_course_id, $owner, $cdom, $coowners) = split(/:/, $tail); + my ($inst_course_id, $owner, $cdom) = split(/:/, $tail); $owner = &unescape($owner); - $coowners = &unescape($coowners); - my $outcome = &localenroll::new_course($inst_course_id,$owner,$cdom,$coowners); + my $outcome = &localenroll::new_course($inst_course_id,$owner,$cdom); &Reply($client, \$outcome, $userinput); @@ -6029,7 +5999,7 @@ if (-e $pidfile) { $server = IO::Socket::INET->new(LocalPort => $perlvar{'londPort'}, Type => SOCK_STREAM, Proto => 'tcp', - ReuseAddr => 1, + ReuseAddr => 1, Listen => 10 ) or die "making socket: $@\n"; @@ -6092,12 +6062,9 @@ sub HUPSMAN { # sig # a setuid perl script that can be root for us to do this job. # sub ReloadApache { - if (&LONCAPA::try_to_lock('/tmp/lock_apachereload')) { - my $execdir = $perlvar{'lonDaemons'}; - my $script = $execdir."/apachereload"; - system($script); - unlink('/tmp/lock_apachereload'); # Remove the lock file. - } + my $execdir = $perlvar{'lonDaemons'}; + my $script = $execdir."/apachereload"; + system($script); } # @@ -6363,11 +6330,6 @@ my %iphost = &Apache::lonnet::get_iphost my $dist=`$perlvar{'lonDaemons'}/distprobe`; -my $arch = `uname -i`; -if ($arch eq 'unknown') { - $arch = `uname -m`; -} - # -------------------------------------------------------------- # Accept connections. When a connection comes in, it is validated # and if good, a child process is created to process transactions @@ -6434,13 +6396,12 @@ sub make_new_child { #don't get intercepted $SIG{USR1}= \&logstatus; $SIG{ALRM}= \&timeout; - - # - # Block sigpipe as it gets thrownon socket disconnect and we want to - # deal with that as a read faiure instead. - # - my $blockset = POSIX::SigSet->new(SIGPIPE); - sigprocmask(SIG_BLOCK, $blockset); + # + # Block sigpipe as it gets thrownon socket disconnect and we want to + # deal with that as a read faiure instead. + # + my $blockset = POSIX::SigSet->new(SIGPIPE); + sigprocmask(SIG_BLOCK, $blockset); $lastlog='Forked '; $status='Forked'; @@ -7515,10 +7476,6 @@ sub useable_role { return 1; } -sub distro_and_arch { - return $dist.':'.$arch; -} - # ----------------------------------- POD (plain old documentation, CPAN style) =head1 NAME