Custom Object Variables: Contrary to docs, /* custom variable values get cleaned */

"Peter Valdemar Mørch (Lists)" 4ux6as402 at sneakemail.com
Fri Aug 27 15:01:49 CEST 2010


I'm trying to use special chars in "Custom Object Variables" or "Custom 
Variable Macros" - the same concept as I under stand it.

That doesn't work. Because they are subjected to "Macro Cleansing" 
according to "illegal_macro_output_chars" from nagios.cfg.

The doc page "Understanding Macros and How They Work"[1] gives a list of 
macros to which "Macro Cleansing" is applied, and no custom macros are 
mentioned. "Cleansing" is also not metioned on the "Custom Object 
Variables"[2] page.
1: http://nagios.sourceforge.net/docs/3_0/macros.html
2: http://nagios.sourceforge.net/docs/3_0/customobjectvars.html

Applying this patch (against CVS) brings the code and executable 
behavior in line with the documentation (tested on debian lenny): It'll 
probably wrap here, so get it at http://pastebin.com/RR4h4eFL instead

cvs diff: Diffing .
Index: macros.c
===================================================================
RCS file: /cvsroot/nagios/nagios/common/macros.c,v
retrieving revision 1.37
diff -u -r1.37 macros.c
--- macros.c	6 Aug 2010 11:40:46 -0000	1.37
+++ macros.c	27 Aug 2010 12:47:40 -0000
@@ -615,16 +615,10 @@
  		}

  	/***** CUSTOM VARIABLE MACROS *****/
-	else if(macro_name[0]=='_'){
-
+	else if(macro_name[0]=='_')
  		/* get the macro value */
  		result=grab_custom_macro_value(macro_name,arg[0],arg[1],output);

-		/* custom variable values get cleaned */
-		if(result==OK)
-			*clean_options|=(STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS);
-		}
-
  	/* no macro matched... */
  	else{
  #ifdef NSCORE

Any chance of this patch being accepted? If not, the documentation 
should be updated instead! But I don't see the danger of Custom Object 
Variables being exempt from escaping. This (bug?) has apparently been 
there for some time, as it was introduced by:

revision 1.17 date: 2007/10/24 00:54:19;
A rather massive rewrite of the macro logic - phew!

And the first tag after this was: nagios-3-0b6. So I'm guessing it has 
been there since the birth of the Custom Object Variables.

Peter
-- 
Peter Valdemar Mørch
http://www.morch.com

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list