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.

1
  • 2
    Never, ever, set the permissions to any file or directory to 777. There are no exceptions. Jun 14, 2013 at 4:33

1 Answer 1

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
6
  • It's 777 starting with PERFRPTCRONJOB. I did chmod 777 PERFRPTCRONJOB -R Jun 14, 2013 at 0: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, 2013 at 0:54
  • Does that matter? I don't want extra permissions for parent directories of PERFRPTCRONJOB. Jun 14, 2013 at 1: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, 2013 at 1:05
  • 1
    Please don't EVER EVER EVER set 777 permissions. It is absolutely never the correct answer.
    – baumgart
    Jun 14, 2013 at 1:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .