question on security
Chris
csh_jp at yahoo.com
Sun Nov 26 05:16:30 UTC 2006
Hi, Charles,
Thank you for the response. I am sorry that I didn't make it clear. Here is it:
I use Apache 2; there is no error in its log file.
The script doesn't need to write to files, it just retrieve some web page, say,
http://www.yahoo.com/index.html, then extract some data from it and show it.
The following simple script illustrates this:
============ perl script ===============
#!/usr/bin/perl
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
my $resp = $ua->get("http://www.yahoo.com/");
my $resultUsingLWP;
if($resp->is_success) {
$resultUsingLWP = $resp->content;
} else {
$resultUsingLWP = $resp->status_line;
}
print "Content-type: text/html; charset=utf-8\n\n";
print "LWP result: {$resultUsingLWP}";
0
========= end of perl script ========
This runs fine in command line, it prints the HTML code of Yahoo's homepage. But when I
run it as a CGI script from browser, it returns following message:
LWP result: {500 Can't connect to www.yahoo.com:80 (Bad hostname 'www.yahoo.com')}
That's weird that the internet connection is fine (otherwise I wouldn't be able to reply
this email). So it indicates that when a CGI script wants to do this, it will be blocked
by some mechanism... I am not sure if it has anything to do with SELinux...
thanks a lot!
Chris
--- Charles Curley <charlescurley at charlescurley.com> wrote:
> On Sat, Nov 25, 2006 at 11:01:46AM -0800, Chris wrote:
> > Hi,
> >
> > I found that I cannot make my perl script work: it uses LWP or
> > simpleget.pl to retrieve a web page, then process on the data
> > retrieved. This script can work fine in command line, but if I run
> > it as a CGI script, no data can be retrieved.
> >
> > I guess that there is some kind of restrictions on this in the
> > security machanism, but I am not sure. Could anyone shed some light
> > on this for me?
>
> Have you checked your web server's logs? I suspect a lack of
> permission to write to the directory where you want to put the
> files. You didn't indicate your server. Apache runs as apache:apache,
> and tomcat as tomcat:tomcat.
>
> --
>
> Charles Curley /"\ ASCII Ribbon Campaign
> Looking for fine software \ / Respect for open standards
> and/or writing? X No HTML/RTF in email
> http://www.charlescurley.com / \ No M$ Word docs in email
>
> Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
> > --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
More information about the fedora-list
mailing list