--- loncom/lond 2003/03/26 19:34:42 1.120 +++ loncom/lond 2003/03/27 23:00:28 1.121 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.120 2003/03/26 19:34:42 www Exp $ +# $Id: lond,v 1.121 2003/03/27 23:00:28 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -73,6 +73,8 @@ my $DEBUG = 0; # Non zero to ena my $status=''; my $lastlog=''; +my $VERSION='$Revision: 1.121 $'; #' stupid emacs +my $remoteVERSION; my $currenthostid; my $currentdomainid; # @@ -515,22 +517,6 @@ while (1) { 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 { my $client; my $pid; @@ -592,14 +578,7 @@ sub make_new_child { my $remotereq=<$client>; $remotereq=~s/[^\w:]//g; if ($remotereq =~ /^init/) { - if (!&init_host_and_domain($remotereq)) { - &status("Got bad init message, exiting"); - print $client "refused\n"; - $client->close(); - &logthis("WARNING: " - ."Bad init message $remotereq, closing connection"); - exit; - } + &sethost("sethost:$perlvar{'lonHostID'}"); my $challenge="$$".time; print $client "$challenge\n"; &status( @@ -1739,6 +1718,10 @@ sub make_new_child { $client->close(); last; # ------------------------------------------------------------- unknown command + } elsif ($userinput =~ /^sethost:/) { + print $client &sethost($userinput)."\n"; + } elsif ($userinput =~/^version:/) { + print $client &version($userinput)."\n"; } else { # unknown command print $client "unknown_cmd\n"; @@ -2054,6 +2037,28 @@ sub make_passwd_file { 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) =head1 NAME