Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: System and CGI - File Created but not the Content

by scorpio17 (Monsignor)
on Sep 18, 2007 at 14:11 UTC ( #639647=note: print w/ replies, xml ) Need Help??


in reply to Re^2: System and CGI - File Created but not the Content
in thread System and CGI - File Created but not the Content

I've written some CGI scripts under Fedora Core 4 (similar to Red hat) running SELinux, and there are some things you have to watch out for.

The easiest way to verify if this is the problem: log in as root, then use this command:

setenforce 0

This will turn off the enforcement of SELinux security checks - but not the checking. Errors will continue to be logged. On my system the default location was /var/log/messages (this may vary from one flavor of linux to another).

If the error with the CGI script goes away, you know it's SELinux. The log file should help give you a clue as to where the problem is. Turn enforcing back on with:

setenforce 1

If you want a CGI script to be able to write a file, the directory it's writing to much have read and execute permission:

chmod 755 output_dir

It must also have the proper SELinux security context:

chcon -t httpd_sys_content_t output_dir

Also, you have to remember that the CGI script runs with the user id of the web server. For apache, this is usually 'nobody' or 'www'. Make sure this user has permission to run the external executable (ameme?). Then make sure the executable has the the proper security context:

chmod 755 ameme
chcon -t httpd_sys_script_exec_t ameme

You can use "ls -lZ" to check the current security context settings.

Note also that the log file will contain errors that say what the expected context is, in the case SELinux blocks something from running. It will also give the path to the offending directory or executable.


Comment on Re^3: System and CGI - File Created but not the Content
Re^4: System and CGI - File Created but not the Content
by holandes777 (Sexton) on Sep 18, 2007 at 15:13 UTC
    I have a similar situation which I am about to post under "System and CGI - File Created but not the Content (Similar Situation)". It is different becasue here perl is the program trying to write and SELinux was set off all the way back in rc.local. If you guys would have a look it would be greatly appreciated!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://639647]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (16)
As of 2014-10-30 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls