--- loncom/auth/lonauth.pm 2003/11/12 16:55:40 1.59 +++ loncom/auth/lonauth.pm 2004/10/28 16:25:19 1.63 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.59 2003/11/12 16:55:40 www Exp $ +# $Id: lonauth.pm,v 1.63 2004/10/28 16:25:19 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -181,13 +181,15 @@ 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(); # ------------------------------------------------- Output for successful login $r->send_cgi_header(<$lt{'wel'} $lt{'mes'}.

$lt{'pro'}?

+$remoteinfo $maincall @@ -220,8 +223,9 @@ ENDSUCCESS sub failed { my ($r,$message) = @_; my $bodytag=&Apache::loncommon::bodytag('Unsuccessful Login'); + my $add=&addcontent(); $r->send_cgi_header(<print(< Unsuccessful Login to the LearningOnline Network with CAPA - $bodytag

Sorry ...

$message

@@ -241,6 +244,17 @@ $bodytag ENDFAILED } +# --------------------------------------------------------------------- Charset + +sub addcontent { + my $encoding=&Apache::lonlocal::current_encoding; + if ($encoding) { + return '; charset='.$encoding; + } else { + return ''; + } +} + # ------------------------------------------------------------------ Rerouting! sub reroute { @@ -255,7 +269,6 @@ ENDRFHEADER Rerouting Login to the LearningOnline Network with CAPA - $bodytag

Sorry ...

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

You are already logged in

Please either continue the current session or @@ -331,7 +343,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'); @@ -388,8 +405,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; }