$ anchor doesn't work in Directory ~ regexp
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apache2 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
$ (end-of-line anchor) seems to break regular expressions with the Directory config directive.
The $ is not being treated literally, but it is not ignored either. If present, it seems to completely prevent matching.
Steps to demonstrate:
1. Create the following test files in your tree (e.g. under /var/www/
echo "should be protected" > foo.BAK
mkdir dir.BAK
echo "should be protected" >dir.BAK/file
echo "should be readable" > french.BAKERY
2. Add to /etc/apache2/
# This is intended to prevent access to any *.BAK (or contents, if directory)
# Note: We are using a regular expression, not wildcard syntax, and there is
# no initial ^ anchor. Therefore it should match at the tail of any path.
<Directory ~ "\.BAK$">
Order allow,deny
Deny from all
Satisfy all
</Directory>
3. sudo /etc/init.d/apache2 restart
4. Try to access the files.
wget -O- http://
wget -O- http://
wget -O- http://
wget -O- http://
5. Remove the trailing "$" from the Directory ~ regex in apache2.conf, and restart the server
6. Test again:
wget -O- http://
wget -O- http://
wget -O- http://
ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: apache2 2.2.20-1ubuntu1.2
ProcVersionSign
Uname: Linux 3.0.0-16-generic x86_64
NonfreeKernelMo
Apache2ConfdDir
ApportVersion: 1.23-0ubuntu4
Architecture: amd64
Date: Mon Mar 5 21:08:07 2012
InstallationMedia: Xubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
ProcEnviron:
PATH=(custom, user)
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: apache2
UpgradeStatus: No upgrade log present (probably fresh install)
modified.
mtime.conffile.
From http:// httpd.apache. org/docs/ 2.2/mod/ core.html# directorymatch:
"The end-of-line character ($) cannot be matched with this directive."
I appreciate that you're using <Directory ~ ...> rather than <DirectoryMatch "...">, but I cannot find any documented difference between the two. I suspect that they work the same internally.
So I'm marking this bug as Invalid. If you find reason to disagree, please do reopen.