homepage Welcome to WebmasterWorld Guest from 174.129.103.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Open() returns permission denied in Perl CGI
jagkrish




msg:3843823
 3:38 pm on Feb 6, 2009 (gmt 0)

I have problem in opening a file in Perl CGI coding. I was able to open a file when I have it in /var/www/cgi-bin/ or /var/www/html/ directories.

I was not able to open a file from any other directory. I don't see any access problem in the httpd logs (access_log), put the open() function returns "Permission denied" error. I have kept the 755 permission for the file.

the file is in /dep/abc/def/<varing-name>/*.log

I have created <Directory "/dep/abc/def/">
options all
Allowoveride None
Order allow,deny
allow all
</directory> in httpd.conf file..

I'm not sure this problem comes because httpd.conf configuration issues or permission problem in Perl

If it is httpd.conf issue then access_log file should show that error... that is not happening..

If Perl permission issue then it should open the file even if it is /var/www/cgi-bin directory

Please help me, I want to open a text file from /dep/abc/def/<variying-directory>/<variyingfilename>.log

The variying based on the user selection.

 

janharders




msg:3843922
 5:04 pm on Feb 6, 2009 (gmt 0)

the permissions are most likely the problem - though it's not a matter where the file sits, it's about who owns the file you want to read and which mode is set on it.
if it's the same user, anything including reading should work (644 for example). if it's owned by another user, just give read-permission to world, again, 644 should do.

it's not about permissions on your cgi-script.

krugs




msg:3844075
 8:29 pm on Feb 6, 2009 (gmt 0)

Where is this directory:

/dep/abc/def/<varing-name>/*.log

in relationship to your root directory?

Do the folders also have proper read/write/exe permissions?

jagkrish




msg:3844281
 5:19 am on Feb 7, 2009 (gmt 0)

My apache running as "nobody" and group "nobody"

My files are in "root" and "root"

I have permissions for 755 755 for all the files and directories.

Still I get permission denied problem..

Can you give me httpd.conf entry for accessing a directory and file in that directory.

jagkrish




msg:3844315
 7:44 am on Feb 7, 2009 (gmt 0)

I hvae entry in httpd.conf file as

<Directory "/dep/abc/def/">
Options All
AllowOverride None
Options ExecCGI FollowSymLinks Indexes
Order allow,deny
Allow from all
</Directory>

and my files are in /dep/abc/def/#*$! directory
in which my /dep/abc/def is the base directory and the #*$!/filename will be varying depend on the user selecting it

I have function as

sub get_log_content {
my $fullFilename = shift;
my @contents;
my $error=0;
open(FILE, $fullFilename) ($error = 1);
if ($error) {
push @contents, "$fullFilename File Open Error: $!";
return @contents;
}
while (<FILE>) {
push @contents, $_;
}
close(FILE);
return @contents;
}

When I call these function it returns

/dep/abc/def/#*$!/yyy.log File Open Error: Permission denied

all the path have permission 755, own is root and group is root

and apache is running as nobody and nobody

I was able to open a file only in / & /var/www/cgi-bin & /var/www/html locations and not able to access anywhere else

Please help me out

[edited by: phranque at 1:56 pm (utc) on Feb. 7, 2009]
[edit reason] disabled graphic smileys ;) [/edit]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved