Diff for /loncom/lond between versions 1.120 and 1.121

version 1.120, 2003/03/26 19:34:42 version 1.121, 2003/03/27 23:00:28
Line 73  my $DEBUG = 0;         # Non zero to ena Line 73  my $DEBUG = 0;         # Non zero to ena
 my $status='';  my $status='';
 my $lastlog='';  my $lastlog='';
   
   my $VERSION='$Revision$'; #' stupid emacs
   my $remoteVERSION;
 my $currenthostid;  my $currenthostid;
 my $currentdomainid;  my $currentdomainid;
 #  #
Line 515  while (1) { Line 517  while (1) {
     make_new_child($client);      make_new_child($client);
 }  }
   
 sub init_host_and_domain {  
     my ($remotereq) = @_;  
     my (undef,$hostid)=split(/:/,$remotereq);  
     if (!defined($hostid)) { $hostid=$perlvar{'lonHostID'}; }  
     if ($hostip{$perlvar{'lonHostID'}} eq $hostip{$hostid}) {  
  $currenthostid=$hostid;  
  $currentdomainid=$hostdom{$hostid};  
  &logthis("Setting hostid to $hostid, and domain to $currentdomainid");  
     } else {  
  &logthis("Requested host id $hostid not an alias of ".  
  $perlvar{'lonHostID'}." refusing connection");  
  return 0;  
     }  
     return 1;  
 }  
   
 sub make_new_child {  sub make_new_child {
     my $client;      my $client;
     my $pid;      my $pid;
Line 592  sub make_new_child { Line 578  sub make_new_child {
       my $remotereq=<$client>;        my $remotereq=<$client>;
               $remotereq=~s/[^\w:]//g;                $remotereq=~s/[^\w:]//g;
               if ($remotereq =~ /^init/) {                if ($remotereq =~ /^init/) {
   if (!&init_host_and_domain($remotereq)) {    &sethost("sethost:$perlvar{'lonHostID'}");
       &status("Got bad init message, exiting");  
       print $client "refused\n";  
       $client->close();  
       &logthis("<font color=blue>WARNING: "  
        ."Bad init message $remotereq, closing connection</font>");  
       exit;  
   }  
   my $challenge="$$".time;    my $challenge="$$".time;
                   print $client "$challenge\n";                    print $client "$challenge\n";
                   &status(                    &status(
Line 1739  sub make_new_child { Line 1718  sub make_new_child {
                        $client->close();                         $client->close();
        last;         last;
 # ------------------------------------------------------------- unknown command  # ------------------------------------------------------------- unknown command
      } elsif ($userinput =~ /^sethost:/) {
          print $client &sethost($userinput)."\n";
      } elsif ($userinput =~/^version:/) {
          print $client &version($userinput)."\n";
                    } else {                     } else {
                        # unknown command                         # unknown command
                        print $client "unknown_cmd\n";                         print $client "unknown_cmd\n";
Line 2054  sub make_passwd_file { Line 2037  sub make_passwd_file {
     return $result;      return $result;
 }  }
   
   sub sethost {
       my ($remotereq) = @_;
       my (undef,$hostid)=split(/:/,$remotereq);
       if (!defined($hostid)) { $hostid=$perlvar{'lonHostID'}; }
       if ($hostip{$perlvar{'lonHostID'}} eq $hostip{$hostid}) {
    $currenthostid=$hostid;
    $currentdomainid=$hostdom{$hostid};
    &logthis("Setting hostid to $hostid, and domain to $currentdomainid");
       } else {
    &logthis("Requested host id $hostid not an alias of ".
    $perlvar{'lonHostID'}." refusing connection");
    return 'unable_to_set';
       }
       return 'ok';
   }
   
   sub version {
       my ($userinput)=@_;
       $remoteVERSION=(split(/:/,$userinput))[1];
       return "version:$VERSION";
   }
   
 # ----------------------------------- POD (plain old documentation, CPAN style)  # ----------------------------------- POD (plain old documentation, CPAN style)
   
 =head1 NAME  =head1 NAME

Removed from v.1.120  
changed lines
  Added in v.1.121


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>