0

I have a cgi script that opens a file (using python).

The cgi script runs fine but when I try to open this file, I get a permission error:

Traceback (most recent call last):   File "/asdf/pkgs/linux/intel/apache/2.2.14.rhas5.x86_64/htdocs/Sites/cgi-bin/avgsBarGraphView.py", line 304, in <module>
    main()   File "/asdf/pkgs/linux/intel/apache/2.2.14.rhas5.x86_64/htdocs/Sites/cgi-bin/avgsBarGraphView.py", line 61, in main
    f=open('/asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile','r') PermissionError: [Errno 13] Permission denied: '/asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile'

I've added the folder containing /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile to my httpd.conf.

<Directory "/asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

I've also changed the permissions of the folder TEST_FILES to 777 and the permissions of testfile to 777. I can open the file via python from the command line but when I try to open this file by running a cgi-script, it fails.

serverFaulter
  • 385
  • 2
  • 4
  • 9

1 Answers1

0

Check "x" permission for every (sub)directory in the path /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile

You can do this with the command:

ls -ld /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES /asdf/home/asdf/PYTHON/PERFRPTCRONJOB /asdf/home/asdf/PYTHON /asdf/home/asdf /asdf/home /asdf
porton
  • 312
  • 1
  • 14
  • It's 777 starting with PERFRPTCRONJOB. I did chmod 777 PERFRPTCRONJOB -R – serverFaulter Jun 14 '13 at 00:51
  • I've edited my answer. There is an instruction to check **all** directories in the path, not just some of them – porton Jun 14 '13 at 00:54
  • Does that matter? I don't want extra permissions for parent directories of PERFRPTCRONJOB. – serverFaulter Jun 14 '13 at 01:00
  • Every directory in the path should be "executable". Otherwise the file won't open. If you cannot fulfill this requirement, change your directory structure. There is nothing more I can help you: Only you can know which permissions are allowable for which directories – porton Jun 14 '13 at 01:05
  • Oh, one more correction: `ls -l` should be changed to `ls -ld` (I've edited the answer.) – porton Jun 14 '13 at 01:06
  • 1
    Please don't EVER EVER EVER set 777 permissions. It is absolutely never the correct answer. – baumgart Jun 14 '13 at 01:31