mod_perl2 start one script twice
I have follow simple script: !#/usr/bin/perl print "Content-Type: text/html\n\n"; print "Counter: " . (++$counter) . "\n"; print time(), "\n"; sleep(20); print time(), "\n"; Starting that script twice in two different browser windows gives me same results. In second window I start script after some period (about 10 seconds) after first script started. First and Second scripts ends at the same time. So, I misunderrstand, why results are same? As I see it, apache must give work to second child processes for second request (because first busy). And scripts must end works in different time (first script in 10 seconds before second) and give different results (same counter result, but different times). Even if script runs sequentially for each request, results will difference and second script ends after 30 seconds (10 remained for 1st script and 20 for 2nd). But it is not! If I copy script and run two same scripts with different names it works fine. Second question about childs. I not fully understand, how childs work. One child can handle only one script? It's important, because if one child can handle different scripts, than module global variables saves their values between different script calls. For example, if script1 and script2 uses module My::TestPackage, first script sets $My::TestPackage::variable = 123, then script2, after it request, will see in $My::TestPackage::variable value 123, but I haven't seen mention about that situation in official documentations. -- View this message in context: http://www.nabble.com/mod_perl2-start-one-script-twice-tp20107113p20107113.html Sent from the mod_perl - General mailing list archive at Nabble.com.
Generic print concatenation question
Hi. This is probably a question better asked to the perl monks or similar, but if there are any of them lurking around here, it would save me a subscription. In various programs, I do a lot of printing, for results or for logging. Really many print statements, in forms such as : print OUT "$var1 some fixed string [$var2] another string\n"; OR print OUT $var1,"some fixed string [",$var2,"] another string","\n"; OR print OUT $var1 . "some fixed string [" . $var2 . "] another string" . "\n"; and other variations. Some of these forms are easier to handle and type than others, depending a bit on circusmtances. In many cases for instance, $var1 above is always the same string (a prefix of some kind common to all print's or many of them in a row), but $var2 is different each time (both the specific variable and its content). The individual print statements cannot be grouped together as one print, they happen at different places/times. Now, my question is, considering the way perl handles these things internally, how do these different forms compare in terms of eficiency ? I would not ask, if there were not sometimes really many of these being executed over and over again. I figure it may be worth knowing if one of the forms above (or another one I haven't tried) is really better than others in the sense that it saves magabytes of memory or cumulated seconds of processing time. Thanks in advance, André
Re: Generic print concatenation question
> This is probably a question better asked to the perl monks or similar, > but if there are any of them lurking around here, it would save me a > subscription. it's a subscription worth having :) I've learnt more about Perl since I've been there than in the preceding decade. > Now, my question is, considering the way perl handles these things > internally, how do these different forms compare in terms of eficiency ? Perl sorts all of this out at compile time, so: print "$var1 text" and print $var1.' text' are represented by exactly the same opcodes: perl -MO=Concise -e 'my $var = 'abc'; print $var .q{ text}' c <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 5 <2> sassign vKS/2 ->6 3<$> const[PV "abc"] s/BARE ->4 4<0> padsv[$var:1,2] sRM*/LVINTRO ->5 6 <;> nextstate(main 2 -e:1) v:{ ->7 b <@> print vK ->c 7<0> pushmark s ->8 a<2> concat[t2] sK/2 ->b 8 <0> padsv[$var:1,2] s ->9 9 <$> const[PV " text"] s ->a perl -MO=Concise -e 'my $var = 'abc'; print "$var text"' c <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 5 <2> sassign vKS/2 ->6 3<$> const[PV "abc"] s/BARE ->4 4<0> padsv[$var:1,2] sRM*/LVINTRO ->5 6 <;> nextstate(main 2 -e:1) v:{ ->7 b <@> print vK ->c 7<0> pushmark s ->8 -<1> ex-stringify sK/1 ->b - <0> ex-pushmark s ->8 a <2> concat[t2] sK/2 ->b 8 <0> padsv[$var:1,2] s ->9 9 <$> const[PV " text"] s ->a clint
Re: mod_perl2 start one script twice
CthuMP wrote: > > Starting that script twice in two different browser windows gives me same > results. In second window I start script after some period (about 10 > seconds) after first script started. First and Second scripts ends at the > same time. > I have solved that problem. If someone interesting, it was an opera cache. Starting in different browsers gives me correct results. -- View this message in context: http://www.nabble.com/mod_perl2-start-one-script-twice-tp20107113p20111625.html Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: mod_perl2 start one script twice
CthuMP wrote: I have follow simple script: !#/usr/bin/perl print "Content-Type: text/html\n\n"; print "Counter: " . (++$counter) . "\n"; print time(), "\n"; sleep(20); print time(), "\n"; Starting that script twice in two different browser windows gives me same results. In second window I start script after some period (about 10 seconds) after first script started. First and Second scripts ends at the same time. So, I misunderrstand, why results are same? If you're actually seeing the same results from the 'print time()' calls, something weird is going on. A proxy server between you and the server might cause that i suppose, or something the browser is doing with caching, but that shouldn't really happen at the server end i don't think (unless there is some sort of caching mechanism going on there too. As I see it, apache must give work to second child processes for second request (because first busy). And scripts must end works in different time (first script in 10 seconds before second) and give different results (same counter result, but different times). That sounds accurate to me Even if script runs sequentially for each request, results will difference and second script ends after 30 seconds (10 remained for 1st script and 20 for 2nd). But it is not! If I copy script and run two same scripts with different names it works fine. Second question about childs. I not fully understand, how childs work. One child can handle only one script? It's important, because if one child can handle different scripts, than module global variables saves their values between different script calls. For example, if script1 and script2 uses module My::TestPackage, first script sets $My::TestPackage::variable = 123, then script2, after it request, will see in $My::TestPackage::variable value 123, but I haven't seen mention about that situation in official documentations. Each apache child will handle any and all scripts. You can't reliably share global variables like that for exactly the reason you mention. Generally, if you're running code under mod_perl you should be running it under 'use strict' (which would break your original example). Adam
Re: mod_perl2 start one script twice
CthuMP wrote: CthuMP wrote: Starting that script twice in two different browser windows gives me same results. In second window I start script after some period (about 10 seconds) after first script started. First and Second scripts ends at the same time. I have solved that problem. If someone interesting, it was an opera cache. Starting in different browsers gives me correct results. If you want to avoid this, there are HTTP headers that you can set for the response of the server, that will tell the browser not to cache this page. But since you are obviously starting with this, I don't want to spoil your fun. You will find this around lesson 17 or so.. Better to do one thing at a time. ;-)
Re: mod_perl2 start one script twice
It's quite simple really. You're running 2 instances of the script. To retain the value of $counter, read up the mod_perl documentation for tips. CthuMP wrote: I have follow simple script: !#/usr/bin/perl print "Content-Type: text/html\n\n"; print "Counter: " . (++$counter) . "\n"; print time(), "\n"; sleep(20); print time(), "\n"; Starting that script twice in two different browser windows gives me same results. In second window I start script after some period (about 10 seconds) after first script started. First and Second scripts ends at the same time. So, I misunderrstand, why results are same? As I see it, apache must give work to second child processes for second request (because first busy). And scripts must end works in different time (first script in 10 seconds before second) and give different results (same counter result, but different times). Even if script runs sequentially for each request, results will difference and second script ends after 30 seconds (10 remained for 1st script and 20 for 2nd). But it is not! If I copy script and run two same scripts with different names it works fine. Second question about childs. I not fully understand, how childs work. One child can handle only one script? It's important, because if one child can handle different scripts, than module global variables saves their values between different script calls. For example, if script1 and script2 uses module My::TestPackage, first script sets $My::TestPackage::variable = 123, then script2, after it request, will see in $My::TestPackage::variable value 123, but I haven't seen mention about that situation in official documentations.
Re: Sleepycat::DbXml problem "httpd: symbol lookup error"
2008/10/13 Fred Moyer <[EMAIL PROTECTED]> > Felipe de Jesús Molina Bravo wrote: > >> >>maybe is important to say how compile apache and modperl >>(it was very difficult): >> >> >>Can you try compiling mod_perl as a shared object? Static module >>support for mp2 is not as well supported. >> >>perl Makefile.PL MP_APXS=/path/to/httpd/apxs >> >> I will try it . >> >> mmm maybe it is another thread... but I prefer static modper for the >> next arguments: >> >> 1. I guess the static modperl is faster than dynamic I know that >> dynamic is more maintainable that static; for my aplication i require >> modperl more soon; >> > > Maybe it is faster, maybe it isn't. Either way, it is very unlikely that > you would run up against this difference as a bottleneck in your > application. > > 2. When modperl is dynamic i had some segment fault when i share objects >> at the start of apache; when is static i don't have problem ... (maybe i >> some errors in my code) >> > > That could be - if you could post those faults and also your startup.pl > program we may be able to help. > > there are things that worry me: >> 1. In my linux distribution (gentoo) there are not any package with static >> modperl >> > > > >> 2. I see that most of the community uses modperl as dynamic ... maybe is >> it a sign of die the static modperl? >> > > Building mod_perl as a static module was the defacto standard with > mod_perl1, just as building as a dynamic module is defacto with mod_perl2. > I would not try to get caught up in the differences though and suggest that > you try to get a working build as a dynamically loaded module. If you > encounter problems there, they will definitely be of interest to the rest of > us who build mod_perl as a shared object. > > > > > >> what is the opinion of community ? >> >> >> greetings >> > well my problem was resolved with next steps: my distribution is gentoo ... i have installed several versions of gcc (maybe this cause my problem), then with gcc-config command configure default version of gcc to 4.1.2 follow the instructions at: http://www.gentoo.org/doc/en/gcc-upgrading.xml and that's all see you
Re: mod_perl2 start one script twice
Second question about childs. I not fully understand, how childs work. In a little bit more details : When you start Apache, one single process is started. That's what you can call the "main" Apache. It reads and checks the configuration, and bombs out if anything is wrong. If nothing is wrong, it will then "fork" a number of "children" Apache. That initial number is set in your configuration file. The "main" Apache continues to live, and it is that one that is "listening" on port 80. Each of the children is identical, and they can all handle any request. Each child contains the full configuration of Apache, all the add-on modules etc.. If you are using mod_perl, then each of these children also contains its own copy of mod_perl and of the perl interpreter. Don't forget this. When a request comes into Apache (the main one), it looks to see which of his children has nothing to do at the moment, and gives the request to that one for processing. If there are no children free, the main Apache may decide to start a new one. That is also defined in the configuration (MaxChild). If there are too many free children, the main Apache may decide to kill some (to save memory etc..). In other words, the main Apache does not handle requests, it just gives work to his children and controls what they are doing and how long they live. It's terrible and immoral, but that's the way it works. Each child may handle many requests. How many before it dies, depends on another configuration parameter : MaxRequestsPerChild. If this is set to 0, it stays alive "forever" (or until the main Apache decides to kill it). Which specific requests a child will handle, is rather unpredictable : it depends on which child the main Apache gives the next request. (This is not entirely true, but we'll leave that for later). Now the one selected child handle this one request that he received from his main Apache "papa". If it is a request that involves mod_perl, you have to be careful, because the perl interpreter that is started by mod_perl in this child, remains "alive" as long as this child itself lives, and it does "remember" some things from one request to the next. For example, that's what makes it fast : the first time it runs one cgi-bin script, it will compile it and keep the resulting compiled code in memory. The next time a request comes to this same Apache child for the same script, it will not need to compile it again, but it will re-use the compiled version. If the request goes to another child, then that one will also compile the script and keep it in memory, because it does not know about the other child. For example, if the script is big, and if there are 15 Apache children, and you call the same script 20 times, it is possible that the first 15 calls will be slow, and then the last 5 times it will be very fast. That is because each child may get one request, and they all have to first compile the script. But at the second time, they don't have to anymore. There is a danger to this : for some types of variables in your script, perl will remember the last value you put in it, and the next time the script runs in the same child, it will start with that same value. So make sure that all variables that you use, are initialised properly when you start the script. In other words, write : my $var = 0; instead of my $var; Note : each Apache child is a totally separate process, and each of these processes has its own memory and its own perl interpreter. So you can in principle NOT "communicate" between one cgi-bin script and the other (or between two consecutive runs of the same script), because you never know in which Apache child your next request is going to run. And variables are NOT shared between different requests, even of the same script, except as indicated above. Now, if you are very careful, and if you know exactly what you are doing, and if you know exactly how to do it, you might be able, within the same Apache child, to initialise a variable once, and leave it to that same value so that the next time a script runs in the same Apache child, it will find that same value already initialised. But re-read the previous paragraph 3 times, making sure you understand all the if's. Because if you do this without understanding all those ifs, you will create errors that are very nasty and very difficult to find. All the above is clearly explained in the mod_perl on-line documentation, but it never hurts to repeat it.
Re: Generic print concatenation question
On Wed, Oct 22, 2008 at 5:28 AM, André Warnier <[EMAIL PROTECTED]> wrote: > another one I haven't tried how about an Inline::C function that wraps printf and takes $var2 as an argument, and another that takes $var1 as an argument which overwrites the static buffer allocated for the format string?
tests failing when installing libapreq under Leopard
Hi All. I've googled tons and searched the list and can't seem to find an answer to my problem. I am trying to install libapreq 1.33 on OS X Leopard. I have successfully compiled and installed Apache 1.3 with mod_perl 1.3 statically linked. That seems to work fine. I can start apache and the log file shows mod_perl to be installed and everything seems ok at that point. Next I tried to install Apache::Request by downloading libapreq-1.33.tar.gz from CPAN but 'make test' is resulting in errors. 100% of the tests are failing. I should note that I did execute "export ARCHFLAGS=-arch x86_64" prior to building all packages as suggested in the past. Here is what i believe to be the relevant error message from the test script: [Wed Oct 22 12:08:51 2008] [notice] Apache/1.3.41 (Darwin) mod_perl/1.30 configured -- resuming normal operations [Wed Oct 22 12:08:51 2008] [info] Server built: Oct 22 2008 11:19:51 [Wed Oct 22 12:08:51 2008] [notice] Accept mutex: flock (Default: flock) [Wed Oct 22 12:08:53 2008] [error] Can't load '/usr/local/src/libapreq-1.33/blib/arch/auto/Apache/Cookie/Cookie.bundle' for module Apache::Cookie: dlopen(/usr/local/src/libapreq-1.33/blib/arch/auto/Apache/Cookie/Cookie.bundle, 1): Symbol not found: _ap_null_cleanup\n Referenced from: /usr/local/src/libapreq-1.33/blib/arch/auto/Apache/Cookie/Cookie.bundle\n Expected in: dynamic lookup\n at /Library/Perl/5.8.8/darwin-thread-multi-2level/mod_perl.pm line 14\nCompilation failed in require at /usr/local/src/libapreq-1.33/t/response/TestApReq/big_input.pm line 9.\nBEGIN failed--compilation aborted at /usr/local/src/libapreq-1.33/t/response/TestApReq/big_input.pm line 9.\nCompilation failed in require at (eval 10) line 3.\n Unfortunately this error message is a little outside of my understanding. Here is a copy/paste of my console during the whole installation process: bartobrians-macbook-pro:src brian$ cd libapreq-1.33 bartobrians-macbook-pro:libapreq-1.33 brian$ perl Makefile.PL -apxs /usr/local/httpd/sbin/apxs -httpd /usr/local/httpd/sbin/httpd [ info] generating script t/TEST Checking if your kit is complete... Looks good Writing Makefile for libapreq mkdir ../blib mkdir ../blib/arch mkdir ../blib/arch/auto mkdir ../blib/arch/auto/libapreq Writing Makefile for Apache::Request Writing Makefile for Apache::Cookie Writing Makefile for libapreq bartobrians-macbook-pro:libapreq-1.33 brian$ make cp lib/Apache/libapreq.pm blib/lib/Apache/libapreq.pm cp libapreq.pod blib/lib/libapreq.pod cc -c -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/modules/perl -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/include -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/regex -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/os/unix -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include -O3 -DVERSION=\"\" -DXS_VERSION=\"\" "-I/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE" apache_request.c cc -c -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/modules/perl -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/include -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/regex -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/os/unix -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include -O3 -DVERSION=\"\" -DXS_VERSION=\"\" "-I/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE" apache_cookie.c cc -c -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/modules/perl -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/include -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/regex -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/Apache/include/os/unix -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include -O3 -DVERSION=\"\" -DXS_VERSION=\"\" "-I/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE" apache_multipart_buffer.c rm -rf ../blib/arch/auto/libapreq/libapreq.a /usr/bin/ar cr ../blib/arch/auto/libapreq/libapreq.a apache_request.o apache_cookie.o apache_multipart_buffer.o && /usr/bin/ar ts ../blib/arch/auto/libapreq/libapreq.a __.SYMDEF SORTED apache_request.o apache_cookie.o apache_multipart_buffer.o chmod 755 ../blib/arch/auto/libapreq/libapreq.a cp apache_multipart_buffer.h ../blib/arch/auto/libapreq/include/apache_multipart_buffer.h cp apache_cookie.h ../blib/arch/auto/libapreq/include/apache_cookie.h cp apache_request.h ../blib/arch/auto/libapreq/include/apache_reques
Re: Generic print concatenation question
On Wed, Oct 22, 2008 at 6:28 AM, André Warnier <[EMAIL PROTECTED]> wrote: > I would not ask, if there were not sometimes really many of these being > executed over and over again. I figure it may be worth knowing if one of > the forms above (or another one I haven't tried) is really better than > others in the sense that it saves magabytes of memory or cumulated seconds > of processing time. If you run your app through Devel::NYTProf, you won't have to guess. - Perrin
PerlAuthenHandler & phpMyAdmin
Hello all, Today I tried to limit access to phpMyAdmin using my own Authen.pm module. It works well but not always. Looks like phpMyAdmin has problems with HTTP post method if I enable my PerlAuthenHandler Authen.pm. Otherwise phpMyAdmin and Authen.pm work well. The error I get in phpMyAdmin is: Fatal error: PMA_sendHeaderLocation called when headers are already sent! in /opt/datajoy/www/lib/phpMyAdmin/libraries/common.lib.php on line 650 I am not sure what causes this problem. It may be phpMyAdmin issue or there is something wrong in my Authen.pm. But since my Authen.pm works well when limiting access to directories/files and since I have no problem with phpMyAdmin if I use .htaccess with password file (AuthUserFile) I thought it might be mod_perl issue. Anyone else noticed strange behaviour when using PerlAuthenHandler? It is the same if I use PerlAccessHandler. I hope someone can direct me where to look for solution. Best regards, Miha Server software: Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 I also noticed this problem in older versions of Apache, perl, mod_perl and php. Bellow are my Apache settings for phpMyAdmin dir and Authen.pm module: PerlSendHeader Off AuthName DatajoyWebAuth AuthType Basic PerlAuthenHandler Datajoy::Authen require valid-user package Datajoy::Authen; use strict; use Apache2::Access (); use Apache2::RequestUtil (); use Apache2::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED); use Datajoy::Application; use Datajoy::Config; sub Authenticate { my ($domain,$user,$pass,$file)[EMAIL PROTECTED]; my $result=0; my $app=Datajoy::Application->new(); $app->Db_Connect; my $sth=$app->{dbh}->prepare("select users.org_id, users.id, pages.path from domains,users,pages where domains.page_id=pages.id and users.org_id=domains.org_id and domains.domain=? and users.username=?"); $sth->execute($domain,$user); my ($org_id,$user_id,$domain_path)=$sth->fetchrow_array; if ($org_id && $user_id) { my $auth=undef; eval '$auth='.$app->{config}->{auth_module}.'->new($app)'; if (! $@) { my ($logged_in,$uref)=$auth->Login($org_id,$user,$pass); if ($logged_in>0) { $result=1; } } } return $result; } sub handler { my $r=shift; my ($status,$pass)=$r->get_basic_auth_pw; return $status unless $status == Apache2::Const::OK; my $domain=$r->hostname(); my $user=$r->user; my $file=$r->filename(); if (Authenticate($domain,$user,$pass,$file)) { return Apache2::Const::OK; } else { $r->note_basic_auth_failure; return Apache2::Const::HTTP_UNAUTHORIZED; } } 1;
Re: PerlAuthenHandler & phpMyAdmin
Usually, if you run into problems that only affect POST requests, that means that somewhere earlier in the apache cycle there is something consuming the posted data. Looking at the code you've posted though, it's not immediately obvious that that is the problem, nor is it obvious that it's actually the even related to the problem that phpMyAdmin is displaying. That is something you can look into further though Perhaps part of DataJoy::Application is reading the post variables out of STDIN. Adam Miha Lampret wrote: Hello all, Today I tried to limit access to phpMyAdmin using my own Authen.pm module. It works well but not always. Looks like phpMyAdmin has problems with HTTP post method if I enable my PerlAuthenHandler Authen.pm. Otherwise phpMyAdmin and Authen.pm work well. The error I get in phpMyAdmin is: Fatal error: PMA_sendHeaderLocation called when headers are already sent! in /opt/datajoy/www/lib/phpMyAdmin/libraries/common.lib.php on line 650 I am not sure what causes this problem. It may be phpMyAdmin issue or there is something wrong in my Authen.pm. But since my Authen.pm works well when limiting access to directories/files and since I have no problem with phpMyAdmin if I use .htaccess with password file (AuthUserFile) I thought it might be mod_perl issue. Anyone else noticed strange behaviour when using PerlAuthenHandler? It is the same if I use PerlAccessHandler. I hope someone can direct me where to look for solution. Best regards, Miha Server software: Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0 I also noticed this problem in older versions of Apache, perl, mod_perl and php. Bellow are my Apache settings for phpMyAdmin dir and Authen.pm module: PerlSendHeader Off AuthName DatajoyWebAuth AuthType Basic PerlAuthenHandler Datajoy::Authen require valid-user package Datajoy::Authen; use strict; use Apache2::Access (); use Apache2::RequestUtil (); use Apache2::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED); use Datajoy::Application; use Datajoy::Config; sub Authenticate { my ($domain,$user,$pass,$file)[EMAIL PROTECTED]; my $result=0; my $app=Datajoy::Application->new(); $app->Db_Connect; my $sth=$app->{dbh}->prepare("select users.org_id, users.id, pages.path from domains,users,pages where domains.page_id=pages.id and users.org_id=domains.org_id and domains.domain=? and users.username=?"); $sth->execute($domain,$user); my ($org_id,$user_id,$domain_path)=$sth->fetchrow_array; if ($org_id && $user_id) { my $auth=undef; eval '$auth='.$app->{config}->{auth_module}.'->new($app)'; if (! $@) { my ($logged_in,$uref)=$auth->Login($org_id,$user,$pass); if ($logged_in>0) { $result=1; } } } return $result; } sub handler { my $r=shift; my ($status,$pass)=$r->get_basic_auth_pw; return $status unless $status == Apache2::Const::OK; my $domain=$r->hostname(); my $user=$r->user; my $file=$r->filename(); if (Authenticate($domain,$user,$pass,$file)) { return Apache2::Const::OK; } else { $r->note_basic_auth_failure; return Apache2::Const::HTTP_UNAUTHORIZED; } } 1;
AC US 2008
Hi All, wondering who is going to present at the Apache US 2008 conference in New Orleans. I'll be there 11/2 - 11/9 -- Philip M. Gollucci ([EMAIL PROTECTED]) c: 703.336.9354 Consultant - P6M7G8 Inc. http://p6m7g8.net Senior System Admin - RideCharge, Inc. http://ridecharge.com 1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70 3F8C 75B8 8FFB DB9B 8C1C Work like you don't need the money, love like you'll never get hurt, and dance like nobody's watching.
Re: AC US 2008
Philip M. Gollucci wrote: > Hi All, > > wondering who is going to present at the Apache US 2008 conference in > New Orleans. > > I'll be there 11/2 - 11/9 > I'm presenting on wednesday afternoon: http://us.apachecon.com/c/acus2008/sessions/4 --Geoff
Re: AC US 2008
Geoffrey Young wrote: Philip M. Gollucci wrote: Hi All, wondering who is going to present at the Apache US 2008 conference in New Orleans. I'll be there 11/2 - 11/9 I'm presenting on wednesday afternoon: http://us.apachecon.com/c/acus2008/sessions/4 Looking forward to seeing this presentation. I'll be there Monday evening to Friday morning, hacking mod_perl at the hackathon on Tuesday.
Re: PerlAuthenHandler & phpMyAdmin
You are right. In Datajoy::Application I was using CGI.pm. Removing "new CGI" code from Application.pm solved the problem. Thank you for your help. Best regards, Miha On Wed, Oct 22, 2008 at 8:49 PM, Adam Prime <[EMAIL PROTECTED]> wrote: > Usually, if you run into problems that only affect POST requests, that means > that somewhere earlier in the apache cycle there is something consuming the > posted data. Looking at the code you've posted though, it's not immediately > obvious that that is the problem, nor is it obvious that it's actually the > even related to the problem that phpMyAdmin is displaying. That is > something you can look into further though Perhaps part of > DataJoy::Application is reading the post variables out of STDIN. > > Adam > > > > Miha Lampret wrote: >> >> Hello all, >> >> Today I tried to limit access to phpMyAdmin using my own Authen.pm >> module. It works well but not always. Looks like phpMyAdmin has >> problems with HTTP post method if I enable my PerlAuthenHandler >> Authen.pm. Otherwise phpMyAdmin and Authen.pm work well. >> >> The error I get in phpMyAdmin is: >> Fatal error: PMA_sendHeaderLocation called when headers are already >> sent! in /opt/datajoy/www/lib/phpMyAdmin/libraries/common.lib.php on >> line 650 >> >> I am not sure what causes this problem. It may be phpMyAdmin issue or >> there is something wrong in my Authen.pm. But since my Authen.pm works >> well when limiting access to directories/files and since I have no >> problem with phpMyAdmin if I use .htaccess with password file >> (AuthUserFile) I thought it might be mod_perl issue. Anyone else >> noticed strange behaviour when using PerlAuthenHandler? It is the same >> if I use PerlAccessHandler. >> >> I hope someone can direct me where to look for solution. >> >> Best regards, >> Miha >> >> Server software: >> Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch mod_perl/2.0.4 >> Perl/v5.10.0 >> I also noticed this problem in older versions of Apache, perl, mod_perl >> and php. >> >> Bellow are my Apache settings for phpMyAdmin dir and Authen.pm module: >> >> >>PerlSendHeader Off >>AuthName DatajoyWebAuth >>AuthType Basic >>PerlAuthenHandler Datajoy::Authen >>require valid-user >> >> >> >> package Datajoy::Authen; >> >> use strict; >> use Apache2::Access (); >> use Apache2::RequestUtil (); >> use Apache2::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED); >> >> use Datajoy::Application; >> use Datajoy::Config; >> >> sub Authenticate { >>my ($domain,$user,$pass,$file)[EMAIL PROTECTED]; >>my $result=0; >> >>my $app=Datajoy::Application->new(); >>$app->Db_Connect; >> >>my $sth=$app->{dbh}->prepare("select users.org_id, users.id, pages.path >> from domains,users,pages >> where domains.page_id=pages.id and users.org_id=domains.org_id >> and domains.domain=? and users.username=?"); >>$sth->execute($domain,$user); >>my ($org_id,$user_id,$domain_path)=$sth->fetchrow_array; >> >>if ($org_id && $user_id) { >>my $auth=undef; >>eval '$auth='.$app->{config}->{auth_module}.'->new($app)'; >>if (! $@) { >>my ($logged_in,$uref)=$auth->Login($org_id,$user,$pass); >>if ($logged_in>0) { >>$result=1; >>} >>} >>} >> >>return $result; >> } >> >> sub handler { >>my $r=shift; >> >>my ($status,$pass)=$r->get_basic_auth_pw; >> >>return $status unless $status == Apache2::Const::OK; >> >>my $domain=$r->hostname(); >>my $user=$r->user; >>my $file=$r->filename(); >> >>if (Authenticate($domain,$user,$pass,$file)) { >>return Apache2::Const::OK; >>} else { >>$r->note_basic_auth_failure; >>return Apache2::Const::HTTP_UNAUTHORIZED; >>} >> >> } >> >> 1; >> > >