Re: Problem with Perl sections in httpd.conf, mod_perl 1.26
Here's a bit more information: Given two directives: $VirtualHost{$host}-{Alias} = [ '/perl/', $vhostdir/$dir/perl/ ]; $VirtualHost{$host}-{Alias} = $vhost{config}-{Alias}; The first works. The second does not. According to Apache::PerlSections-dump, %VirtualHost is *exactly* the same when using both directives - yet it seems the server ignores the Alias directive when it's assigned from $vhost{config} (either that, mod_perl fails to pass it to the server). Also, if I set a variable within httpd.conf to mimic $vhost{config} and then assign that to $VirtualHost{$host}, it works without a problem. The issuse is definitely with the variable being read in from an external file. Strange, no? On Fri, Apr 19, 2002 at 01:31:45AM -0400, PinkFreud babbled thus: Date: 19 Apr 2002 01:31:45 -0400 Date: Fri, 19 Apr 2002 01:31:45 -0400 From: PinkFreud [EMAIL PROTECTED] To: Salvador Ortiz Garcia [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Problem with Perl sections in httpd.conf, mod_perl 1.26 Mail-Followup-To: Salvador Ortiz Garcia [EMAIL PROTECTED], [EMAIL PROTECTED] User-Agent: Mutt/1.3.25i On Thu, Apr 18, 2002 at 11:15:15PM -0500, Salvador Ortiz Garcia babbled thus: Subject: Re: Problem with Perl sections in httpd.conf, mod_perl 1.26 From: Salvador Ortiz Garcia [EMAIL PROTECTED] To: PinkFreud [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] X-Mailer: Ximian Evolution 1.0.3 Date: 18 Apr 2002 23:15:15 -0500 On Mon, 2002-04-15 at 23:17, PinkFreud wrote: I have a rather odd problem, one which I can only assume is a bug somewhere, due to how bizarre it is. I am attmempting to generate virtual host configs via mod_perl, using Perl sections in httpd.conf. Not all hosts will be using a /perl Alias, though, so I'm reading in an external config, which looks like the following: [ Deleted ] Plese try changing your Alias array ref to a simple scalar: ... 'Alias' = '/perl/ /home/vhosts/linuxhelp.mirkwood.net/perl/', ... That should work. Nope. Still can't find it. What gets me is the syntax I use for Alias works just fine when the code is in httpd.conf. It only fails to work when I read it in via a require'd file. This same behavior occurs when I use your syntax in the require'd file as well. /me scratches his head, perplexed. And yes, I think its an old bug in perl_handle_command_av. Salvador Ortiz. -- Mike Edwards Brainbench certified Master Linux Administrator http://www.brainbench.com/transcript.jsp?pid=158188 --- Unsolicited advertisments to this address are not welcome.
Re: Problem with Perl sections in httpd.conf, mod_perl 1.26
On Fri, 2002-04-19 at 01:43, PinkFreud wrote: Here's a bit more information: Given two directives: $VirtualHost{$host}-{Alias} = [ '/perl/', $vhostdir/$dir/perl/ ]; $VirtualHost{$host}-{Alias} = $vhost{config}-{Alias}; The first works. The second does not. According to Apache::PerlSections-dump, %VirtualHost is *exactly* the same when using both directives - yet it seems the server ignores the Alias directive when it's assigned from $vhost{config} (either that, mod_perl fails to pass it to the server). Also, if I set a variable within httpd.conf to mimic $vhost{config} and then assign that to $VirtualHost{$host}, it works without a problem. The issuse is definitely with the variable being read in from an external file. Strange, no? Yes, weird. I'm hunting any remaining bugs related to Perl Sections. Can you please test the attached patch vs 1.26? (please forget about the patch posted by Michel, it is mine and in CVS now, but in this I'm trying a more radical approach and checking for the proper nesting of directives) Then try to reproduce your problems under MOD_PERL_TRACE=ds (see the DEBUGGIN section in the mod_perl man page), thats is, compile mod_perl with PERL_TRACE=1 and run your Apache in single process mode: # MOD_PERL_TRACE=ds path_to_your/httpd -X And please post the generated log. Regards. Salvador Ortiz diff -ru mod_perl-1.26.orig/src/modules/perl/perl_config.c mod_perl-1.26.msg/src/modules/perl/perl_config.c --- mod_perl-1.26.orig/src/modules/perl/perl_config.c Tue Jul 10 20:47:15 2001 +++ mod_perl-1.26.msg/src/modules/perl/perl_config.c Thu Feb 21 01:43:10 2002 -51,6 +51,7 #include mod_perl.h extern API_VAR_EXPORT module *top_module; +IV mp_cmdparms = 0; #ifdef PERL_SECTIONS static int perl_sections_self_boot = 0; -1166,6 +1167,9 char *tmpkey; I32 tmpklen; SV *tmpval; +const command_rec *orec = cmd-cmd; +const char *old_end_token = cmd-end_token; +cmd-end_token = (const char *)cmd-info; (void)hv_iterinit(hv); while ((tmpval = hv_iternextsv(hv, tmpkey, tmpklen))) { char line[MAX_STRING_LEN]; -1173,6 +1177,13 if (SvMAGICAL(tmpval)) mg_get(tmpval); /* tied hash FETCH */ if(SvROK(tmpval)) { if(SvTYPE(SvRV(tmpval)) == SVt_PVAV) { + module *tmod = top_module; + const command_rec *c; + if(!(c = find_command_in_modules((const char *)tmpkey, tmod))) { + fprintf(stderr, command_rec for directive `%s' not found!\n, tmpkey); + continue; + } + cmd-cmd = c; /* for do_quote */ perl_handle_command_av((AV*)SvRV(tmpval), 0, tmpkey, cmd, cfg); continue; -1195,8 +1206,12 if(errmsg) log_printf(cmd-server, Perl: %s, errmsg); } -/* Emulate the handling of end token for the section */ +cmd-cmd = orec; +cmd-info = cmd-end_token; +cmd-end_token = old_end_token; +/* Emulate the handling of end token for the section perl_set_config_vectors(cmd, cfg, core_module); +*/ } #ifdef WIN32 -1225,13 +1240,21 pool *p = cmd-pool; char *arg; const char *errmsg = NULL; +const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); +if (err != NULL) { +return err; +} +if (main_server-is_virtual) { + return VirtualHost doesn't nest!; +} + dSECiter_start if(entries) { SECiter_list(perl_virtualhost_section(cmd, dummy, tab)); } -arg = pstrdup(cmd-pool, getword_conf (cmd-pool, key)); +arg = getword_conf (cmd-pool, key); #if MODULE_MAGIC_NUMBER = 19970912 errmsg = init_virtual_host(p, arg, main_server, s); -1256,9 +1279,9 perl_section_hash_walk(cmd, s-lookup_defaults, tab); cmd-server = main_server; +TRACE_SECTION_END(VirtualHost); dSECiter_stop -TRACE_SECTION_END(VirtualHost); return NULL; } -1281,6 +1304,11 #ifdef PERL_TRACE char *sname = SECTION_NAME(Location); #endif +const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); +if (err != NULL) { +return err; +} dSECiter_start -1295,10 +1323,10 new_url_conf = create_per_dir_config (cmd-pool); -cmd-path = pstrdup(cmd-pool, getword_conf (cmd-pool, key)); +cmd-path = getword_conf (cmd-pool, key); cmd-override = OR_ALL|ACCESS_CONF; -if (cmd-info) { /* LocationMatch */ +if (cmd-cmd-cmd_data) { /* LocationMatch */ r = pregcomp(cmd-pool, cmd-path, REG_EXTENDED); } else if (!strcmp(cmd-path, ~)) { -1317,12 +1345,12 conf-r = r; add_per_url_conf (cmd-server, new_url_conf); +TRACE_SECTION_END(sname); dSECiter_stop cmd-path = old_path; cmd-override = old_overrides; -TRACE_SECTION_END(sname); return NULL; } -1334,6 +1362,11 #ifdef PERL_TRACE char *sname = SECTION_NAME(Directory); #endif +const char *err = ap_check_cmd_context(cmd, + NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); +if (err != NULL) { +
Re: Problem with Perl sections in httpd.conf, mod_perl 1.26
Log is attached. I'm amused with this line: handle_command (Alias /perl/ /home/vhosts/linuxhelp.mirkwood.net/perl/): OK That looks right, but I *still* get a 404 error: 404 Not Found Not Found The requested URL /perl/ was not found on this server. _ Apache/1.3.24 Server at linuxhelp.mirkwood.net Port 80 [Fri Apr 19 21:33:08 2002] [error] [client x.x.x.x] File does not exist: /home/vhosts/linuxhelp.mirkwood.net/htdocs/perl/ (note it's still trying to go to htdocs/perl/) ls -d /home/vhosts/linuxhelp.mirkwood.net/perl/ drwxr-xr-x2 root root 4096 Apr 15 02:07 /home/vhosts/linuxhelp.mirkwood.net/perl// Hope that helps. On Fri, Apr 19, 2002 at 03:37:35PM -0500, Salvador Ortiz Garcia babbled thus: Subject: Re: Problem with Perl sections in httpd.conf, mod_perl 1.26 From: Salvador Ortiz Garcia [EMAIL PROTECTED] To: PinkFreud [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] X-Mailer: Ximian Evolution 1.0.3 Date: 19 Apr 2002 15:37:35 -0500 On Fri, 2002-04-19 at 01:43, PinkFreud wrote: Here's a bit more information: Given two directives: $VirtualHost{$host}-{Alias} = [ '/perl/', $vhostdir/$dir/perl/ ]; $VirtualHost{$host}-{Alias} = $vhost{config}-{Alias}; The first works. The second does not. According to Apache::PerlSections-dump, %VirtualHost is *exactly* the same when using both directives - yet it seems the server ignores the Alias directive when it's assigned from $vhost{config} (either that, mod_perl fails to pass it to the server). Also, if I set a variable within httpd.conf to mimic $vhost{config} and then assign that to $VirtualHost{$host}, it works without a problem. The issuse is definitely with the variable being read in from an external file. Strange, no? Yes, weird. I'm hunting any remaining bugs related to Perl Sections. Can you please test the attached patch vs 1.26? (please forget about the patch posted by Michel, it is mine and in CVS now, but in this I'm trying a more radical approach and checking for the proper nesting of directives) Then try to reproduce your problems under MOD_PERL_TRACE=ds (see the DEBUGGIN section in the mod_perl man page), thats is, compile mod_perl with PERL_TRACE=1 and run your Apache in single process mode: # MOD_PERL_TRACE=ds path_to_your/httpd -X And please post the generated log. Regards. Salvador Ortiz -- Mike Edwards Brainbench certified Master Linux Administrator http://www.brainbench.com/transcript.jsp?pid=158188 --- Unsolicited advertisments to this address are not welcome. loading perl module 'Apache'...loading perl module 'Apache::Constants::Exports'...ok ok init `PerlHandler' stack perl_cmd_push_handlers: @PerlHandler, 'Apache::Status' pushing `Apache::Status' into `PerlHandler' handlers [Fri Apr 19 21:32:57 2002] [warn] module mod_php4.c is already added, skipping [Fri Apr 19 21:32:57 2002] [warn] module mod_ssl.c is already added, skipping loading perl module 'Apache'...ok loading perl module 'Tie::IxHash'...not ok Warn: Directive `vhost' not found in handle_command_av! LocationMatch OK perl_section: VirtualHost linuxhelp.mirkwood.net perl_section: Location /perl/ init `PerlHandler' stack perl_cmd_push_handlers: @PerlHandler, 'Apache::Registry' pushing `Apache::Registry' into `PerlHandler' handlers PerlHandler Apache::Registry (OK) Limit=no Options ExecCGI (OK) Limit=no SetHandler perl-script (OK) Limit=no perl_section: /Location Location OK DocumentRoot /home/vhosts/linuxhelp.mirkwood.net/htdocs (OK) Limit=no Group users (OK) Limit=no ServerAdmin test@vhost (OK) Limit=no handle_command (Alias /perl/ /home/vhosts/linuxhelp.mirkwood.net/perl/): OK CustomLog /home/vhosts/linuxhelp.mirkwood.net/logs/linuxhelp.mirkwood.net.access_log combined (OK) Limit=no User sauron (OK) Limit=no ServerName linuxhelp.mirkwood.net (OK) Limit=no ErrorLog /home/vhosts/linuxhelp.mirkwood.net/logs/linuxhelp.mirkwood.net.error_log (OK) Limit=no handle_command (ScriptAlias /cgi-bin/ /home/vhosts/linuxhelp.mirkwood.net/cgi-bin/): OK ServerAlias linuxhelp (OK) Limit=no perl_section: /VirtualHost perl_section: VirtualHost orodruin.rivendell.mirkwood.net CustomLog /var/log/apache/orodruin.access_log combined (OK) Limit=no ServerAlias orodruin (OK) Limit=no ProxyPassReverse / http://orodruin.mirkwood.net:80/ (OK) Limit=no ServerName
Re: Problem with Perl sections in httpd.conf, mod_perl 1.26
On Thu, Apr 18, 2002 at 11:15:15PM -0500, Salvador Ortiz Garcia babbled thus: Subject: Re: Problem with Perl sections in httpd.conf, mod_perl 1.26 From: Salvador Ortiz Garcia [EMAIL PROTECTED] To: PinkFreud [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] X-Mailer: Ximian Evolution 1.0.3 Date: 18 Apr 2002 23:15:15 -0500 On Mon, 2002-04-15 at 23:17, PinkFreud wrote: I have a rather odd problem, one which I can only assume is a bug somewhere, due to how bizarre it is. I am attmempting to generate virtual host configs via mod_perl, using Perl sections in httpd.conf. Not all hosts will be using a /perl Alias, though, so I'm reading in an external config, which looks like the following: [ Deleted ] Plese try changing your Alias array ref to a simple scalar: ... 'Alias' = '/perl/ /home/vhosts/linuxhelp.mirkwood.net/perl/', ... That should work. Nope. Still can't find it. What gets me is the syntax I use for Alias works just fine when the code is in httpd.conf. It only fails to work when I read it in via a require'd file. This same behavior occurs when I use your syntax in the require'd file as well. /me scratches his head, perplexed. And yes, I think its an old bug in perl_handle_command_av. Salvador Ortiz. -- Mike Edwards Brainbench certified Master Linux Administrator http://www.brainbench.com/transcript.jsp?pid=158188 --- Unsolicited advertisments to this address are not welcome.
Re: Problem with Perl sections in httpd.conf, mod_perl 1.26
On 16 Apr 2002, PinkFreud wrote: I have a rather odd problem, one which I can only assume is a bug somewhere, due to how bizarre it is. I am attmempting to generate virtual host configs via mod_perl, using Perl sections in httpd.conf. Not all hosts will be using a /perl Alias, though, so I'm reading in an external config, which looks like the following: This sounds like hte problem that I suffered with for about a year, until someone posted this patch recently to the mod_perl list that fixes the problem for me. For me, the symptom was that *sometimes*, certain entries in Perl sections would not configure, no matter what was placed in them. The patch below fixes it for me. Try the patch below and see if the problem goes away. I'm not sure if this patch has made it into CVS yet or not. Regards, Mike -- diff -ur mod_perl-1.26.orig/src/modules/perl/perl_config.c mod_perl-1.26/src/modules/perl/perl_config.c --- mod_perl-1.26.orig/src/modules/perl/perl_config.c Tue Jul 10 21:47:15 2001 +++ mod_perl-1.26/src/modules/perl/perl_config.cWed Feb 20 14:59:00 2002 -1166,6 +1166,7 char *tmpkey; I32 tmpklen; SV *tmpval; +void *old_info = cmd-info; (void)hv_iterinit(hv); while ((tmpval = hv_iternextsv(hv, tmpkey, tmpklen))) { char line[MAX_STRING_LEN]; -1195,6 +1196,7 if(errmsg) log_printf(cmd-server, Perl: %s, errmsg); } +cmd-info = old_info; /* Emulate the handling of end token for the section */ perl_set_config_vectors(cmd, cfg, core_module); } -1511,9 +1513,7 void *dummy = perl_set_config_vectors(cmd, config, core_module); void *old_info = cmd-info; -if (strstr(key, Match)) { - cmd-info = (void*)key; -} +cmd-info = (void*)strstr(key,Match); if(strnEQ(key, Location, 8)) perl_urlsection(cmd, dummy, hv); --
Re: Problem with Perl sections in httpd.conf, mod_perl 1.26
Thanks for the patch, Michael. Unfortunately, this doesn't seem to fix my problem. :( [Tue Apr 16 19:11:47 2002] [error] [client x.x.x.x] File does not exist: /home/vhosts/linuxhelp.mirkwood.net/htdocs/perl/ It's still ignoring the Alias directive, when require'd from another file. On Tue, Apr 16, 2002 at 02:53:35PM -0500, Michael Schout babbled thus: Date: Tue, 16 Apr 2002 14:53:35 -0500 (CDT) From: Michael Schout [EMAIL PROTECTED] To: PinkFreud [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Problem with Perl sections in httpd.conf, mod_perl 1.26 On 16 Apr 2002, PinkFreud wrote: I have a rather odd problem, one which I can only assume is a bug somewhere, due to how bizarre it is. I am attmempting to generate virtual host configs via mod_perl, using Perl sections in httpd.conf. Not all hosts will be using a /perl Alias, though, so I'm reading in an external config, which looks like the following: This sounds like hte problem that I suffered with for about a year, until someone posted this patch recently to the mod_perl list that fixes the problem for me. For me, the symptom was that *sometimes*, certain entries in Perl sections would not configure, no matter what was placed in them. The patch below fixes it for me. Try the patch below and see if the problem goes away. I'm not sure if this patch has made it into CVS yet or not. Regards, Mike -- diff -ur mod_perl-1.26.orig/src/modules/perl/perl_config.c mod_perl-1.26/src/modules/perl/perl_config.c --- mod_perl-1.26.orig/src/modules/perl/perl_config.c Tue Jul 10 21:47:15 2001 +++ mod_perl-1.26/src/modules/perl/perl_config.cWed Feb 20 14:59:00 2002 @@ -1166,6 +1166,7 @@ char *tmpkey; I32 tmpklen; SV *tmpval; +void *old_info = cmd-info; (void)hv_iterinit(hv); while ((tmpval = hv_iternextsv(hv, tmpkey, tmpklen))) { char line[MAX_STRING_LEN]; @@ -1195,6 +1196,7 @@ if(errmsg) log_printf(cmd-server, Perl: %s, errmsg); } +cmd-info = old_info; /* Emulate the handling of end token for the section */ perl_set_config_vectors(cmd, cfg, core_module); } @@ -1511,9 +1513,7 @@ void *dummy = perl_set_config_vectors(cmd, config, core_module); void *old_info = cmd-info; -if (strstr(key, Match)) { - cmd-info = (void*)key; -} +cmd-info = (void*)strstr(key,Match); if(strnEQ(key, Location, 8)) perl_urlsection(cmd, dummy, hv); -- -- Mike Edwards Brainbench certified Master Linux Administrator http://www.brainbench.com/transcript.jsp?pid=158188 --- Unsolicited advertisments to this address are not welcome.
Problem with Perl sections in httpd.conf, mod_perl 1.26
I have a rather odd problem, one which I can only assume is a bug somewhere, due to how bizarre it is. I am attmempting to generate virtual host configs via mod_perl, using Perl sections in httpd.conf. Not all hosts will be using a /perl Alias, though, so I'm reading in an external config, which looks like the following: ### Begin external vhost config ### $suexec = 0; $vhost{config} = { Location = { /perl/ = { SetHandler = perl-script, PerlHandler = Apache::Registry, Options = ExecCGI } }, Alias = [ '/perl/' = $vhostdir/$dir/perl/ ] }; ### End external vhost config # This config is being read by the following line: require $vhostdir/$dir/.config if (-r $vhostdir/$dir/.config); The configuration options are being added to %VirtualHost as follows: map { $VirtualHost{$host}-{$_} = $vhost{config}-{$_} } keys(%{$vhost{config}}); Now for the oddity: The above doesn't work. Both Data::Dumper and Apache::PerlSections show the options as being added to %VirtualHost, but the server never seems to see the Alias (no idea on the Location directive, since the Alias fails to work). Examination of the error_log shows that the server is trying to get htdocs/perl/, as if the Alias didn't exist. Just to make things a bit stranger: if I add those sections directly into my vhost code in httpd.conf, they work. Again, Data::Dumper and Apache::PerlSections shows what I expect (other than the options being ordered a bit differently in the hash, but that's normal). This is what makes me suspect a bug, because this is so bizarre. Included below is the output I grabbed from Apache:PerlSections in both cases. Any ideas? This problem is really quite annoying. ### Working config # %VirtualHost = ( 'linuxhelp.mirkwood.net' = { 'Location' = { '/perl/' = { 'PerlHandler' = 'Apache::Registry', 'Options' = 'ExecCGI', 'SetHandler' = 'perl-script' } }, 'DocumentRoot' = '/home/vhosts/linuxhelp.mirkwood.net/htdocs', 'ServerAdmin' = 'test@vhost', 'CustomLog' = '/home/vhosts/linuxhelp.mirkwood.net/logs/linuxhelp.mirkwood.net.access_log combined', 'Alias' = [ '/perl/', '/home/vhosts/linuxhelp.mirkwood.net/perl/' ], 'ServerName' = 'linuxhelp.mirkwood.net', 'ErrorLog' = '/home/vhosts/linuxhelp.mirkwood.net/logs/linuxhelp.mirkwood.net.error_log', 'ScriptAlias' = [ '/cgi-bin/', '/home/vhosts/linuxhelp.mirkwood.net/cgi-bin/' ], 'ServerAlias' = 'linuxhelp' } ); ### Alias is broken here - WHY? %VirtualHost = ( 'linuxhelp.mirkwood.net' = { 'Location' = { '/perl/' = { 'PerlHandler' = 'Apache::Registry', 'Options' = 'ExecCGI', 'SetHandler' = 'perl-script' } }, 'ScriptAlias' = [ '/cgi-bin/', '/home/vhosts/linuxhelp.mirkwood.net/cgi-bin/' ], 'DocumentRoot' = '/home/vhosts/linuxhelp.mirkwood.net/htdocs', 'ServerAdmin' = 'test@vhost', 'Alias' = [ '/perl/', '/home/vhosts/linuxhelp.mirkwood.net/perl/' ], 'CustomLog' = '/home/vhosts/linuxhelp.mirkwood.net/logs/linuxhelp.mirkwood.net.access_log combined', 'ServerAlias' = 'linuxhelp', 'ServerName' = 'linuxhelp.mirkwood.net', 'ErrorLog' = '/home/vhosts/linuxhelp.mirkwood.net/logs/linuxhelp.mirkwood.net.error_log' } ); -- Mike Edwards Brainbench certified Master Linux Administrator http://www.brainbench.com/transcript.jsp?pid=158188 --- Unsolicited advertisments to this address are not welcome.