Hi:
I'm unable to invoke a LWP call inside my CGI Perl script if SELinux is
turned on. Here's a snippet of the code:
my $file = defined ($ARGV[0]) ? $ARGV[0] : $cgi->param('file');
my $ua = LWP::UserAgent->new();
my $addr = "http://$TARGET_HOST/cgi-bin/file_exist.pl";
my $req = HTTP::Request->new(GET => $addr . "file=" . $file);
my $res = $ua->request($req);
if (! defined $ARGV[0]) {
print $cgi->header;
}
if ($res->is_success) {
print $res->content,"\n";
} else {
print "Error ",$res->status_line, " $file $addr \n";
print $res->content;
print $res->as_string;
}
I'm getting the following error message:
Error 500 Can't connect to <machine>:80 (connect: Permission denied)
Content-Type: text/plain Client-Date: Thu, 17 Feb 2011 06:22:20 GMT
Client-Warning: Internal response 500 Can't connect to <machine>:80 (connect:
Permission denied)
Either one of the following fixes the problem :
1) turn SELinux off (echo 0 > /selinux/enforce)
2) Run the CGI program via command line instead of CGI call (I run the
program as root as I can't su to the apache account)
Here are some more information
file permission of the CGI script
-rwx------. 1 apache apache 921 Feb 16 23:56 file_exist.cgi
[root@haselbytest10 cgi-bin]# cat /proc/version
Linux version 2.6.32-71.el6.x86_64
([email protected]) (gcc version 4.4.4 20100726 (Red Hat
4.4.4-13) (GCC) ) #1 SMP Wed Sep 1 01:33:01 EDT 2010
[root@haselbytest10 cgi-bin]# cat /etc/issue
Red Hat Enterprise Linux Server release 6.0 (Santiago)
Any ideas why? Sorry, I'm not that familiar with SELinux and I can't
find
SELinux related messages (except for it is turned on / turned off messages) in
/var/log/messages.
Thanks in advance.
Regards,
Ludwig Lim
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph