Apache/PHP GDBM failing with Driver initialization failed for handler: gdbm

693 Views Asked by At

I have a system that has used PHP to build a GDBM file that is then referenced by Apache to perform basic authentication. It has been running since 1999 with many versions of apache and PHP until now when I am doing an upgrade to match corporate policy.

If I run php from the command line (specifying the appropriate php.ini file) then the DBA functionality works correctly.

However when it is called from within Apache at the point it calls dba_open(...) from PHP I get:

Warning: dba_open(/etc/httpd/conf/users.tmp,n): Driver initialization failed for handler: gdbm: File open error in /var/www/phpinc/bxxx.inc

PHP was built with the following command:

./configure --with-iconv --with-mysql --with-mysql-sock=/var/run/mysql/mysql.sock --with-apxs2=/usr/local/apache2/bin/apxs --with-gdbm --enable-mbstring --with-gd --enable-dba

And I only added the --enable-dba based on some other comments.

gdbm_dump was failing and reporting:

gdbm_dump: gdbm_open failed: Unexpected end of file

but now having managed to rebuild the GDBM datafile using command-line PHP it works correctly - hence it seems there might be (or was) a character encoding issues or something similar

Inside apache it fails with:

 [authn_dbm:error] [pid 14104:tid 140279619360512] (20014)Internal error (specific information not available): [client 10.160.9.247:52710] AH01754: could not open dbm (type GDBM) auth file: /etc/httpd/conf/users, referer: xxxxx

I am assuming it has to be something to do with a library mismatch on the machine a but I can't think of any more ways to debug it. Any help or suggestions would be much appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

OK. sorted!

Firstly I downloaded the gdbm source and built/installed it.

Then I added to PHP and Apache configure lines an explicit --with-gdbm=/usr/src/gdbm-1.11.

Then I noticed that the new gdbm had installed itself /usr/local/lib but this was not in my search path in ld.so.conf. So I copied the files and created the correct links (.so.4, etc) in /usr/lib64.

Finally my issue with it working from the command line was permission related - since having created a version from the command line it no longer had the apache ownership required to open inside apache. For those who follow the specific error you see for dba_open() is:

dba_open(...): Driver initialization failed for handler: gdbm: File open error

which of course would have been quite helpful apart from all the other "dll hell" throwing things off the trail.

Anyway in the end the solution game from using ldd to look at:

/usr/local/bin/php
/usr/local/apache2/bin/httpd
/usr/local/apache2/lib/libapr-1.so.0
/usr/local/apache2/lib/libaprutil-1.so.0
/usr/local/apache2/modules/libphp5.so

Once I could see they were linking to different version of libgdbm it all started to sort itself out.