I have problem in execution of perl scripts. I am using Alias for the directory of the server like that:
Alias /epbin3/ /opt/v-hosts/user/epbin/
<Location /epbin3>
AddHandler cgi-script .cgi .pl
# SetHandler cgi-script
# SetHandler perl-script
# PerlResponseHandler ModPerl::PerlRun
Options All
AllowOverride None
</Location>
When I'm trying to execute any perl file the browser return error 500.the error shown below:
[Sun Jun 09 15:50:19 2013] [error] [client ipClient] Premature end of script headers: searchHotelsTh4.pl
[Sun Jun 09 15:50:22 2013] [error] [client ipClient] (2)No such file or directory: exec of '/opt/v-hosts/epilgrim/epbin/searchHotelsTh4.pl' failed
Please anyone can tell me what's the problem and how I can solve this issue?
If I guess correctly than you have no Directory directive which allows the file access to the file system:
<Directory /opt/v-hosts/user/epbin/>
AddHandler cgi-script .cgi .pl
Options All
AllowOverride None
</Directory>
A properly formed HTTP reply contains a blank line between the headers and the body. It is likely that searchHotelsTh4.pl is lacking such a blank line, either because it does not output headers at all or the blank line is missing, i.e. you might have this:
Content-type: text/plain
Hello, world!
when you need this:
Content-type: text/plain
Hello, world!
Related
I have entries like these in apache2 error.log
[Thu Jan 12 09:18:51.078445 2023] [core:error] [pid 47992] [client 152.89.196.211:53158] AH10244: invalid URI path (/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh)
[Wed Jan 11 06:01:09.820582 2023] [core:error] [pid 30833] [client 185.225.74.55:39856] AH10244: invalid URI path (/cgi-bin/.%%%%32%%65/.%%%%32%%65/.%%%%32%%65/.%%%%32%%65/.%%%%32%%65/bin/sh)
[Wed Jan 11 17:16:49.643509 2023] [core:error] [pid 41882] [client 152.89.196.211:52746] AH10244: invalid URI path (/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh)
I got this to work on the command line:
fail2ban-regex test.log '.*\[client <HOST>:\d+\] AH10244.*$'
Every time I try to stick the regex into a .conf file like so:
[Definition]
failregex = .*\[client <HOST>:\d+\] AH10244.*$
ignoreregex =
fail2ban complains:
Running tests
=============
Use failregex line : filter.conf
ERROR: No failure-id group in 'filter.conf'
I've looked in the man pages and online but I can't find an explanation of what this message is trying to say, or how to fix it.
The Questions
How do I wrap a .conf file around this regex?
What does that error mean?
Could I (how would I) use the pre-defined stuff in apache-common.conf to make this regex more robust?
This fixed it:
fail2ban-regex test.log ./filter.conf
I had my test files (test.log and filter.conf) in my home dir. When I ( from the home dir ) issued the command:
fail2ban-regex test.log filter.conf
I assumed that I was referencing ./test.log and ./filter.conf but I think that fail2ban was looking in the filter.d/ folder to try to find filter.conf.
I found that if filter.conf was in the /etc/fail2ban/filter.d/ folder, then fail2ban-regex test.log filter.conf succeeded.
I have installed the Apache::PageKit module and while testing this module it shows below error.
But the availability of module, using below it is there
bash-3.2$
bash-3.2$ perl -MApache::PageKit -e1
bash-3.2$
bash-3.2$ ./t/TEST -start-httpd
[warning] setting ulimit to allow core files
ulimit -c unlimited; /usr/bin/perl /install/others/Apache-PageKit-1.14/t/TEST -start-httpd --documentroot '/install/others/Apache-PageKit-1.14/eg'
/install/others/apache2/bin/httpd -d /install/others/Apache-PageKit-1.14/t -f /install/others/Apache-PageKit-1.14/t/conf/httpd.conf -D APACHE2 -D PERL_USEITHREADS
using Apache/2.2.25 (prefork MPM)
waiting 60 seconds for server to start: .Syntax error on line 24 of /install/others/Apache-PageKit-1.14/t/conf/extra.last.conf:
Can't locate loadable object for module Apache::URI in #INC (#INC contains: /tmp/apache_test /install/others/Apache-PageKit-1.14/blib/lib /install/others/Apache-PageKit-1.14/blib/arch /install/others/lib/perl5/site_perl/5.8.8 /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/ /install/others/lib64/perl5/5.8.8/x86_64-linux-thread-multi /install/others/lib/perl5/site_perl /install/others/lib/CPAN/lib /install/others/Apache-PageKit-1.14/t /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//mod_perl.pm line 14\nCompilation failed in require at /install/others/Apache-PageKit-1.14/t/conf/extra.last.conf line 28.\nBEGIN failed--compilation aborted\t(in cleanup) Can't locate loadable object for module Apache::URI in #INC (#INC contains: /tmp/apache_test /install/others/Apache-PageKit-1.14/blib/lib /install/others/Apache-PageKit-1.14/blib/arch /install/others/lib/perl5/site_perl/5.8.8 /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/ /install/others/lib64/perl5/5.8.8/x86_64-linux-thread-multi /install/others/lib/perl5/site_perl /install/others/lib/CPAN/lib /install/others/Apache-PageKit-1.14/t /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//mod_perl.pm line 14\nCompilation failed in require at /install/others/Apache-PageKit-1.14/t/conf/extra.last.conf line 28.\nBEGIN failed--compilation aborted at /install/others/Apache-PageKit-1.14/t/conf/extra.last.conf line 28.\n
[ error]
server has died with status 255 (t/logs/error_log wasn't created, start the server in the debug mode)
sh: line 1: 25604 Terminated /usr/bin/perl /install/others/Apache-PageKit-1.14/t/TEST -start-httpd --documentroot '/install/others/Apache-PageKit-1.14/eg'
bash-3.2$
bash-3.2$
bash-3.2$
bash-3.2$ perl -MApache::URI -e1
bash-3.2$
Here line 24 is <Perl>. so pagekit could not able to parse this line.
bash-3.2$ vi /install/others/Apache-PageKit-1.14/t/conf/extra.last.conf
# WARNING: this file is generated (from /install/others/Apache-PageKit-1.14/t/conf/extra.last.conf.in), do not edit
# generated on Thu Jul 11 08:09:38 2013
# 01: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestConfig.pm:961
# 02: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestConfig.pm:979
# 03: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestConfig.pm:1452
# 04: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestConfig.pm:1564
# 05: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestRun.pm:502
# 06: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestRunPerl.pm:107
# 07: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestRun.pm:713
# 08: /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/TestRun.pm:713
# 09: /install/others/Apache-PageKit-1.14/t/TEST:72
# Apache::Reload is very very helpfull during development,
# but it is not required. So install it and uncomment
# the following lines
#
# PerlModule Apache::Reload
# PerlInitHandler Apache::Reload
# PerlSetVar ReloadAll On
# <Perl >
<Perl>
# It is not necasary to preload this modules, but it helps
How can i resolve this.
Thanks
Shanmugam A.
Hi,
Thanks for your reply, now i have installed Perl 5.8.8, Apache 2.2.25, Modperl 2.0.8 and Apache2::PageKit for this combination i have below error while starting the apache.
bash-3.2$
bash-3.2$ /install/others/apache2/bin/apachectl start
[Mon Jul 15 11:28:10 2013] [error] Can't locate loadable object for module Apache::Constants in #INC (#INC contains: /install/others/lib/perl5/5.8.8 /install/others/lib/perl5/site_perl/5.8.8 /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/ /install/others/lib64/perl5/5.8.8/x86_64-linux-thread-multi /install/others/lib/perl5/site_perl/5.8.8 /install/others/lib/perl5/site_perl /install/others/lib/CPAN/lib /dso/dsoapps/iesdev/qtngsas70/DSOMP/lib /dso/dsoapps/iesdev/qtngsas70/DSOMP/bin. /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 . /install/others/apache2) at /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//mod_perl.pm line 14.\nCompilation failed in require at /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//ModPerl/P2.pm line 2.\nBEGIN failed--compilation aborted at /install/others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//ModPerl/P2.pm line 2.\nCompilation failed in require at (eval 2) line 3.\n
[Mon Jul 15 11:28:10 2013] [error] Can't load Perl module ModPerl::P2 for server (null):0, exiting...
Note: Here i am setting up from Unix to Linux server.
In Unix it was the combination of Apache 1.3.27, mod_perl 1.27 Apache::PageKit And in Apache Configuration below is the additional part added with default
#################################################################
<IfModule mod_perl.c>
PerlModule ModPerl::P2
<Location /P2>
SetHandler perl-script
PerlHandler ModPerl::P2
PerlSendHeader On
</Location>
PerlModule ModPerl::P1
<Location /P1>
SetHandler perl-script
PerlHandler ModPerl::P1
PerlSendHeader On
</Location>
PerlModule Apache::DBI
#### Entered by Tom Frizzell April 25 2008
PerlFixupHandler Apache::SIG
</IfModule>
###############################################################
# PageKit setup
PassEnv ORACLE_HOME ORACLE_SID ORACLE_USERID TAPEMON_HOME TAPEMON_LIB
<Perl>
use lib "/chshttp/prod/qtngsas70/DSOMP/lib";
</Perl>
SetHandler perl-script
PerlSetVar PKIT_ROOT /chshttp/prod/qtngsas70/DSOMP/www
PerlSetVar PKIT_SERVER test
PerlHandler +Apache::PageKit
<Perl>
Apache::PageKit->startup('/chshttp/prod/qtngsas70/DSOMP/www', 'test');
</Perl>
PerlInitHandler +Apache::Reload
# Error Handling
PerlModule Apache::ErrorReport
PerlSetVar ErrorReportHandler display
This Configuration i have changed all Apache::PageKit to Apache2::PageKit and respective source code as well. I have just copied the files ModPerl::P1 and ModPerl::P2 from Unix server to Linux. But it shows the error as above.
Shall i know how to resolve this.
Thanks
Hi,
When i access the page is shows 500 internal error. and the apache log says that (Can't locate object method "is_main" in the perl module Apache::SIG). Shall i know how to resolve this.
bash-3.2$ more error_log
[Sun Jul 14 09:38:12 2013] [notice] Apache/2.2.25 (Unix) configured -- resuming normal operations
[Sun Jul 14 09:40:01 2013] [notice] caught SIGTERM, shutting down
[Tue Jul 16 06:39:59 2013] [notice] Apache/2.2.25 (Unix) mod_perl/2.0.8 Perl/v5.8.8 configured -- resuming normal operations
[Tue Jul 16 06:41:01 2013] [error] [client 10.191.51.22] Can't locate object method "is_main" via package "Apache2::RequestRec" at /install/
others/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi//Apache/SIG.pm line 14.\n
my updated apache configuration is
#################################################################
<IfModule mod_perl.c>
PerlModule ModPerl::P2
<Location /P2>
SetHandler perl-script
PerlHandler ModPerl::P2
# PerlSendHeader On
PerlOptions +ParseHeaders
</Location>
PerlModule ModPerl::P1
<Location /P1>
SetHandler perl-script
PerlHandler ModPerl::P1
# PerlSendHeader On
PerlOptions +ParseHeaders
</Location>
PerlModule Apache::DBI
PerlFixupHandler Apache::SIG
LogFormat "%h %l %u %t \"%r\" %s %b %{SIGPIPE}e"
</IfModule>
###############################################################
# PageKit setup TAPEMON_HOME TAPEMON_LIB
PassEnv ORACLE_HOME ORACLE_SID ORACLE_USERID
<Perl>
use mod_perl2;
# It is not necasary to preload this modules, but it helps
# to find errors in your instalation.
use Apache2::URI ();
use Apache2::Cookie ();
use Apache2::Request ();
use Apache::SessionX ();
use Apache2::Util ();
use Compress::Zlib ();
use File::Find ();
use HTML::FillInForm ();
use HTML::Parser ();
use HTML::Template ();
use XML::LibXML ();
use Apache2::PageKit();
use lib "/dso/dsoapps/iesdev/qtngsas70/DSOMP/lib";
</Perl>
SetHandler perl-script
PerlSetVar PKIT_ROOT /dso/dsoapps/iesdev/qtngsas70/DSOMP/www
PerlSetVar PKIT_SERVER test
PerlHandler +Apache2::PageKit
<Perl>
Apache2::PageKit->startup('/dso/dsoapps/iesdev/qtngsas70/DSOMP/www', 'test');
</Perl>
PerlInitHandler +Apache2::Reload
# Error Handling
PerlModule Apache2::ErrorReport
PerlSetVar ErrorReportHandler display
Shall i know how can i resolve this
Thanks
Shanmugam A.
It looks like Apache-PageKit works only with mod_perl1, but not with mod_perl2 (the latter would use Apache2::URI, not Apache::URI). So you should probably look for an alternative, or if you really need this module, then you have to find a way to install Apache1 and mod_perl1 on your system.
I have experience with setting up multiple Perl program with mac before, but come to a strange situation today.
I delete one of my existing Perl folder and download it from GitHub, when I try to run again, it shows this error: [an error occurred while processing this directive].
So, what I do to debug is:
1) I create test.shtml (some problem displaying the arrow sign in here)
#exec cgi="/Users/lion/htdocs/app/cgi-bin/test.pl"-->
2) I create test.pl
#!/usr/bin/perl
print "content-type: text/html \n\n";
print "test";
3) I create a new htaccess
AddType text/html .shtml
AddHandler server-parsed .shtml
4) I set the test.pl permission to 777
5) I tested with http://app.local/test.shtml
-> come out error [an error occurred while processing this directive].
6) If I manually run from console, it is working fine.
Here's my apache config as well.
<VirtualHost *:80>
DocumentRoot "/Users/lion/htdocs/app"
ServerName app.local
ScriptAlias /cgi-bin/ "/Users/lion/htdocs/app/cgi-bin/"
</VirtualHost>
My apache error log show this:
[Wed Nov 09 16:45:25 2011] [error] [client 127.0.0.1] invalid CGI ref "/Users/lion/htdocs/app/cgi-bin/test.pl" in /Users/lion/htdocs/app/test.shtml
Not sure what I missed out, my other Perl program is running just fine. Run out of ideas what cause the problem.
exec cgi expects a URL-path, not a file system path as an argument.
Try
#exec cgi="/cgi-bin/test.pl"
or just
#exec cgi="test.pl"
Well, after spending sometime for debugging, found out the cause is a .htaccess with authentication in cgi-bin, it blocks the redirection.
I am getting some very annoying behaviour from my perl cgi scripts running under apache.
I get referer information added on the end of simple print statements, and it's driving me nuts.
[Sun Feb 20 21:34:47 2011] [error] [client xx] ruid: 48, referer: http://www.x.com/
[Sun Feb 20 21:34:47 2011] [error] [client xx] euid: 48, referer: http://www.x.com/
[Sun Feb 20 21:34:47 2011] [error] [client xx] test, referer: http://www.x.com/
[Sun Feb 20 21:34:47 2011] [error] [client xx] Premature end of script headers: test.cgi, referer: http://www.x.com/
This only seems to happen when the url is reached by navigating from another page (hence having a referer yes). The above apache log output was produced with the below incredibly simple depo script:
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
my $q = CGI->new;
print STDERR "ruid: $<\n";
print STDERR "euid: $>\n";
print STDERR "test\n";
Anyone seen this before? It feels like an apache setting i need to turn off.
Thanks
Matt
Take a look at your apache config files (httpd.conf and friends) and find the CustomLog directive which is used by your error log to see which LogFormat it uses, then modify that LogFormat (or create a new one) to remove %{Referer} from the list of fields to include in the log messages. (And don't forget to reload the apache config after changing it, of course.)
I am new to CGI-Perl and sessions. I have a problem running the following code.
I have four files
1. Session.html or Session.pm
2. name.pl
3. hobbies.pl
4. job.pl
The Session.pm is place in /var/www/html folder and the rest of the files are placed in /var/www/cgi-bin/session folder.
I have a basic html file(Session.html) which has a link to perl script it is giving the following error
[Mon Jan 04 14:21:24 2010] [error] [client ::1] Options ExecCGI is off in this directory: /var/www/html/name.pl, referer: http://localhost/Session.html
[Mon Jan 04 14:21:29 2010] [error] [client ::1] Options ExecCGI is off in this directory: /var/www/html/name.pl, referer: http://localhost/Session.html
[Mon Jan 04 14:22:42 2010] [error] [client ::1] (13)Permission denied: exec of '/var/www/cgi-bin/session/name.pl' failed, referer: http://localhost/Session.pm
[Mon Jan 04 14:22:42 2010] [error] [client ::1] Premature end of script headers: name.pl, referer: http://localhost/Session.pm
Please help me out in executing the above example. Please give me the steps to be followed from the start.
... Options ExecCGI is off in this directory: /var/www/html/name.pl, ...
This error points to trying to run name.pl in /var/www/html/ instead of /var/www/cgi-bin/session/
Is the Session.html you posted correct because it doesn't seem to tally with this error?
... (13)Permission denied: exec of '/var/www/cgi-bin/session/name.pl' failed, ...
The name.pl cannot be run because it doesn't have execution rights set (on Linux/Unix you need to chmod a+x name.pl).
You may need to show what Session.pm does (it doesn't look like you using the CPAN module Session here).
On a general note I would consider simplifying what you doing down to a simple HTML & CGI script first and get that working. Then start looking into sessions etc.
Check out Ovid's CGI Tutorial for some sage advice on the Perl/CGI subject.
/I3az/