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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phil469
    New Member
    • Aug 2007
    • 1

    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 'SuexecUserGrou p 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_SENDFIL E
    -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_U NSERIALIZED_ACC EPT
    -D APR_HAS_OTHER_C HILD
    -D AP_HAVE_RELIABL E_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_SCOREBO ARD="logs/apache_runtime_ status"
    -D DEFAULT_LOCKFIL E="logs/accept.lock"
    -D DEFAULT_ERRORLO G="logs/error_log"
    -D AP_TYPES_CONFIG _FILE="conf/mime.types"
    -D SERVER_CONFIG_F ILE="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>Tes t 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_LAN GUAGE=en-us HTTP_ACCEPT_ENC ODING=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_SIGNATUR E=
    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=ro ot@localhost SCRIPT_FILENAME =/var/www/david/cgi-bin/test.pl REMOTE_PORT=575 09 GATEWAY_INTERFA CE=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
Working...