[Nagios-devel] CGI Patch for Nagios 1.0b6

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] CGI Patch for Nagios 1.0b6

Post by Guest »

This is a multi-part message in MIME format.
--------------010204010108070503070900
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I previously submitted a patch file for Nagios1.0b3 that would allow for
the CGI's to be truly portable, as in no need to reconfigure or remake
whenever you wanted to move them or have multiple instances of the CGI's
on the same box. What I did was added a method to the cgiutils.c class
to get the location of the cgi.cfg file from an environment variable,
NAGIOS_CGI_CONFIG. If there is no environment variable set, then it
will do what Nagios currently does and use the hard-coded value in the
locations.h file (created with you ran ./configure).

The patch never made it to the 1.0b6 release, so I recreated it and
attached it to this email. It's easy to run. All you have to do is,
before you do a make (after ./configure), copy this patch file into the
/nagios-1.0b6/cgi directory and type patch -p1 < nagios1.0b6-cgi.patch
and it will edit the cgi's properly. Then to set the environment
variable, you need to edit your httpd.conf. I know how to do this for
Apache (you need version 1.3.7 or higher). Inside the Directory entry
you made for the /nagios/cgi-bin path you add the line:

SetEnv NAGIOS_CGI_CONFIG /usr/local/nagios/etc/cgi.cfg

Obviously change the value to be wherever your cgi.cfg is located. So
if you ahve multiple set of CGI's running on one box (like we do here),
for each different Directory entry, set the environment variable
appropriately and all the CGI's will work fine.

This is the only hardcoded reference the CGI's use. Inside cgi.cfg is
the location of the main cfg file (nagios.cfg), and the cgi's parse the
rest of the information they need from there. Just make sure that you
have all your directory and file settings set properly in the config files.

I'd really like to see this change added to the distribution. It allows
for CGI portability and it is completely backward compatible. If
someone can let me know how I can go about having this added to the
normal Nagios distribution, I'd really appreciate it. Thanks.

-Russell Scibetti

--
Russell Scibetti
Quadrix Solutions, Inc.
http://www.quadrix.com
(732) 235-2335, ext. 7038


--------------010204010108070503070900
Content-Type: text/plain;
name="nagios1.0b6-cgi.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios1.0b6-cgi.patch"

diff -c cgi/auth.c newcgi/auth.c
*** cgi/auth.c Sat Apr 27 01:44:07 2002
--- newcgi/auth.c Wed Sep 18 11:11:22 2002
***************
*** 107,113 ****
}

/* read in authorization override vars from config file... */
! fp=fopen(DEFAULT_CGI_CONFIG_FILE,"r");
if(fp!=NULL){

while(read_line(input_buffer,MAX_INPUT_BUFFER,fp)){
--- 107,113 ----
}

/* read in authorization override vars from config file... */
! fp=fopen(get_cgi_config_location(),"r");
if(fp!=NULL){

while(read_line(input_buffer,MAX_INPUT_BUFFER,fp)){
diff -c cgi/avail.c newcgi/avail.c
*** cgi/avail.c Tue Aug 20 20:53:21 2002
--- newcgi/avail.c Wed Sep 18 11:14:16 2002
***************
*** 256,265 ****
reset_cgi_vars();

/* read the CGI configuration file */
! result=read_cgi_config_file(DEFAULT_CGI_CONFIG_FILE);
if(result==ERROR){
document_header(FALSE);
! cgi_config_file_error(DEFAULT_CGI_CONFIG_FILE);
document_footer();
return ERROR;
}
--- 256,265 ----
reset_cgi_vars();

/* read the CGI configuration file */
! result=read_cgi_config_file(get_cgi_config_location());
if(result==ERROR){
document_header(FALSE);
! cgi_config_file_error(get_cgi_config_location());
document_footer();
return ERROR;
}
***************
*** 283,289 ****
}

/* read all status data */
! result=read_all_status_data(DEFAULT_CGI_CONFIG_FILE,READ_ALL_STATUS_DATA);
if(result==ERROR){
document_header(FALSE);
status_data_error();
--- 283,289 ----
}

/* read all status data */
! result=read_all_status_data(get_cgi_config_location(),READ_ALL_STATUS_DATA);
if(result==ERROR){
document_header(FALSE);
status_data_error();
diff -c cgi/cgiutils.c newcgi/cgiutils.c
*** cgi/cgiutils.c Tue Aug 20

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: russell@quadrix.com
Locked