Return-Path:
-
-
+ mod_perl Pocket Reference
+
+
- By Stas Bekman, Jim Brandt
+ By Andrew Ford
@@ -647,11 +647,11 @@ with mod_perl 2.0. For most people it's
-
-
+ Writing Apache Modules with Perl and C
+
+
- By Stas Bekman, Eric Cholet
+ By Lincoln Stein, Doug MacEachern
@@ -666,11 +666,11 @@ with mod_perl 2.0. For most people it's
@@ -685,11 +685,11 @@ with mod_perl 2.0. For most people it's
-
-
+ mod_perl2 User's Guide
+
+
- By Andrew Ford
+ By Stas Bekman, Jim Brandt
@@ -704,11 +704,11 @@ with mod_perl 2.0. For most people it's
-
-
+ Practical mod_perl
+
+
- By Lincoln Stein, Doug MacEachern
+ By Stas Bekman, Eric Cholet
@@ -723,11 +723,11 @@ with mod_perl 2.0. For most people it's
@@ -1035,7 +1035,7 @@ Changes file.
Last modified Mon Feb 11 03:41:47 2013
+Last modified Sat Feb 15 14:50:07 2014
Modified: perl/site/docs/2.0/user/intro/start_fast.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/intro/start_fast.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/2.0/user/performance/mpm.html URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/performance/mpm.html?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/2.0/user/performance/mpm.html (original) +++ perl/site/docs/2.0/user/performance/mpm.html Sat Feb 15 22:56:21 2014 @@ -629,11 +629,11 @@ performance out of it.">Last modified Mon Feb 11 03:41:48 2013
+Last modified Sat Feb 15 14:50:08 2014
Modified: perl/site/docs/2.0/user/performance/mpm.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/performance/mpm.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/2.0/user/performance/prevent.html URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/performance/prevent.html?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/2.0/user/performance/prevent.html (original) +++ perl/site/docs/2.0/user/performance/prevent.html Sat Feb 15 22:56:21 2014 @@ -628,11 +628,11 @@ keep the performance high">Last modified Mon Feb 11 03:41:48 2013
+Last modified Sat Feb 15 14:50:08 2014
Modified: perl/site/docs/2.0/user/performance/prevent.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/performance/prevent.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/2.0/user/porting/compat.html URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/porting/compat.html?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/2.0/user/porting/compat.html (original) +++ perl/site/docs/2.0/user/porting/compat.html Sat Feb 15 22:56:21 2014 @@ -628,11 +628,11 @@ from mod_perl 1.0 to mod_perl 2.0.">Last modified Mon Feb 11 03:41:47 2013
+Last modified Sat Feb 15 14:50:07 2014
Modified: perl/site/docs/2.0/user/porting/compat.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/porting/compat.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/2.0/user/porting/porting.html URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/porting/porting.html?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/2.0/user/porting/porting.html (original) +++ perl/site/docs/2.0/user/porting/porting.html Sat Feb 15 22:56:21 2014 @@ -630,11 +630,11 @@ handlers.">Last modified Mon Feb 11 03:41:47 2013
+Last modified Sat Feb 15 14:50:07 2014
Modified: perl/site/docs/2.0/user/porting/porting.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/porting/porting.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/2.0/user/troubleshooting/troubleshooting.html URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/troubleshooting/troubleshooting.html?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/2.0/user/troubleshooting/troubleshooting.html (original) +++ perl/site/docs/2.0/user/troubleshooting/troubleshooting.html Sat Feb 15 22:56:21 2014 @@ -628,11 +628,11 @@ troubleshooting.">This warning is normally as a result of variables that your script is sharing +with subroutines globally, rather than passing by value or reference. As +the cause and solution of this is virtually identical to another commonly +encountered problem (Sometimes it works, sometimes it doesn't), +the text is not repeated here but is instead included in that section which +follows this one.
+You may have read somewhere out there that this warning can be ignored, +but if you read on you will see that you should never ignore the warning. +The other thing that might confuse you is that this warning is normally +encountered when defining subroutines within subroutines. So why would you +experience it in your script where that is not the case? The reason is +because mod_perl wraps your script in its own subroutine (see the Perl Reference +documentation for more details).
+When you start running your scripts under mod_perl, you might find
+yourself in a situation where a script seems to work, but sometimes it
+screws up. And the more it runs without a restart, the more it screws
+up. Often the problem is easily detectable and solvable. You have to
+test your script under a server running in single process mode
+(httpd -X
).
Generally the problem is the result of using global variables (normally accompanied +by a Variable $x will not stay shared at warning). Because +global variables don't change from one script invocation to another +unless you change them, you can find your scripts do strange things.
+Let's look at three real world examples:
+The first example is amazing: Web Services. Imagine that you enter +some site where you have an account, perhaps a free email +account. Having read your own mail you decide to take a look at +someone else's.
+You type in the username you want to peek at and a dummy password and +try to enter the account. On some services this will work!!!
+You say, why in the world does this happen? The answer is simple: +Global Variables. You have entered the account of someone who +happened to be served by the same server child as you. Because of +sloppy programming, a global variable was not reset at the beginning +of the program and voila, you can easily peek into someone else's +email! Here is an example of sloppy code:
+use vars ($authenticated); + my $q = new CGI; + my $username = $q->param('username'); + my $passwd = $q->param('passwd'); + authenticate($username,$passwd); + # failed, break out + unless ($authenticated){ + print "Wrong passwd"; + exit; + } + # user is OK, fetch user's data + show_user($username); + + sub authenticate{ + my ($username,$passwd) = @_; + # some checking + $authenticated = 1 if SOME_USER_PASSWD_CHECK_IS_OK; + }+
Do you see the catch? With the code above, I can type in any valid
+username and any dummy password and enter that user's account,
+provided she has successfully entered her account before me using the
+same child process! Since $authenticated
is global--if it becomes 1
+once, it'll stay 1 for the remainder of the child's life!!! The
+solution is trivial--reset $authenticated
to 0 at the beginning of
+the program.
A cleaner solution of course is not to rely on global variables, but +rely on the return value from the function.
+my $q = CGI->new; + my $username = $q->param('username'); + my $passwd = $q->param('passwd'); + my $authenticated = authenticate($username,$passwd); + # failed, break out + unless ($authenticated){ + print "Wrong passwd"; + exit; + } + # user is OK, fetch user's data + show_user($username); + + sub authenticate{ + my ($username,$passwd) = @_; + # some checking + return (SOME_USER_PASSWD_CHECK_IS_OK) ? 1 : 0; + }+
Of course this example is trivial--but believe me it happens!
+Just another little one liner that can spoil your day, assuming you
+forgot to reset the $allowed
variable. It works perfectly OK in
+plain mod_cgi:
$allowed = 1 if $username eq 'admin';+
But using mod_perl, and if your system administrator with superuser +access rights has previously used the system, anybody who is lucky +enough to be served later by the same child which served your +administrator will happen to gain the same rights.
+The obvious fix is:
+$allowed = $username eq 'admin' ? 1 : 0;+
Another good example is usage of the /o
regular expression
+modifier, which compiles a regular expression once, on its first
+execution, and never compiles it again. This problem can be difficult
+to detect, as after restarting the server each request you make will
+be served by a different child process, and thus the regex pattern for
+that child will be compiled afresh. Only when you make a request that
+happens to be served by a child which has already cached the regex
+will you see the problem. Generally you miss that. When you press
+reload, you see that it works (with a new, fresh child). Eventually it
+doesn't, because you get a child that has already cached the regex
+and won't recompile because of the /o
modifier.
An example of such a case would be:
+my $pat = $q->param("keyword"); + foreach( @list ) { + print if /$pat/o; + }+
To make sure you don't miss these bugs always test your CGI in +single process mode.
+To solve this particular /o
modifier problem refer to Compiled Regular Expressions.
For more details and further examples please see the Perl Reference documentation.
+It doesn't strictly belong to this document, since it's talking about @@ -1563,7 +1737,7 @@ Changes file.
Last modified Mon Feb 11 03:41:48 2013
+Last modified Sat Feb 15 14:50:08 2014
Modified: perl/site/docs/2.0/user/troubleshooting/troubleshooting.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/troubleshooting/troubleshooting.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/2.0/user/troubleshooting/troubleshooting.pod.orig URL: http://svn.apache.org/viewvc/perl/site/docs/2.0/user/troubleshooting/troubleshooting.pod.orig?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/2.0/user/troubleshooting/troubleshooting.pod.orig (original) +++ perl/site/docs/2.0/user/troubleshooting/troubleshooting.pod.orig Sat Feb 15 22:56:21 2014 @@ -675,6 +675,158 @@ when you encounter this problem. +=head2 Variable $x will not stay shared at + +This warning is normally as a result of variables that your script is sharing +with subroutines globally, rather than passing by value or reference. As +the cause and solution of this is virtually identical to another commonly +encountered problem (LLast modified Mon Feb 11 03:41:44 2013
+Last modified Sat Feb 15 14:50:06 2014
Last modified Mon Feb 11 03:41:51 2013
+Last modified Sat Feb 15 14:50:09 2014
Last modified Mon Feb 11 03:41:51 2013
+Last modified Sat Feb 15 14:50:09 2014
Modified: perl/site/docs/general/advocacy/advocacy.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/general/advocacy/advocacy.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/general/control/control.html URL: http://svn.apache.org/viewvc/perl/site/docs/general/control/control.html?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/general/control/control.html (original) +++ perl/site/docs/general/control/control.html Sat Feb 15 22:56:21 2014 @@ -628,6 +628,25 @@ setups.">Last modified Mon Feb 11 03:41:51 2013
+Last modified Sat Feb 15 14:50:09 2014
Modified: perl/site/docs/general/control/control.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/general/control/control.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/general/correct_headers/correct_headers.html URL: http://svn.apache.org/viewvc/perl/site/docs/general/correct_headers/correct_headers.html?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/general/correct_headers/correct_headers.html (original) +++ perl/site/docs/general/correct_headers/correct_headers.html Sat Feb 15 22:56:21 2014 @@ -629,6 +629,25 @@ pay attention to, and how to work with tLast modified Mon Feb 11 03:41:51 2013
+Last modified Sat Feb 15 14:50:09 2014
Modified: perl/site/docs/general/correct_headers/correct_headers.pdf URL: http://svn.apache.org/viewvc/perl/site/docs/general/correct_headers/correct_headers.pdf?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== Binary files - no diff available. Modified: perl/site/docs/general/correct_headers/correct_headers.pod.orig URL: http://svn.apache.org/viewvc/perl/site/docs/general/correct_headers/correct_headers.pod.orig?rev=1568699&r1=1568698&r2=1568699&view=diff ============================================================================== --- perl/site/docs/general/correct_headers/correct_headers.pod.orig (original) +++ perl/site/docs/general/correct_headers/correct_headers.pod.orig Sat Feb 15 22:56:21 2014 @@ -122,7 +122,7 @@ this argument first. use Date::Parse; # Date::Parse parses RCS format, Apache::Util::parsedate doesn't $Mtime ||= - Date::Parse::str2time(substr q$Date: 2007-03-28 23:15:34 +0000 (Wed, 28 Mar 2007) $, 6); + Date::Parse::str2time(substr q$Date: 2007-03-28 16:15:34 -0700 (Wed, 28 Mar 2007) $, 6); $r->set_last_modified($Mtime); =head3 Expires and Cache-Control