Page 1 of 1

[Nagios-devel] Bug: Nagios 3.2.1 status.cgi,

Posted: Wed Aug 04, 2010 7:29 pm
by Guest
Hello everyone, I repeated the described behavior on a fresh install of
Nagios 3.2.1 from sources (because our productive Nagios has been
patched, and I don't trust the installed Vautour to *completely* stay
out of this):

1. Configure at least two hosts (I duplicated "localhost" to "thishost")

2. Open a status.cgi page such that one of the hostnames appears
*several* times in the "Host" column (I happen to have two CRITICAL
services, HTTP and SSH; going to "Unhandled Service Problems" and
sorting the list by "Duration" did the trick for me)

3. Add an action_url and/or notes_url statement to the repeated host
which uses a macro, like this:
notes_url /something/$HOSTNAME$
action_url /another/$HOSTADDRESS$

4. The hyperlinks are OK the *first* time the host is listed, but the
URL gets truncated at the start of the macro on all following mentions:

> $ grep '^ > sed -e '/ BORDER=3D/s/^/ /' -e 's/ BORDER=3D.*/ .../' \
> > -e 's/ title=3D[^>]*/ .../' -e 's/ align[^>]*/ .../' \
> > -e 's/ TARGET=3D[^>]*/ .../' -e "s| SRC=3D[^ ]*/| SRC=3D'.../|"

> localhost=

> thishost
> localhost=

> buf_ptr=3Dinput_buffer;
> while(buf_ptr){
[...]
> if((delim_ptr=3Dstrchr(buf_ptr,'$'))){
> delim_ptr[0]=3D'\x0';

I patched it as listed below, and the symptom vanished. Unfortunately,
I'm not fluent enough in the Nagios code to be sure that this
a) doesn't break functionality in other cases,
b) does not create a memory leak, and
c) conforms to established coding style (I see a "my_free()" used in
other places) ...

Kind regards,
J. Bern



$ diff -aur common/macros.c.orig common/macros.c
--- common/macros.c.orig 2008-11-30 18:22:58.000000000 +0100
+++ common/macros.c 2010-08-04 22:04:52.985198549 +0200
@@ -77,6 +77,7 @@
/* replace macros in notification commands with their values */
int process_macros(char *input_buffer, char **output_buffer, int options=
){
char *temp_buffer=3DNULL;
+ char *save_buffer=3DNULL;
char *buf_ptr=3DNULL;
char *delim_ptr=3DNULL;
int in_macro=3DFALSE;
@@ -111,7 +112,7 @@
log_debug_info(DEBUGL_MACROS,1,"Processing: '%s'\n",input_buffer)=
;
#endif

- buf_ptr=3Dinput_buffer;
+ save_buffer=3Dbuf_ptr=3D(input_buffer?strdup(input_buffer):NULL);
while(buf_ptr){

/* save pointer to this working part of buffer */
@@ -267,6 +268,7 @@
log_debug_info(DEBUGL_MACROS,1,"**** END MACRO PROCESSING
*************\n");
#endif

+ if (save_buffer) free(save_buffer);
return OK;
}
--=20
Jochen Bern, Systemingenieur --- LINworks GmbH
Postfach 100121, 64201 Darmstadt | Robert-Koch-Str. 9, 64331 Weiterstadt
PGP (1024D/4096g) FP =3D D18B 41B1 16C0 11BA 7F8C DCF7 E1D5 FAF4 444E 1C2=
7
Tel. +49 6151 9067-231, Zentr. -0, Fax -299 - Amtsg. Darmstadt HRB 85202
Unternehmenssitz Weiterstadt, Gesch=E4ftsf=FChrer Metin Dogan, Oliver Mic=
hel





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]