Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand macros for non-existant custom variable as empty string #984

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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