cgi-bin problems

15 posts / 0 new
Last post
#1 Wed, 05/20/2009 - 14:05
lex

cgi-bin problems

Hi,

I imported virtual servers (webmin & virtualmin installed on ubuntu 8.10 that had already some sites configured) but I'm struggling with sites that use cgi scripts.

When a cgi script is called, I get lots of 500 and messages like: Error: Can't open for output counter file. Reason: Permission denied

So I guess it must be a permission issue. First I thought it might be a folder thing, as virtualmin seems to want things to be in /public_html although the original sites were and are at /user/htdocs. But simple html files work fine.

What am I to do?

Wed, 05/20/2009 - 14:19
Joe
Joe's picture

--

Check out the forum guidelines!

Wed, 05/20/2009 - 14:53 (Reply to #2)
lex

Well the error log doesn't help a lot

[Thu May 21 00:45:16 2009] [error] [client 88.31.255.234] (2)No such file or directory: exec of '/home/default/-domain-.com/user/htdocs/cgi-bin/links/search.cgi' failed, referer: http://www.-domain-.com/
[Thu May 21 00:45:16 2009] [error] [client 88.31.255.234] Premature end of script headers: search.cgi, referer: http://www.-domain-.com/

Well, the script is there, and if I call a 'hello world' perl script in the same folder it works fine. The search.cgi script is reading a lot of other files. All this worked fine before "importing the virtual server". So I was hoping this something you've seen happening before when importing servers and that it'd be easy to solve...

I'll continue 'playing' with it now.

And thanks for your answer!

Wed, 05/20/2009 - 14:57 (Reply to #3)
andreychek

Howdy,

Well, just to be super-sure -- if you do a:

ls -l /home/default/-domain-.com/user/htdocs/cgi-bin/links/search.cgi

It sees that there okay?
-Eric

Wed, 05/20/2009 - 15:07 (Reply to #4)
lex

Here you go:

[code:1]
root@ubuntu:/home/default/-domain-.com/user/htdocs/cgi-bin/links# ls -l
total 156
-rwxr-xr-x 1 gci matrixdomain 4217 2009-05-06 01:39 rate.cgi
-rwxr-xr-x 1 gci matrixdomain 10847 2009-05-06 02:04 report.cgi
-rwxr-xr-x 1 gci matrixdomain 10812 2009-05-06 02:05 report.cgi-new.html
-rwxr-xr-x 1 gci matrixdomain 10729 2009-05-06 02:05 report.cgi.old.html
-rwxr-xr-x 1 gci default 13298 2009-05-20 23:53 search.cgi
-rwxr-xr-x 1 gci matrixdomain 11966 2009-05-06 01:39 search.cgi.10-12-99
-rwxr-xr-x 1 gci matrixdomain 6764 2009-05-06 01:39 subscribe.cgi
-rwxr-xr-x 1 gci default 2597 2009-05-06 02:04 test.cgi
[/code:1]

So yes, I'm sure.

Wed, 05/20/2009 - 15:21 (Reply to #5)
Joe
Joe's picture

So, the group ownership looks suspicious. I don't know if it's causing this particular problem...but suexec is very particular about permissions and ownership.

You might check the suexec_log for more on what suexec is thinking.

--

Check out the forum guidelines!

Wed, 05/20/2009 - 15:33 (Reply to #6)
lex

First of all: I really appreciate how fast you're answering here, that's quite unbelievable.

About suexec, I've disabled that. You see, before installing webmin and virtualmin, I tried it on the server and it made most of the dynamically perl driven sites stop working. So after installing virtualmin, that was an apache mod (I think ;) which I've disabled. (Together with google I found out how to do it.)

So it can't be suexec. (I think)

About the groups as you see them: they were all matrixdomain first, but I tried changing that to 'default' as you can see, as that's the group they're in. But still, they worked before, and changing matrixdomain to default had no effect. Neither on test.cgi, that one simply worked with both groups...

Wed, 05/20/2009 - 16:30 (Reply to #7)
Joe
Joe's picture

Ah, then since it's not using suexec, the Apache user needs to be able to get there and run those apps.

Ordinarily, in a system installed using install.sh Apache is automatically added to the group of each new virtual server (which allows slightly tighter permissions on homes). But, since you're using a distro unsupported by the install script, you may have skipped that step. Apache might not be able to get to that script.

Try adding the apache user (www-data, I think on Ubuntu) to the "default" group in /etc/groups. Restart Apache, and see what happens.

--

Check out the forum guidelines!

Thu, 05/21/2009 - 00:17 (Reply to #8)
lex

(forgot to mention all folders in the path seem chmodded right (755))

Thu, 05/21/2009 - 06:32 (Reply to #9)
andreychek

I can take a peek if you like.

What I'd need are:

1. Root login details

2. The URL you use to access the CGI script that's not working

3. And if you could include a link to this forum post in the message body, that'd be helpful :-)

You can email the above to eric@virtualmin.com.
-Eric

Thu, 05/21/2009 - 11:48 (Reply to #10)
andreychek

Howdy,

Okay, I think I see the large problem that was causing the 500 error.

The path to Perl was set to /usr/local/bin/perl, rather than where Perl is on your system, /usr/bin/perl.

I updated that in your script.

At this point, you get a different error, but one that's a bit easier to understand :-) It's now saying it can't open the search log file.

Now, it wasn't specific about what or where the file was -- I added some custom code to your script to list the path to the file it was trying to open, so now the problem should be more apparent.

However, I'll leave it to you to take from here :-)

Try loading that URL again, and the error you see should help out now.

Yell if you have any questions :-)
-Eric

Wed, 05/20/2009 - 23:14
lex

I think that was already the case. In /etc/group I found:

[code:1]
default:«»x:2004:admin,www-data,hn,gci
klanten:«»x:1001:admin,www-data,klanten,govert,jitcom,jitnl
[/code:1]

All sites are in those two groups.

Wed, 05/20/2009 - 23:21 (Reply to #12)
Joe
Joe's picture

I dunno. You've got me stumped. Is the path leading up to it all 750 or greater? (group needs to have execute permission all the way up the path)

--

Check out the forum guidelines!

Thu, 05/21/2009 - 00:15 (Reply to #13)
lex

Would you like/mind to have a look at the server yourself?

Thu, 05/21/2009 - 13:47
lex

Thanks a lot!

crazy no, how something like that could have happened? Seems strange it didn't produce the error before switching over to webmin/virtualmin. To be honest, I immediately thought all cgi scripts, or lots of them, would now not work and was not looking forward to lots of hours of correcting it all. So I'm kind of happy now.

Thanks a lot, really.

Now off trying to find out why the server is not sending mails anymore... :)

Topic locked