Skip to content

Commit

Permalink
expand macros for non-existant custom variable as empty string
Browse files Browse the repository at this point in the history
Closes #983
  • Loading branch information
klaernie committed Oct 7, 2024
1 parent a30a89e commit e28b8db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Nagios Core 4 Change Log
* Send a recovery notification if the object recovered while flapping (#847) (Dylan Anderson)
* Fix for separate build directory & a couple small cleanups (Doug Nazar)
* Update tutorial links in Readme (Igor Udot)
* Expand the custom variable macros to an empty string, if the custom variable does not exist

4.5.5 - 2024-09-17
------------------
Expand Down
8 changes: 7 additions & 1 deletion common/macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ int grab_custom_object_macro_r(nagios_macros *mac, char *macro_name, customvaria
customvariablesmember *temp_customvariablesmember = NULL;
int result = ERROR;

if(macro_name == NULL || vars == NULL || output == NULL)
if(macro_name == NULL || output == NULL)
return ERROR;

/* get the custom variable */
Expand All @@ -2484,6 +2484,12 @@ int grab_custom_object_macro_r(nagios_macros *mac, char *macro_name, customvaria
}
}

/* expand nonexistant custom variables as an empty string */
if( result == ERROR ){
*output = "";
result = OK;
}

return result;
}

Expand Down

0 comments on commit e28b8db

Please sign in to comment.