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

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?

The script used to run on my old server.

Its a portal script called web-app.

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.

Hehehe…I don’t think screenshots will be necessary for talking about the UID and GID. :wink:

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

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

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

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

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

Are we sure suexec is correctly configured?

suexec -V

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"

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.

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

> 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"

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 never 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 somewhere.

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

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

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.

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 “Wed Jun 03 11:16:07 2009”, so it has no relation to the problem we’re talking about. What appears in suexec_log at that time for that request?

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.

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)

[2009-06-03 12:10:16]: target uid/gid (500/501) mismatch with directory (500/501) or program (0/0)

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.

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.