LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 01-28-2005, 02:50 PM   #1
sujte
Member
 
Registered: Jul 2003
Posts: 48

Rep: Reputation: 15
FormMail problem


The FormMail.cgi script returns an 'internal server' error as follows...

--------------------------------------------------------------------------------
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.0.46 (Red Hat) Server at www.dtcglobal.com Port 80
--------------------------------------------------------------------------------

My root web directory is
/var/www/html

My cgi-bin directory is
/var/www/html/cgi-bin

The permissions on the directory and the FormMail.cgi file are rwxr_wr_w

The /etc/httpd/conf/httpd.conf file sets up the cgi-bin alias as follows
--------------------------------------------------------------------------------
LoadModule cgi_module modules/mod_cgi.so
...
<Directory "/var/www/html/cgi-bin">
AllowOverride All
Options ExecCGI
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
--------------------------------------------------------------------------------

My form executes the cgi as follows,
method="post" action="/cgi-bin/FormMail.cgi">

I get the error every time. Any ideas that can help me get this mail program running would be greatly appreciated.

Thanks
 
Old 01-28-2005, 02:53 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Who owns the script?

Which user is the webserver running as?
 
Old 01-28-2005, 03:00 PM   #3
Donboy
Member
 
Registered: Aug 2003
Location: Little Rock, Arkansas
Distribution: RH, Fedora, Suse, AIX
Posts: 736

Rep: Reputation: 31
You said your permissions are... rwxr_wr_w

I think you need to give them execute permission as well. Try CHMOD 755 whatever.cgi

I also suggest changing the name of that script to something a little less obvious, like my_mailer.cgi or something. The reason is, spammers have automated tools that will search for obvious names like "Formmail.cgi" because its very common. Still, security by obscurity is no solution, so if you can, try to change the script so it will only accept input from certain IPs (or whatever).
 
Old 01-28-2005, 03:05 PM   #4
sujte
Member
 
Registered: Jul 2003
Posts: 48

Original Poster
Rep: Reputation: 15
Here are the error messages from the error_log. The first is when I pointed to FormMail.cgi, and the second to FormMail.pl. I seem to get the same errors. The html forms that the errors claim do not exist, do exist.

[Fri Jan 28 13:45:03 2005] [error] [client 172.31.100.1] File does not exist: /var/www/html/Style Sheet, referer: http://www.dtcglobal.com/contact.html
[Fri Jan 28 13:45:05 2005] [error] [client 172.31.100.1] File does not exist: /var/www/html/Style Sheet, referer: http://www.dtcglobal.com/home.html
[Fri Jan 28 13:45:12 2005] [error] [client 172.31.100.1] (2)No such file or directory: exec of '/var/www/html/cgi-bin/FormMail.cgi' failed, referer: http://www.dtcglobal.com/home.html
[Fri Jan 28 13:45:12 2005] [error] [client 172.31.100.1] Premature end of script headers: FormMail.cgi, referer: http://www.dtcglobal.com/home.html


[Fri Jan 28 13:47:23 2005] [error] [client 172.31.100.1] File does not exist: /var/www/html/Style Sheet, referer: http://www.dtcglobal.com/contact.html
[Fri Jan 28 13:47:25 2005] [error] [client 172.31.100.1] File does not exist: /var/www/html/Style Sheet, referer: http://www.dtcglobal.com/home.html
[Fri Jan 28 13:47:31 2005] [error] [client 172.31.100.1] (2)No such file or directory: exec of '/var/www/html/cgi-bin/FormMail.pl' failed, referer: http://www.dtcglobal.com/home.html
[Fri Jan 28 13:47:31 2005] [error] [client 172.31.100.1] Premature end of script headers: FormMail.pl, referer: http://www.dtcglobal.com/home.html


Here is the cgi-bin directory contents.

/var/www/html/cgi-bin
[root@rh1 cgi-bin]# ls -l
total 68
-rwxr-xr-x 1 root root 29171 Jan 28 12:49 FormMail.cgi
-rwxrwxrwx 1 pkappaz root 29171 Jan 26 18:14 FormMail.pl
-rw-r--r-- 1 root root 8 Jan 28 13:16 test.txt
[root@rh1 cgi-bin]#
 
Old 01-28-2005, 03:32 PM   #5
Donboy
Member
 
Registered: Aug 2003
Location: Little Rock, Arkansas
Distribution: RH, Fedora, Suse, AIX
Posts: 736

Rep: Reputation: 31
Dont make the permissions too loose. If you are running suexec on your apache, it will not let you execute scripts where the perms are too loose. Just do 755.

You can check to see if you're running suexec by looking for the suexec log. When you try to execute your script, it should show the user/group it tried to run as. It should also give you some info if it failed.

If you are running suexec, you should have suexecusergroup directive defined in your virtual host section that tells what user/group you want to execute scripts as. In that event, you'll need to chown your script to the user/group you have specified.

I doubt you're running all of this, but its good to eliminate this.
 
Old 02-07-2005, 05:25 PM   #6
sujte
Member
 
Registered: Jul 2003
Posts: 48

Original Poster
Rep: Reputation: 15
Who owns the script? I have had it owned by root, and by oracle with permissions set to 755. I get the same results either way.

Which user is the webserver running as? Apache.
 
Old 02-07-2005, 09:40 PM   #7
Donboy
Member
 
Registered: Aug 2003
Location: Little Rock, Arkansas
Distribution: RH, Fedora, Suse, AIX
Posts: 736

Rep: Reputation: 31
Hmmm... So did you find out if you are running suexec? Did you have any "suexecusergroup" directives listed in your virtual host stanza in the httpd.conf file??

If you did, then its a matter of chown'ing the script to the correct user. I don't recommend running as root. Definitely run the script as an unpriv user.

The only other thing that comes to mind would be problems with your script itself. It could be that you are using the wrong CR/LF for the script. Unix uses Line Feeds, not Carriage Returns. So if you have any in your script, it could be a problem. Do you have access to the command line? If so, run...

vi -b yourscript.cgi

and see if there are any ^M characters at the end of each line. If so, you'll need to remove those and try running the script again.
 
Old 02-11-2005, 03:52 PM   #8
sujte
Member
 
Registered: Jul 2003
Posts: 48

Original Poster
Rep: Reputation: 15
It was the nasty ^M that was causing the problem. I removed all of them, and the script worked fine. Thanks.
 
Old 02-11-2005, 04:00 PM   #9
Donboy
Member
 
Registered: Aug 2003
Location: Little Rock, Arkansas
Distribution: RH, Fedora, Suse, AIX
Posts: 736

Rep: Reputation: 31
Sounds like you are using a text editor in Windows and saving your scripts to your unix drives. In that case, you can get a text editor like EditPlus (www.editplus.com) and they have the ability to change the format to either CR or LF. This is much easier than killing all those ^M's when viewing the file in binary mode.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 with Formmail cucolin@ Programming 0 06-25-2004 01:45 AM
Sendmail(FormMail) dineshb Linux - General 1 03-22-2004 08:54 AM
Help on FormMail.pl sanjibgupta Linux - Newbie 0 09-30-2003 02:21 AM
sendmail/formmail problems dleone Linux - General 2 01-09-2003 09:11 PM
FormMail.pl cottonmouth Linux - Security 1 12-29-2002 08:47 PM


All times are GMT -5. The time now is 03:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration