LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 05-09-2005, 02:58 AM   #1
lewkh
Member
 
Registered: Oct 2004
Posts: 69

Rep: Reputation: 15
CGI -PERL Problem!!!


Hi everybody,
I am using Fedora Core 3 and Apache version 2.0.52 release 3. I am trying to test the cgi perl script as following:

#!/usr/bin/perl -w
use strict;
print "Content-type: text/html\n\n";
my $list=`ls`;
print "<HTML>";
print "<HEAD>";
print "<TITLE>LISTING</TITLE>";
print "</HEAD>";
print "<BODY>";
print "<H1> $list</H1>";
print "</BODY>";
print "</HEAD>";
print "</HTML>";

While I run this script at Firefox browser, it prompts 500 Internal Server Error and the /var/log/http/error_log show like
Use of uninitialized value in concatenation (.) or string at <script _line no>
But when I put the same script and run it at RedHat Linux 9 (Apache 2.0.40), there is runable without any problem. Thus I wonder know is there a security issue I need to configure at Apache 2.0.52 version?

Please advise....... Thanks


 
Old 05-09-2005, 11:18 AM   #2
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
As I understand it, the stock Apache 2.0 httpd.conf setup in FC3 limits cgi execution to /var/www/cgi-bin/:

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

To execute cgi script elsewhere, you need to add:

Options ExecCGI
and
AddHandler cgi-script .cgi


Here is an example I pulled from one of my systems using virtual hosts to allow cgi execution in /var/www/html/:

#Using AddHandler:

<VirtualHost *:80 *:8080>
DocumentRoot /var/www/html
Server Admin root@localhost
ServerName 192.168.1.202
AddHandler cgi-script .cgi
ServerSignature email
Directorylndex index.html index.htm index.shtml
</VirtualHost>

#Note: You may need to add to the DirectoryIndex list depending on how you making the call.


#This is the standard allow:

<Directory "/var/www/cgi-bin">
Options ExecCGI
AllowOverride None
Allow from all
Order allow,deny
</Directory>


#This allows execution in /var/www/html/:

<Directory"/var/www/html">
Options ExecCGI
AllowOverride None
Allow from all
Order allow,deny
</Directory>
 
Old 05-09-2005, 11:49 PM   #3
lewkh
Member
 
Registered: Oct 2004
Posts: 69

Original Poster
Rep: Reputation: 15
Hi WhatsHisName,
The script is runnable, but the problem only occur on the system command unreadable ( Pass null to $list)

#!/usr/bin/perl -w
use strict;
print "Content-type: text/html\n\n";
my $list=`ls`; #If I change to my $list=`/bin/date`; the client browser will display the current date.
print "<HTML>"; #but like ls command it won't display. Once I put the script on RedHat 9, the ls
print "<HEAD>"; #command can be parsed to variable $list.
print "<TITLE>LISTING</TITLE>";
print "</HEAD>";
print "<BODY>";
print "<H1> $list</H1>";
print "</BODY>";
print "</HEAD>";
print "</HTML>";

I have configured the directory to let cgi runnable but I only do not know why the system command unable to be parsed?
Is there any else I have to configure ?
 
Old 05-10-2005, 12:19 AM   #4
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
If you enabled SELinux during the initial security setup, try either disabling it or setting it to “warn” and retesting execution. In essence, the purpose of SELinux is to interrupt processes and the passing of data that are not specifically approved.

If you want to get a severe headache, you can read the RHEL4 SELinux manual (http://www.redhat.com/docs/manuals/e...el-selg-en.pdf) for more details.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP:perl CGI problem supermyself Programming 2 06-12-2005 08:34 AM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 05:07 AM
CGI/Perl problem with SuExec kalbaz Linux - General 2 10-18-2003 06:25 PM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM
Problem with perl and cgi files JSP Linux - General 1 03-22-2002 08:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 04:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration