Kindly ignore if its not a valid question. I am trying to open a file, which is present in my home directory(/home/prasanna).I am getting the file name from the user and concatinating it with the path.
My question is can we access the file outside the cgi-bin/htdocs directory.I think this is clear. But when i tried to open i couldnt able to open. Can any one help me
Update:-I am using apache as my web server
-Prasanna.KAlso, if the file doesn't have the proper permissions, that may be blocking the read. If you're using the full path, and the path matches correctly, check permissions.
Yes to all of what ptum said.
As a possible fix, you can change permissions on your home directory and the file(s) the web users will need to access. However, this may present a security risk on multiple levels.
#!/usr/bin/perl -wT
use strict;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
open (OUT, ">/no/perm/path/junkfile") or die $!;
print OUT ("hi there\n");
close(OUT);
I get this -
Software error: Permission denied at /var/www/html/perl/create.cgi line 7. For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.
However when i changed the path to /tmp/junkfile (world-writeable for me) it works just fine. I guess if you turn on the fatalsToBrowser (turn it off for production) you will get more info. Also take a look at your apache logs!
cheers
SK
The most of the errors can happen with the permissions issues. I hope that you got enough information from the above replies. In addition to that , i want to add one more thing.
In Redhat Linux Enterprise Edition - 4, we have some thing called as "Selinux". That is another extended linux security for linux files. That one also plays as important role in file permissions when using through apache. You can also find the enough information in "man selinux". You go through that page and give appropriate file permissions.
perlmonks.org content © perlmonks.org and kprasanna_79, ptum, sk, TedPride, vennirajan, wink
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03