On 26 Sep 2000 [EMAIL PROTECTED] wrote:
> dougm 00/09/26 14:02:44
>
> Modified: . Changes
> src/modules/perl perl_config.c
> Log:
> fix for Perl{Module,Require} in .htaccess
>
> Revision Changes Path
> 1.524 +3 -0 modperl/Changes
>
> Index: Changes
> ===================================================================
> RCS file: /home/cvs/modperl/Changes,v
> retrieving revision 1.523
> retrieving revision 1.524
> diff -u -r1.523 -r1.524
> --- Changes 2000/09/26 20:11:03 1.523
> +++ Changes 2000/09/26 21:02:36 1.524
> @@ -10,6 +10,9 @@
>
> =item 1.24_01-dev
>
> +fix for Perl{Module,Require} in .htaccess,
> +thanks to Will Trillich and Andrew Gideon for the spot
> +
> static+apaci fixes for aix [Jens-Uwe Mager <[EMAIL PROTECTED]>]
>
> fix bug in Perl{Set,Add}Var so $r->dir_config->get('key') sees the
>
>
>
> 1.104 +7 -2 modperl/src/modules/perl/perl_config.c
>
> Index: perl_config.c
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
> retrieving revision 1.103
> retrieving revision 1.104
> diff -u -r1.103 -r1.104
> --- perl_config.c 2000/09/26 20:05:22 1.103
> +++ perl_config.c 2000/09/26 21:02:42 1.104
> @@ -587,8 +587,11 @@
> return NULL;
> }
> }
> - *(char **)push_array(cls->PerlModule) = pstrdup(parms->pool, arg);
>
> + if (cld->PerlModule) {
> + *(char **)push_array(cls->PerlModule) = pstrdup(parms->pool, arg);
> + }
> +
> #ifdef PERL_SECTIONS
> if(CAN_SELF_BOOT_SECTIONS)
> perl_section_self_boot(parms, dummy, arg);
> @@ -618,7 +621,9 @@
> }
> }
>
> - *(char **)push_array(cls->PerlRequire) = pstrdup(parms->pool, arg);
> + if (cls->PerlRequire) {
> + *(char **)push_array(cls->PerlRequire) = pstrdup(parms->pool, arg);
> + }
>
> #ifdef PERL_SECTIONS
> if(CAN_SELF_BOOT_SECTIONS)
I don't think that this is the best aproach, let me explain:
IMHO the real problem relies in allow Perl{Module|Require} directives in
.htaccess files, The cls->PermModule and cls->PerlRequire arrays are both
in the per server part of mod_perl config, so allow to modify them (in
this case append to) when apache is parsing a .htaccess (a per request
operation to create a per directory config) simply don't make sense.
First, both arrays are procesed only inside perl_startup for the case that
the real require was delayed, and when apache starts servicing requests
and parsing .htaccess files, the perl startup was done.
Second, Loading a perl module at per request time that will be remain in
core for the rest of the live of the running child and can not be shared
among other children in general isn't a good idea so is better don't
promote that practice.
Worse, allow that can create false expectations to the user, because if
the PerlRequire is used for its side effects, ie out of subs code that
code will be run only the first time a child sees the .htaccess and any
other request served by that child will be silent, so from the point of
view of the module programer that code runs at random times. [see note1]
The corrent fix IMHO is simply don't allow that directives in
per directory containers:
{ "PerlRequire", (crft) perl_cmd_require,
NULL,
- OR_ALL, ITERATE, "A Perl script name, pulled in via require" },
+ RSRC_CONF, ITERATE, "A Perl script name, pulled in via require" },
{ "PerlModule", (crft) perl_cmd_module,
NULL,
- OR_ALL, ITERATE, "List of Perl modules" },
+ RSRC_CONF, ITERATE, "List of Perl modules" },
Right now its don't works, so nothing is broken.
[note1]
A "fix" for that behavior is a simple 'delete $INC{$module_name}' at the
end, but ussing that as common practice is a bad thing. Much better is a
simple
<Perl>
MyModule::parsing_htaccess('foo','bar')
</Perl>
inside the .htaccess file.
BTW, I have a _very_ small and well tested patch for a new directive
'PerlDo', that acts exactly like a
<Perl>
{On line of perl code}
</Perl>
as
PerlDo {On line of perl code}
In perl_config, near line 1695:
--- mod_perl-1.24.orig/src/modules/perl/perl_config.c
+++ mod_perl-1.24/src/modules/perl/perl_config.c
@@ -1695,8 +1696,11 @@
if(PERL_RUNNING()) {
code = newSV(0);
sv_setpv(code, "");
- if(arg)
- errmsg = perl_srm_command_loop(parms, code);
+ if(arg) {
+ if(parms->info) { /* PerlDo */
+ sv_catpv(code, (char *)arg);
+ } else errmsg = perl_srm_command_loop(parms, code);
+ }
}
else {
MP_TRACE_s(fprintf(stderr,
--- mod_perl-1.24.orig/src/modules/perl/mod_perl.c
13:04:47 2000+++ mod_perl-1.24/src/modules/perl/mod_perl.c
22:11:52 2000
@@ -95,6 +95,7 @@
#ifdef PERL_SECTIONS
{ "<Perl>", (crft) perl_section, NULL, SECTION_ALLOWED, RAW_ARGS, "Perl code" },
{ "</Perl>", (crft) perl_end_section, NULL, SECTION_ALLOWED, NO_ARGS, "End Perl
code" },
+ { "PerlDo", (crft) perl_section, (void*)1, SECTION_ALLOWED, RAW_ARGS, "Eval a
+perl expresion in context" },
#endif
{ "=pod", (crft) perl_pod_section, NULL, OR_ALL, RAW_ARGS, "Start of POD" },
Regards.
Salvador Ortiz
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]