Bug 44181 - add UnAlias
Summary: add UnAlias
Status: REOPENED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_alias (show other bugs)
Version: 2.5-HEAD
Hardware: Other other
: P5 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-07 16:33 UTC by Dan Jacobson
Modified: 2016-02-24 18:00 UTC (History)
1 user (show)



Attachments
Patch to allow "Alias /whatever/ !" to stop alias processing. (1.16 KB, patch)
2016-02-24 18:00 UTC, Jeff W
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Jacobson 2008-01-07 16:33:58 UTC
Just as bash has an unalias command, so should Apache!
Comment 1 Joshua Slive 2008-01-08 09:28:36 UTC
Use case? The analogy with bash is not at all helpful, since the type of
processing is completely different. In most cases where you want to "undo" an
Alias, you can simply add another Alias the remaps to the old location.
Comment 2 Dan Jacobson 2008-01-08 16:13:01 UTC
#Counteract alias.conf interference:
Alias /icons/ "/home/nordsburg/mailman/icons/"
#Wish could just do
#Unalias /icons/
#but alas, I must hardwire the paths here as there is no Unalias.
#Furthermore, alias.conf could have been nice and made a softer alias,
#which would then tried my icons dir. if the file weren't found in
#its, but maybe there is no such softer alias, for better or worse.

Anyway, there should be a way to say "Unpollute my environment for
this item. Just make it behave like it would originally, whatever that
was." Or maybe you have already thrown away that information. (Or maybe
allowing Unalias in .htaccess would allow security problems.)

Anyway, imagine in bash if one had to do
alias rm=rm or
alias rm=\\rm or
alias rm=/bin/rm or
whatever. Yuck. And one day it is moved to /usr/bin and kaboom.

Anyway, you should show how there already is a simpler way to achieve
Unalias /norfelfeller/ or
Unalias <*> [some way to say Unalias Everything].
P.S., Unalias probably better than UnAlias.
Comment 4 rahul 2008-05-28 04:27:41 UTC
Apache trunk (2.3-head) installations (nolonger?) pollutes your namespace with aliases. Thus a request for /icons/myicon.gif will search in <docroot>/icons/myicon.gif rather than <apacheroot>/icons/myicon.gif
This should take care of your problem (as specified in the site you link to)

 
Comment 5 Dan Jacobson 2008-06-01 19:18:15 UTC
OK good. Also did hurt http://www.mediawiki.org/wiki/Manual:Configuring_file_uploads#Check_Apache_aliases
Comment 6 rahul 2008-06-02 03:49:23 UTC
Updating the bug as it is no longer an issue.
Comment 7 bos 2010-08-09 22:41:40 UTC
This bug (namespace polluting) still exists in 2.3.6 (out-of-the-box configuration) when using httpd-autoindex.conf, even when disabling autoindex for a particular site:

[Tue Aug 10 04:36:10.406428 2010] [notice] [pid 15584:tid 16384] SIGHUP received.  Attempting to restart
Digest: cleaning up shared memory
[Tue Aug 10 04:36:11.244445 2010] [notice] [pid 15584:tid 16384] Digest: generating secret for digest authentication ...
[Tue Aug 10 04:36:11.244642 2010] [notice] [pid 15584:tid 16384] Digest: done
[Tue Aug 10 04:36:12.095625 2010] [notice] [pid 15584:tid 16384] Apache/2.3.6 (Unix) DAV/2 PHP/5.3.0 configured -- resuming normal operations
[Tue Aug 10 04:36:12.095956 2010] [notice] [pid 15584:tid 16384] Command line: '/usr/bin/httpd'
[Tue Aug 10 04:36:16.946550 2010] [error] [pid 27512:tid 32771] [client 192.168.1.66:1146] File does not exist: /usr/apache2/icons/pdf_s.png, referer: http://bos.hack.org:8080/

The file exists in <docroot>/icons/pdf_s.png but Apache tries to access it in <wwwroot>. If autoindex is disabled is commented out the icon in question is accessed without problems. It is also accessed if the Alias-line in httpd-autoindex.conf is commented out, but this yields broken icons for the FancyIndexing option.

So, I'll still vote for an Unalias-command because atleast I want autoindex / FancyIndexing available on one site and disabled on another.
Comment 8 Cliff McIntire 2011-09-01 03:23:42 UTC
I am dealing with one situation where an unAlias directive would be very helpful.

I have a couple thousand auto-generated virtual hosts.  They each include some combination of a few common config files.  These files include Aliases.

In a few cases, I wish to include everything in the config files, but I wish to unAlias the aliases so some particular virtual hosts serve everything from the docroot.

An explicit realias ("Alias /foo /virthost/doc/root/foo") doesn't work (should it?), nor is it ideal.  An unalias is better, because the virtual hosts on which I want to unalias paths are all including another common config file.  I want to put "unAlias /foo" in that common file.
Comment 9 Jeff W 2016-02-24 18:00:48 UTC
Created attachment 33589 [details]
Patch to allow "Alias /whatever/ !" to stop alias processing.

This hasn't seen any activity in a few years, but it's actually very easy to do in 2.4 with a small patch (attached).

The ProxyPass directive works very similar to Alias, except it maps a proxy rather than another directory.  With that directive, syntax like "ProxyPass /mirror/foo/i !" can be used to stop proxy processing for a given path.  That same syntax can be applied to alias processing.  I.e. "Alias /whatever/ !" can be made to stop alias processing for a given path.

For example, if you have 1000 vhosts, 999 of which need an alias, then you can create a config like this:

Alias /my_alias/ /my/real/path/

... 900 VirtualHost entries that need that alias ...

<VirtualHost>
   ...
   Alias /my_alias/ !
</VirtualHost>

... 99 more VirtualHost entries that need that alias ...

There are two spots in mod_alias that have to be touched for this to work, both in try_alias_list: one for regular aliases and one for regular expressions.  In both cases, if an alias matches and it maps to "!" you just stop there and return that there was no match.