version 1.12, 2000/12/25 12:44:43
|
version 1.15, 2001/05/05 13:14:45
|
Line 2
|
Line 2
|
# Cookie Based Access Handler for Construction Area |
# Cookie Based Access Handler for Construction Area |
# (lonacc: 5/21/99,5/22,5/29,5/31 Gerd Kortemeyer) |
# (lonacc: 5/21/99,5/22,5/29,5/31 Gerd Kortemeyer) |
# 6/15,16/11,22/11, |
# 6/15,16/11,22/11, |
# 01/06,01/11,6/1,9/25,9/28,11/22,12/25 Gerd Kortemeyer |
# 01/06,01/11,6/1,9/25,9/28,11/22,12/25,12/26, |
|
# 01/06/01,05/04,05/05 Gerd Kortemeyer |
|
|
package Apache::loncacc; |
package Apache::loncacc; |
|
|
Line 10 use strict;
|
Line 11 use strict;
|
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
use Apache::File; |
use Apache::File; |
use CGI::Cookie(); |
use CGI::Cookie(); |
|
use Fcntl qw(:flock); |
|
|
|
sub constructaccess { |
|
my ($url,$ownerdomain)=@_; |
|
my ($ownername)=($url=~/\/(?:\~|priv\/)(\w+)/); |
|
unless (($ownername) && ($ownerdomain)) { return ''; } |
|
|
|
if (($ownername eq $ENV{'user.name'}) && |
|
($ownerdomain eq $ENV{'user.domain'})) { |
|
return ($ownername,$ownerdomain); |
|
} |
|
|
|
my $capriv='user.priv.ca./'. |
|
$ownerdomain.'/'.$ownername.'./'. |
|
$ownerdomain.'/'.$ownername; |
|
map { |
|
if ($_ eq $capriv) { |
|
return ($ownername,$ownerdomain); |
|
} |
|
} keys %ENV; |
|
|
|
return ''; |
|
} |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
Line 22 sub handler {
|
Line 46 sub handler {
|
$handle=~s/\W//g; |
$handle=~s/\W//g; |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { |
if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { |
my $ownername=$requrl; |
|
$ownername=~s/\/(?:\~|priv\/)(\w+).*/\1/; |
|
my $ownerdomain=$r->dir_config('lonDefDomain'); |
|
my @handleparts=split(/\_/,$handle); |
|
my $username=$handleparts[0]; |
|
my $domain=$handleparts[2]; |
|
if (($username ne $ownername) || ($domain ne $ownerdomain)) { |
|
$r->log_reason |
|
("$username at $domain not authorized", $r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
my @profile; |
my @profile; |
{ |
{ |
my $idf=Apache::File->new("$lonidsdir/$handle.id"); |
my $idf=Apache::File->new("$lonidsdir/$handle.id"); |
|
flock($idf,LOCK_SH); |
@profile=<$idf>; |
@profile=<$idf>; |
|
$idf->close(); |
} |
} |
my $envi; |
my $envi; |
for ($envi=0;$envi<=$#profile;$envi++) { |
for ($envi=0;$envi<=$#profile;$envi++) { |
Line 48 sub handler {
|
Line 63 sub handler {
|
$ENV{'request.state'} = "construct"; |
$ENV{'request.state'} = "construct"; |
$ENV{'request.filename'} = $r->filename; |
$ENV{'request.filename'} = $r->filename; |
|
|
|
unless (&constructaccess($requrl,$r->dir_config('lonDefDomain'))) { |
|
$r->log_reason("Unauthorized $requrl", $r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
# -------------------------------------------------------- Load POST parameters |
# -------------------------------------------------------- Load POST parameters |
|
|
|
|
Line 78 sub handler {
|
Line 98 sub handler {
|
if ($lines[$i]=~/^$contentsep/) { |
if ($lines[$i]=~/^$contentsep/) { |
if ($name) { |
if ($name) { |
chomp($value); |
chomp($value); |
$ENV{"form.$name"}=$value; |
|
if ($fname) { |
if ($fname) { |
$ENV{"form.$name.filename"}=$fname; |
$ENV{"form.$name.filename"}=$fname; |
$ENV{"form.$name.mimetype"}=$fmime; |
$ENV{"form.$name.mimetype"}=$fmime; |
|
} else { |
|
$value=~s/\s+$//s; |
} |
} |
|
$ENV{"form.$name"}=$value; |
} |
} |
if ($i<$#lines) { |
if ($i<$#lines) { |
$i++; |
$i++; |