views:

31

answers:

1

Hi, please help! I'm really going nuts with this problem!

I have a CGI perl script and it always fails at the following line when executed from the Apache HTTP server:

tie %db, 'MLDBM', "$data_path/$db_name.db", O_RDONLY, 0640 or die $!

and the error is Permission denied:

Software error:

Permission denied at /var/www/cgi-bin/rich/pages/display line 381.

For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.

But when executed from the command line, it works without any problem.

I have ensured that the directories and the file to tie have the correct permissions.

So what else have I missed? What configurations in the Apache's httpd.conf I could be getting wrong? Admittedly, I didn't have any previous experience with the Apache HTTP server, so this is pretty much my first time playing around with it. However, I have read the manuals more than once to look for things I could be wrong at, but I didn't notice anything. But I could be wrong of course.

Thanks!!

A: 

Have you verified that $data_path and $db_name contain what you think they do?

Is $data_path an absolute path which is not reliant on the active user's identity or home directory?

What does ls -l $data_path/$db_name.db show for the file's ownership and permissions?

I've never run across (or heard of) anything in apache that would prevent a CGI process from having permission to open files, so I highly doubt that it's an apache config issue. Most likely it's either looking for the wrong file or the file's permissions are incorrect for the user that apache is running the CGI process as.

Dave Sherohman
$data_path is an absolute path and $db_name.db is a normal binary file. The file permission for $data_path/$db_name.db is ''-rwxrwxrwx''. As I said, when the script is executed from the command line ''./display'', there is no problem at all with opening the file. I even changed the user and group running the Apache server to the owner of the file, but still no luck.
@user: can you open the file for simple reading? i.e. `open my $fh, '<', "$data_path/$db_name.db" or die "failed to open $data_path/$db_name.db: $!";`
Ether