Apache::ASP - I think bug...

1999-12-08 Thread BeerBong

Hello Joshua!

I think, I catch new bug of Apache::ASP again, although may be Apache::ASP
is innocent in this case.

I have 2 Apache servers - simple/proxy and mod_perl and secured virtual site
of management big Samara portal.

Secured on simple Apache.






AuthType Basic
AuthName $realm
AuthUserFile /usr/web/users_file
AuthGroupFile /usr/web/groups_file
require group $group







This site is located at http://195.128.133.23:777 - here listen simple
Apache, mod_perl Apache listen on http://195.128.133.23:778 address and I
don't want that anyone can acces mod_perl Apache from outside the server

Therefore, I have following handler.



sub My::ProxyRemoteAddr ($)
{
my $r = shift;

# we'll only look at the X-Forwarded-For header if the requests
# comes from our proxy at localhost
return FORBIDDEN unless ($r->connection->remote_ip =~ /^195.128.133/);

if (my ($ip) = $r->header_in('X-Forwarded-For') =~ /([^,\s]+)$/)
{
   $r->connection->remote_ip($ip);
}

return OK;
}



All worked just pretty fine until I try, for fun, connect to mod_perl
directly...

http://195.128.133.23:778/

As I await - I got



Forbidden
You don't have permission to access / on this server.




Apache/1.3.9 Server at www.samara.ru-editor Port 778



Huh! It's cool! But...
After it I return to 777 port and request
http://195.128.133.23:777/index.shtml
and got a error:



Errors Output

> Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
while "strict refs" in use at (eval 13) line 14.
, /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142

Debug Output

> STARTING ASP HANDLER (v0.17) for file
/usr/web/www.samara.ru-editor/data/index.shtml
> GlobalASA package
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa
> ASP object created - GlobalASA: Apache::ASP::GlobalASA=HASH(0x8700d08);
Request: Apache::ASP::Request=HASH(0x870443c); Response:
Apache::ASP::Response=HASH(0x876b0b0); Server:
Apache::ASP::Server=HASH(0x8705c0c); app_state: 1; basename: index.shtml;
buffering_on: 1; cgi_headers: 0; clean: 0; compile_includes: 1; dbg: 2;
debugs_output: ARRAY(0x876b134); errs: 0; filename:
/usr/web/www.samara.ru-editor/data/index.shtml; global:
/usr/web/www.samara.ru-editor/global; global_package: ; id:
_usr_web_www_samara_ru_editor_data_index_shtmlxDYN; includes_dir:
/usr/web/inc; init_packages: ARRAY(0x83bed14); mail_alert_to: ;
mail_errors_to: ; mtime: 944649459; no_cache: ; no_session: 0; no_state: 1;
package:
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa;
pod_comments: 1; r: Apache=SCALAR(0x8634908); stat_inc: ; stat_inc_match: ;
unique_packages: 0;
> executing _usr_web_www_samara_ru_editor_data_index_shtmlxDYN
> executing
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa::_usr
_web_www_samara_ru_editor_global_portal_inc
> executing
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa::_usr
_web_inc_dbi_inc
> Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
while "strict refs" in use at (eval 13) line 14.
, /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142

Last 100 Bytes of Buffered Output

= 'Management site of  www.samara.ru | Rubrics';
 // -->
 




ASP to Perl Program

  1: package
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa; ;;
no strict; ;; use vars qw($Application $Session $Response $Server $Request);
;; sub
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa::_usr
_web_www_samara_ru_editor_data_index_shtmlxDYN {  ;;  return(1) unless
$_[0];  ;;
$Response->Include('/usr/web/www.samara.ru-editor/global/portal.inc', );
$Response->Write('
  2: ');
  3:
  4: sub main_page {
  5:   my $err = shift;
  6:
  7:   header ("Login - Password");
  8:   info_report ($err);
  9:
 10: $Response->Write('
 11:
 12: Management site of  http://www.samara.ru>www.samara.ru
 13: 
 14:
 15: 
 16:  
 17:   
 18:Login:
 19:   
 20:   
 21:
 22:   
 23:  
 24:  
 25:   
 26:Password:
 27:   
 28:   
 29:
 30:   
 31:  
 32: 
 33:
 34: 
 35:
 36: ');
 37:
 38:   footer ();
 39:   $Response->End();
 40: }
 41:
 42: if ($Request->Form("login")) {
 43:   my ($newsmaker_id,$password,$super);
 44:
 45:   my $dbh = my_DBInitialize ();
 46:   my $sth_login = my_prepare (\$db

Re: Apache::ASP - I think bug...

1999-12-08 Thread Joshua Chamas

BeerBong wrote:
> 
> Hello Joshua!
> 
> I think, I catch new bug of Apache::ASP again, although may be Apache::ASP
> is innocent in this case.
> 
> I have 2 Apache servers - simple/proxy and mod_perl and secured virtual site
> of management big Samara portal.
> 

Your 2 server configuration has nothing to do with Apache::ASP
errors.  However, depending on the ProxyPass used at the front
server, you may end up with varying VirtualHosts handling
the request on the backend server, so make sure you are connecting
to the same vhost that the front end accelerator points at.

> 
> > Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
> while "strict refs" in use at (eval 13) line 14.
> , /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142
> 

You have use strict enabled, so you need to work through this
error.  use strict error handling needs some work still, and
dealing with them in Apache::ASP is fairly new business.

> After some refreshes - I got another output, which is not done by
> index.shtml!

This sounds like a browser cache problem, make sure you hit 
shift+refresh (Netscape) or control-refresh(IE) to really reload 
a page.  This could also be a bad mix of Apache::ASP & use strict 
errors.  Can you get me some code that reproduces this behavior?

I think that there is some work to do on use strict error 
handling, but when in doubt, try stopping and then starting
apache.

-- Joshua
_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks >> free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051



Re: Apache::ASP - I think bug...

1999-12-09 Thread BeerBong

Btw, I use Apache::ASP 0.17

> Your 2 server configuration has nothing to do with Apache::ASP
> errors.  However, depending on the ProxyPass used at the front
> server, you may end up with varying VirtualHosts handling
> the request on the backend server, so make sure you are connecting
> to the same vhost that the front end accelerator points at.

I'm sure that I'm connecting to the same vhost. I totally have 2 virtual
sites, therefore 2 vhost on simple and 2 vhost on power Apache. Other
virtual site doesn't have scripts with the same names, and therefore will
answer Not Found, if frontend server passes to other backend server.
--


RewriteEngine On
RewriteLogLevel 0
RewriteRule ^/((cgi-bin/|perl/|cgi-perl/).*)$ http://$ip:$port/$1
[P,L]
RewriteRule ^/(.*\.(pl|shtml|asp))$   http://$ip:$port/$1
[P,L]

ProxyPassReverse   / http://$ip:$port/





PerlSetVar IncludesDir /usr/web/inc

   SetHandler perl-script
   PerlHandler Apache::ASP
   PerlSetVar Debug $Debug
   PerlSetVar Global /usr/web/$host/global
   PerlSetVar NoState 1
   PerlSetVar DynamicIncludes 1






   Listen $ip:$port1



   Listen $ip:$port2

   PerlPostReadRequestHandler My::ProxyRemoteAddr


   ServerName $directory
   DocumentRoot /usr/web/$directory/data

   Use no_users_macro
   Use asp_script_macro $directory $Debug
   Use proxy_macro $ip $port2
   Use log_macro $directory
   Use auth_macro $directory $directory









--

>
> >
> > > Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
> > while "strict refs" in use at (eval 13) line 14.
> > , /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142
> >
>
> You have use strict enabled, so you need to work through this
> error.  use strict error handling needs some work still, and
> dealing with them in Apache::ASP is fairly new business.

Joshua, this output
--
Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
> > while "strict refs" in use at (eval 13) line 14.
--
is sent by another not completed script - rubrics.shtml, when I request
index.shtml! I tried to request 778 port while I'm writing rubrics.shtml

>
> > After some refreshes - I got another output, which is not done by
> > index.shtml!
>
> This sounds like a browser cache problem, make sure you hit
> shift+refresh (Netscape) or control-refresh(IE) to really reload
> a page.

I know what are browser cache problems :) Not it is not browser cache
problem, because after restarting Apache -browser and server works correct
after even 1000 requests, until I request 778 port.

 This could also be a bad mix of Apache::ASP & use strict
> errors.  Can you get me some code that reproduces this behavior?

Yes, I can, but I think it is not a cause of problem, because after restart
Apache
(I leave rubrics.shtml with silly error

my $sth_rubrics = my_prepare("select
level,rubric_id,parent_id,type_id,name,alt_name,priority from
portal.rubrics");
^
 error
must be
my $sth_rubrics = my_prepare(\$dbh,"select
level,rubric_id,parent_id,type_id,name,alt_name,priority from
portal.rubrics");
)
when I request rubrics.shtml I got a error above, but _all_ other scripts
works correct, until I request 778 port, all scripts are mixed, and
index.shtml returns error of rubrics.shtml and rubrics.shtml returns output
of divisions.shtml and etc.
And other (not shtml, driven by Apache::ASP) files returns correct.

>
> I think that there is some work to do on use strict error
> handling, but when in doubt, try stopping and then starting
> apache.

Stopping and starting solves this problem fine :) But how about other
solution...


>
> -- Joshua
> _
> Joshua Chamas Chamas Enterprises Inc.
> NodeWorks >> free web link monitoring Huntington Beach, CA  USA
> http://www.nodeworks.com1-714-625-4051
>



Re: Apache::ASP - I think bug...

1999-12-09 Thread Joshua Chamas

BeerBong wrote:
> 
> --
> Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
> > > while "strict refs" in use at (eval 13) line 14.
> --
> is sent by another not completed script - rubrics.shtml, when I request
> index.shtml! I tried to request 778 port while I'm writing rubrics.shtml
> 

The port used by the server only affects the configuration
apache::asp uses, otherwise it will be unaffected.  The 
real problem is other than the port here, but it is a clue!

> 
> I know what are browser cache problems :) Not it is not browser cache
> problem, because after restarting Apache -browser and server works correct
> after even 1000 requests, until I request 778 port.
> 

Sorry, but it never hurts to check, I get tripped up by it all the time.

>  This could also be a bad mix of Apache::ASP & use strict
> > errors.  Can you get me some code that reproduces this behavior?
> 
> Yes, I can, but I think it is not a cause of problem, because after restart
> Apache
> (I leave rubrics.shtml with silly error
> 

This problem is too weird for me to guess at and will need
a small bit of code that reproduces the problem for you.
We should probably take this off the modperl list for
now as we may be going at this for a while.

> 
> Stopping and starting solves this problem fine :) But how about other
> solution...
> 

Let's find one!

-- Joshua
_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks >> free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051



Re: Apache::ASP - I think bug...

1999-12-10 Thread BeerBong

> > > Not that if you are using the same sub routine name,
> > > you might want to just define it once in global.asa,
> > > and have it vary its behavior based on what script
> > > is calling it, which you can get from $0, or
> > > &File::Basename::basename($0)
> >
> > Shit, It was in your documentation, and I forget about it. May be there
is a
> > reason write down some attentions to Windows ASP programmers, I just
migrate
> > my Windows ASP technology to Apache::ASP did't get any attentions while
>
> Let me know if you had any hiccups in particular while
> migrating that I can help, like compatibility issues ?

There was a need of IncludesDir and Buffering was broke, but you done it.

And may be you need to try insert some attentions on compile while there are
subs with the same name in 2+ scripts
Btw, we can suppose that two users place their own scripts in one
application and named subs the same...
Although you may say, that for every independent user we need create new
application.

> > Nope, routines has very different implementation, which is own for every
> > script. I'll need to give subs different names, for example, with
prefix - script name.
> > What a pity... Compiling to unique packages a little decreased
performance,
> > as I understand, because default for UniquePackages is off...
> >
>
> Try the UniquePackages config, I don't think there is a difference
> on performance, not much anyway, it seemed more natural to that
> compiled includes be able to see the same globals as the main script,
> which was the motivation for not making it the default.

With UniquePackages I can't call subs defined in DynamicIncludes, because
DynamicInclude is compiled to own package.
May be is there reason to give by compiler a unique name for subs in scripts
and leave UniquePackages off ?

Global.asa
-
sub shared_one {
print "Some global text";
};

-

include.inc
-
<%
sub shared_two {
%>
Some global text
<%
};
%>
-

script.asp
-

<%
sub test{
};

shared_one();
shared_two();
test();
%>
-
But compiler translate it to
script.asp
-

<%
sub _test{
};

shared_one();
shared_two();
_test();
%>
-

While I writing it, I think, it is more Windows ASP way than perl
Apache::ASP, although I don't know perl good as C or ASP.
May be better way is implement include.inc as package and use
UniquePackages? And my includes contains only subs.

Package.pm
---
sub shared_two {

my($request) = $main::Request;<<< But it
is not elegant as include.inc
my($env) = $request->Write("some global text");


};

-

script.asp
-
<%
use Package;
sub test{
};

shared_one();
shared_two();
test();
%>
-

The only one method I see, it is call all subs in scripts with unique
prefix.

--
Sergey Polyakov (BeerBong)
Chief of Web Lab (http://www.mustdie.ru/~beerbong)






RESOLVED Re: Apache::ASP - I think bug...

1999-12-09 Thread Joshua Chamas

ModPerl list,

It looks like the problem here was that BeerBong had
the same subroutine name defined in multiple scripts,
and since by default all Apache::ASP are compiled into
the same package namespace, one script would call another's
subroutine, whichever was most recently compiled.

If you want to define the same sub name in different scripts,
you need to set the UniquePackages config, so that each 
script will be compiled in its own namespace.  Better I think
to have one common subroutine name defined in global.asa,
or an include that keys off the script filename in $0 or 
File::Basename::basename($0) to determine its modified behavior.

This problem was made harder to figure out because "use strict"
errors work oddly under Apache::ASP to say the least mostly
likely requiring that you restart the dev web server after
getting a "use strict" compile error.

"use strict" errors used to go directly to the apache error log,
but I have trapped them so they will show up in the Apache::ASP
debug output (in my dev version of .18), to HTML if you have 
debug set to 2 or -2, but this is only the first time the compile 
is tried. I'm still trying to get scripts to try to recompile 
after the first use strict error without success.

Anyone have any pointers here on "use strict" compilation errors?
BTW, I found you can trap their output by overriding $SIG{__WARN__}

--Joshua

_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks >> free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051

BeerBong wrote:
> 
> Hello Joshua!
> 
> I think, I catch new bug of Apache::ASP again, although may be Apache::ASP
> is innocent in this case.
> 
> I have 2 Apache servers - simple/proxy and mod_perl and secured virtual site
> of management big Samara portal.
> 
> Secured on simple Apache.
> 
> 
> 
> 
> 
> 
> AuthType Basic
> AuthName $realm
> AuthUserFile /usr/web/users_file
> AuthGroupFile /usr/web/groups_file
> require group $group
> 
> 
> 
> 
> 
> 
> This site is located at http://195.128.133.23:777 - here listen simple
> Apache, mod_perl Apache listen on http://195.128.133.23:778 address and I
> don't want that anyone can acces mod_perl Apache from outside the server
> 
> Therefore, I have following handler.
> 
> 
> 
> sub My::ProxyRemoteAddr ($)
> {
> my $r = shift;
> 
> # we'll only look at the X-Forwarded-For header if the requests
> # comes from our proxy at localhost
> return FORBIDDEN unless ($r->connection->remote_ip =~ /^195.128.133/);
> 
> if (my ($ip) = $r->header_in('X-Forwarded-For') =~ /([^,\s]+)$/)
> {
>$r->connection->remote_ip($ip);
> }
> 
> return OK;
> }
> 
> 
> 
> All worked just pretty fine until I try, for fun, connect to mod_perl
> directly...
> 
> http://195.128.133.23:778/
> 
> As I await - I got
> 
> 
> 
> Forbidden
> You don't have permission to access / on this server.
> 
> 
> 
> Apache/1.3.9 Server at www.samara.ru-editor Port 778
> 
> 
> 
> Huh! It's cool! But...
> After it I return to 777 port and request
> http://195.128.133.23:777/index.shtml
> and got a error:
> 
> 
> 
> Errors Output
> 
> > Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
> while "strict refs" in use at (eval 13) line 14.
> , /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142
> 
> Debug Output
> 
> 
> After some refreshes - I got another output, which is not done by
> index.shtml!
> As you can see in debug output 'Last 100 Bytes of Buffered Output' is not
> present in 'ASP to Perl Program' !
> Because 'Last 100 bytes' - code of another script - divisions.shtml ! And
> the same thing happens with all other scripts.
> divisions.shtml shows code of rubrics.shtml and etc.
> 
> What you can say ?
> --
> Sergey Polyakov (BeerBong)
> Chief of Web Lab (http://www.mustdie.ru/~beerbong)