--- loncom/lond 2010/07/17 20:01:56 1.447 +++ loncom/lond 2010/07/20 02:42:27 1.448 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.447 2010/07/17 20:01:56 raeburn Exp $ +# $Id: lond,v 1.448 2010/07/20 02:42:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,7 +58,7 @@ my $DEBUG = 0; # Non zero to ena my $status=''; my $lastlog=''; -my $VERSION='$Revision: 1.447 $'; #' stupid emacs +my $VERSION='$Revision: 1.448 $'; #' stupid emacs my $remoteVERSION; my $currenthostid="default"; my $currentdomainid; @@ -66,8 +66,9 @@ my $currentdomainid; my $client; my $clientip; # IP address of client. my $clientname; # LonCAPA name of client. -my $clientversion; # LonCAPA version running on client -my @clientdoms; # Array of domains on $clientip +my $clientversion; # LonCAPA version running on client. +my $clienthomedom; # LonCAPA domain of homeID for client. + # primary library server. my $server; @@ -1072,7 +1073,7 @@ sub pong_handler { # Implicit Inputs: # $currenthostid - Global variable that carries the name of the host # known as. -# $clientname - Global variable that carries the name of the hsot we're connected to. +# $clientname - Global variable that carries the name of the host we're connected to. # Returns: # 1 - Ok to continue processing. # 0 - Program should exit. @@ -1111,7 +1112,7 @@ sub establish_key_handler { # Implicit Inputs: # $currenthostid - Global variable that carries the name of the host # known as. -# $clientname - Global variable that carries the name of the hsot we're connected to. +# $clientname - Global variable that carries the name of the host we're connected to. # Returns: # 1 - Ok to continue processing. # 0 - Program should exit. @@ -1148,7 +1149,7 @@ sub load_handler { # Implicit Inputs: # $currenthostid - Global variable that carries the name of the host # known as. -# $clientname - Global variable that carries the name of the hsot we're connected to. +# $clientname - Global variable that carries the name of the host we're connected to. # Returns: # 1 - Ok to continue processing. # 0 - Program should exit @@ -1657,6 +1658,14 @@ sub server_loncaparev_handler { } ®ister_handler("serverloncaparev", \&server_loncaparev_handler, 0, 1, 0); +sub server_homeID_handler { + my ($cmd,$tail,$client) = @_; + my $userinput = "$cmd:$tail"; + &Reply($client,\$perlvar{'lonHostID'},$userinput); + return 1; +} +®ister_handler("serverhomeID", \&server_homeID_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. @@ -1778,17 +1787,21 @@ sub authenticate_handler { if($pwdcorrect) { my $canhost = 1; unless ($clientcancheckhost) { - unless (grep(/^\Q$udom\E$/,@clientdoms)) { + my $uprimary_id = &Apache::lonnet::domain($udom,'primary'); + my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id); + my @intdoms = &Apache::lonnet::get_internet_names($clientname); + unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) { my ($remote,$hosted); my $remotesession = &get_usersession_config($udom,'remotesession'); if (ref($remotesession) eq 'HASH') { $remote = $remotesession->{'remote'} } - my $hostedsession = &get_usersession_config($clientdoms[0],'hostedsession'); + my $hostedsession = &get_usersession_config($clienthomedom,'hostedsession'); if (ref($hostedsession) eq 'HASH') { $hosted = $hostedsession->{'hosted'}; } - $canhost = &Apache::lonnet::can_host_session($udom,$currentdomainid,$clientversion, + $canhost = &Apache::lonnet::can_host_session($udom,$clientname, + $clientversion, $remote,$hosted); } } @@ -6490,15 +6503,9 @@ sub make_new_child { # ------------------------------------------------------------ Process requests my $keep_going = 1; my $user_input; - @clientdoms = (); - if (ref($iphost{$clientip}) eq 'ARRAY') { - foreach my $id (@{$iphost{$clientip}}) { - my $clientdom = &Apache::lonnet::host_domain($id); - unless (grep(/^\Q$clientdom\E/,@clientdoms)) { - push(@clientdoms,$clientdom); - } - } - } + my $clienthost = &Apache::lonnet::hostname($clientname); + my $clientserverhomeID = &Apache::lonnet::get_server_homeID($clienthost); + $clienthomedom = &Apache::lonnet::host_domain($clientserverhomeID); while(($user_input = get_request) && $keep_going) { alarm(120); Debug("Main: Got $user_input\n");