perl doesn't seem to be working

dan

Verified User
Joined
Jan 2, 2007
Messages
98
Location
North Wales, UK
hi, hope someone can help!
perl doesn't seem to be working at all in the cgi-bin directories, accessible via the web. logging in via ssh and running the perl script manually (i.e perl script.cgi/pl or ./script.cgi/pl) works file. running the same script through a browser, returns a 500 error, with no real details of what's wrong. the apache error log says "premature end of file". i tested whether it was the perl script i was using or not by putting a simple 3 liner on there:
Code:
#!/usr/bin/perl
print "Content-type:text/plain\n\n";
print "hello!";
which also returned an error 500.
currently running latestl DA, perl 5.8.7 (i'm led to believe this is a development version?), fbsd6.2.
is it safe to upgrade perl to 5.8.8 (latest) by reinstalling the port, or will this screw things up more?
thanks for your help.
dan
 
Have you checked to make sure that /usr/bin/perl is the valid path for your server?

You write that perl scriptname.pl works.

Does ./scriptname.pl work?

Jeff
 
yes. i checked /usr/bin/perl is valid and exists. i ran "./test.pl" and "perl test.pl" and both outputted results on the shell console as expected. running it through the web interface though, returns a 500 error, "premature end of script headers". basically, my 3 line test script couldn't be any simpler, and every web server with perl installed should work with it.
any ideas what might be wrong?
 
Is there any output in the suexec error log?

Try the script in your browser, and then in SSH tail /var/log/httpd/suexec_log

That should give you an idea what's going wrong.

Cheers,
 
Code:
[2007-08-29 20:59:56]: info: (target/actual) uid: (cuccoscratch/cuccoscratch) gid: (cuccoscratch/cuccoscratch) cmd: test.pl
[2007-08-29 20:59:56]: error: target uid/gid (1020/1020) mismatch with directory (1020/1003) or program (1020/1003)
1020 is cuccoscratch user
1003 is apache
why's this causing this to stop working?
all the scripts are chmod'd +x, so i really can't see what the issue is! aips not had a bizarre issue drive me crazy like this for ages!! haha
 
Last edited:
suexec requires the owner and group of any script to match the directory the script is inside. Try changing your script's group to 1003 and I think it will work. If not, you may need to change public_html to 1020:1020 (and make sure the script is 1020:1020 then too).
 
but surely then i'd have to change everyone's cgi bin to be the same? and these cgi bin's are automatically setup when DA creates a new domain. am i going to have to manually chown and/or chgrp everyone's cgi bin scripts?
 
i chgrp -R'd the cgi-bin directory to 1020, and the script started to work.
i was just about to say that all the other cgi bin's on the server were group owned to apache. but looking at it more closely, the groups were all the user's. so i wonder if this user just didn't get setup right?
 
If the Perl scripts are inside cgi-bin directories and already have user:user ownership, you can correct the group on the cgi-bin directories themselves withthis:
Code:
for d in /home/*/domains/*/public_html/cgi-bin; do chgrp `stat -c '%u' $d` $d; done
 
i chgrp -R'd the cgi-bin directory to 1020, and the script started to work.
i was just about to say that all the other cgi bin's on the server were group owned to apache. but looking at it more closely, the groups were all the user's. so i wonder if this user just didn't get setup right?

DA should set them to user:user when they are created, although I have no idea how one could get to user:apache. Perhaps it's something the user did, I don't know.

Good to hear you got it working though. :)

Cheers,
 
i've no idea. truely weird though. this was a user account i setup for a friend, but i'm doing a fair bit of developing work. i don't think anyone else actually uses the cgi bin, since more or less everything these days is written in php. but there's just some things that php won't do! (file upload progress bars for POSTing forms). this is when i discovered the issue.
i upgraded to perl 5.8.8 and mod_perl 1.30 as well. doesn't seem to have affected anything, so that's all good too!
thanks for your help! :D
 
A long time ago, in a universe far away, old versions of DirectAdmin created cgi-bin directories as USERNAME:apache.

Jeff
 
haha yea. weird thing is, i keep my DA up to date, getting the latest version whenever I check for updates.
The account in question was created using 1.30.1, upgraded to 1.03.2 since then. Not sure what happened there, but I'll be watching out for it on the next account I create!
 
Back
Top