Hello All:
This is probably more an apache issue than a perl issue. Still, I have been asking for help from apache folks and gotten none. So in the words of Mathezar of Galaxy Quest, "You are our last hope!"
There is a similar thread under "System and CGI - File Created but not the Content". I thought this was different enough to post separately becasue SELinux is off in my case and perl is the file writter.
#!/usr/bin/perl
use strict;
print "Content-Type: text/html\r\n\r\n";
print "<HTML>\n";
print "<HEAD>\n";
print "</HEAD>\n";
print "<BODY>\n";
my $filename ="/var/www/html/DATA/kk.txt";
open(KK,">$filename");
close(KK); # this line and the nex
+t 2 were not part of
system("chmod 666 $filename"); # of the original code.
+ They were added to
open(KK,">>$filename"); # see if changing the p
+ermissions would help
print "we are trying to write\n";
print KK "we are trying to write\n";
close(KK);
print "</BODY>\n";
print "</HTML>\n";
When executed the browser shows "we are trying to write", the /var/www/html/DATA/kk.txt file exists, it is 666, owned by apache and has zero content.
I am running FC4, Apache 2.0.54, perl 5.8.6, the server is not attached to the internet.
I have done what should never be done: 777 permissions on /var, /var/www, /var/www/html.
Below html I have a directory called DATA, also 777
user apache owns everything below var
setenforce 0 to remove SElinux
(basically, a desperate and ridiculous attempt to allow files to be written)
The odd thing is that the original program (from which this was extracted) up to 10am 9/17/2006. After that, the machine, untouched, exhibited the new behaviour.
All written files prior to 10 am 9/17 are apache 644 and have content. All written files after to 10am 9/17 are apache 644 and are empty.
1) I am probably not doing this the right way ... where should I be writting the files and how should I set upms and httpd.conf. I have been trolling google with "apache permissions" apachec cgi write files" and the like. If you have links to howtos, please send them!
2) In the above case, can I determine the reason and fix it? It would be nice to be able to dial back the permissions to something reasonable
Thanks in advance.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.