version 1.53, 2003/07/16 20:42:31
|
version 1.61, 2004/01/13 16:29:40
|
Line 46 use Apache::loncommon();
|
Line 46 use Apache::loncommon();
|
use Apache::lonnet(); |
use Apache::lonnet(); |
use Apache::lonmenu(); |
use Apache::lonmenu(); |
use Fcntl qw(:flock); |
use Fcntl qw(:flock); |
|
use Apache::lonlocal; |
|
|
my %FORM; |
my %FORM; |
|
|
Line 107 sub success {
|
Line 108 sub success {
|
$FORM{'interface'}=$userenv{'interface'}; |
$FORM{'interface'}=$userenv{'interface'}; |
} |
} |
$ENV{'environment.remote'}=$userenv{'remote'}; |
$ENV{'environment.remote'}=$userenv{'remote'}; |
|
# --------------- Do not trust query string to be put directly into environment |
|
foreach ('imagesuppress','appletsuppress', |
|
'embedsuppress','fontenhance','blackwhite', |
|
'interface','localpath','localres') { |
|
$FORM{$_}=~s/[\n\r\=]//gs; |
|
} |
# --------------------------------------------------------- Write first profile |
# --------------------------------------------------------- Write first profile |
|
|
{ |
{ |
Line 177 sub success {
|
Line 184 sub success {
|
my $setflags=&Apache::lonmenu::setflags(); |
my $setflags=&Apache::lonmenu::setflags(); |
my $maincall=&Apache::lonmenu::maincall(); |
my $maincall=&Apache::lonmenu::maincall(); |
my $bodytag=&Apache::loncommon::bodytag('Successful Login'); |
my $bodytag=&Apache::loncommon::bodytag('Successful Login'); |
|
my $add=&addcontent(); |
# ------------------------------------------------- Output for successful login |
# ------------------------------------------------- Output for successful login |
|
|
$r->send_cgi_header(<<ENDHEADER); |
$r->send_cgi_header(<<ENDHEADER); |
Content-type: text/html |
Content-type: text/html$add |
Set-cookie: $cookie |
Set-cookie: $cookie |
|
|
ENDHEADER |
ENDHEADER |
|
my %lt=&Apache::lonlocal::texthash( |
|
'wel' => 'Welcome', |
|
'mes' => 'Welcome to the Learning<i>Online</i> Network with CAPA. Please wait while your session is being set up', |
|
'pro' => 'Problems', |
|
'log' => 'loginproblems.html', |
|
); |
$r->print(<<ENDSUCCESS); |
$r->print(<<ENDSUCCESS); |
<html> |
<html> |
<head> |
<head> |
Line 193 $startupremote
|
Line 207 $startupremote
|
$bodytag |
$bodytag |
$setflags |
$setflags |
$windowinfo |
$windowinfo |
<h1>Welcome!</h1> |
<h1>$lt{'wel'}</h1> |
Welcome to the Learning<i>Online</i> Network with CAPA. |
$lt{'mes'}.<p> |
Please wait while your session |
<a href="/adm/$lt{'log'}">$lt{'pro'}?</a></p> |
is being set up.<p> |
|
<a href="/adm/loginproblems.html">Problems?</a></p> |
|
$maincall |
$maincall |
</body> |
</body> |
</html> |
</html> |
Line 209 ENDSUCCESS
|
Line 221 ENDSUCCESS
|
sub failed { |
sub failed { |
my ($r,$message) = @_; |
my ($r,$message) = @_; |
my $bodytag=&Apache::loncommon::bodytag('Unsuccessful Login'); |
my $bodytag=&Apache::loncommon::bodytag('Unsuccessful Login'); |
|
my $add=&addcontent(); |
$r->send_cgi_header(<<ENDFHEADER); |
$r->send_cgi_header(<<ENDFHEADER); |
Content-type: text/html |
Content-type: text/html$add |
|
|
ENDFHEADER |
ENDFHEADER |
$r->print(<<ENDFAILED); |
$r->print(<<ENDFAILED); |
Line 230 $bodytag
|
Line 243 $bodytag
|
ENDFAILED |
ENDFAILED |
} |
} |
|
|
|
# --------------------------------------------------------------------- Charset |
|
|
|
sub addcontent { |
|
my $encoding=&Apache::lonlocal::current_encoding; |
|
if ($encoding) { |
|
return '; charset='.$encoding; |
|
} else { |
|
return ''; |
|
} |
|
} |
|
|
|
# ------------------------------------------------------------------ Rerouting! |
|
|
|
sub reroute { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag('Rerouting'); |
|
$r->send_cgi_header(<<ENDRFHEADER); |
|
Content-type: text/html |
|
|
|
ENDRFHEADER |
|
$r->print(<<ENDRFAILED); |
|
<html> |
|
<head> |
|
<title>Rerouting Login to the LearningOnline Network with CAPA</title> |
|
</head> |
|
<html> |
|
$bodytag |
|
<h1>Sorry ...</h1> |
|
Please <a href="/">log in again</a>. |
|
</body> |
|
</html> |
|
ENDRFAILED |
|
} |
|
|
# ---------------------------------------------------------------- Main handler |
# ---------------------------------------------------------------- Main handler |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
|
|
# Are we re-routing? |
|
if (-e '/home/httpd/html/lon-status/reroute.txt') { |
|
&reroute($r); |
|
return OK; |
|
} |
|
|
|
&Apache::lonlocal::get_language_handle($r); |
|
|
|
# -------------------------------- Prevent users from attempting to login twice |
|
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
|
my $lonid=$cookies{'lonID'}; |
|
my $cookie; |
|
if ($lonid) { |
|
my $handle=$lonid->value; |
|
$handle=~s/\W//g; |
|
my $lonidsdir=$r->dir_config('lonIDsDir'); |
|
if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { |
|
# Indeed, a valid token is found |
|
$r->send_cgi_header(<<ENDFHEADER); |
|
Content-type: text/html |
|
|
|
ENDFHEADER |
|
my $bodytag=&Apache::loncommon::bodytag('Already logged in'); |
|
$r->print(<<ENDFAILED); |
|
<html> |
|
<head> |
|
<title>Already logged in</title> |
|
</head> |
|
<html> |
|
$bodytag |
|
<h1>You are already logged in</h1> |
|
<p>Please either <a href="/adm/roles">continue the current session</a> or |
|
<a href="/adm/logout">logout</a>.</p> |
|
<p> |
|
<a href="/adm/loginproblems.html">Problems?</a></p> |
|
</body> |
|
</html> |
|
ENDFAILED |
|
return OK; |
|
} |
|
} |
|
|
|
# ---------------------------------------------------- No valid token, continue |
|
|
|
|
my $buffer; |
my $buffer; |
$r->read($buffer,$r->header_in('Content-length'),0); |
$r->read($buffer,$r->header_in('Content-length'),0); |
my @pairs=split(/&/,$buffer); |
my @pairs=split(/&/,$buffer); |
Line 252 sub handler {
|
Line 344 sub handler {
|
failed($r,'Username, password and domain need to be specified.'); |
failed($r,'Username, password and domain need to be specified.'); |
return OK; |
return OK; |
} |
} |
|
|
|
# split user logging in and "su"-user |
|
|
|
($FORM{'uname'},$FORM{'suname'})=split(/\:/,$FORM{'uname'}); |
$FORM{'uname'} =~ s/\W//g; |
$FORM{'uname'} =~ s/\W//g; |
|
$FORM{'suname'} =~ s/\W//g; |
$FORM{'udom'} =~ s/\W//g; |
$FORM{'udom'} =~ s/\W//g; |
|
|
my $role = $r->dir_config('lonRole'); |
my $role = $r->dir_config('lonRole'); |
Line 305 sub handler {
|
Line 402 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
if (($firsturl eq '') || ($firsturl eq '/adm/logout')) { |
if (($firsturl eq '') || |
|
($firsturl=~/^\/adm\/(logout|remote)/)) { |
$firsturl='/adm/roles'; |
$firsturl='/adm/roles'; |
} |
} |
|
# --------------------------------- Are we attempting to login as somebody else? |
success($r,$FORM{'uname'},$FORM{'udom'},$authhost,$firsturl); |
if ($FORM{'suname'}) { |
|
# ------------ see if the original user has enough privileges to pull this stunt |
|
if (&Apache::lonnet::privileged($FORM{'uname'},$FORM{'udom'})) { |
|
# ---------------------------------------------------- see if the su-user exists |
|
unless (&Apache::lonnet::homeserver($FORM{'suname'},$FORM{'udom'}) |
|
eq 'no_host') { |
|
&Apache::lonnet::logthis(&Apache::lonnet::homeserver($FORM{'suname'},$FORM{'udom'})); |
|
# ------------------------------ 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'}. |
|
' logging in as '.$FORM{'suname'}); |
|
$FORM{'uname'}=$FORM{'suname'}; |
|
} else { |
|
&Apache::lonnet::logthis('Attempted switch user to privileged user'); |
|
} |
|
} |
|
} else { |
|
&Apache::lonnet::logthis('Non-privileged user attempting switch user'); |
|
} |
|
} |
|
&success($r,$FORM{'uname'},$FORM{'udom'},$authhost,$firsturl); |
return OK; |
return OK; |
} |
} |
|
|