Cgi POST error(s)

Hello,

I have everything set up properly and all my hosts are being monitored properly etc etc.
I can navigate the cgi’s with no problems except when I come to a form that uses POST.
I have tried using packet sniffer (everything seems ok), running the CGI on the command line (again ok), re-building nagios(no errors, found gd, looks ok), sticking a few printfs here and there in cmd.cgi(and rebuilding it), tried modifying a few apache settings(no difference, no ‘Limit POST’).

The cgi shows up as sleeping when I do ‘ps -ax’, and the browser keeps on waiting. If I stop the transaction in the browser, I notice a vague error in apache logs:
Premature end of script headers: /home/nagios/nagios/sbin/cmd.cgi

Now, does anyone have any idea why when everything seems to work fine EXCEPT when I POST information via form?

I’m led to believe that it must be an Apache configuration problem since after searching everywhere(mailing list archives, here, google) I’m the only one with this problem. This is nagios 2.0b4.

I guess my next step might be to do a quick hack of the cgi and see if I can change all the POST to GET and see if that helps. :x

Any ideas?
Terence

Edited ]

some sort of security plugin in apache?

Luca

Premature end of script headers for me was fixed when I recompiled nagios.
try ldd cmd.cgi and see what it says.

I found out that it stops (waits for input) on the fread in getcgi.c (around line 180):

            if(!fread(cgiinput,content_length,1,stdin)){
                    printf("getcgivars(): Could not read input from STDIN.\n");
                    exit(1);
                    }

#ldd -v cmd.cgi
libc.so.6 => /lib/tls/libc.so.6 (0x4001c000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

    Version information:
    /home/nagios/nagios/sbin/cmd.cgi:
            libc.so.6 (GLIBC_2.1) => /lib/tls/libc.so.6
            libc.so.6 (GLIBC_2.3) => /lib/tls/libc.so.6
            libc.so.6 (GLIBC_2.0) => /lib/tls/libc.so.6
    /lib/tls/libc.so.6:
            ld-linux.so.2 (GLIBC_2.3) => /lib/ld-linux.so.2
            ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2
            ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2
            ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2

So with the fread problem, I now have a better idea where to begin. :smiley:

EDIT:
I have changed from:
if(!fread(cgiinput,content_length,1,stdin)){
to:
if(!fread(cgiinput,1,1,stdin)){
and it still doesn’t go past this point… :expressionless:

EDIT:

I made a simple cgi script and I have determined that it must be an apache setting. This script does not read stdin when its in /home/nagios/nagios/sbin/ (aliased) but works fine when its in /usr/local/cgi-bin/ (apache default). :?

EDIT:

I found out that when I have AllowOverride set to ‘None’ the script I created above works, but when I set it to ‘AuthConfig’ it stops on the fread.

<Directory “/home/nagios/nagios/sbin”>
AllowOverride None

AllowOverride AuthConfig

    Options ExecCGI
    Order allow,deny
    Allow from all
Edited Thu Sep 22 2005, 11:34AM ]

Try going over the steps again.
nagios.sourceforge.net/docs/1_0/installweb.html

Here’s the solution to my problem:

The problem was I was using mod_auth_script v1.03 and it had erratic problems as I mentioned above.

I upgraded to mod_auth_script v1.10 and it works as expected.

So, it was not a problem with apache nor nagios but mod_auth_script version 1.03.