Imported Upstream version 4.3.4

This commit is contained in:
Mario Fetka 2017-10-20 15:43:36 +02:00
parent 7faf575ca1
commit dac8330c0a
27 changed files with 555 additions and 218 deletions

1
.gitignore vendored
View File

@ -8,6 +8,7 @@ autom4te.cache
config.log
config.status
daemon-init
openrc-init
Makefile
tags
.deps/

165
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,165 @@
# Contributing
Thank you for considering contributing your time and effort to this Nagios project.
This document serves as our guidelines for contribution. Keep in mind that these
are simply *guidelines* - nothing here is set in stone.
## Questions
If you have a question, you don't need to file an Issue. You can simply connect
with the Nagios Support Team via the
[Nagios Support Forum](https://support.nagios.com/forum/).
Not to say that you **can't** open an Issue - but you'll likely get a much faster
response by posting it on the forum.
## Ideas
If you have an idea your best bet is to open an Issue. This gets it on the radar much
quicker than any other method.
First, let's define what an "Idea" really is. An Idea is simply an
[Enhancement](#enhancements) request in its infancy.
There's really nothing to it!
Something as simple as "I think that this project should somehow connect with a
widget" is a valid Idea.
These are unrefined and raw. That's why you open an issue - so everyone gets a chance
to chime in and come up with a plan!
## Feedback
Feedback can be given via several methods. The *easiest* method is by opening an Issue.
You're more than welcome to leave feedback on the
[Nagios Support Forum](https://support.nagios.com/forum/) as well.
By opening an Issue, however, you're insuring that the maintainers and reviewers are
the first ones to see the feedback. In most cases, this is likely ideal.
## Bugs
Here's where it starts to get serious.
Following the guidelines outlined in this section allows the maintainers, developers, and
community to understand and reproduce your bug report.
Make sure to search existing open and closed [Issues](https://guides.github.com/features/issues/)
before opening a bug report. If you find a closed Issue that seems like it's the same
thing that you're experiencing, open a new Issue and include a link to the original Issue
in the body of the new one.
**If you have a bug, you *NEED* to open an Issue.**
Not only that, but when you open the Issue, this is what we ***absolutely require***:
* Use a clear and concise title for the Issue to identify the problem accurately
* Describe the bug with as much detail as you can
* Include the version of the project containing the bug you're reporting
* Include your operating system information (`uname -a`)
* Include a list of third party modules that are installed and/or loaded
* Explain the behavior you expected to see (and why) vs. what actually happened
Once you've got that covered - there's still more to include if you want to
make a ***killer*** report:
* Describe the ***exact steps*** that reproduce the problem
* Provide **specific** examples to demonstrate those steps
* If your bug is from an older version, make sure test against the latest (and/or the `maint` branch)
* Include any screenshots that can help explain the issue
* Include a file containing `strace` and/or `valgrind` output
* Explain when the problem started happening: was it after an upgrade? or was it always present?
* Define how reliably you can reproduce the bug
* Any other information that you decide is relevant is also welcome
## Enhancements
An enhancement is either a completely new feature or an improvement to existing
functionality. We consider it to be a bit different than idea - based solely
on the fact that it's more detailed than an idea would be.
So you've got an idea for an ehancement? Great!
Following the guidelines outlined in this section allows maintainers, developers, and
the community to understand your enhancement and determine whether or not it's worth
doing and/or what's involved in carrying it out.
Make sure to search open and closed Issues and Pull Requests to determine if
someone has either submitted the enhancement. If you feel like your enhancement
is similar to one found, make sure to link the original in your request.
Enhancements are submitted by opening an Issue.
Unlike an [Idea](#idea), when you decide to submit your enhancement and open
the Issue, we require at least the following information:
* Use a clear and descriptive title to illustrate the enhancement you're requesting
* Describe the current behavior (if it exists) and what changes you think should be made
* Explain the enhancement in detail - make sure it makes sense and is easily understandable
* Specify why the enhancement would be useful and who it would be useful to
* If there is some other project or program where this enhancement already exists, make sure
to link to it
Beyond that, there are a few more things you can do to make sure you **really** get your
point across:
* Create a mockup of the enhancement (if applicable) and attach whatever files you can
* Provide a step-by-step description of the suggested enhancement
* Generate a fully dressed use-case for the enhancement request
* Create a specification for the preferred implementation of the enhancement
* Include a timeline regarding development expectations towards the request
## Submitting Code
Everything else in this document has lead up to this moment - how can ***you*** submit
code to the **project**.
We allow code submissions via [Pull Requests](https://help.github.com/articles/about-pull-requests/).
These let you (and us) discuss and review any changes to code in any repository you've made.
How to create and manage Pull Requests is outside of the scope of this document, but make
sure to check out GitHub's official documentation ([link here](https://help.github.com/))
to get a handle on it.
While you're forking the repository to create a patch or an enhancement, create a *new
branch* to make the change - it will be easier to submit a pull request using a new
branch in your forked repository!
When you submit a Pull Request, make sure you follow the guidelines:
* Make sure you're submitting to the proper branch. Branch `maint` is used for the
**next** bugfix release. The next enhancement release branch will vary.
* ***NEVER*** submit a Pull Request to `master` branch.
* Keep commit messages as concise as possible.
* Update the appropriate files in regards to your changes:
* `CHANGES`
* `THANKS`
* End all committed files with a newline.
* Test your changes and include the results as a comment.

View File

@ -2,7 +2,28 @@
Nagios Core 4 Change Log
########################
4.3.2 - xxxx-xx-xx
4.3.4 - 2017-08-24
------------------
* Improved config file parsing (Mark Felder)
* Fixed configure script to check for existence of /run for lock file (in regards to CVE-2017-12847, Bryan Heden)
* Use absolute paths when deleting check results files (Emmanuel Dreyfus)
* Add sanity checking in reassign_worker (sq5bpf)
4.3.3 - 2017-08-12
------------------
* xodtemplate.c wrong option-deprecation code warning (alex2grad / John Frickson)
* On-demand host check always use cached host state (John Frickson)
* 'á' causes Serivce Status Information to not be displayed (John Frickson)
* New Macro(s) to generate URL for host / service object (John Frickson)
* Fix minor map issues (Troy Lea)
* Fix lockfile issues (Bryan Heden)
* Switch order of daemon_init and drop_priveleges (CVE-2017-12847, Bryan Heden)
* Add an OpenRC init script (Michael Orlitzky)
4.3.2 - 2017-05-09
------------------
FIXED
* Every 15sec /var/log/messages is flooded with "nagios: set_environment_var" (John Frickson)

View File

@ -197,7 +197,7 @@ distclean: clean
cd $(SRC_TTAP) && $(MAKE) $@
cd $(SRC_WORKERS) && $(MAKE) $@
rm -f sample-config/*.cfg sample-config/*.conf sample-config/template-object/*.cfg
rm -f daemon-init pkginfo
rm -f daemon-init openrc-init pkginfo
rm -f Makefile subst
rm -f config.log config.status config.cache
rm -f tags

7
THANKS
View File

@ -70,6 +70,7 @@ wrong, please let me know.
* David Kmoch
* David Schlecht
* David Tilloy
* David Walser
* Dawid Golunski
* Dean Lane
* Denis Seleznyov
@ -183,10 +184,12 @@ wrong, please let me know.
* Luigi Balzano
* Luiz Felipe R E
* Luke Ross
* Emmanuel Dreyfus
* Marc Powell
* Marcus Fleige
* Marcus Hildenbrand
* Mark DeTrano
* Mark Felder
* Mark Frost
* Mark Goldfinch
* Mark Schenker
@ -218,6 +221,7 @@ wrong, please let me know.
* Michael Lubben
* Michael Marineau
* Michael O'Reilly
* Michael Orlitzky
* Michael Smedius
* Michal Zimen
* Michelle Craft
@ -258,6 +262,7 @@ wrong, please let me know.
* Ralph Rossner
* Ray Bengen
* Remi Paulmier
* Rémi Verschelde
* Rene Klootwijk
* Ricardo Maraschini
* Richard Mayhew
@ -282,6 +287,7 @@ wrong, please let me know.
* Sergio Guzman
* Shad Lords
* Simon Beale
* sq5bpf
* Stanley Hopcroft
* Stefan Rompf
* Stefan Schurtz
@ -318,6 +324,7 @@ wrong, please let me know.
* Tomer Okavi
* Ton Voon
* Torsten Huebler
* Troy Lea
* Tyler Lund
* Uwe Knop
* Uwe Knop

View File

@ -400,7 +400,6 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
char *temp_ptr = NULL;
servicedependency *temp_dependency = NULL;
service *master_service = NULL;
int state_changes_use_cached_state = TRUE; /* TODO - 09/23/07 move this to a global variable */
int flapping_check_done = FALSE;
@ -676,7 +675,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
else {
/* can we use the last cached host state? */
/* usually only use cached host state if no service state change has occurred */
if((state_change == FALSE || state_changes_use_cached_state == TRUE) && temp_host->has_been_checked == TRUE && ((current_time - temp_host->last_check) <= cached_host_check_horizon)) {
if(state_change == FALSE && temp_host->has_been_checked == TRUE && ((current_time - temp_host->last_check) <= cached_host_check_horizon)) {
log_debug_info(DEBUGL_CHECKS, 1, "* Using cached host state: %d\n", temp_host->current_state);
update_check_stats(ACTIVE_ONDEMAND_HOST_CHECK_STATS, current_time);
update_check_stats(ACTIVE_CACHED_HOST_CHECK_STATS, current_time);
@ -770,7 +769,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
log_debug_info(DEBUGL_CHECKS, 1, "Host is currently UP, so we'll recheck its state to make sure...\n");
/* only run a new check if we can and have to */
if(execute_host_checks && (state_change == TRUE && state_changes_use_cached_state == FALSE) && temp_host->last_check + cached_host_check_horizon < current_time) {
if(execute_host_checks && state_change == TRUE && temp_host->last_check + cached_host_check_horizon < current_time) {
schedule_host_check(temp_host, current_time, CHECK_OPTION_DEPENDENCY_CHECK);
}
else {
@ -786,7 +785,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
log_debug_info(DEBUGL_CHECKS, 1, "Host is currently %s.\n", host_state_name(temp_host->current_state));
if(execute_host_checks && (state_change == TRUE && state_changes_use_cached_state == FALSE)) {
if(execute_host_checks && state_change == TRUE) {
schedule_host_check(temp_host, current_time, CHECK_OPTION_NONE);
}
/* else fake the host check, but (possibly) resend host notifications to contacts... */

View File

@ -107,7 +107,7 @@ int read_main_config_file(char *main_config_file) {
/* open the config file for reading */
if((thefile = mmap_fopen(main_config_file)) == NULL) {
logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Cannot open main configuration file '%s' for reading!", main_config_file);
return ERROR;
exit(ERROR);
}
/* save the main config file macro */
@ -175,6 +175,11 @@ int read_main_config_file(char *main_config_file) {
}
}
else if(!strcmp(variable, "website_url")) {
my_free(website_url);
website_url = strdup(value);
}
else if(!strcmp(variable, "loadctl_options"))
error = set_loadctl_options(value, strlen(value)) != OK;
else if(!strcmp(variable, "check_workers"))
@ -1267,12 +1272,11 @@ int read_main_config_file(char *main_config_file) {
my_free(value);
/* make sure a log file has been specified */
strip(log_file);
if(!strcmp(log_file, "")) {
if(daemon_mode == FALSE)
printf("Error: Log file is not specified anywhere in main config file '%s'!\n", main_config_file);
return ERROR;
if(log_file == NULL) {
logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Log file is not specified anywhere in main config file '%s'!", main_config_file);
exit(ERROR);
}
strip(log_file);
return OK;
}

View File

@ -593,6 +593,22 @@ int main(int argc, char **argv) {
my_free(mac->x[MACRO_PROCESSSTARTTIME]);
asprintf(&mac->x[MACRO_PROCESSSTARTTIME], "%llu", (unsigned long long)program_start);
/* enter daemon mode (unless we're restarting...) */
if(daemon_mode == TRUE && sigrestart == FALSE) {
result = daemon_init();
/* we had an error daemonizing, so bail... */
if(result == ERROR) {
logit(NSLOG_PROCESS_INFO | NSLOG_RUNTIME_ERROR, TRUE, "Bailing out due to failure to daemonize. (PID=%d)", (int)getpid());
cleanup();
exit(EXIT_FAILURE);
}
/* get new PID */
nagios_pid = (int)getpid();
}
/* drop privileges */
if(drop_privileges(nagios_user, nagios_group) == ERROR) {
@ -612,21 +628,6 @@ int main(int argc, char **argv) {
/* error has already been logged */
exit(EXIT_FAILURE);
}
/* enter daemon mode (unless we're restarting...) */
if(daemon_mode == TRUE && sigrestart == FALSE) {
result = daemon_init();
/* we had an error daemonizing, so bail... */
if(result == ERROR) {
logit(NSLOG_PROCESS_INFO | NSLOG_RUNTIME_ERROR, TRUE, "Bailing out due to failure to daemonize. (PID=%d)", (int)getpid());
cleanup();
exit(EXIT_FAILURE);
}
/* get new PID */
nagios_pid = (int)getpid();
}
/* this must be logged after we read config data, as user may have changed location of main log file */
logit(NSLOG_PROCESS_INFO, TRUE, "Nagios %s starting... (PID=%d)\n", PROGRAM_VERSION, (int)getpid());

View File

@ -189,6 +189,7 @@ int free_child_process_memory;
int child_processes_fork_twice;
char *use_timezone;
char *website_url;
int allow_empty_hostgroup_assignment;
@ -263,6 +264,7 @@ void init_main_cfg_vars(int first_time) {
nagios_user = NULL;
nagios_group = NULL;
website_url = NULL;
use_regexp_matches = FALSE;
use_true_regexp_matching = FALSE;
@ -2131,7 +2133,11 @@ int process_check_result_queue(char *dirname) {
/* if the file is too old, we delete it */
if (stat_buf.st_mtime + max_check_result_file_age < time(NULL)) {
delete_check_result_file(dirfile->d_name);
if (delete_check_result_file(file) != OK
&& delete_check_result_file(dirfile->d_name) != OK)
logit(NSLOG_RUNTIME_WARNING, TRUE, "Error: Unable to delete '%s' or '%s'!", file, dirfile->d_name);
continue;
}
@ -2361,16 +2367,17 @@ int process_check_result_file(char *fname) {
/* deletes as check result file, as well as its ok-to-go file */
int delete_check_result_file(char *fname) {
char *temp_buffer = NULL;
int result = OK;
/* delete the result file */
unlink(fname);
result = unlink(fname);
/* delete the ok-to-go file */
asprintf(&temp_buffer, "%s.ok", fname);
unlink(temp_buffer);
result |= unlink(temp_buffer);
my_free(temp_buffer);
return OK;
return result;
}
@ -3383,6 +3390,7 @@ void free_memory(nagios_macros *mac) {
my_free(command_file);
mac->x[MACRO_COMMANDFILE] = NULL; /* assigned from command_file */
my_free(log_archive_path);
my_free(website_url);
for (i = 0; i < MAX_USER_MACROS; i++) {
my_free(macro_user[i]);
@ -3442,6 +3450,7 @@ int reset_variables(void) {
my_free(ocsp_command);
my_free(ochp_command);
my_free(website_url);
/* Next re-initialize configuration variables */
init_main_cfg_vars(0);

View File

@ -604,9 +604,13 @@ static void fo_reassign_wproc_job(void *job_)
{
struct wproc_job *job = (struct wproc_job *)job_;
job->wp = get_worker(job->command);
if (job->wp != NULL) {
job->id = get_job_id(job->wp);
/* macros aren't used right now anyways */
wproc_run_job(job, NULL);
} else {
logit(NSLOG_RUNTIME_WARNING, TRUE, "wproc: Error: can't get_worker() in fo_reassign_wproc_job\n");
}
}
static int handle_worker_result(int sd, int events, void *arg)

View File

@ -1088,33 +1088,37 @@ const char *url_encode(const char *input) {
return str;
}
static char * copy_wc_to_output(wchar_t wc, char *outstp, int output_max) {
static inline char* encode_character(char in, char *outcp, int output_max)
{
char *entity = NULL;
int rep_lth, out_len = outcp - encoded_html_string;
int wctomb_result;
char mbtemp[ 10];
wctomb_result = wctomb(mbtemp, wc);
if(( wctomb_result > 0) &&
((( outstp - encoded_html_string) + wctomb_result) < output_max)) {
strncpy( outstp, mbtemp, wctomb_result);
outstp += wctomb_result;
}
return outstp;
switch(in) {
case '&': entity = "&amp;"; break;
case '"': entity = "&quot;"; break;
case '\'': entity = "&#39;"; break;
case '<': entity = "&lt;"; break;
case '>': entity = "&gt;"; break;
}
static char * encode_character(wchar_t wc, char *outstp, int output_max) {
char temp_expansion[11];
sprintf(temp_expansion, "&#%u;", (unsigned int)wc);
if(((outstp - encoded_html_string) + strlen(temp_expansion)) <
(unsigned int)output_max) {
strncpy(outstp, temp_expansion, strlen( temp_expansion));
outstp += strlen( temp_expansion);
if (entity) {
rep_lth = strlen(entity);
if (out_len + rep_lth < output_max) {
strcpy(outcp, entity);
outcp += rep_lth;
}
return outstp;
return outcp;
}
if (out_len + 6 >= output_max)
return outcp;
sprintf(outcp, "&#%u", (unsigned int)in);
outcp += strlen(outcp);
return outcp;
}
#define WHERE_OUTSIDE_TAG 0 /* Not in an HTML tag */
#define WHERE_IN_TAG_NAME 1 /* In HTML tag name (either opening
or closing tag) */
@ -1131,11 +1135,8 @@ static char * encode_character(wchar_t wc, char *outstp, int output_max) {
char * html_encode(char *input, int escape_newlines) {
int len;
int output_max;
char *outstp;
wchar_t *wcinput;
wchar_t *inwcp;
wchar_t *tagname = L"";
size_t mbstowcs_result;
char *incp, *outcp;
char *tagname = "";
int x;
int where_in_tag = WHERE_OUTSIDE_TAG; /* Location in HTML tag */
wchar_t attr_value_start = (wchar_t)0; /* character that starts the
@ -1145,135 +1146,124 @@ char * html_encode(char *input, int escape_newlines) {
/* we need up to six times the space to do the conversion */
len = (int)strlen(input);
output_max = len * 6;
if(( outstp = encoded_html_string = (char *)malloc(output_max + 1)) == NULL)
if(( outcp = encoded_html_string = (char *)malloc(output_max + 1)) == NULL)
return "";
strcpy(encoded_html_string, "");
/* Convert the string to a wide character string */
if(( wcinput = malloc( len * sizeof( wchar_t))) == NULL) {
return "";
}
if((mbstowcs_result = mbstowcs( wcinput, input, len)) == (size_t)-1) {
free( wcinput);
return "";
}
/* Process all converted characters */
for( x = 0, inwcp = wcinput; x < (int)mbstowcs_result && '\0' != *inwcp;
x++, inwcp++) {
for (x = 0, incp = input; x < len && *incp; x++, incp++) {
/* Most ASCII characters don't get encoded */
if(( *inwcp >= 0x20 && *inwcp <= 0x7e) &&
( !( '"' == *inwcp || '&' == *inwcp || '\'' == *inwcp ||
'<' == *inwcp || '>' == *inwcp))) {
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
if (*incp >= 0x20 && *incp <= 0x7e && !strchr("'\"&^<>", *incp)) {
*outcp++ = *incp;
switch(where_in_tag) {
case WHERE_IN_TAG_NAME:
switch(*inwcp) {
switch(*incp) {
case 0x20:
where_in_tag = WHERE_IN_TAG_OUTSIDE_ATTRIBUTE;
*inwcp = 0;
*incp = 0;
break;
case '!':
where_in_tag = WHERE_IN_COMMENT;
break;
}
break;
case WHERE_IN_TAG_OUTSIDE_ATTRIBUTE:
if(*inwcp != 0x20) {
if(*incp != 0x20)
where_in_tag = WHERE_IN_TAG_IN_ATTRIBUTE_NAME;
}
break;
case WHERE_IN_TAG_IN_ATTRIBUTE_NAME:
if(*inwcp == '=') {
if(*incp == '=')
where_in_tag = WHERE_IN_TAG_AT_EQUALS;
}
break;
case WHERE_IN_TAG_AT_EQUALS:
if(*inwcp != 0x20) {
attr_value_start = *inwcp;
if(*incp != 0x20) {
attr_value_start = *incp;
where_in_tag = WHERE_IN_TAG_IN_ATTRIBUTE_VALUE;
}
break;
case WHERE_IN_TAG_IN_ATTRIBUTE_VALUE:
if((*inwcp == 0x20) && (attr_value_start != '"') &&
(attr_value_start != '\'')) {
if((*incp == 0x20) && (attr_value_start != '"') && (attr_value_start != '\''))
where_in_tag = WHERE_IN_TAG_OUTSIDE_ATTRIBUTE;
}
break;
}
}
/* Special handling for quotes */
else if(FALSE == escape_html_tags &&
('"' == *inwcp || '\'' == *inwcp)) {
else if(escape_html_tags == FALSE && (*incp == '"' || *incp == '\'')) {
switch(where_in_tag) {
case WHERE_OUTSIDE_TAG:
if(tag_depth >0) {
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
}
else {
outstp = encode_character(*inwcp, outstp, output_max);
}
if (tag_depth > 0)
*outcp++ = *incp;
else
outcp = encode_character(*incp, outcp, output_max);
break;
case WHERE_IN_COMMENT:
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
*outcp++ = *incp;
break;
case WHERE_IN_TAG_AT_EQUALS:
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
attr_value_start = *inwcp;
*outcp++ = *incp;
attr_value_start = *incp;
where_in_tag = WHERE_IN_TAG_IN_ATTRIBUTE_VALUE;
break;
case WHERE_IN_TAG_IN_ATTRIBUTE_VALUE:
if(*(inwcp-1) == '\\') {
/* This covers the case where the quote is backslash
escaped. */
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
}
else if(attr_value_start == *inwcp) {
if(*(incp-1) == '\\')
/* This covers the case where the quote is backslash escaped. */
*outcp++ = *incp;
else if(attr_value_start == *incp) {
/* If the quote is the same type of quote that started
the attribute value and it is not backslash
escaped, it signals the end of the attribute value */
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
*outcp++ = *incp;
where_in_tag = WHERE_IN_TAG_OUTSIDE_ATTRIBUTE;
}
else {
/* If we encounter an quote that did not start the
attribute value and is not backslash escaped,
use it as is */
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
}
break;
default:
if (tag_depth > 0 && !wcscmp(tagname, L"script"))
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
else
outstp = encode_character(*inwcp, outstp, output_max);
/* If we encounter an quote that did not start the attribute
value and is not backslash escaped, use it as is */
*outcp++ = *incp;
break;
default:
if (tag_depth > 0 && !strcmp(tagname, "script"))
*outcp++ = *incp;
else
outcp = encode_character(*incp, outcp, output_max);
break;
}
}
/* newlines turn to <BR> tags */
else if(escape_newlines == TRUE && '\n' == *inwcp) {
strncpy( outstp, "<BR>", 4);
outstp += 4;
else if(escape_newlines == TRUE && *incp == '\n') {
strncpy( outcp, "<BR>", 4);
outcp += 4;
}
else if(escape_newlines == TRUE && '\\' == *inwcp && '\n' == *( inwcp + 1)) {
strncpy( outstp, "<BR>", 4);
outstp += 4;
inwcp++; /* needed so loop skips two wide characters */
else if(escape_newlines == TRUE && *incp == '\\' && *(incp + 1) == '\n') {
strncpy( outcp, "<BR>", 4);
outcp += 4;
incp++; /* needed so loop skips two characters */
}
/* TODO - strip all but allowed HTML tags out... */
else if(('<' == *inwcp) && (FALSE == escape_html_tags)) {
else if (*incp == '<' && escape_html_tags == FALSE) {
switch(where_in_tag) {
case WHERE_OUTSIDE_TAG:
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
*outcp++ = *incp;
where_in_tag = WHERE_IN_TAG_NAME;
switch(*(inwcp+1)) {
switch(*(incp+1)) {
case '/':
tag_depth--;
break;
@ -1281,68 +1271,73 @@ char * html_encode(char *input, int escape_newlines) {
break;
default:
tag_depth++;
tagname = inwcp + 1;
tagname = incp + 1;
break;
}
break;
default:
if (tag_depth > 0 && !wcscmp(tagname, L"script"))
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
if (tag_depth > 0 && !strcmp(tagname, "script"))
*outcp++ = *incp;
else
outstp = encode_character(*inwcp, outstp, output_max);
outcp = encode_character(*incp, outcp, output_max);
break;
}
}
else if(('>' == *inwcp) && (FALSE == escape_html_tags)) {
else if( *incp == '>' && escape_html_tags == FALSE) {
switch(where_in_tag) {
case WHERE_IN_TAG_NAME:
case WHERE_IN_TAG_OUTSIDE_ATTRIBUTE:
case WHERE_IN_COMMENT:
case WHERE_IN_TAG_IN_ATTRIBUTE_NAME:
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
*outcp++ = *incp;
where_in_tag = WHERE_OUTSIDE_TAG;
*inwcp = 0;
*incp = 0;
break;
case WHERE_IN_TAG_IN_ATTRIBUTE_VALUE:
if((attr_value_start != '"') && (attr_value_start != '\'')) {
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
*outcp++ = *incp;
where_in_tag = WHERE_OUTSIDE_TAG;
}
else {
outstp = encode_character(*inwcp, outstp, output_max);
}
break;
default:
if (tag_depth > 0 && !wcscmp(tagname, L"script"))
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
else
outstp = encode_character(*inwcp, outstp, output_max);
outcp = encode_character(*incp, outcp, output_max);
break;
default:
if (tag_depth > 0 && !strcmp(tagname, "script"))
*outcp++ = *incp;
else
outcp = encode_character(*incp, outcp, output_max);
break;
}
}
/* check_multi puts out a '&ndash' so don't encode the '&' in that case */
else if (*inwcp == '&' && escape_html_tags == FALSE) {
if (tag_depth > 0 && !wcsncmp(inwcp, L"&ndash", 6))
outstp = copy_wc_to_output(*inwcp, outstp, output_max);
else if (*incp == '&' && escape_html_tags == FALSE) {
if (tag_depth > 0 && !strcmp(incp, "&ndash"))
*outcp++ = *incp;
else
outstp = encode_character(*inwcp, outstp, output_max);
outcp = encode_character(*incp, outcp, output_max);
}
else if ((unsigned char)*incp > 0x7f)
/* pass through UTF-8 characters */
*outcp++ = *incp;
/* for simplicity, all other chars represented by their numeric value */
else {
outstp = encode_character(*inwcp, outstp, output_max);
}
else
outcp = encode_character(*incp, outcp, output_max);
}
/* Null terminate the encoded string */
*outstp = '\x0';
*outcp = '\x0';
encoded_html_string[ output_max - 1] = '\x0';
return encoded_html_string;
}
}

View File

@ -689,6 +689,7 @@ int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *ar
/* HOST MACROS */
/***************/
case MACRO_HOSTGROUPNAMES:
case MACRO_HOSTINFOURL:
*free_macro = TRUE;
case MACRO_HOSTNAME:
case MACRO_HOSTALIAS:
@ -828,6 +829,7 @@ int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *ar
/* SERVICE MACROS */
/******************/
case MACRO_SERVICEGROUPNAMES:
case MACRO_SERVICEINFOURL:
*free_macro = TRUE;
case MACRO_SERVICEDESC:
case MACRO_SERVICESTATE:
@ -1813,6 +1815,12 @@ int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host *temp_ho
*output = (char *)mkstr("%u", temp_host->hourly_value +
host_services_value(temp_host));
break;
case MACRO_HOSTINFOURL:
buf1 = get_url_encoded_string(temp_host->name);
asprintf(output, "%s/cgi-bin/extinfo.cgi?type=1&host=%s",
website_url ? website_url : "website_url not set", buf1);
my_free(buf1);
break;
#endif
/***************/
@ -2145,6 +2153,21 @@ int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, service *t
case MACRO_SERVICEIMPORTANCE:
*output = (char *)mkstr("%u", temp_service->hourly_value);
break;
case MACRO_SERVICEINFOURL:
buf1 = get_url_encoded_string(temp_service->host_name);
buf2 = get_url_encoded_string(temp_service->description);
asprintf(output, "%s/cgi-bin/extinfo.cgi?type=2&host=%s&service=%s",
website_url ? website_url : "website_url not set",
buf1, buf2);
my_free(buf1);
my_free(buf2);
break;
my_free(buf1);
break;
#endif
/***************/
@ -2778,6 +2801,8 @@ int init_macrox_names(void) {
add_macrox_name(SERVICEIMPORTANCE);
add_macrox_name(HOSTANDSERVICESIMPORTANCE);
add_macrox_name(HOSTGROUPMEMBERADDRESSES);
add_macrox_name(HOSTINFOURL);
add_macrox_name(SERVICEINFOURL);
return OK;
}

21
configure vendored
View File

@ -1405,7 +1405,8 @@ Optional Packages:
sets path to check results spool directory
--with-temp-dir=<path> sets path to temp directory
--with-init-dir=<path> sets directory to place init script into
--with-lockfile=<path> sets path and file name for lock file
--with-lockfile=<path> sets path for lock file (default:
[/var]/run/nagios.lock)
--with-iobroker=<method>
specify the method to use with iobroker: epoll,
poll, or select
@ -2353,9 +2354,9 @@ ac_config_headers="$ac_config_headers include/config.h lib/snprintf.h lib/iobrok
PKG_NAME=nagios
PKG_VERSION="4.3.2"
PKG_VERSION="4.3.4"
PKG_HOME_URL="https://www.nagios.org/"
PKG_REL_DATE="2017-05-09"
PKG_REL_DATE="2017-08-24"
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@ -4942,11 +4943,17 @@ fi
default_lockfile_path=/var/run/nagios.lock
if test -d /run; then
default_lockfile_path=/run/nagios.lock
fi
# Check whether --with-lockfile was given.
if test "${with_lockfile+set}" = set; then :
withval=$with_lockfile; lockfile=$withval
else
lockfile=$localstatedir/nagios.lock
lockfile=$default_lockfile_path
fi
@ -4954,7 +4961,6 @@ fi
case $host_os in
linux*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for glibc at least version 2.4" >&5
@ -5978,7 +5984,7 @@ if test -z "$UNZIP"; then
as_fn_error $? "Cannot continue without unzip!" "$LINENO" 5
fi
ac_config_files="$ac_config_files Makefile lib/Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile worker/Makefile worker/ping/Makefile xdata/Makefile daemon-init t/Makefile t-tap/Makefile"
ac_config_files="$ac_config_files Makefile lib/Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile worker/Makefile worker/ping/Makefile xdata/Makefile daemon-init openrc-init t/Makefile t-tap/Makefile"
@ -6604,6 +6610,7 @@ do
"worker/ping/Makefile") CONFIG_FILES="$CONFIG_FILES worker/ping/Makefile" ;;
"xdata/Makefile") CONFIG_FILES="$CONFIG_FILES xdata/Makefile" ;;
"daemon-init") CONFIG_FILES="$CONFIG_FILES daemon-init" ;;
"openrc-init") CONFIG_FILES="$CONFIG_FILES openrc-init" ;;
"t/Makefile") CONFIG_FILES="$CONFIG_FILES t/Makefile" ;;
"t-tap/Makefile") CONFIG_FILES="$CONFIG_FILES t-tap/Makefile" ;;
@ -7363,8 +7370,6 @@ perl subst sample-config/template-object/printer.cfg
perl subst sample-config/template-object/switch.cfg
echo ""
echo ""
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: *** Configuration summary for $PKG_NAME $PKG_VERSION $PKG_REL_DATE ***:" >&5

View File

@ -10,9 +10,9 @@ AC_PREFIX_DEFAULT(/usr/local/nagios)
PKG_NAME=nagios
PKG_VERSION="4.3.2"
PKG_VERSION="4.3.4"
PKG_HOME_URL="https://www.nagios.org/"
PKG_REL_DATE="2017-05-09"
PKG_REL_DATE="2017-08-24"
dnl Figure out how to invoke "install" and what install options to use.
AC_PROG_INSTALL
@ -265,15 +265,22 @@ AC_ARG_WITH(init_dir,
AC_SUBST(init_dir)
dnl User can override lock file location
dnl Use the /var/run/ path by default
dnl and use /run if it is available
default_lockfile_path=/var/run/nagios.lock
if test -d /run; then
default_lockfile_path=/run/nagios.lock
fi
AC_ARG_WITH(lockfile,
AC_HELP_STRING([--with-lockfile=<path>],
[sets path and file name for lock file]),
[sets path for lock file (default: [/var]/run/nagios.lock)]),
lockfile=$withval,
lockfile=$localstatedir/nagios.lock
lockfile=$default_lockfile_path
)
AC_SUBST(lockfile)
dnl Determine the library to be used by the iobroker
dnl epoll_*() is linux specific and was added to glibc 2.3.2, so we
@ -794,7 +801,7 @@ if test -z "$UNZIP"; then
AC_MSG_ERROR([Cannot continue without unzip!])
fi
AC_OUTPUT(Makefile lib/Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile worker/Makefile worker/ping/Makefile xdata/Makefile daemon-init t/Makefile t-tap/Makefile)
AC_OUTPUT(Makefile lib/Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile worker/Makefile worker/ping/Makefile xdata/Makefile daemon-init openrc-init t/Makefile t-tap/Makefile)
perl subst include/locations.h
@ -821,8 +828,6 @@ perl subst sample-config/template-object/printer.cfg
perl subst sample-config/template-object/switch.cfg
dnl Review options
echo ""
echo ""

View File

@ -91,6 +91,10 @@ check_config ()
echo "ERROR: Could not delete '$NagiosCfgtestFile'"
exit 8
fi
if ! su $NagiosUser -c "touch $NagiosCfgtestFile"; then
echo "ERROR: Could not create or update '$NagiosCfgtestFile'"
exit 8
fi
TMPFILE=$(mktemp /tmp/.configtest.XXXXXXXX)
$NagiosBin -vp $NagiosCfgFile > "$TMPFILE"
@ -99,24 +103,18 @@ check_config ()
if test "$WARN" = "0" && test "${ERR}" = "0"; then
echo "OK - Configuration check verified" > $NagiosCfgtestFile
chmod 0644 $NagiosCfgtestFile
chown -h $NagiosUser:$NagiosGroup $NagiosCfgtestFile
/bin/rm "$TMPFILE"
return 0
elif test "${ERR}" = "0"; then
# Write the errors to a file we can have a script watching for.
echo "WARNING: Warnings in config files - see log for details: $NagiosCfgtestFile" > $NagiosCfgtestFile
egrep -i "(^warning|^error)" "$TMPFILE" >> $NagiosCfgtestFile
chmod 0644 $NagiosCfgtestFile
chown -h $NagiosUser:$NagiosGroup $NagiosCfgtestFile
/bin/rm "$TMPFILE"
return 0
else
# Write the errors to a file we can have a script watching for.
echo "ERROR: Errors in config files - see log for details: $NagiosCfgtestFile" > $NagiosCfgtestFile
egrep -i "(^warning|^error)" "$TMPFILE" >> $NagiosCfgtestFile
chmod 0644 $NagiosCfgtestFile
chown -h $NagiosUser:$NagiosGroup $NagiosCfgtestFile
cat "$TMPFILE"
exit 8
fi
@ -209,10 +207,9 @@ case "$1" in
fi
fi
touch $NagiosVarDir/nagios.log $NagiosRetentionFile
su $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"
remove_commandfile
touch $NagiosRunFile
chown -h $NagiosUser:$NagiosGroup $NagiosRunFile $NagiosVarDir/nagios.log $NagiosRetentionFile
$NagiosBin -d $NagiosCfgFile
if [ -d $NagiosLockDir ]; then touch $NagiosLockDir/$NagiosLockFile; fi

View File

@ -1,5 +1,5 @@
PROJECT_NAME = Nagios
PROJECT_NUMBER = 4.3.2
PROJECT_NUMBER = 4.3.4
PROJECT_BRIEF = "Dev docs for Nagios core and neb-module hackers"
INPUT = lib/ docs/

View File

@ -7,10 +7,10 @@ angular.module("mapApp")
cgiurl: "@cgiurl",
layoutIndex: "@layout",
dimensions: "@dimensions",
ulxValue: "@ulx",
ulyValue: "@uly",
lrxValue: "@lrx",
lryValue: "@lry",
ulx: "@ulx",
uly: "@uly",
lrx: "@lrx",
lry: "@lry",
root: "=root",
maxzoom: "=maxzoom",
nolinks: "@nolinks",

View File

@ -1,7 +1,7 @@
<?php
include_once(dirname(__FILE__).'/includes/utils.inc.php');
$this_version = '4.3.2';
$this_version = '4.3.4';
$this_year = '2017';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
@ -140,7 +140,7 @@ $this_year = '2017';
<div id="currentversioninfo">
<div class="product">Nagios<sup><span style="font-size: small;">&reg;</span></sup> Core<sup><span style="font-size: small;">&trade;</span></sup></div>
<div class="version">Version <?php echo $this_version; ?></div>
<div class="releasedate">May 09, 2017</div>
<div class="releasedate">August 24, 2017</div>
<div class="checkforupdates"><a href="https://www.nagios.org/checkforupdates/?version=<?php echo $this_version; ?>&amp;product=nagioscore" target="_blank">Check for updates</a></div>
</div>

View File

@ -27,6 +27,18 @@
if ($layout > 10 || $layout < 0)
$layout = 6;
}
/* This allows a user supplied layout */
if (
filter_input(INPUT_GET, 'layout', FILTER_VALIDATE_INT) === 0 ||
filter_input(INPUT_GET, 'layout', FILTER_VALIDATE_INT, array(
"options" => array("min_range"=>1, "max_range"=>10)
)
)
) {
$layout = $_GET['layout'];
}
if ($layout == 4)
$layout = 6;
?>

View File

@ -1,7 +1,7 @@
<?php
include_once(dirname(__FILE__).'/includes/utils.inc.php');
$this_version = '4.3.2';
$this_version = '4.3.4';
$link_target = 'main';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

View File

@ -24,8 +24,8 @@
#include "shared.h"
#define PROGRAM_VERSION "4.3.2"
#define PROGRAM_MODIFICATION_DATE "2017-05-09"
#define PROGRAM_VERSION "4.3.4"
#define PROGRAM_MODIFICATION_DATE "2017-08-24"
NAGIOS_BEGIN_DECL
@ -66,6 +66,7 @@ extern int obsess_over_hosts;
extern int enable_timing_point;
extern char *config_file_dir;
extern char *website_url;
#ifdef HAVE_TZNAME
#ifdef CYGWIN

View File

@ -38,7 +38,7 @@
#define MAX_USER_MACROS 256 /* maximum number of $USERx$ macros */
#define MACRO_X_COUNT 157 /* size of macro_x[] array */
#define MACRO_X_COUNT 159 /* size of macro_x[] array */
NAGIOS_BEGIN_DECL
@ -218,6 +218,8 @@ typedef struct nagios_macros nagios_macros;
#define MACRO_SERVICEIMPORTANCE 154
#define MACRO_HOSTANDSERVICESIMPORTANCE 155
#define MACRO_HOSTGROUPMEMBERADDRESSES 156
#define MACRO_HOSTINFOURL 157
#define MACRO_SERVICEINFOURL 158
/************* MACRO CLEANING OPTIONS *****************/

View File

@ -21,7 +21,7 @@
Summary: Open Source host, service and network monitoring program
Name: nagios
Version: 4.3.2
Version: 4.3.4
Release: 2%{?dist}
License: GPL
Group: Applications/System

66
openrc-init.in Normal file
View File

@ -0,0 +1,66 @@
#!/sbin/openrc-run
# This is a custom variable, and has the following default value if a
# specific config file is not defined by the user.
: ${NAGIOS_CONFIG:="@sysconfdir@/nagios.cfg"}
# These two facilitate the bindir variable substitution below.
prefix=@prefix@
exec_prefix=@exec_prefix@
# The rest are OpenRC variables.
extra_commands="checkconfig"
extra_started_commands="reload"
# We put "--daemon" in command_args and not command_args_background
# because the latter interacts weirdly with the config file argument.
command="@bindir@/nagios"
command_args="--daemon ${NAGIOS_CONFIG}"
pidfile="@lockfile@"
depend(){
# Most daemons don't really *need* the network; they're happy with
# the loopback interface. However, nagios might start generating
# "EVERYTHING IS DOWN" alerts if it starts before the real live
# network comes up.
need net
use logger
after mysql postgresql
}
reload(){
checkconfig || return $?
ebegin "Reloading configuration"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
checkconfig(){
ebegin "Verifying config files"
# Save the output in case verification fails and errors are printed.
OUTPUT=$( ${command} --verify-config "${NAGIOS_CONFIG}" )
# Save the exit code from the verification so that `echo` doesn't
# clobber it. Then, if verification failed, show its
# output. Otherwise, succeed quietly.
local exit_code=$?
[ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2
eend $exit_code
}
start_pre() {
# Without this, the "start" action will appear to succeed even if
# the config file contains errors, and the daemon fails to start.
# Another approach would be to wait for the PID file to appear, but
# this is fast enough and feels cleaner.
checkconfig || return $?
}
stop_pre() {
# If this is a restart, check to make sure the user's config
# isn't busted before we stop the running daemon.
if [ "${RC_CMD}" = "restart" ] ; then
checkconfig || return $?
fi
}

View File

@ -12,10 +12,10 @@ else
fi
# Current version number
CURRENTVERSION=4.3.2
CURRENTVERSION=4.3.4
# Last date
LASTDATE=2017-05-09
LASTDATE=2017-08-24
if [ "x$1" = "x" ]
then

View File

@ -679,12 +679,28 @@ int xodtemplate_process_config_file(char *filename, int options) {
}
/* check validity of object type */
if(strcmp(input, "timeperiod") && strcmp(input, "command") && strcmp(input, "contact") && strcmp(input, "contactgroup") && strcmp(input, "host") && strcmp(input, "hostgroup") && strcmp(input, "servicegroup") && strcmp(input, "service") && strcmp(input, "servicedependency") && strcmp(input, "serviceescalation") && strcmp(input, "hostgroupescalation") && strcmp(input, "hostdependency") && strcmp(input, "hostescalation")) {
if(strcmp(input, "hostextinfo") && strcmp(input, "serviceextinfo")) {
if( strcmp(input, "timeperiod")
&& strcmp(input, "command")
&& strcmp(input, "contact")
&& strcmp(input, "contactgroup")
&& strcmp(input, "host")
&& strcmp(input, "hostgroup")
&& strcmp(input, "servicegroup")
&& strcmp(input, "service")
&& strcmp(input, "servicedependency")
&& strcmp(input, "serviceescalation")
&& strcmp(input, "hostgroupescalation")
&& strcmp(input, "hostdependency")
&& strcmp(input, "hostescalation")) {
if ( strcmp(input, "hostextinfo")
&& strcmp(input, "serviceextinfo")) {
logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid object definition type '%s' in file '%s' on line %d.\n", input, filename, current_line);
result = ERROR;
break;
}
logit(NSLOG_CONFIG_WARNING, TRUE, "WARNING: Extinfo objects are deprecated and will be removed in future versions\n");
}
@ -2399,7 +2415,7 @@ int xodtemplate_add_object_property(char *input, int options) {
}
else if(!strcmp(variable, "retry_interval") || !strcmp(variable, "retry_check_interval")) {
if(!strcmp(variable, "retry_check_interval"))
logit(NSLOG_CONFIG_WARNING, TRUE, "WARNING: The normal_retry_interval attribute is deprecated and will be removed in future versions. Please use retry_interval instead.\n");
logit(NSLOG_CONFIG_WARNING, TRUE, "WARNING: The retry_check_interval attribute is deprecated and will be removed in future versions. Please use retry_interval instead.\n");
temp_host->retry_interval = strtod(value, NULL);
temp_host->have_retry_interval = TRUE;
}
@ -2858,7 +2874,7 @@ int xodtemplate_add_object_property(char *input, int options) {
}
else if(!strcmp(variable, "retry_interval") || !strcmp(variable, "retry_check_interval")) {
if(!strcmp(variable, "retry_check_interval"))
logit(NSLOG_CONFIG_WARNING, TRUE, "WARNING: The normal_retry_interval attribute is deprecated and will be removed in future versions. Please use retry_interval instead.\n");
logit(NSLOG_CONFIG_WARNING, TRUE, "WARNING: The retry_check_interval attribute is deprecated and will be removed in future versions. Please use retry_interval instead.\n");
temp_service->retry_interval = strtod(value, NULL);
temp_service->have_retry_interval = TRUE;
}

View File

@ -237,6 +237,7 @@ int xsddefault_save_status_data(void) {
fprintf(fp, "\tcheck_command=%s\n", (temp_host->check_command == NULL) ? "" : temp_host->check_command);
fprintf(fp, "\tcheck_period=%s\n", (temp_host->check_period == NULL) ? "" : temp_host->check_period);
fprintf(fp, "\tnotification_period=%s\n", (temp_host->notification_period == NULL) ? "" : temp_host->notification_period);
fprintf(fp, "\timportance=%u\n", temp_host->hourly_value);
fprintf(fp, "\tcheck_interval=%f\n", temp_host->check_interval);
fprintf(fp, "\tretry_interval=%f\n", temp_host->retry_interval);
fprintf(fp, "\tevent_handler=%s\n", (temp_host->event_handler == NULL) ? "" : temp_host->event_handler);
@ -303,6 +304,7 @@ int xsddefault_save_status_data(void) {
fprintf(fp, "\tcheck_command=%s\n", (temp_service->check_command == NULL) ? "" : temp_service->check_command);
fprintf(fp, "\tcheck_period=%s\n", (temp_service->check_period == NULL) ? "" : temp_service->check_period);
fprintf(fp, "\tnotification_period=%s\n", (temp_service->notification_period == NULL) ? "" : temp_service->notification_period);
fprintf(fp, "\timportance=%u\n", temp_service->hourly_value);
fprintf(fp, "\tcheck_interval=%f\n", temp_service->check_interval);
fprintf(fp, "\tretry_interval=%f\n", temp_service->retry_interval);
fprintf(fp, "\tevent_handler=%s\n", (temp_service->event_handler == NULL) ? "" : temp_service->event_handler);