[PHP-DEV] PHP3 and .htaccess: The story so far From: Shevek (shevek <email protected>)
Date: 01/31/00

I am new to the PHP list. I am chasing a bug. This affects bugs in the PHP
database #1884, #3030, #3364, possibly others.

In short:

I get permission denied every time I try to read a page. An error is
logged: 'Cannot read .htaccess' when the .htaccess does not exist.

So fire up gdb, break on ap_pcfg_openfile() and run, pass 'cont' until we
hit the error. We are here:

#0 0x80c5c26 in ap_pcfg_openfile ()
#1 0x80b1dd3 in ap_parse_htaccess ()
#2 0x80c1a3c in directory_walk ()
#3 0x80c2ca0 in process_request_internal ()
#4 0x80c30d4 in ap_process_request ()
#5 0x80bafc1 in child_main ()
#6 0x80bb154 in make_child ()
#7 0x80bb2af in startup_children ()
#8 0x80bb8ac in standalone_main ()
#9 0x80bbfff in main ()
#10 0x804c36e in _start ()

If we allow overrides in a <Directory>, we get directory configuration in
directory_walk(). We then try to parse a .htaccess file, so we call
ap_parse_htaccess(), which calls ap_pcfg_openfile(). This calls
ap_pfopen(), which (as may be deduced from the surrounding statements) is
returning NULL without saying anything in errno. Therefore, since we have
a NULL but errno is neither ENOENT or ENOTDIR, ap_parse_htaccess() craps
itself and says 'I'm going to disallow you just in case'.

[This is probably why 'AllowOverride' caused some problems in bug #3030,
#1884, #3364, it would make the directory_walk() start differently]

So we now look at ap_pfopen(), we mess with alloc.c:

   1821 else {
   1822 fd = fopen(name, mode);
   1823 if (fd == NULL) {
   1824 ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
   1825 "Failed to open %s : %s",
   1826 name, strerror(errno));
   1827 }
   1828 }

We get:
[Mon Jan 31 20:53:19 2000] [warn] Attempting config file /var/lib/httpd/.htaccess
[Mon Jan 31 20:53:19 2000] [warn] Failed to open /var/lib/httpd/.htaccess : Success
[Mon Jan 31 20:53:19 2000] [warn] Opening config file /var/lib/httpd/.htaccess (Success)
[Mon Jan 31 20:53:19 2000] [crit] [client 194.207.107.51] /var/lib/httpd/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

Not friendly.

We're not out of fds (the known Solaris bug). It's a new process.

root@ /proc/20530/fd# ls -l
total 0
lrwx------ 1 root root 64 Jan 31 20:46 0 -> [0307]:214075
lrwx------ 1 root root 64 Jan 31 20:46 1 -> [0307]:214075
lrwx------ 1 root root 64 Jan 31 20:46 15 -> [0000]:96390559
l-wx------ 1 root root 64 Jan 31 20:46 16 -> [0306]:322803
l-wx------ 1 root root 64 Jan 31 20:46 17 -> [0306]:322804
l-wx------ 1 root root 64 Jan 31 20:46 18 -> [0306]:322805
l-wx------ 1 root root 64 Jan 31 20:46 19 -> [0306]:322810
l-wx------ 1 root root 64 Jan 31 20:46 2 -> [0306]:322803
l-wx------ 1 root root 64 Jan 31 20:46 20 -> [0306]:53468
lr-x------ 1 root root 64 Jan 31 20:46 3 -> [0306]:302237
lr-x------ 1 root root 64 Jan 31 20:46 4 -> [0306]:302237

So what's the story here, why is putting PHP3 in making Apache fail on a
simple OS fopen()? I am here lost.

Any suggestions gratefully accepted. I'm about to try Apache-1.3.11 to see
if that changes things.

Ta.

S.

--
Shevek
GM/CS/MU -d+ H+>++ s+: !g p2 au0 !a w+++ v-(---) C++++$ UL++++$ UB+
US+++$ UI+++$ P++>++++ L++++$ 3+ E--- N K- !W(-----) M(-) !V -po+ Y+
t+ 5++ !j !R G' !tv b+++ D++ B--- e+ u+* h++ f? r++ n---- y?
Recent UH+>++ UO+ UC++ U?+++ UV++ and collecting.

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>