LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   FormMail problem (https://www.linuxquestions.org/questions/red-hat-31/formmail-problem-283404/)

sujte 01-28-2005 01:50 PM

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

david_ross 01-28-2005 01:53 PM

Who owns the script?

Which user is the webserver running as?

Donboy 01-28-2005 02:00 PM

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).

sujte 01-28-2005 02:05 PM

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]#

Donboy 01-28-2005 02:32 PM

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.

sujte 02-07-2005 04:25 PM

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.

Donboy 02-07-2005 08:40 PM

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.

sujte 02-11-2005 02:52 PM

It was the nasty ^M that was causing the problem. I removed all of them, and the script worked fine. Thanks.

Donboy 02-11-2005 03:00 PM

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.


All times are GMT -5. The time now is 12:53 AM.