469,891 Members | 2,315 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,891 developers. It's quick & easy.

Permission Denied when reading a home directory file from Apache cgi script

I'm having an issue when trying to read a file in a user's homedir from a cgi script. I have a virtual host section in my httpd.conf file which I'll include. The cgi script is a very basic script written in Perl just for testing. I believe I need to find the correct <Directory> entry or some other Directive in Apache to make this work, but I've had no luck for a week now. I've tried many different things, but w/ no luck. I even tried adding the 'SuexecUserGroup david david' directive inside the VirtualHost section, but no luck there either, same results. Any help would be greatly appreciated. I realize it's a lot of info, but I'll try to provide enough so anyone could duplicate the problem if they have that much time. Thanks in advance for any tips or thoughts. Here's all the info:

httpd -V
Server version: Apache/2.2.4 (Unix)
Server built: Jun 26 2007 10:00:55
Server's Module Magic Number: 20051115:4
Server loaded: APR 1.2.8, APR-Util 1.2.8
Compiled using: APR 1.2.8, APR-Util 1.2.8
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
/etc/httpd.conf (pertinent lines, nothing else changed from defaults)
User apache
Group apache
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/david
ScriptAlias /test /var/www/david/cgi-bin/test.pl
ErrorLog logs/david-error_log
CustomLog logs/david-access_log common
<Directory "/var/www/david/cgi-bin">
SetHandler cgi-script
AllowOverride None
Options +All FollowSymLinks +ExecCGI +Includes
EnableSendFile Off
Order allow,deny
Allow from all
</Directory>

<Directory "/home/david">
AllowOverride None
Options +All FollowSymLinks +ExecCGI +Includes -Indexes -Multiviews
EnableSendFile Off
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
DocumentRoot permissions and files
[HPA-linux]/var/www/david#>ls -al
total 24
drwxr-xr-x 3 david david 4096 2007-08-17 15:34 ./
drwxrwxrwx 10 apache apache 4096 2007-08-17 15:33 ../
drwxr-xr-x 2 david david 4096 2007-08-17 15:43 cgi-bin/
[HPA-linux]/var/www/david#>cd cgi-bin
[HPA-linux]/var/www/david/cgi-bin#>ls -al
total 24
drwxr-xr-x 2 david david 4096 2007-08-17 15:43 ./
drwxr-xr-x 3 david david 4096 2007-08-17 15:34 ../
-rwxr-xr-x 1 david david 500 2007-08-17 15:43 test.pl*
test.pl
#!/usr/bin/perl
print "Content-Type: text/html\n\n";

print "<html>\n";
print "<head>\n";
print "<title>Test Page</title>\n";
print "</head>\n";
print "<body>\n";

print "Hello World!\n\n";
print "<BR>\n";
print "<BR>\n";
system ("env");
print "<BR>\n";
print "<BR>\n";
system ("cat /home/david/kaka.html");
print "<BR>\n";
print "<BR>\n";
system ("cat /home/david/html/kaka.html");
print "<BR>\n";
print "<BR>\n";
print "After cat of file.\n";
print "<BR>\n";

print "</body>\n";
print "</html>\n";
Output on the glass when accessing the /test page
Hello World!

HTTP_ACCEPT=*/* HTTP_ACCEPT_LANGUAGE=en-us HTTP_ACCEPT_ENCODING=gzip, deflate HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322) HTTP_HOST=###.###.###.### HTTP_CONNECTION=Keep-Alive PATH=/sbin:/usr/sbin:/bin:/usr/bin SERVER_SIGNATURE=
Apache/2.2.4 (Fedora) Server at ###.###.###.### Port 80
SERVER_SOFTWARE=Apache/2.2.4 (Fedora) SERVER_NAME=###.###.###.### SERVER_ADDR=192.168.1.202 SERVER_PORT=80 REMOTE_ADDR=###.###.###.###
DOCUMENT_ROOT=/var/www/david SERVER_ADMIN=root@localhost SCRIPT_FILENAME=/var/www/david/cgi-bin/test.pl REMOTE_PORT=57509 GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP/1.1 REQUEST_METHOD=GET QUERY_STRING= REQUEST_URI=/test SCRIPT_NAME=/test





After cat of file.
Error Log Entries:
[Fri Aug 17 15:42:56 2007] [error] [client XXX.XXX.XXX.XXX]
[Fri Aug 17 15:43:43 2007] [error] [client XXX.XXX.XXX.XXX] cat: /home/david/kaka.html: Permission denied
[Fri Aug 17 15:43:43 2007] [error] [client XXX.XXX.XXX.XXX] cat: /home/david/html/kaka.html: Permission denied
Aug 17 '07 #1
0 6609

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by bird | last post: by
1 post views Thread by charlie fortune | last post: by
4 posts views Thread by Martin | last post: by
8 posts views Thread by Tom Strickland | last post: by
4 posts views Thread by nitinpatel1117 | last post: by
reply views Thread by Simo D | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.