Problem with CGI not working

24 posts / 0 new
Last post
#1 Sun, 05/31/2009 - 13:12
southerns

Problem with CGI not working

This is a break away from my other thread

http://www.virtualmin.com/forums/limit/10/limitstart/20/help-home-for-newbies/re%3ahow-can-i-move-users-from-old-domain-to-new-domain.html

andreychek wrote:

Hi Shane, You said you renamed the two domains -- how did you go about doing that? If you didn't do that from within Virtualmin, using "Server Configuration -> Move Virtual Server", Virtualmin may be confused at the moment, not knowing those names have been changed. -Eric

Hi

Yes I am using Centos 5.3 The script is set to 755 as they suggested.

here is a copy of suexec log

[2009-05-28 04:55:21]: uid: (500/saweb) gid: (501/501) cmd: index.cgi [2009-05-28 05:00:18]: uid: (500/saweb) gid: (501/501) cmd: index.cgi [2009-05-28 05:00:25]: uid: (500/saweb) gid: (501/501) cmd: index.cgi [2009-05-28 05:00:33]: uid: (500/saweb) gid: (501/501) cmd: index.cgi [2009-05-28 05:18:20]: uid: (500/saweb) gid: (501/501) cmd: index.cgi

Thanx Shane

Sun, 05/31/2009 - 13:18
Joe
Joe's picture

Are you sure your script actually works? Can you run it from the command line, as the user, and see sane results?

There are no suexec errors here, anyway...so those suexec policy violation messags don't make any sense. Is the script owned by uid 500 and gid 501?

--

Check out the forum guidelines!

Mon, 06/01/2009 - 00:52 (Reply to #2)
southerns

The script used to run on my old server.

Its a portal script called web-app.

Mon, 06/01/2009 - 01:04 (Reply to #3)
southerns

where do I check this.

"Is the script owned by uid 500 and gid 501? "

If in webmin file manager then I can go to the cgi file and check it

I can then email you a screen shot of it, what email must I send it to.

Mon, 06/01/2009 - 01:28 (Reply to #4)
Joe
Joe's picture

Hehehe...I don't think screenshots will be necessary for talking about the UID and GID. ;-)

ls -ln /home/domainname/cgi-bin/

Assuming your scripts are in /home/domainname/cgi-bin.

--

Check out the forum guidelines!

Mon, 06/01/2009 - 07:39 (Reply to #5)
southerns

Hi.

Here is the reply.

> ls -ln /home/saweb/cgi-bin/
total 1272
-rwxr-xr-x 1 500 501 61 May 28 00:20 awstats.pl
-rwxrwxr-x 1 500 501 1271744 May 16 2008 cgi-bin.zip
-rwxrwxr-x 1 500 501 224 May 19 2008 hello.cgi
-rwxrwxr-x 1 500 501 224 May 19 2008 hello2.cgi
drwxr-xr-x 2 500 501 4096 May 28 02:36 install
lrwxrwxrwx 1 0 0 23 May 28 00:20 lang -> /usr/share/awstats/lang
lrwxrwxrwx 1 0 0 22 May 28 00:20 lib -> /usr/share/awstats/lib
lrwxrwxrwx 1 0 0 26 May 28 00:20 plugins -> /usr/share/awstats/plugins
-rwxr-xr-x 1 500 501 3514 May 16 2008 test.cgi
-rwxr-xr-x 1 500 501 3514 May 19 2008 test2.cgi

Mon, 06/01/2009 - 09:04 (Reply to #6)
andreychek

Alright, let's back up a little bit.

Can you describe the problem you're having, again? What are the symptoms?

Also, as Joe had mentioned above -- if you log into your server over SSH, and run the script from the command line, does that work? Do you get some form of output?
-Eric

Mon, 06/01/2009 - 13:02 (Reply to #7)
southerns

When I try run the cgi on the site I just get a blank screen.

I ran it from ssh and got alot of html code,
which when I cut and pasted in to my wysiwyg editor showed me a form with lots of input fields etc,
which makes sense as this is an installation scrip

Mon, 06/01/2009 - 13:40 (Reply to #8)
Joe
Joe's picture

Are we sure suexec is correctly configured?

suexec -V

--

Check out the forum guidelines!

Mon, 06/01/2009 - 22:43 (Reply to #9)
southerns

Not sure here is response.
Also I use Firefox, but don't think that is problem

> suexec -V
-D AP_DOC_ROOT="/home"
-D AP_GID_MIN=100
-D AP_HTTPD_USER="apache"
-D AP_LOG_EXEC="/var/log/httpd/suexec.log"
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
-D AP_UID_MIN=500
-D AP_USERDIR_SUFFIX="public_html"

Tue, 06/02/2009 - 02:03 (Reply to #10)
Joe
Joe's picture

Client browser is not relevant.

So, suexec is configured correctly.

Remind me what error, if any, you get in the virtual server error_log (/home/domain/logs/error_log) when you make a request?

And, likewise suexec_log (/var/log/httpd/suexec_log)?

I know it seems like we're going in circles here...that's because we are. I've <i>never</i> seen a situation where the script actually worked when run from the command line, the permissions and ownership were correct, and there were no errors in either log, but the script doesn't run. It just doesn't happen. We've gotta have some kind of error <i>somewhere</i>.

--

Check out the forum guidelines!

Tue, 06/02/2009 - 05:53 (Reply to #11)
andreychek

Yeah, whenever I go to the site listed above -- while Firefox does indeed show a blank page, looking at the headers, Apache is seeing &quot;Internal Server Error&quot;.

So there should be an error in the logs -- I'd look in both the logs for that particular Virtual Server (in /home/USERNAME/logs/error_log), the system logs (in /var/log/apache2/error_log), and suexec (/var/log/apache2/suexec.log).
-Eric

Mon, 06/01/2009 - 22:48 (Reply to #12)
southerns

Not sure if this is of any help.

In Opera says:

You tried to access the address http://www.saweb.biz/cgi-bin/install.cgi, which is currently unavailable. Please make sure that the Web address (URL) is correctly spelled and punctuated, then try reloading the page.

Firefox just gives a blank page,
but if I spell it wrong (installh.cgi instead of install.cgi)
then it says page cant be found.

Mon, 06/01/2009 - 23:45 (Reply to #13)
southerns

Just re-posting this to also get it on the 2nd page.

Not sure here is suexec -V response.
Also I use Firefox, but don't think that is problem

&gt; suexec -V
-D AP_DOC_ROOT=&quot;/home&quot;
-D AP_GID_MIN=100
-D AP_HTTPD_USER=&quot;apache&quot;
-D AP_LOG_EXEC=&quot;/var/log/httpd/suexec.log&quot;
-D AP_SAFE_PATH=&quot;/usr/local/bin:/usr/bin:/bin&quot;
-D AP_UID_MIN=500
-D AP_USERDIR_SUFFIX=&quot;public_html&quot;

Tue, 06/02/2009 - 21:19 (Reply to #14)
southerns

Here is the last few lines of the /var/log/virtualmin/saweb.biz_error_log

The last entry was me just before I went to the log

[Wed Jun 03 11:07:50 2009] [error] [client 66.249.65.193] Premature end of script headers: index.cgi
[Wed Jun 03 11:12:49 2009] [error] [client 66.249.65.193] suexec policy violation: see suexec log for more details
[Wed Jun 03 11:12:49 2009] [error] [client 66.249.65.193] Premature end of script headers: index.cgi
[Wed Jun 03 11:14:46 2009] [error] [client 65.55.106.238] suexec policy violation: see suexec log for more details
[Wed Jun 03 11:14:46 2009] [error] [client 65.55.106.238] Premature end of script headers: index.cgi
[Wed Jun 03 11:16:07 2009] [error] [client 41.177.26.203] suexec policy violation: see suexec log for more details
[Wed Jun 03 11:16:07 2009] [error] [client 41.177.26.203] Premature end of script headers: install.cgi

Not sure if this helps, but there is no such directory /var/log/apache2/ .
I did find this log. /var/log/httpd/error_log

If you look at the last few lines its looking at /var/www/html/
as far as I know the saweb domain is set to, /home/saweb/public_html
That is what the default server is set to, must I make that the same as the saweb one as that is supposed to be the servers domain name.
I noticed that the if I access the server via IP it does go to saweb domain.

[Sun May 31 04:02:12 2009] [notice] Digest: generating secret for digest authentication ...
[Sun May 31 04:02:12 2009] [notice] Digest: done
[Sun May 31 04:02:13 2009] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Sun May 31 04:02:13 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Sun May 31 04:02:13 2009] [notice] Graceful restart requested, doing restart
[Sun May 31 04:02:14 2009] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
httpd: Could not reliably determine the server's fully qualified domain name, using 64.85.163.4 for ServerName
[Sun May 31 04:02:15 2009] [notice] Digest: generating secret for digest authentication ...
[Sun May 31 04:02:15 2009] [notice] Digest: done
[Sun May 31 04:02:15 2009] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Sun May 31 04:02:15 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Sun May 31 04:02:15 2009] [notice] Graceful restart requested, doing restart
[Sun May 31 04:02:15 2009] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
httpd: Could not reliably determine the server's fully qualified domain name, using 64.85.163.4 for ServerName
[Sun May 31 04:02:17 2009] [notice] Digest: generating secret for digest authentication ...
[Sun May 31 04:02:17 2009] [notice] Digest: done
[Sun May 31 04:02:17 2009] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Sun May 31 04:02:17 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Sun May 31 04:02:17 2009] [notice] Graceful restart requested, doing restart
[Sun May 31 04:02:17 2009] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
httpd: Could not reliably determine the server's fully qualified domain name, using 64.85.163.4 for ServerName
[Sun May 31 04:02:18 2009] [notice] Digest: generating secret for digest authentication ...
[Sun May 31 04:02:18 2009] [notice] Digest: done
[Sun May 31 04:02:18 2009] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Sun May 31 04:02:19 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Mon Jun 01 02:47:19 2009] [error] [client 190.0.197.246] File does not exist: /var/www/html/README
[Mon Jun 01 02:47:19 2009] [error] [client 190.0.197.246] File does not exist: /var/www/html/horde
[Mon Jun 01 02:47:20 2009] [error] [client 190.0.197.246] File does not exist: /var/www/html/horde2
[Mon Jun 01 02:47:20 2009] [error] [client 190.0.197.246] File does not exist: /var/www/html/horde3
[Mon Jun 01 02:47:21 2009] [error] [client 190.0.197.246] File does not exist: /var/www/html/horde-3.0.9
[Mon Jun 01 02:47:21 2009] [error] [client 190.0.197.246] File does not exist: /var/www/html/Horde
[Mon Jun 01 23:56:09 2009] [error] [client 65.116.18.101] File does not exist: /var/www/html/user
[Mon Jun 01 23:56:14 2009] [error] [client 65.116.18.101] File does not exist: /var/www/html/user
[Tue Jun 02 06:18:03 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/roundcubemail
[Tue Jun 02 06:18:03 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/rc
[Tue Jun 02 06:18:04 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/webmail
[Tue Jun 02 06:18:04 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/roundcube
[Tue Jun 02 06:18:04 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/mail
[Tue Jun 02 06:18:04 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/README
[Tue Jun 02 06:18:18 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/roundcubemail
[Tue Jun 02 06:18:18 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/rc
[Tue Jun 02 06:18:19 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/webmail
[Tue Jun 02 06:18:19 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/roundcube
[Tue Jun 02 06:18:19 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/mail
[Tue Jun 02 06:18:20 2009] [error] [client 213.194.149.4] File does not exist: /var/www/html/README
[Wed Jun 03 06:29:07 2009] [error] [client 92.240.68.153] File does not exist: /var/www/html/photo, referer: http://www.altavista.com/image/randomlink

not sure if this helps.

Tue, 06/02/2009 - 21:25 (Reply to #15)
Joe
Joe's picture

I wanted to see suexec_log. Which is referenced by your error_log. The system-wide error_log is only providing details about startup, and other stuff...and there are obviously no entries at &quot;Wed Jun 03 11:16:07 2009&quot;, so it has no relation to the problem we're talking about. What appears in suexec_log at that time for that request?

--

Check out the forum guidelines!

Tue, 06/02/2009 - 22:19 (Reply to #16)
southerns

This is the only one I can find

/var/log/httpd/suexec_log

[2009-06-03 11:14:46]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 11:16:07]: uid: (500/saweb) gid: (501/501) cmd: install.cgi
[2009-06-03 11:16:07]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 11:17:48]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 11:17:48]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 11:32:44]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 11:32:44]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 11:42:43]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 11:42:43]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 11:47:42]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 11:47:42]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 11:52:41]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 11:52:41]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 11:57:45]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 11:57:45]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 12:01:29]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 12:01:29]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 12:02:39]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 12:02:39]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 12:07:38]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 12:07:38]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)
[2009-06-03 12:10:16]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 12:10:16]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)

The reference to index.cgi is what used to run when the script was installed before.

If you want I can email you the admin login and you can check for your self, maybe I am looking in the wrong places.

Tue, 06/02/2009 - 22:24 (Reply to #17)
southerns

I just remembered that the saweb was restored from an old Virtualmin backup from my old server,
which was a vps system with saweb as the primary domain,
where as this is a dedicated server with saweb as the primary domain.
(By primary domain I mean if you type in the ip that is the domain that shows).
Both systems had other virtual domains also on them)

Tue, 06/02/2009 - 23:49 (Reply to #18)
Joe
Joe's picture

<div class='quote'>[2009-06-03 12:10:16]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)</div>

This is the problem. Though I don't understand it, because the files you showed us earlier are not the files you're trying to run now. index.cgi and install.cgi don't exist in the file list you showed us earlier...and this suexec_log error tells me they are owned by root (0/0), which is never expected to work.

--

Check out the forum guidelines!

Wed, 06/03/2009 - 01:31 (Reply to #19)
southerns

i will try to workout where this one was from then.

Hi

Yes I am using Centos 5.3
The script is set to 755 as they suggested.

here is a copy of suexec log

[2009-05-28 04:55:21]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-05-28 05:00:18]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-05-28 05:00:25]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-05-28 05:00:33]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-05-28 05:18:20]: uid: (500/saweb) gid: (501/501) cmd: index.cgi

Thanx
Shane

Does it make any difference that there is no apache2 directory like asked for earlier.

You see the technicians where I host did the webmin
and virtualmin installation.

Wed, 06/03/2009 - 01:38 (Reply to #20)
Joe
Joe's picture

<div class='quote'>Does it make any difference that there is no apache2 directory like asked for earlier.</div>

No. Eric was speaking of Debian/Ubuntu paths. No such path exists on CentOS.

That suexec_log is really old. This one is the one I'm talking about:

<div class='quote'>[2009-06-03 12:10:16]: uid: (500/saweb) gid: (501/501) cmd: index.cgi
[2009-06-03 12:10:16]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)</div>

Again, this tells me that your scripts are not owned by the user. 0/0 is root.

--

Check out the forum guidelines!

Wed, 06/03/2009 - 05:24
southerns

Okay thanx was just checking

So any idea what I need to do now or do need to login to see.

Remeber that the same script also wont work on the one other domains

Wed, 06/03/2009 - 10:08 (Reply to #22)
Joe
Joe's picture

I <i>still</i> want to see the actual files you're trying to run. As far as suexec is concerned they are owned by root:root, which will never work. In other words, as far as I know, everything is behaving as it should.

So, who owns install.cgi and index.cgi? (The file list you showed us earlier does not contain those files.)

--

Check out the forum guidelines!

Wed, 06/03/2009 - 22:08
southerns

HEY GOOD NEWS&gt;

The scripts was owned by Root, changed it to the domains user and
bang it started to work, after a few more file settings where changed it's running.

Thanx Eric and Joe for all the help.

http://saweb.biz/cgi-bin/index.cgi

Now comes the slow pain staking job of customising it again.

Feel free to call back in a week to see the final result.

Its great to use a program(Webmin/Virtualmin)
where the guys handling the support are as clued up with whats going on
and as helpfull as you guys.

Regards
Shane
One Happy Camper
:D

Topic locked