I have a directory "/upload" where files are uploaded and downloaded from the internet.
Here are my file permissions
[root@localhost upload]# ls -al
total 56
drw-rw-rw- 3 wohldad nobody 4096 Aug 24 08:51 .
drwxr-xr-x 26 root root 4096 Aug 22 00:41 ..
-rw-r--r-- 1 nobody nobody 2318 Aug 24 08:50 1124891436
-rw-r--r-- 1 nobody nobody 14726 Aug 24 08:51 1124891462
The files I'm opening and downloading are 1124891436 and 1124891462. My web server is running as "nobody" and "nobody" has read and write permissions to the directory and files.
Now when I try to open the file to read it using:
open(DLFILE, "<$file_location/$id") || Error('open', 'file');
@fileholder = <DLFILE>;
close (DLFILE) || Error ('close', 'file');
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=@filename[0]\n\n";
print @fileholder
}
sub Error {
print "Content-type: text/html\n\n";
print "The server can't $_[0] the $_[1]: $! \n";
exit;
}
I get an "The server can't open the file: Permission denied" error.
When I change the directory permissions to: 676, thus adding execute permissions for "nobody" I can download the file.
I read that "open" only needs read and write permissions on a file, is this true? Or do I also need "execute" permissions on a file to user perl's "open"?
How can I open a file without having to need execute permissions?
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.