Diff for /loncom/auth/lonauth.pm between versions 1.122 and 1.143

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


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