Diff for /loncom/auth/lonauth.pm between versions 1.125 and 1.144

version 1.125, 2013/08/13 13:22:24 version 1.144, 2017/08/08 16:43:54
Line 1 Line 1
 # The LearningOnline Network  # The LearningOnline Network
 # User Authentication Module  # User Authentication Module
 #  #
 # $Id$  # $Id$
 #  #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
 #  #
 # LON-CAPA is free software; you can redistribute it and/or modify  # LON-CAPA is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by  # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or  # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  # (at your option) any later version.
 #  #
 # LON-CAPA is distributed in the hope that it will be useful,  # LON-CAPA is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of  # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.  # GNU General Public License for more details.
 #  #
 # You should have received a copy of the GNU General Public License  # You should have received a copy of the GNU General Public License
 # along with LON-CAPA; if not, write to the Free Software  # along with LON-CAPA; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #  #
 # /home/httpd/html/adm/gpl.txt  # /home/httpd/html/adm/gpl.txt
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
 package Apache::lonauth;  package Apache::lonauth;
   
 use strict;  use strict;
 use LONCAPA;  use LONCAPA qw(:DEFAULT :match);
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use CGI qw(:standard);  use CGI qw(:standard);
 use DynaLoader; # for Crypt::DES version  use Apache::loncommon();
 use Crypt::DES;  use Apache::lonnet;
 use Apache::loncommon();  use Apache::lonmenu();
 use Apache::lonnet;  use Apache::createaccount;
 use Apache::lonmenu();  use Fcntl qw(:flock);
 use Apache::createaccount;  use Apache::lonlocal;
 use Fcntl qw(:flock);  use Apache::File();
 use Apache::lonlocal;  use HTML::Entities;
 use Apache::File();  use Digest::MD5;
 use HTML::Entities;   
    # ------------------------------------------------------------ Successful login
 # ------------------------------------------------------------ Successful login  sub success {
 sub success {      my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
     my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,   $form) = @_;
  $form) = @_;  
   # ------------------------------------------------------------ Get cookie ready
 # ------------------------------------------------------------ Get cookie ready      my $cookie =
     my $cookie =   &Apache::loncommon::init_user_environment($r, $username, $domain,
  &Apache::loncommon::init_user_environment($r, $username, $domain,    $authhost, $form,
   $authhost, $form,    {'extra_env' => $extra_env,});
   {'extra_env' => $extra_env,});  
       my $public=($username eq 'public' && $domain eq 'public');
     my $public=($username eq 'public' && $domain eq 'public');  
       if ($public or $lowerurl eq 'noredirect') { return $cookie; }
     if ($public or $lowerurl eq 'noredirect') { return $cookie; }  
   # -------------------------------------------------------------------- Log this
 # -------------------------------------------------------------------- Log this  
       &Apache::lonnet::log($domain,$username,$authhost,
     &Apache::lonnet::log($domain,$username,$authhost,                           "Login $ENV{'REMOTE_ADDR'}");
                          "Login $ENV{'REMOTE_ADDR'}");  
   # ------------------------------------------------- Check for critical messages
 # ------------------------------------------------- Check for critical messages  
       my @what=&Apache::lonnet::dump('critical',$domain,$username);
     my @what=&Apache::lonnet::dump('critical',$domain,$username);      if ($what[0]) {
     if ($what[0]) {   if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
  if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {      $lowerurl='/adm/email?critical=display';
     $lowerurl='/adm/email?critical=display';          }
         }      }
     }  
   # ----------------------------------------------------------- Get cookies ready
 # ------------------------------------------------------------ Get cookie ready      my ($securecookie,$defaultcookie);
     $cookie="lonID=$cookie; path=/";      if ($ENV{'SERVER_PORT'} == 443) {
 # -------------------------------------------------------- Menu script and info          $securecookie="lonID=$cookie; path=/; HttpOnly; secure";
     my $destination = $lowerurl;          my $lonidsdir=$r->dir_config('lonIDsDir');
           if (($lonidsdir) && (-e "$lonidsdir/$cookie.id")) {
     if (defined($form->{role})) {              my $linkname=substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, 32).'_linked';
         my $envkey = 'user.role.'.$form->{role};              if (-e "$lonidsdir/$linkname.id") {
         my $now=time;                  unlink("$lonidsdir/$linkname.id");
         my $then=$env{'user.login.time'};              }
         my $refresh=$env{'user.refresh.time'};              my $made_symlink = eval { symlink("$lonidsdir/$cookie.id",
         my $update=$env{'user.update.time'};                                                "$lonidsdir/$linkname.id"); 1 };
         if (!$update) {              if ($made_symlink) {
             $update = $then;                  $defaultcookie = "lonLinkID=$linkname; path=/; HttpOnly;";
         }                  &Apache::lonnet::appenv({'user.linkedenv' => "$lonidsdir/$linkname.id"});
         if (exists($env{$envkey})) {              }
             my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus);          }
             &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,      } else {
                                          \$trolecode,\$tstatus,\$tstart,\$tend);          $defaultcookie = "lonID=$cookie; path=/; HttpOnly;";
             if ($tstatus eq 'is') {      }
                 $destination  .= ($destination =~ /\?/) ? '&' : '?';  # -------------------------------------------------------- Menu script and info
                 my $newrole = &HTML::Entities::encode($form->{role},'"<>&');      my $destination = $lowerurl;
                 $destination .= 'selectrole=1&'.$newrole.'=1';  
             }      if (defined($form->{role})) {
         }          my $envkey = 'user.role.'.$form->{role};
     }          my $now=time;
     if (defined($form->{symb})) {          my $then=$env{'user.login.time'};
         my $destsymb = $form->{symb};          my $refresh=$env{'user.refresh.time'};
         $destination  .= ($destination =~ /\?/) ? '&' : '?';          my $update=$env{'user.update.time'};
         if ($destsymb =~ /___/) {          if (!$update) {
             # FIXME Need to deal with encrypted symbs and urls as needed.              $update = $then;
             my ($map,$resid,$desturl)=split(/___/,$destsymb);          }
             unless ($desturl=~/^(adm|editupload|public)/) {          if (exists($env{$envkey})) {
                 $desturl = &Apache::lonnet::clutter($desturl);              my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus);
             }              &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
             $desturl = &HTML::Entities::encode($desturl,'"<>&');                                           \$trolecode,\$tstatus,\$tstart,\$tend);
             $destsymb = &HTML::Entities::encode($destsymb,'"<>&');              if ($tstatus eq 'is') {
             $destination .= '&destinationurl='.$desturl.                  $destination  .= ($destination =~ /\?/) ? '&' : '?';
                             '&destsymb='.$destsymb;                  my $newrole = &HTML::Entities::encode($form->{role},'"<>&');
         } else {                  $destination .= 'selectrole=1&'.$newrole.'=1';
             $destsymb = &HTML::Entities::encode($destsymb,'"<>&');              }
             $destination .= '&destinationurl='.$destsymb;          }
         }      }
     }      if (defined($form->{symb})) {
     if ($destination =~ m{^/adm/roles}) {          my $destsymb = $form->{symb};
         $destination  .= ($destination =~ /\?/) ? '&' : '?';          $destination  .= ($destination =~ /\?/) ? '&' : '?';
         $destination .= 'source=login';          if ($destsymb =~ /___/) {
     }              # FIXME Need to deal with encrypted symbs and urls as needed.
               my ($map,$resid,$desturl)=split(/___/,$destsymb);
     my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";');              $desturl = &Apache::lonnet::clutter($desturl);
     my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';              $desturl = &HTML::Entities::encode($desturl,'"<>&');
     my $brcrum = [{'href' => '',              $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
                    'text' => 'Successful Login'},];              $destination .= 'destinationurl='.$desturl.
     my $start_page=&Apache::loncommon::start_page('Successful Login',                              '&destsymb='.$destsymb;
                                                   $header,          } else {
                                                   {'bread_crumbs' => $brcrum,});              $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
     my $end_page  =&Apache::loncommon::end_page();              $destination .= 'destinationurl='.$destsymb;
           }
  my $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';      }
 # ------------------------------------------------- Output for successful login      if ($destination =~ m{^/adm/roles}) {
           $destination  .= ($destination =~ /\?/) ? '&' : '?';
     &Apache::loncommon::content_type($r,'text/html');          $destination .= 'source=login';
     $r->header_out('Set-cookie' => $cookie);      }
     $r->send_http_header;  
       my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";');
     my %lt=&Apache::lonlocal::texthash(      my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
        'wel' => 'Welcome',      my $brcrum = [{'href' => '',
        'pro' => 'Login problems?',                     'text' => 'Successful Login'},];
        );      my $args = {'bread_crumbs' => $brcrum,};
     my $loginhelp = &loginhelpdisplay($domain);      unless ((defined($form->{role})) || (defined($form->{symb}))) {
     if ($loginhelp) {          my $update=$env{'user.update.time'};
         $loginhelp = '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';          if (!$update) {
     }              $update = $env{'user.login.time'};
           }
     my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');           my %roles_in_env;
     $r->print(<<ENDSUCCESS);          my $showcount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
 $start_page          if ($showcount == 1) {
 $windowinfo              foreach my $rolecode (keys(%roles_in_env)) {
 <h1>$lt{'wel'}</h1>                  my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)});
 $welcome                  if ($cid) {
 $loginhelp                      my %coursedescription =
 $continuelink                          &Apache::lonnet::coursedescription($cid,{'one_time' => '1'});
 $end_page                      if ($coursedescription{'type'} eq 'Placement') {
 ENDSUCCESS                          $args->{'crstype'} = 'Placement';
 }                      }
                       last;
 # --------------------------------------------------------------- Failed login!                  }
               }
 sub failed {          }
     my ($r,$message,$form) = @_;      }
     my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef);      my $start_page=&Apache::loncommon::start_page('Successful Login',
     my $retry = '/adm/login?username='.$form->{'uname'}.                                                    $header,$args);
                 '&domain='.$form->{'udom'};      my $end_page  =&Apache::loncommon::end_page();
     if (exists($form->{role})) {  
         $retry .= '&role='.$form->{role};   my $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';
     }  # ------------------------------------------------- Output for successful login
     if (exists($form->{symb})) {  
         $retry .= '&symb='.$form->{symb};      &Apache::loncommon::content_type($r,'text/html');
     }      if ($securecookie) {
     my $end_page   = &Apache::loncommon::end_page();          $r->headers_out->add('Set-cookie' => $securecookie);
     &Apache::loncommon::content_type($r,'text/html');      }
     $r->send_http_header;      if ($defaultcookie) {
     my $loginhelp = &loginhelpdisplay($form->{'udom'});          $r->headers_out->add('Set-cookie' => $defaultcookie);
     if ($loginhelp) {      }
         $loginhelp = '<p><a href="'.$loginhelp.'">'.&mt('Login problems?').'</a></p>';      $r->send_http_header;
     }  
       my %lt=&Apache::lonlocal::texthash(
     $r->print(         'wel' => 'Welcome',
        $start_page         'pro' => 'Login problems?',
       .'<h1>'.&mt('Sorry ...').'</h1>'         );
       .'<p class="LC_warning">'.&mt($message).'</p>'      my $loginhelp = &loginhelpdisplay($domain);
       .'<p>'.&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>')      if ($loginhelp) {
       .'</p>'          $loginhelp = '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
       .$loginhelp      }
       .$end_page  
     );      my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
  }      $r->print(<<ENDSUCCESS);
   $start_page
 # ------------------------------------------------------------------ Rerouting!  $windowinfo
   <h1>$lt{'wel'}</h1>
 sub reroute {  $welcome
     my ($r) = @_;  $loginhelp
     &Apache::loncommon::content_type($r,'text/html');  $continuelink
     $r->send_http_header;  $end_page
     my $msg='<h1>'.&mt('Sorry ...').'</h1>'  ENDSUCCESS
            .&mt('Please [_1]log in again[_2].');      return;
     &Apache::loncommon::simple_error_page($r,'Rerouting',$msg);  }
 }  
   # --------------------------------------------------------------- Failed login!
 # ---------------------------------------------------------------- Main handler  
   sub failed {
 sub handler {      my ($r,$message,$form) = @_;
     my $r = shift;      (undef,undef,undef,my $clientmathml,my $clientunicode) =
     my $londocroot = $r->dir_config('lonDocRoot');          &Apache::loncommon::decode_user_agent();
     my $form;      my $args = {};
 # Are we re-routing?      if ($clientunicode && !$clientmathml) {
     if (-e "$londocroot/lon-status/reroute.txt") {          $args = {'browser.unicode' => 1};
  &reroute($r);      }
  return OK;  
     }      my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef,$args);
       my $uname = &Apache::loncommon::cleanup_html($form->{'uname'});
     &Apache::lonlocal::get_language_handle($r);      my $udom = &Apache::loncommon::cleanup_html($form->{'udom'});
       if (&Apache::lonnet::domain($udom,'description') eq '') {
 # -------------------------------- Prevent users from attempting to login twice          undef($udom);
     my $handle = &Apache::lonnet::check_for_valid_session($r);      }
     if ($handle ne '') {      my $retry = '/adm/login';
         my $lonidsdir=$r->dir_config('lonIDsDir');      if ($uname eq $form->{'uname'}) {
         if ($handle=~/^publicuser\_/) {          $retry .= '?username='.$uname;
 # For "public user" - remove it, we apparently really want to login      }
             unlink($r->dir_config('lonIDsDir')."/$handle.id");      if ($udom) {
         } else {          $retry .= (($retry=~/\?/)?'&amp;':'?').'domain='.$udom;
 # Indeed, a valid token is found      }
             &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);      if (exists($form->{role})) {
     &Apache::loncommon::content_type($r,'text/html');          my $role = &Apache::loncommon::cleanup_html($form->{role});
     $r->send_http_header;          if ($role ne '') {
     my $start_page =               $retry .= (($retry=~/\?/)?'&amp;':'?').'role='.$role;
         &Apache::loncommon::start_page('Already logged in');          }
     my $end_page =       }
         &Apache::loncommon::end_page();      if (exists($form->{symb})) {
             my $dest = '/adm/roles';          my $symb = &Apache::loncommon::cleanup_html($form->{symb});
             if ($env{'form.firsturl'} ne '') {          if ($symb ne '') {
                 $dest = $env{'form.firsturl'};              $retry .= (($retry=~/\?/)?'&amp;':'?').'symb='.$symb;
             }          }
             $r->print(      }
                $start_page      my $end_page = &Apache::loncommon::end_page();
               .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'      &Apache::loncommon::content_type($r,'text/html');
               .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'      $r->send_http_header;
                     ,'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>')      my @actions =
               .'</p>'           (&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));
               .$end_page      my $loginhelp = &loginhelpdisplay($udom);
             );      if ($loginhelp) {
             return OK;          push(@actions, '<a href="'.$loginhelp.'">'.&mt('Login problems?').'</a>');
         }      }
     }      #FIXME: link to helpdesk might be added here
   
 # ---------------------------------------------------- No valid token, continue      $r->print(
          $start_page
         .'<h2>'.&mt('Sorry ...').'</h2>'
     my $buffer;        .&Apache::lonhtmlcommon::confirm_success(&mt($message),1).'<br /><br />'
     if ($r->header_in('Content-length') > 0) {        .&Apache::lonhtmlcommon::actionbox(\@actions)
  $r->read($buffer,$r->header_in('Content-length'),0);        .$end_page
     }      );
     my %form;   }
     foreach my $pair (split(/&/,$buffer)) {  
        my ($name,$value) = split(/=/,$pair);  # ------------------------------------------------------------------ Rerouting!
        $value =~ tr/+/ /;  
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;  sub reroute {
        $form{$name}=$value;      my ($r) = @_;
     }       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
     if ((!$form{'uname'}) || (!$form{'upass0'}) || (!$form{'udom'})) {      my $msg='<b>'.&mt('Sorry ...').'</b><br />'
  &failed($r,'Username, password and domain need to be specified.',             .&mt('Please [_1]log in again[_2].');
  \%form);      &Apache::loncommon::simple_error_page($r,'Rerouting',$msg,{'no_auto_mt_msg' => 1});
         return OK;  }
     }  
   # ---------------------------------------------------------------- Main handler
 # split user logging in and "su"-user  
   sub handler {
     ($form{'uname'},$form{'suname'})=split(/\:/,$form{'uname'});      my $r = shift;
     $form{'uname'} = &LONCAPA::clean_username($form{'uname'});      my $londocroot = $r->dir_config('lonDocRoot');
     $form{'suname'}= &LONCAPA::clean_username($form{'suname'});  # Are we re-routing?
     $form{'udom'}  = &LONCAPA::clean_domain(  $form{'udom'});      if (-e "$londocroot/lon-status/reroute.txt") {
    &reroute($r);
     my $role   = $r->dir_config('lonRole');   return OK;
     my $domain = $r->dir_config('lonDefDomain');      }
     my $prodir = $r->dir_config('lonUsersDir');  
     my $contact_name = &mt('LON-CAPA helpdesk');      &Apache::lonlocal::get_language_handle($r);
   
 # ---------------------------------------- Get the information from login token  # -------------------------------- Prevent users from attempting to login twice
       my $handle = &Apache::lonnet::check_for_valid_session($r);
     my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'},      if ($handle ne '') {
                                       $form{'serverid'});          my $lonidsdir=$r->dir_config('lonIDsDir');
           if ($handle=~/^publicuser\_/) {
     if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||   # For "public user" - remove it, we apparently really want to login
         ($tmpinfo eq 'no_such_host')) {              unlink($r->dir_config('lonIDsDir')."/$handle.id");
  &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form);          } else {
         return OK;  # Indeed, a valid token is found
     } else {              &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
  my $reply = &Apache::lonnet::reply('tmpdel:'.$form{'logtoken'},      &Apache::loncommon::content_type($r,'text/html');
    $form{'serverid'});      $r->send_http_header;
         if ( $reply ne 'ok' ) {      my $start_page =
             &failed($r,'Session could not be opened.',\%form);          &Apache::loncommon::start_page('Already logged in');
     &Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $form{'serverid'}." to get login token");      my $end_page =
     return OK;          &Apache::loncommon::end_page();
  }              my $dest = '/adm/roles';
     }              if ($env{'form.firsturl'} ne '') {
                   $dest = $env{'form.firsturl'};
     if (!&Apache::lonnet::domain($form{'udom'})) {              }
         &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);              $r->print(
         return OK;                 $start_page
     }                .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
                 .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'
     my ($key,$firsturl,$rolestr,$symbstr)=split(/&/,$tmpinfo);                      ,'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>')
     if ($rolestr) {                .'</p>'
         $rolestr = &unescape($rolestr);                .$end_page
     }              );
     if ($symbstr) {              return OK;
         $symbstr= &unescape($symbstr);          }
     }      }
     if ($rolestr =~ /^role=/) {  
         (undef,$form{'role'}) = split('=',$rolestr);  # ---------------------------------------------------- No valid token, continue
     }  
     if ($symbstr =~ /^symb=/) {   
         (undef,$form{'symb'}) = split('=',$symbstr);      my $buffer;
     }      if ($r->header_in('Content-length') > 0) {
    $r->read($buffer,$r->header_in('Content-length'),0);
     my $keybin=pack("H16",$key);      }
       my %form;
     my $cipher;      foreach my $pair (split(/&/,$buffer)) {
     if ($Crypt::DES::VERSION>=2.03) {         my ($name,$value) = split(/=/,$pair);
  $cipher=new Crypt::DES $keybin;         $value =~ tr/+/ /;
     }         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
     else {         $form{$name}=$value;
  $cipher=new DES $keybin;      }
     }  
     my $upass='';      if ((!$form{'uname'}) || (!$form{'upass0'}) || (!$form{'udom'})) {
     for (my $i=0;$i<=2;$i++) {   &failed($r,'Username, password and domain need to be specified.',
  my $chunk=   \%form);
     $cipher->decrypt(unpack("a8",pack("H16",substr($form{'upass'.$i},0,16))));          return OK;
       }
  $chunk.=  
     $cipher->decrypt(unpack("a8",pack("H16",substr($form{'upass'.$i},16,16))));  # split user logging in and "su"-user
   
  $chunk=substr($chunk,1,ord(substr($chunk,0,1)));      ($form{'uname'},$form{'suname'})=split(/\:/,$form{'uname'});
  $upass.=$chunk;      $form{'uname'} = &LONCAPA::clean_username($form{'uname'});
     }      $form{'suname'}= &LONCAPA::clean_username($form{'suname'});
       $form{'udom'}  = &LONCAPA::clean_domain(  $form{'udom'});
 # ---------------------------------------------------------------- Authenticate  
       my $role   = $r->dir_config('lonRole');
     my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});      my $domain = $r->dir_config('lonDefDomain');
     my ($cancreate,$statustocreate) =      my $prodir = $r->dir_config('lonUsersDir');
         &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});      my $contact_name = &mt('LON-CAPA helpdesk');
     my $defaultauth;  
     if (ref($cancreate) eq 'ARRAY') {  # ---------------------------------------- Get the information from login token
         if (grep(/^login$/,@{$cancreate})) {  
             $defaultauth = 1;      my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'},
         }                                        $form{'serverid'});
     }  
     my $clientcancheckhost = 1;      if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||
     my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,          ($tmpinfo eq 'no_such_host')) {
                                               $form{'udom'},$defaultauth,   &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form);
                                               $clientcancheckhost);          return OK;
           } else {
 # --------------------------------------------------------------------- Failed?   my $reply = &Apache::lonnet::reply('tmpdel:'.$form{'logtoken'},
      $form{'serverid'});
     if ($authhost eq 'no_host') {          if ( $reply ne 'ok' ) {
  &failed($r,'Username and/or password could not be authenticated.',              &failed($r,'Session could not be opened.',\%form);
  \%form);      &Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $form{'serverid'}." to get login token");
         return OK;      return OK;
     } elsif ($authhost eq 'no_account_on_host') {   }
         if ($defaultauth) {      }
             my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');  
             unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {      if (!&Apache::lonnet::domain($form{'udom'})) {
                 return OK;          &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);
             }          return OK;
             my $start_page =       }
                 &Apache::loncommon::start_page('Create a user account in LON-CAPA');  
             my $lonhost = $r->dir_config('lonHostID');      my ($key,$firsturl,$rolestr,$symbstr,$iptokenstr)=split(/&/,$tmpinfo);
             my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};      if ($rolestr) {
             my $contacts =           $rolestr = &unescape($rolestr);
                 &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',      }
                                                         $form{'udom'},$origmail);      if ($symbstr) {
             my ($contact_email) = split(',',$contacts);           $symbstr= &unescape($symbstr);
             my $output =       }
                 &Apache::createaccount::username_check($form{'uname'},$form{'udom'},      if ($iptokenstr) {
                                                        $domdesc,'',$lonhost,          $iptokenstr = &unescape($iptokenstr);
                                                        $contact_email,$contact_name,      }
                                                        undef,$statustocreate);      if ($rolestr =~ /^role=/) {
             &Apache::loncommon::content_type($r,'text/html');          (undef,$form{'role'}) = split('=',$rolestr);
             $r->send_http_header;      }
             &Apache::createaccount::print_header($r,$start_page);      if ($symbstr =~ /^symb=/) {
             $r->print('<h3>'.&mt('Account creation').'</h3>'.          (undef,$form{'symb'}) = split('=',$symbstr);
                       &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.      }
                       $output.&Apache::loncommon::end_page());      if ($iptokenstr =~ /^iptoken=/) {
             return OK;          (undef,$form{'iptoken'}) = split('=',$iptokenstr);
         } else {      }
             &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);  
             return OK;      my $upass = $ENV{HTTPS} ? $form{'upass0'}
         }          : &Apache::loncommon::des_decrypt($key,$form{'upass0'});
     }  
   # ---------------------------------------------------------------- Authenticate
     if (($firsturl eq '') ||   
  ($firsturl=~/^\/adm\/(logout|remote)/)) {      my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
  $firsturl='/adm/roles';      my ($cancreate,$statustocreate) =
     }          &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});
 # --------------------------------- Are we attempting to login as somebody else?      my $defaultauth;
     if ($form{'suname'}) {      if (ref($cancreate) eq 'ARRAY') {
 # ------------ see if the original user has enough privileges to pull this stunt          if (grep(/^login$/,@{$cancreate})) {
  if (&Apache::lonnet::privileged($form{'uname'},$form{'udom'})) {              $defaultauth = 1;
 # ---------------------------------------------------- see if the su-user exists          }
     unless (&Apache::lonnet::homeserver($form{'suname'},$form{'udom'})      }
  eq 'no_host') {      my $clientcancheckhost = 1;
  &Apache::lonnet::logthis(&Apache::lonnet::homeserver($form{'suname'},$form{'udom'}));      my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
 # ------------------------------ see if the su-user is not too highly privileged                                                $form{'udom'},$defaultauth,
  unless (&Apache::lonnet::privileged($form{'suname'},$form{'udom'})) {                                                $clientcancheckhost);
 # -------------------------------------------------------- actually switch users     
     &Apache::lonnet::logperm('User '.$form{'uname'}.' at '.$form{'udom'}.  # --------------------------------------------------------------------- Failed?
  ' logging in as '.$form{'suname'});  
     $form{'uname'}=$form{'suname'};      if ($authhost eq 'no_host') {
  } else {   &failed($r,'Username and/or password could not be authenticated.',
     &Apache::lonnet::logthis('Attempted switch user to privileged user');   \%form);
  }          return OK;
     }      } elsif ($authhost eq 'no_account_on_host') {
  } else {          if ($defaultauth) {
     &Apache::lonnet::logthis('Non-privileged user attempting switch user');              my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');
  }              unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {
     }                  return OK;
               }
     my ($is_balancer,$otherserver) =               my $start_page =
         &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'});                  &Apache::loncommon::start_page('Create a user account in LON-CAPA');
               my $lonhost = $r->dir_config('lonHostID');
     if ($is_balancer) {              my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
         if (!$otherserver) {               my $contacts =
             ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});                  &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
         }                                                          $form{'udom'},$origmail);
         if ($otherserver) {              my ($contact_email) = split(',',$contacts);
             &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,              my $output =
                      \%form);                  &Apache::createaccount::username_check($form{'uname'},$form{'udom'},
     $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl);                                                         $domdesc,'',$lonhost,
         } else {                                                         $contact_email,$contact_name,
             $r->print(&noswitch());                                                         undef,$statustocreate);
         }              &Apache::loncommon::content_type($r,'text/html');
         return OK;              $r->send_http_header;
     } else {              &Apache::createaccount::print_header($r,$start_page);
         if (!&check_can_host($r,\%form,$authhost)) {              $r->print('<h3>'.&mt('Account creation').'</h3>'.
             my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});                        &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.
             if ($otherserver) {                        $output.&Apache::loncommon::end_page());
                 &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,              return OK;
                          \%form);          } else {
                 $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl);              &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);
             } else {              return OK;
                 $r->print(&noswitch());          }
             }      }
             return OK;  
         }      if (($firsturl eq '') ||
    ($firsturl=~/^\/adm\/(logout|remote)/)) {
 # ------------------------------------------------------- Do the load balancing   $firsturl='/adm/roles';
       }
 # ---------------------------------------------------------- Determine own load  
         my $loadlim = $r->dir_config('lonLoadLim');      my $hosthere;
         my $loadavg;      if ($form{'iptoken'}) {
         {          my %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'});
             my $loadfile=Apache::File->new('/proc/loadavg');          my $delete = &Apache::lonnet::tmpdel($form{'iptoken'});
             $loadavg=<$loadfile>;          if (($sessiondata{'domain'} eq $form{'udom'}) &&
         }              ($sessiondata{'username'} eq $form{'uname'})) {
         $loadavg =~ s/\s.*//g;              $hosthere = 1;
         my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);          }
         my $userloadpercent=&Apache::lonnet::userload();      }
   
 # ---------------------------------------------------------- Are we overloaded?  # --------------------------------- Are we attempting to login as somebody else?
         if ((($userloadpercent>100.0)||($loadpercent>100.0))) {      if ($form{'suname'}) {
             my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent,1,$form{'udom'});  # ------------ see if the original user has enough privileges to pull this stunt
             if (!$unloaded) {   if (&Apache::lonnet::privileged($form{'uname'},$form{'udom'})) {
                 ($unloaded) = &Apache::lonnet::choose_server($form{'udom'});  # ---------------------------------------------------- see if the su-user exists
             }      unless (&Apache::lonnet::homeserver($form{'suname'},$form{'udom'})
             if ($unloaded) {   eq 'no_host') {
                 &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',   &Apache::lonnet::logthis(&Apache::lonnet::homeserver($form{'suname'},$form{'udom'}));
                          undef,\%form);  # ------------------------------ see if the su-user is not too highly privileged
                 $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);   unless (&Apache::lonnet::privileged($form{'suname'},$form{'udom'})) {
                 return OK;  # -------------------------------------------------------- actually switch users
             }      &Apache::lonnet::logperm('User '.$form{'uname'}.' at '.$form{'udom'}.
         }   ' logging in as '.$form{'suname'});
         &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef,      $form{'uname'}=$form{'suname'};
                  \%form);   } else {
         return OK;      &Apache::lonnet::logthis('Attempted switch user to privileged user');
     }   }
 }      }
    } else {
 sub check_can_host {      &Apache::lonnet::logthis('Non-privileged user attempting switch user');
     my ($r,$form,$authhost,$domdesc) = @_;   }
     return unless (ref($form) eq 'HASH');      }
     my $canhost = 1;  
     my $lonhost = $r->dir_config('lonHostID');      my ($is_balancer,$otherserver);
     my $udom = $form->{'udom'};  
     my @intdoms;      unless ($hosthere) {
     my $internet_names = &Apache::lonnet::get_internet_names($lonhost);          ($is_balancer,$otherserver) =
     if (ref($internet_names) eq 'ARRAY') {              &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'},'login');
         @intdoms = @{$internet_names};          if ($is_balancer) {
     }              if ($otherserver eq '') {
     my $uprimary_id = &Apache::lonnet::domain($udom,'primary');                  my $lowest_load;
     my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);                  ($otherserver,undef,undef,undef,$lowest_load) = &Apache::lonnet::choose_server($form{'udom'});
     unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) {                  if ($lowest_load > 100) {
         my $machine_dom = &Apache::lonnet::host_domain($lonhost);                      $otherserver = &Apache::lonnet::spareserver($lowest_load,$lowest_load,1,$form{'udom'});
         my $hostname = &Apache::lonnet::hostname($lonhost);                  }
         my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname);              }
         my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);              if ($otherserver ne '') {
         my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);                  my @hosts = &Apache::lonnet::current_machine_ids();
         my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);                  if (grep(/^\Q$otherserver\E$/,@hosts)) {
         my $loncaparev;                      $hosthere = $otherserver;
         if ($authhost eq 'no_account_on_host') {                  }
             $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);              }
         } else {          }
             $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);      }
         }  
         $canhost = &Apache::lonnet::can_host_session($udom,$lonhost,$loncaparev,      if (($is_balancer) && (!$hosthere)) {
                                                      $udomdefaults{'remotesessions'},          if ($otherserver) {
                                                      $defdomdefaults{'hostedsessions'});              &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
     }                       \%form);
     unless ($canhost) {              my $switchto = '/adm/switchserver?otherserver='.$otherserver;
         if ($authhost eq 'no_account_on_host') {              if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
             my $checkloginvia = 1;                  $switchto .= '&origurl='.$firsturl;
             my ($login_host,$hostname) =               }
                 &Apache::lonnet::choose_server($udom,$checkloginvia);              if ($form{'role'}) {
             &Apache::loncommon::content_type($r,'text/html');                  $switchto .= '&role='.$form{'role'};
             $r->send_http_header;              }
             if ($login_host ne '') {              if ($form{'symb'}) {
                 my $protocol = $Apache::lonnet::protocol{$login_host};                  $switchto .= '&symb='.$form{'symb'};
                 $protocol = 'http' if ($protocol ne 'https');              }
                 my $newurl = $protocol.'://'.$hostname.'/adm/createaccount';              $r->internal_redirect($switchto);
                 $r->print(&Apache::loncommon::start_page('Create a user account in LON-CAPA').          } else {
                           '<h3>'.&mt('Account creation').'</h3>'.              $r->print(&noswitch());
                           &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.          }
                           '<p>'.&mt('You will be able to create one by logging into a LON-CAPA server within the [_1] domain.',$domdesc).'</p>'.          return OK;
                           '<p>'.&mt('[_1]Log in[_2]','<a href="'.$newurl.'">','</a>').      } else {
                           &Apache::loncommon::end_page());          if (!&check_can_host($r,\%form,$authhost)) {
             } else {              my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});
                 $r->print(&Apache::loncommon::start_page('Access to LON-CAPA unavailable').              if ($otherserver) {
                           '<h3>'.&mt('Account creation unavailable').'</h3>'.                  &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
                           &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.                           \%form);
                           '<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'.                  my $switchto = '/adm/switchserver?otherserver='.$otherserver;
                           &Apache::loncommon::end_page());                  if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
             }                      $switchto .= '&origurl='.$firsturl;
         } else {                  }
             &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,                  if ($form{'role'}) {
                      $form);                      $switchto .= '&role='.$form{'role'};
             my ($otherserver) = &Apache::lonnet::choose_server($udom);                  }
             $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);                  if ($form{'symb'}) {
         }                      $switchto .= '&symb='.$form{'symb'};
     }                  }
     return $canhost;                  $r->internal_redirect($switchto);
 }              } else {
                   $r->print(&noswitch());
 sub noswitch {              }
     my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').              return OK;
                  '<h3>'.&mt('Session unavailable').'</h3>'.          }
                  &mt('This LON-CAPA server is unable to host your session.').'<br />'.  
                  '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.  # ------------------------------------------------------- Do the load balancing
                  &Apache::loncommon::end_page();  
     return $result;  # ---------------------------------------------------------- Determine own load
 }          my $loadlim = $r->dir_config('lonLoadLim');
           my $loadavg;
 sub loginhelpdisplay {          {
     my ($authdomain) = @_;              my $loadfile=Apache::File->new('/proc/loadavg');
     my $login_help = 1;              $loadavg=<$loadfile>;
     my $lang = &Apache::lonlocal::current_language();          }
     if ($login_help) {          $loadavg =~ s/\s.*//g;
         my $dom = $authdomain;          my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
         if ($dom eq '') {          my $userloadpercent=&Apache::lonnet::userload();
             $dom = &Apache::lonnet::default_login_domain();  
         }  # ---------------------------------------------------------- Are we overloaded?
         my %domconfhash = &Apache::loncommon::get_domainconf($dom);          if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
         my $loginhelp_url;              my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent,1,$form{'udom'});
         if ($lang) {              if (!$unloaded) {
             $loginhelp_url = $domconfhash{$dom.'.login.helpurl_'.$lang};                  ($unloaded) = &Apache::lonnet::choose_server($form{'udom'});
             if ($loginhelp_url ne '') {              }
                 return $loginhelp_url;              if ($unloaded) {
             }                  &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',
         }                           undef,\%form);
         $loginhelp_url = $domconfhash{$dom.'.login.helpurl_nolang'};                  $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);
         if ($loginhelp_url ne '') {                  return OK;
             return $loginhelp_url;              }
         } else {          }
             return '/adm/loginproblems.html';          if (($is_balancer) && ($hosthere)) {
         }              $form{'noloadbalance'} = $hosthere;
     }          }
     return;          &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef,
 }                   \%form);
           return OK;
 1;      }
 __END__  }
   
   sub check_can_host {
       my ($r,$form,$authhost,$domdesc) = @_;
       return unless (ref($form) eq 'HASH');
       my $canhost = 1;
       my $lonhost = $r->dir_config('lonHostID');
       my $udom = $form->{'udom'};
       my @intdoms;
       my $internet_names = &Apache::lonnet::get_internet_names($lonhost);
       if (ref($internet_names) eq 'ARRAY') {
           @intdoms = @{$internet_names};
       }
       my $uprimary_id = &Apache::lonnet::domain($udom,'primary');
       my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
       unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) {
           my $machine_dom = &Apache::lonnet::host_domain($lonhost);
           my $hostname = &Apache::lonnet::hostname($lonhost);
           my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname);
           my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
           my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
           my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);
           my $loncaparev;
           if ($authhost eq 'no_account_on_host') {
               $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);
           } else {
               $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);
           }
           $canhost = &Apache::lonnet::can_host_session($udom,$lonhost,$loncaparev,
                                                        $udomdefaults{'remotesessions'},
                                                        $defdomdefaults{'hostedsessions'});
       }
       unless ($canhost) {
           if ($authhost eq 'no_account_on_host') {
               my $checkloginvia = 1;
               my ($login_host,$hostname) =
                   &Apache::lonnet::choose_server($udom,$checkloginvia);
               &Apache::loncommon::content_type($r,'text/html');
               $r->send_http_header;
               if ($login_host ne '') {
                   my $protocol = $Apache::lonnet::protocol{$login_host};
                   $protocol = 'http' if ($protocol ne 'https');
                   my $newurl = $protocol.'://'.$hostname.'/adm/createaccount';
                   $r->print(&Apache::loncommon::start_page('Create a user account in LON-CAPA').
                             '<h3>'.&mt('Account creation').'</h3>'.
                             &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
                             '<p>'.&mt('You will be able to create one by logging into a LON-CAPA server within the [_1] domain.',$domdesc).'</p>'.
                             '<p>'.&mt('[_1]Log in[_2]','<a href="'.$newurl.'">','</a>').
                             &Apache::loncommon::end_page());
               } else {
                   $r->print(&Apache::loncommon::start_page('Access to LON-CAPA unavailable').
                             '<h3>'.&mt('Account creation unavailable').'</h3>'.
                             &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
                             '<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'.
                             &Apache::loncommon::end_page());
               }
           } else {
               &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,
                        $form);
               my ($otherserver) = &Apache::lonnet::choose_server($udom);
               $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);
           }
       }
       return $canhost;
   }
   
   sub noswitch {
       my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').
                    '<h3>'.&mt('Session unavailable').'</h3>'.
                    &mt('This LON-CAPA server is unable to host your session.').'<br />'.
                    '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.
                    &Apache::loncommon::end_page();
       return $result;
   }
   
   sub loginhelpdisplay {
       my ($authdomain) = @_;
       my $login_help = 1;
       my $lang = &Apache::lonlocal::current_language();
       if ($login_help) {
           my $dom = $authdomain;
           if ($dom eq '') {
               $dom = &Apache::lonnet::default_login_domain();
           }
           my %domconfhash = &Apache::loncommon::get_domainconf($dom);
           my $loginhelp_url;
           if ($lang) {
               $loginhelp_url = $domconfhash{$dom.'.login.helpurl_'.$lang};
               if ($loginhelp_url ne '') {
                   return $loginhelp_url;
               }
           }
           $loginhelp_url = $domconfhash{$dom.'.login.helpurl_nolang'};
           if ($loginhelp_url ne '') {
               return $loginhelp_url;
           } else {
               return '/adm/loginproblems.html';
           }
       }
       return;
   }
   
   1;
   __END__
   
   

Removed from v.1.125  
changed lines
  Added in v.1.144


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