hesco has asked for the wisdom of the Perl Monks concerning the following question:
My test script looks like this:[Fri Nov 21 09:02:15 2008] [error] [client 76.17.99.50] Premature end +of script headers: test_ult.cgi
The Q&A section (How to get over 'premature end of script headers' in Apache?) on this site mentions that suExec could be an issue and in this situation the relevant CentOS / plesk server has an http.conf file enabling suExec.#!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); $| = 1; my $q = CGI->new(); print $q->header, $q->start_html('test.cgi at ult****.com'), $q->h1("Found me in ult****.com vhost "), $q->end_html; $| = 0; 1;
Carp responds with a blank browser screen (and empty source).
As root, running this from a command line, look like this:
So I have a couple of questions here. Is there a simple way, as root, from the command line, to run this script as the apache user? If this script is not running as apache, how would I determine what user suExec has it running as? Can anyone offer any other pointers to help me determine what my issue here might be?cgi-bin]# ./test_ult.cgi Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>test.cgi at ult****.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <h1>Found me in ult****.com vhost </h1> </body> </html> cgi-bin]#
My real script (nms' FormMail.pl) is also throwing this same error. I usually work in Debian, not CentOS. I usually work at a cli, and am not use to seeing Plesk written config files warning me I will break everything should I edit them. Not sure to what extent this unusual environment may be a factor. I'm hopeful that if I can figure this out for a simple test script, I'll be able to translate this to the real issue I face this morning.
-- Hugh
UPDATE:
ANOTHER UPDATE:grep apache /etc/passwd says: apache:x:48:48:Apache:/var/www:/sbin/nologin
Thanks all. And thank you ig and eye for the pointers about suExec and SELinux. And I had not known how to set a temporary shell with the su command. That looks useful for the future.
To resolve this issue Friday night, I had to immerse myself in the suExec documentation for the first time and feel that I have finally wrapped my head around how that works. Once doing so, it was a rather quick path to resolving this issue. But first I had to spend an hour or two immersing myself in literature about seLinux, before finally assuming that it was not the issue in this case. However there is more practical advice in eye's and ig's posts below, than in the articles I read Friday. Fully understanding seLinux will have to wait for another day, but it will start with a review of this thread, when the time comes. Thanks again.
|
|---|