Mailing List Archive

premature ScriptAlias/Alias translation
ScriptAlias /B/C /usr/local/httpd/cgi-bin/tester
Alias /B /usr/local/httpd/htdocs/x.html

doesn't doesn't work as it should (should = my interpretation)
/B/C always gets thumped by the Alias.

A possible patch follows,




*** ../../apache_0.8.7/src/mod_alias.c Mon Jul 31 18:46:04 1995
--- mod_alias.c Wed Aug 16 15:10:59 1995
***************
*** 140,148 ****

char *try_alias_list (request_rec *r, array_header *aliases)
{
! alias_entry *entries = (alias_entry *)aliases->elts;
! int i;

for (i = 0; i < aliases->nelts; ++i) {
alias_entry *p = &entries[i];
int l = strlen(p->fake);
--- 140,171 ----

char *try_alias_list (request_rec *r, array_header *aliases)
{
! alias_entry *entries;
! int i, script_alias_length;

+ /* First check for a matching ScriptAlias that we don't want to thump */
+ extern module cgi_module;
+ array_header *saliases =
+ (array_header *)get_module_config(r->server->module_config, &cgi_module);
+
+ entries = (alias_entry *)saliases->elts;
+
+ script_alias_length = 0;
+ for (i = 0; i < saliases->nelts; ++i) {
+ alias_entry *p = &entries[i];
+ int l = strlen(p->fake);
+
+ if(!strncmp(r->uri, p->fake, l)
+ && (p->fake[l-1] == '/' || l == strlen(r->uri) || r->uri[l] == '/'))
+ {
+ script_alias_length = l; /* Remember the fake script alias length */
+ break;
+ }
+ }
+
+ /* Let's now check the other aliases */
+ entries = (alias_entry *)aliases->elts;
+
for (i = 0; i < aliases->nelts; ++i) {
alias_entry *p = &entries[i];
int l = strlen(p->fake);
***************
*** 150,156 ****
if(!strncmp(r->uri, p->fake, l)
&& (p->fake[l-1] == '/' || l == strlen(r->uri) || r->uri[l] == '/'))
{
! return pstrcat(r->pool, p->real, r->uri + l, NULL);
}
}

--- 173,180 ----
if(!strncmp(r->uri, p->fake, l)
&& (p->fake[l-1] == '/' || l == strlen(r->uri) || r->uri[l] == '/'))
{
! if (l > script_alias_length) /* don't use a shorter Alias */
! return pstrcat(r->pool, p->real, r->uri + l, NULL);
}
}
Re: premature ScriptAlias/Alias translation [ In reply to ]
> >
> > *** ../../apache_0.8.7/src/mod_alias.c Mon Jul 31 18:46:04 1995
^^^^

> Is this diff against the right sources Rob?

if it works, yes.

I never downloaded 0.8.8. The changes appeared minor enough not to bother.

My friend running 0.8.8 reported the problem, so I think there's
a good chance the problem is the same and the patch will work.


rob
Re: premature ScriptAlias/Alias translation [ In reply to ]
> Sigh... right diagnosis, ugly fix (I really want to keep code in one
> module from invoking code in another unless absolutely necessary).

> Could I beg your indulgence for a day or two ...
> .. to come up with a better fix?

okay, upload a gif to show you are on your knees first :-)


How about if the family of alias types get stored in 1 table with a type
marker, then all parts of the code can have access to them, and can
skip the entries for types which aren't of interest, but
any module can also look at them for conflict checking purposes.

The "family" being

Alias
ScriptAlias
Redirect

any others ?

so a table could be

/B/C /usr/local/foo S (script)
/B/ /usr/remote/bar A (vanilla alias)
/Bleah http://www.else.where/Weee/ R (redirect)



just a thought..

rob
--
http://nqcd.lanl.gov/~hartill/
Re: premature ScriptAlias/Alias translation [ In reply to ]
From: Rob Hartill <hartill@ooo.lanl.gov>
Date: Wed, 16 Aug 95 15:25:23 MDT

ScriptAlias /B/C /usr/local/httpd/cgi-bin/tester
Alias /B /usr/local/httpd/htdocs/x.html

doesn't doesn't work as it should (should = my interpretation)
/B/C always gets thumped by the Alias.

A possible patch follows,

Sigh... right diagnosis, ugly fix (I really want to keep code in one
module from invoking code in another unless absolutely necessary).

It would be much better to solve this by folding the ScriptAlias code
back into the Alias module; the only problem with doing that is this
piece of awkwardness: in a ScriptAliased directory, Options ExecCGI
doesn't have to be on for the scripts to work. Could I beg your
indulgence for a day or two (perhaps past the next public release) to
come up with a better fix?

Preliminary notes: in order to do this the way I'd like, we'd need a
way for mod_alias to tell mod_cgi something without either directly
invoking code in the other. One way might be to just give
ScriptAliased scripts a MIME type which users can't type (so no sneaky
undergrad could AddType it in a .htaccess file if AddType were allowed
but ExecCGI disabled); something like "\napplication/cgi-real-magic\n"
Of course, that stops working if users *can* type \n in quoted
strings, as has been requested for LogFormat strings at least.

Another, uglier workaround might be to just stuff a magic cookie onto
the subprocess_env...

rst
Re: premature ScriptAlias/Alias translation [ In reply to ]
> ScriptAlias /B/C /usr/local/httpd/cgi-bin/tester
> Alias /B /usr/local/httpd/htdocs/x.html
>
> doesn't doesn't work as it should (should = my interpretation)
> /B/C always gets thumped by the Alias.
>
> A possible patch follows,
>
>
>
>
> *** ../../apache_0.8.7/src/mod_alias.c Mon Jul 31 18:46:04 1995
^^^^

Is this diff against the right sources Rob?

Ay.