Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Servers > CGI BIN OF HELL

Forgot Password?
 Servers   Anything server related, Apache, MySQL, Samba, server security, sendmail, exim, etc

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 07-06-2004   #1 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 5
CGI BIN OF HELL

Okay this is goign to be long and winded, and a little pissed off typing here and there. Some background is that I used to beable to have a cgi-bin running in less than 20 minutes.. and now here we are about 5 days latter on the 3 or 4th distro of linux still attempting to get this cursed @#$@# thing to work again.

So, here is a few problems since I am sorta versed in apache already.. this absolutly nut kicker suEXEC, wtf is it good for anything other than wanting to smash a few computers just cause they pissed you off? I installed suEXEC cause it's been a year since I last put up a L box, and now I find out it's easier without the stupid thing... "at this point shoudl I get ride of it?"

I can't get anything to run except simple perl ... in the public_html cgi-bins or in the var/www/html bla bla the cgi root bin won't work worth @#$@ either.

This is almost the biggest @#$@#@## that apache ever wrote, like come on almost 90% of the people use apache specifically for the cgi execution, well why not write a real manual on it already instead of this greek @#$@@#$@#.

Alright, so now that I have vented a little, I'll let you know what is happened, I can't seem to get cgi to work which is obvious, I have 2 machines up for testing both are infected with suEXEC so I am royally A#$@ed there now.

Ya'll got any sudgestions? Comments, or want more descriptions of the problem... cause to me it seems the main server won't let my config changes to happen.

There is NO NOT ANYWHERE THE EXACT CODE THAT SHOUDL BE ADDED.. apache.org should be asshamed of their lammness manual..

Nobody explains anywhere waht +ExecCGI or ExecCGI means, I don't care about all the technicall utter BS, I wanna know what "+" does and what it doesn't do, I also wanna know what ScriptedAlias cgi-bin "/yourdire/cgi-bin/" with "" or with out "" or with / or without.. there is no 100% here or form, but cause I have done this all before I know it's critical how things are setup, and it's utter chaos this isn't specified anywhere.

You don't know if directory statments shoudl have " or if virtual host should have "

"RECOMPILE YOUR CODE"

omg I really have to be a rocket scientist to understand apache...

Well I hope that eased off a little of the *****en, and maybe this will contribute to a dummies guide to apache, and I am no dummie, after working on this cgi-bin thing for 20 hours... I am sorta feeling that way.

Any help appreciated.

MAIN CONFIG : all switches are on etc etc

MY CONFIG

<VirtualHost 192.168.0.10>
DocumentRoot "/home/david/public_html"
ServerName 192.168.0.10
ScriptAlias /cgi-bin/ "/home/david/cgi-bin/"
AddHandler cgi-script .cgi .pl
ErrorLog /home/david/httpd-error.log
</VirtualHost>

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

APACHE 2 btw.. ez
smokedx is offline  



Reply With Quote
Old 07-06-2004   #2 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
Well, first of all about suEXEC: It's not good for anything at all unless you're actively using mod_userdir. If you're not using mod_userdir, you're much better off without it.

As for the actual problem - what errors are you getting? What error is the web browser displaying, what's in your error_log and what's in your suexec_log?
Dolda2000 is offline   Reply With Quote
Old 07-06-2004   #3 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 5
Well I am a little bit calmer now so I'll explain what I want to do, cause that will be easier in itself alone.

I do indeed want to use the userdir, ~this ~that ~there etc etc.

So let's get the file system straight, I understand from reading cause I am using suEXEC, I have to use the userdir, so... I have my file system like this
/home/david/public_html
/home/david/cgi-bin
I had it before like /home/david/public_html/cgi-bin
My understanding is this latter will not work that the cgi-bin has to be in a NON-PUBLIC location with a allias in order to work with suEXEC.

I get numerous issues and problems as I have been hammering on this thing cause I indeed need it desperatly.

So we have that done, now you have seen what is in my httpd.conf file, and I have since made other things happen like I can get a cgi file to open and download, which isn't susposed to happen. So I'll dig out error data now...

[2004-07-06 14:04:11]: uid: (500/david) gid: (500/500) cmd: setup.cgi

That's what I get there but not exactly with the above httpd.conf file cause I have changed it adding the Directory options underneath my VirtualHost, which can be simply changed. and httpd. errors...

now I have a different error cause my scripted alias isn't working properly now...

[Tue Jul 06 14:21:58 2004] [error] [client 192.168.0.101] File does not exist: /home/david/public_html/cgi-bin
[Tue Jul 06 14:22:01 2004] [error] [client 192.168.0.101] File does not exist: /home/david/public_html/c
[Tue Jul 06 15:07:17 2004] [error] [client 192.168.0.101] File does not exist: /home/david/public_html/cgi-bin


OLDER DATA: might be more usefull to figuring out what I am doing wrong:

[Mon Jul 05 14:47:26 2004] [notice] Apache/2.0.49 (Fedora) configured -- resuming normal operations
[Mon Jul 05 21:00:12 2004] [error] [client 192.168.0.101] Directory index forbidden by rule: /var/www/html/
[Mon Jul 05 21:00:20 2004] [error] [client 192.168.0.101] Directory index forbidden by rule: /var/www/html/
[Mon Jul 05 21:02:51 2004] [error] [client 192.168.0.101] Directory index forbidden by rule: /var/www/html/
[Mon Jul 05 21:19:10 2004] [error] [client 192.168.0.101] attempt to invoke directory as script: /var/www/cgi-bin/
[Mon Jul 05 21:19:14 2004] [error] [client 192.168.0.101] (13)Permission denied: exec of '/var/www/cgi-bin/first.pl' faile
[Mon Jul 05 21:19:14 2004] [error] [client 192.168.0.101] Premature end of script headers: first.pl


and sum more data::

[Mon Jul 05 21:31:47 2004] [error] [client 192.168.0.101] fopen: Permission denied
[Mon Jul 05 21:31:47 2004] [error] [client 192.168.0.101] Premature end of script headers: setup.cgi
[Mon Jul 05 21:31:50 2004] [error] [client 192.168.0.101] attempt to invoke directory as script: /home/david/public_html/c
[Mon Jul 05 21:31:53 2004] [error] [client 192.168.0.101] failed to open log file
[Mon Jul 05 21:31:53 2004] [error] [client 192.168.0.101] fopen: Permission denied
[Mon Jul 05 21:31:53 2004] [error] [client 192.168.0.101] Premature end of script headers: setup.cgi
[Mon Jul 05 21:40:09 2004] [error] [client 192.168.0.101] (2)No such file or directory: exec of '/var/www/cgi-bin/ttx/setu
[Mon Jul 05 21:40:09 2004] [error] [client 192.168.0.101] Premature end of script headers: setup.cgi
[Mon Jul 05 21:40:11 2004] [error] [client 192.168.0.101] (2)No such file or directory: exec of '/var/www/cgi-bin/ttx/setu
[Mon Jul 05 21:40:11 2004] [error] [client 192.168.0.101] Premature end of script headers: setup.cgi
[Mon Jul 05 21:40:13 2004] [error] [client 192.168.0.101] attempt to invoke directory as script: /var/www/cgi-bin/ttx/
[Mon Jul 05 21:40:43 2004] [error] [client 192.168.0.101] attempt to invoke directory as script: /var/www/cgi-bin/ttx/
[Mon Jul 05 21:40:45 2004] [error] [client 192.168.0.101] (Exec format error: exec of '/var/www/cgi-bin/ttx/setup.cgi' f


I know how to make all sorts of errors with apache, who doesn't? I know I am in error here, hopefully this will give a better idead.
smokedx is offline   Reply With Quote
Old 07-06-2004   #4 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
I dunno, but it really seems like you haven't set execute permission on that first.pl file. You sure that apache can execute it?
Dolda2000 is offline   Reply With Quote
Old 07-06-2004   #5 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 5
with a shotgun sure....
smokedx is offline   Reply With Quote
Old 07-07-2004   #6 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
Oh sorry, I just realized that was in the first part of the logs.

Doesn't the suexec_log have something to say about this? You'd get that error if suexec refuses to exec the file.
Dolda2000 is offline   Reply With Quote
Old 07-07-2004   #7 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 5
The Solving of a Problem

Okay, so this is what has happend, I have one really simple question what does the -w at the end of the perl call mean???

#!/usr/bin/perl -w

What I have done was to remove suexec, that sob was going to have my machine killed.... by me that is. So I renamed, rebooted, and then uncommented the call by apache's httpd.conf.

I got a test.cgi working shortly after a few small configuration changes. I tried to run anything other than the test.cgi and I got a 500 Internal Server error. Now to make sure that everything is running correctly.. Did this work for me cause I do not have a .htaccess file running yet? Or what's the deal with adding -w to your perl header??... why does this make ever non-commercial commercial cgi script work now?
smokedx is offline   Reply With Quote
Old 07-08-2004   #8 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
The -w is just to put Perl into `warning mode'. It means nothing more than that Perl will print warnings on stderr if you have something suspicious in the Perl code.

What's the error_log message when you try to run anything else?
Dolda2000 is offline   Reply With Quote
Old 07-08-2004   #9 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 5
that is what I was getting, now I get all kinds of errors but everything functions.. how nice.

error] [client 192.168.0.101] Premature end of script headers: setup.cgi
error] [client 192.168.0.101] (2)No such file or directory: exec of '/home/david/public_html/cgi-bin/setup.cgi' failed
error] [client 192.168.0.101] Premature end of script headers: setup.cgi
error] [client 192.168.0.101] Directory index forbidden by rule: /var/www/html/
error] [client 192.168.0.101] Directory index forbidden by rule: /var/www/html/
error] [client 192.168.0.101] (2)No such file or directory: exec of '/home/david/public_html/cgi-bin/hello.cgi' failed
error] [client 192.168.0.101] Premature end of script headers: hello.cgi
error] [client 192.168.0.101] (2)No such file or directory: exec of '/home/david/public_html/cgi-bin/hello.cgi' failed
error] [client 192.168.0.101] Premature end of script headers: hello.cgi
error] [client 192.168.0.101] (2)No such file or directory: exec of '/home/david/public_html/cgi-bin/ubb6_test.cgi' failed
error] [client 192.168.0.101] Premature end of script headers: ubb6_test.cgi
error] [client 192.168.0.101] (13)Permission denied: exec of '/home/david/public_html/cgi-bin/hello.pl' failed
error] [client 192.168.0.101] Premature end of script headers: hello.pl
error] [client 192.168.0.101] (2)No such file or directory: exec of '/home/david/public_html/cgi-bin/hello.pl' failed
error] [client 192.168.0.101] Premature end of script headers: hello.pl
error] [client 192.168.0.101] (2)No such file or directory: exec of '/home/david/public_html/cgi-bin/hello.pl' failed
error] [client 192.168.0.101] Premature end of script headers: hello.pl
error] [client 192.168.0.101] (2)No such file or directory: exec of '/home/david/public_html/cgi-bin/hello.cgi' failed
error] [client 192.168.0.101] Premature end of script headers: hello.cgi
smokedx is offline   Reply With Quote
Old 07-10-2004   #10 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
"but everything functions"? Does that mean it works?
Dolda2000 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 05:29 PM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1