From f38f7128e7058d102ac7898e0f06deaf4d1fd538 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 13 May 2000 21:50:12 +0000 Subject: [PATCH] cgisuidsetup takes an Apache object as well as a CGI object now. --- FS/FS/CGI.pm | 4 ++-- FS/FS/UID.pm | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index 1e8fca644..198477ce6 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -141,8 +141,8 @@ Returns current URL with LEVEL levels of path removed from the end (default 0). sub popurl { my($up)=@_; - my($cgi)=&FS::UID::cgi; - my($url)=new URI::URL $cgi->url; + my $cgi = &FS::UID::cgi; + my $url = new URI::URL ( $cgi->isa('Apache') ? $cgi->uri : $cgi->url ); my(@path)=$url->path_components; splice @path, 0-$up; $url->path_components(@path); diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm index 2315c266d..2cee65d11 100644 --- a/FS/FS/UID.pm +++ b/FS/FS/UID.pm @@ -98,8 +98,10 @@ sub cgisuidsetup { $cgi=shift; if ( $cgi->isa('CGI::Base') ) { carp "Use of CGI::Base is depriciated"; + } elsif ( $cgi->isa('Apache') ) { + } elsif ( ! $cgi->isa('CGI') ) { - croak "Pass a CGI object to cgisuidsetup!"; + croak "fatal: unrecognized object $cgi"; } cgisetotaker; adminsuidsetup($user); @@ -112,6 +114,7 @@ Returns the CGI (see L) object. =cut sub cgi { + carp "warning: \$FS::UID::cgi isa Apache" if $cgi->isa('Apache'); $cgi; } @@ -167,8 +170,10 @@ sub cgisetotaker { $user = lc ( $cgi->var('REMOTE_USER') ); } elsif ( $cgi && $cgi->isa('CGI') && defined $cgi->remote_user ) { $user = lc ( $cgi->remote_user ); + } elsif ( $cgi && $cgi->isa('Apache') ) { + $user = lc ( $cgi->connection->user ); } else { - die "fatal: Can't get REMOTE_USER!"; + die "fatal: Can't get REMOTE_USER! for cgi $cgi"; } $user; } @@ -241,7 +246,7 @@ coderef into the hash %FS::UID::callback : =head1 VERSION -$Id: UID.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $ +$Id: UID.pm,v 1.2 2000-05-13 21:50:12 ivan Exp $ =head1 BUGS -- 2.11.0