hi everybody, I am trying to execute a system command through apache web browser using perl/cgi scripting and also trying to write the system command return value into a file name call session.txt. If i execute the following code in normal perl programming it's executing fine if i am trying to execute the same through apache web browser it showing 512 error for system command and also i can't open,write or read a file through apache web browser and the error message that i am getting in the httpd error log is Error Message: [Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] ls: [Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] /var/lib/php/session/ [Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] : Permission denied [Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] [Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] Permission denied at /var/www/cgi-bin/kkkkk.pl line 4. #!/usr/bin/perl print "Content-type:text/html\n\n"; @var=`ls -tr /var/lib/php/session/`; open(FILE,"/var/lib/php/session/$var[$#var]") or die $!; $filename=<FILE>; close(FILE); open(OUT,">/var/www/html/web-meetme/session.txt") or die $!; print OUT $filename; close(OUT); Code (markup): Thanks in advance
It executes normal from shell because you are executing it probably as root. Apache executes it as apache effective user (cat /etc/httpd/conf/httpd.conf | grep ^User) so it probably more secure way is to chown the /var/lib/php/session/ to apache effective user