Permission problem with CGI script
Lyle
webmaster at cosmicperl.com
Wed Jul 14 10:10:04 PDT 2010
On 14/07/2010 17:39, Andy Selby wrote:
> 'evening all,
> I seem have to have a permission problem creating a 'data.txt' file to
> store comments.
> I think it is an Apache/perl interpreter mis-config but here is the
> script anyway
>
> #!/usr/bin/perl -wT
Have you tried it without Taint mode? I don't see you untainting your
input anywhere..
> use strict;
> use CGI qw/:standard/;
>
> print header,start_html('Comments Form');
> print h1('Comments Form');
>
> my $time = localtime();
> print $time,p;
> print start_form, textarea({
> -name => "text",
> -rows => "10",
> -columns => "50",
> }),p,
> submit,end_form,p;
>
> if (param) {
> #print "you said ",(param('text')),p, #This line works, the
> others below don't
> open (MYFILE, '>>data.txt') or die "couldn't open file $!";
> print MYFILE (param('text')),$time,;
> close (MYFILE);
> print $!;
> };
> print end_html;
>
> Looking in /var/log/httpd/error.log I see...
>
> 'couldn't open file Permission denied at'
>
> I am the owner of cgi-bin/ and html/ though even if I create the
> data.txt file and make it world-writeable I still get the 'couldn't
> open file' line in the log
> This is on a Fedora 12 install
777 permissions? What user is the script executed as? Are you using
SuEXEC (you should)?
What's the PWD when you try to open the file? You may want to chdir to
the right folder...
Hope some of that helps
Lyle
More information about the MiltonKeynes-pm
mailing list