Cgi POST error(s)



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?

Edited ]


some sort of security plugin in apache?



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):

                    printf("getcgivars(): Could not read input from STDIN.\n");

#ldd -v cmd.cgi => /lib/tls/ (0x4001c000)
/lib/ => /lib/ (0x40000000)

    Version information:
   (GLIBC_2.1) => /lib/tls/
   (GLIBC_2.3) => /lib/tls/
   (GLIBC_2.0) => /lib/tls/
   (GLIBC_2.3) => /lib/
   (GLIBC_2.1) => /lib/
   (GLIBC_2.0) => /lib/
   (GLIBC_PRIVATE) => /lib/

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

I have changed from:
and it still doesn’t go past this point… :expressionless:


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). :?


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.


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.