--- loncom/auth/lonauth.pm 2003/11/21 22:10:25 1.60 +++ loncom/auth/lonauth.pm 2005/02/07 20:33:04 1.64 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.60 2003/11/21 22:10:25 www Exp $ +# $Id: lonauth.pm,v 1.64 2005/02/07 20:33:04 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -181,10 +181,16 @@ sub success { # -------------------------------------------------------- Menu script and info my $windowinfo=&Apache::lonmenu::open($clientos); my $startupremote=&Apache::lonmenu::startupremote($lowerurl); + my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl); my $setflags=&Apache::lonmenu::setflags(); my $maincall=&Apache::lonmenu::maincall(); my $bodytag=&Apache::loncommon::bodytag('Successful Login'); my $add=&addcontent(); + my $continuelink; + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { + $continuelink="".&mt('Continue').""; + } # ------------------------------------------------- Output for successful login $r->send_cgi_header(<$lt{'wel'} $lt{'mes'}.

$lt{'pro'}?

+$remoteinfo $maincall +$continuelink ENDSUCCESS @@ -231,7 +239,6 @@ ENDFHEADER Unsuccessful Login to the LearningOnline Network with CAPA - $bodytag

Sorry ...

$message

@@ -268,7 +275,6 @@ ENDRFHEADER Rerouting Login to the LearningOnline Network with CAPA - $bodytag

Sorry ...

Please log in again. @@ -310,7 +316,6 @@ ENDFHEADER Already logged in - $bodytag

You are already logged in

Please either continue the current session or @@ -344,7 +349,12 @@ ENDFAILED failed($r,'Username, password and domain need to be specified.'); return OK; } + +# split user logging in and "su"-user + + ($FORM{'uname'},$FORM{'suname'})=split(/\:/,$FORM{'uname'}); $FORM{'uname'} =~ s/\W//g; + $FORM{'suname'} =~ s/\W//g; $FORM{'udom'} =~ s/\W//g; my $role = $r->dir_config('lonRole'); @@ -401,8 +411,29 @@ ENDFAILED ($firsturl=~/^\/adm\/(logout|remote)/)) { $firsturl='/adm/roles'; } - - success($r,$FORM{'uname'},$FORM{'udom'},$authhost,$firsturl); +# --------------------------------- Are we attempting to login as somebody else? + 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; }