Only in nagios-3.2.0-new: autom4te.cache diff --exclude=CVS -cr nagios-3.2.0/base/config.c nagios-3.2.0-new/base/config.c *** nagios-3.2.0/base/config.c 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/base/config.c 2009-08-09 19:01:13.000000000 -0400 *************** *** 31,37 **** #include "../include/nebmods.h" #include "../include/nebmodules.h" - extern char *log_file; extern char *command_file; extern char *temp_file; --- 31,36 ---- *************** *** 186,191 **** --- 185,198 ---- extern int date_format; extern char *use_timezone; + #ifdef HAVE_LDAP + extern LDAPURLDesc *ldap_config[6]; + extern int num_ldap_config; + extern LDAP *ldap_connection; + extern int num_ldap_connected; + /* y'know, I tried to include the right thing, but there's a tangle of LDAP_F and LDAP_DEPRECATED */ + char ** ldap_get_values (LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ); + #endif extern contact *contact_list; extern contactgroup *contactgroup_list; *************** *** 245,325 **** } ! /* process the main configuration file */ ! int read_main_config_file(char *main_config_file){ ! char *input=NULL; ! char *variable=NULL; ! char *value=NULL; ! char *error_message=NULL; ! char *temp_ptr=NULL; ! mmapfile *thefile=NULL; ! int current_line=0; ! int error=FALSE; ! int command_check_interval_is_seconds=FALSE; char *modptr=NULL; char *argptr=NULL; DIR *tmpdir=NULL; - - - /* 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; - } - - /* save the main config file macro */ - my_free(macro_x[MACRO_MAINCONFIGFILE]); - if((macro_x[MACRO_MAINCONFIGFILE]=(char *)strdup(main_config_file))) - strip(macro_x[MACRO_MAINCONFIGFILE]); - - /* process all lines in the config file */ - while(1){ - - /* free memory */ - my_free(input); - my_free(variable); - my_free(value); - - /* read the next line */ - if((input=mmap_fgets_multiline(thefile))==NULL) - break; - - current_line=thefile->current_line; - - strip(input); - - /* skip blank lines and comments */ - if(input[0]=='\x0' || input[0]=='#') - continue; - - /* get the variable name */ - if((temp_ptr=my_strtok(input,"="))==NULL){ - asprintf(&error_message,"NULL variable"); - error=TRUE; - break; - } - if((variable=(char *)strdup(temp_ptr))==NULL){ - asprintf(&error_message,"malloc() error"); - error=TRUE; - break; - } - - /* get the value */ - if((temp_ptr=my_strtok(NULL,"\n"))==NULL){ - asprintf(&error_message,"NULL value"); - error=TRUE; - break; - } - if((value=(char *)strdup(temp_ptr))==NULL){ - asprintf(&error_message,"malloc() error"); - error=TRUE; - break; - } - strip(variable); - strip(value); - - /* process the variable/value */ - if(!strcmp(variable,"resource_file")){ /* save the macro */ --- 252,262 ---- } ! /* process the variable/value */ ! int process_config_variable_value(char * variable, char * value, char **error_message, int *command_check_interval_is_seconds){ char *modptr=NULL; char *argptr=NULL; DIR *tmpdir=NULL; if(!strcmp(variable,"resource_file")){ /* save the macro */ *************** *** 330,341 **** read_resource_file(value); } else if(!strcmp(variable,"log_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Log file is too long"); ! error=TRUE; ! break; } my_free(log_file); --- 267,321 ---- read_resource_file(value); } + #ifdef HAVE_LDAP + else if(!strcmp(variable,"ldap_server")){ + int res; + + /* + * save the macro + * + * I would prefer at this point to cut upp the value in case two URIs are + * given. As well, multiple ldap_server values could be given. We really + * should ignore this like an external object file, and read it later, but I + * want to do this early so we can poll the monitor config and get additional + * options early enough. This will require some recursion to parse in the + * config content before the sanity-check below + * + * for now, just get the config in for later XOD harvesting + */ + if (0 == ldap_is_ldap_url( value )) { + asprintf(error_message,"ldap url \"%s\" is not a valid url", value); + return TRUE; + } + if (num_ldap_config >= (sizeof(ldap_config)/sizeof(ldap_config[0]))) { + asprintf(error_message,"hard-limited to %d ldap servers", (sizeof(ldap_config)/sizeof(ldap_config[0]))); + return TRUE; + } + switch ((res = ldap_url_parse(value, &(ldap_config[num_ldap_config])))) { + case LDAP_SUCCESS: /* happy happy, la la la */ + num_ldap_config++; + break; + case LDAP_URL_ERR_BADSCHEME: + asprintf(error_message,"ldap rfc2255 url \"%s\" failed to convert (URL doesn't begin with \"ldap://\")", value); + return TRUE; + case LDAP_URL_ERR_BADSCOPE: + asprintf(error_message,"ldap rfc2255 url \"%s\" failed to convert (URL scope string is invalid)", value); + return TRUE; + case LDAP_URL_ERR_MEM: + asprintf(error_message,"ldap rfc2255 url \"%s\" failed to convert (can't allocate memory space)", value); + return TRUE; + default: + asprintf(error_message,"ldap rfc2255 url \"%s\" failed to convert (unknown code %d)", value, res); + return TRUE; + } + } + #endif + else if(!strcmp(variable,"log_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Log file is too long"); ! return TRUE; } my_free(log_file); *************** *** 355,363 **** else if(!strcmp(variable,"debug_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Debug log file is too long"); ! error=TRUE; ! break; } my_free(debug_file); --- 335,342 ---- else if(!strcmp(variable,"debug_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Debug log file is too long"); ! return TRUE; } my_free(debug_file); *************** *** 370,378 **** else if(!strcmp(variable,"command_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Command file is too long"); ! error=TRUE; ! break; } my_free(command_file); --- 349,356 ---- else if(!strcmp(variable,"command_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Command file is too long"); ! return TRUE; } my_free(command_file); *************** *** 386,394 **** else if(!strcmp(variable,"temp_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Temp file is too long"); ! error=TRUE; ! break; } my_free(temp_file); --- 364,371 ---- else if(!strcmp(variable,"temp_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Temp file is too long"); ! return TRUE; } my_free(temp_file); *************** *** 402,416 **** else if(!strcmp(variable,"temp_path")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Temp path is too long"); ! error=TRUE; ! break; } if((tmpdir=opendir((char *)value))==NULL){ ! asprintf(&error_message,"Temp path is not a valid directory"); ! error=TRUE; ! break; } closedir(tmpdir); --- 379,391 ---- else if(!strcmp(variable,"temp_path")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Temp path is too long"); ! return TRUE; } if((tmpdir=opendir((char *)value))==NULL){ ! asprintf(error_message,"Temp path is not a valid directory"); ! return TRUE; } closedir(tmpdir); *************** *** 430,444 **** else if(!strcmp(variable,"check_result_path")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Check result path is too long"); ! error=TRUE; ! break; } if((tmpdir=opendir((char *)value))==NULL){ ! asprintf(&error_message,"Check result path is not a valid directory"); ! error=TRUE; ! break; } closedir(tmpdir); --- 405,417 ---- else if(!strcmp(variable,"check_result_path")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Check result path is too long"); ! return TRUE; } if((tmpdir=opendir((char *)value))==NULL){ ! asprintf(error_message,"Check result path is not a valid directory"); ! return TRUE; } closedir(tmpdir); *************** *** 460,468 **** else if(!strcmp(variable,"lock_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Lock file is too long"); ! error=TRUE; ! break; } my_free(lock_file); --- 433,440 ---- else if(!strcmp(variable,"lock_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Lock file is too long"); ! return TRUE; } my_free(lock_file); *************** *** 515,524 **** else if(!strcmp(variable,"use_syslog")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for use_syslog"); ! error=TRUE; ! break; } use_syslog=(atoi(value)>0)?TRUE:FALSE; --- 487,497 ---- else if(!strcmp(variable,"use_syslog")){ ! if (0 == strcasecmp (value, "true")) use_syslog=TRUE; ! else if (0 == strcasecmp (value, "false")) use_syslog=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for use_syslog"); ! return TRUE; } use_syslog=(atoi(value)>0)?TRUE:FALSE; *************** *** 526,535 **** else if(!strcmp(variable,"log_notifications")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for log_notifications"); ! error=TRUE; ! break; } log_notifications=(atoi(value)>0)?TRUE:FALSE; --- 499,509 ---- else if(!strcmp(variable,"log_notifications")){ ! if (0 == strcasecmp (value, "true")) log_notifications=TRUE; ! else if (0 == strcasecmp (value, "false")) log_notifications=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for log_notifications"); ! return TRUE; } log_notifications=(atoi(value)>0)?TRUE:FALSE; *************** *** 537,546 **** else if(!strcmp(variable,"log_service_retries")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for log_service_retries"); ! error=TRUE; ! break; } log_service_retries=(atoi(value)>0)?TRUE:FALSE; --- 511,521 ---- else if(!strcmp(variable,"log_service_retries")){ ! if (0 == strcasecmp (value, "true")) log_service_retries=TRUE; ! else if (0 == strcasecmp (value, "false")) log_service_retries=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for log_service_retries"); ! return TRUE; } log_service_retries=(atoi(value)>0)?TRUE:FALSE; *************** *** 548,557 **** else if(!strcmp(variable,"log_host_retries")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for log_host_retries"); ! error=TRUE; ! break; } log_host_retries=(atoi(value)>0)?TRUE:FALSE; --- 523,533 ---- else if(!strcmp(variable,"log_host_retries")){ ! if (0 == strcasecmp (value, "true")) log_host_retries=TRUE; ! else if (0 == strcasecmp (value, "false")) log_host_retries=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for log_host_retries"); ! return TRUE; } log_host_retries=(atoi(value)>0)?TRUE:FALSE; *************** *** 559,568 **** else if(!strcmp(variable,"log_event_handlers")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for log_event_handlers"); ! error=TRUE; ! break; } log_event_handlers=(atoi(value)>0)?TRUE:FALSE; --- 535,545 ---- else if(!strcmp(variable,"log_event_handlers")){ ! if (0 == strcasecmp (value, "true")) log_event_handlers=TRUE; ! else if (0 == strcasecmp (value, "false")) log_event_handlers=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for log_event_handlers"); ! return TRUE; } log_event_handlers=(atoi(value)>0)?TRUE:FALSE; *************** *** 570,579 **** else if(!strcmp(variable,"log_external_commands")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for log_external_commands"); ! error=TRUE; ! break; } log_external_commands=(atoi(value)>0)?TRUE:FALSE; --- 547,557 ---- else if(!strcmp(variable,"log_external_commands")){ ! if (0 == strcasecmp (value, "true")) log_external_commands=TRUE; ! else if (0 == strcasecmp (value, "false")) log_external_commands=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for log_external_commands"); ! return TRUE; } log_external_commands=(atoi(value)>0)?TRUE:FALSE; *************** *** 581,590 **** else if(!strcmp(variable,"log_passive_checks")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for log_passive_checks"); ! error=TRUE; ! break; } log_passive_checks=(atoi(value)>0)?TRUE:FALSE; --- 559,569 ---- else if(!strcmp(variable,"log_passive_checks")){ ! if (0 == strcasecmp (value, "true")) log_passive_checks=TRUE; ! else if (0 == strcasecmp (value, "false")) log_passive_checks=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for log_passive_checks"); ! return TRUE; } log_passive_checks=(atoi(value)>0)?TRUE:FALSE; *************** *** 592,601 **** else if(!strcmp(variable,"log_initial_states")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for log_initial_states"); ! error=TRUE; ! break; } log_initial_states=(atoi(value)>0)?TRUE:FALSE; --- 571,581 ---- else if(!strcmp(variable,"log_initial_states")){ ! if (0 == strcasecmp (value, "true")) log_initial_states=TRUE; ! else if (0 == strcasecmp (value, "false")) log_initial_states=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for log_initial_states"); ! return TRUE; } log_initial_states=(atoi(value)>0)?TRUE:FALSE; *************** *** 603,612 **** else if(!strcmp(variable,"retain_state_information")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for retain_state_information"); ! error=TRUE; ! break; } retain_state_information=(atoi(value)>0)?TRUE:FALSE; --- 583,593 ---- else if(!strcmp(variable,"retain_state_information")){ ! if (0 == strcasecmp (value, "true")) retain_state_information=TRUE; ! else if (0 == strcasecmp (value, "false")) retain_state_information=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for retain_state_information"); ! return TRUE; } retain_state_information=(atoi(value)>0)?TRUE:FALSE; *************** *** 616,633 **** retention_update_interval=atoi(value); if(retention_update_interval<0){ ! asprintf(&error_message,"Illegal value for retention_update_interval"); ! error=TRUE; ! break; } } else if(!strcmp(variable,"use_retained_program_state")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for use_retained_program_state"); ! error=TRUE; ! break; } use_retained_program_state=(atoi(value)>0)?TRUE:FALSE; --- 597,614 ---- retention_update_interval=atoi(value); if(retention_update_interval<0){ ! asprintf(error_message,"Illegal value for retention_update_interval"); ! return TRUE; } } else if(!strcmp(variable,"use_retained_program_state")){ ! if (0 == strcasecmp (value, "true")) use_retained_program_state=TRUE; ! else if (0 == strcasecmp (value, "false")) use_retained_program_state=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for use_retained_program_state"); ! return TRUE; } use_retained_program_state=(atoi(value)>0)?TRUE:FALSE; *************** *** 635,644 **** else if(!strcmp(variable,"use_retained_scheduling_info")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for use_retained_scheduling_info"); ! error=TRUE; ! break; } use_retained_scheduling_info=(atoi(value)>0)?TRUE:FALSE; --- 616,626 ---- else if(!strcmp(variable,"use_retained_scheduling_info")){ ! if (0 == strcasecmp (value, "true")) use_retained_scheduling_info=TRUE; ! else if (0 == strcasecmp (value, "false")) use_retained_scheduling_info=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for use_retained_scheduling_info"); ! return TRUE; } use_retained_scheduling_info=(atoi(value)>0)?TRUE:FALSE; *************** *** 649,657 **** retention_scheduling_horizon=atoi(value); if(retention_scheduling_horizon<=0){ ! asprintf(&error_message,"Illegal value for retention_scheduling_horizon"); ! error=TRUE; ! break; } } --- 631,638 ---- retention_scheduling_horizon=atoi(value); if(retention_scheduling_horizon<=0){ ! asprintf(error_message,"Illegal value for retention_scheduling_horizon"); ! return TRUE; } } *************** *** 678,687 **** else if(!strcmp(variable,"obsess_over_services")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for obsess_over_services"); ! error=TRUE; ! break; } obsess_over_services=(atoi(value)>0)?TRUE:FALSE; --- 659,669 ---- else if(!strcmp(variable,"obsess_over_services")){ ! if (0 == strcasecmp (value, "true")) obsess_over_services=TRUE; ! else if (0 == strcasecmp (value, "false")) obsess_over_services=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for obsess_over_services"); ! return TRUE; } obsess_over_services=(atoi(value)>0)?TRUE:FALSE; *************** *** 689,698 **** else if(!strcmp(variable,"obsess_over_hosts")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for obsess_over_hosts"); ! error=TRUE; ! break; } obsess_over_hosts=(atoi(value)>0)?TRUE:FALSE; --- 671,681 ---- else if(!strcmp(variable,"obsess_over_hosts")){ ! if (0 == strcasecmp (value, "true")) obsess_over_hosts=TRUE; ! else if (0 == strcasecmp (value, "false")) obsess_over_hosts=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for obsess_over_hosts"); ! return TRUE; } obsess_over_hosts=(atoi(value)>0)?TRUE:FALSE; *************** *** 700,709 **** else if(!strcmp(variable,"translate_passive_host_checks")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for translate_passive_host_checks"); ! error=TRUE; ! break; } translate_passive_host_checks=(atoi(value)>0)?TRUE:FALSE; --- 683,693 ---- else if(!strcmp(variable,"translate_passive_host_checks")){ ! if (0 == strcasecmp (value, "true")) translate_passive_host_checks=TRUE; ! else if (0 == strcasecmp (value, "false")) translate_passive_host_checks=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for translate_passive_host_checks"); ! return TRUE; } translate_passive_host_checks=(atoi(value)>0)?TRUE:FALSE; *************** *** 717,725 **** service_check_timeout=atoi(value); if(service_check_timeout<=0){ ! asprintf(&error_message,"Illegal value for service_check_timeout"); ! error=TRUE; ! break; } } --- 701,708 ---- service_check_timeout=atoi(value); if(service_check_timeout<=0){ ! asprintf(error_message,"Illegal value for service_check_timeout"); ! return TRUE; } } *************** *** 728,736 **** host_check_timeout=atoi(value); if(host_check_timeout<=0){ ! asprintf(&error_message,"Illegal value for host_check_timeout"); ! error=TRUE; ! break; } } --- 711,718 ---- host_check_timeout=atoi(value); if(host_check_timeout<=0){ ! asprintf(error_message,"Illegal value for host_check_timeout"); ! return TRUE; } } *************** *** 739,747 **** event_handler_timeout=atoi(value); if(event_handler_timeout<=0){ ! asprintf(&error_message,"Illegal value for event_handler_timeout"); ! error=TRUE; ! break; } } --- 721,728 ---- event_handler_timeout=atoi(value); if(event_handler_timeout<=0){ ! asprintf(error_message,"Illegal value for event_handler_timeout"); ! return TRUE; } } *************** *** 750,758 **** notification_timeout=atoi(value); if(notification_timeout<=0){ ! asprintf(&error_message,"Illegal value for notification_timeout"); ! error=TRUE; ! break; } } --- 731,738 ---- notification_timeout=atoi(value); if(notification_timeout<=0){ ! asprintf(error_message,"Illegal value for notification_timeout"); ! return TRUE; } } *************** *** 761,769 **** ocsp_timeout=atoi(value); if(ocsp_timeout<=0){ ! asprintf(&error_message,"Illegal value for ocsp_timeout"); ! error=TRUE; ! break; } } --- 741,748 ---- ocsp_timeout=atoi(value); if(ocsp_timeout<=0){ ! asprintf(error_message,"Illegal value for ocsp_timeout"); ! return TRUE; } } *************** *** 772,789 **** ochp_timeout=atoi(value); if(ochp_timeout<=0){ ! asprintf(&error_message,"Illegal value for ochp_timeout"); ! error=TRUE; ! break; } } else if(!strcmp(variable,"use_agressive_host_checking") || !strcmp(variable,"use_aggressive_host_checking")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for use_aggressive_host_checking"); ! error=TRUE; ! break; } use_aggressive_host_checking=(atoi(value)>0)?TRUE:FALSE; --- 751,768 ---- ochp_timeout=atoi(value); if(ochp_timeout<=0){ ! asprintf(error_message,"Illegal value for ochp_timeout"); ! return TRUE; } } else if(!strcmp(variable,"use_agressive_host_checking") || !strcmp(variable,"use_aggressive_host_checking")){ ! if (0 == strcasecmp (value, "true")) use_aggressive_host_checking=TRUE; ! else if (0 == strcasecmp (value, "false")) use_aggressive_host_checking=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for use_aggressive_host_checking"); ! return TRUE; } use_aggressive_host_checking=(atoi(value)>0)?TRUE:FALSE; *************** *** 802,811 **** enable_predictive_service_dependency_checks=(atoi(value)>0)?TRUE:FALSE; else if(!strcmp(variable,"soft_state_dependencies")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for soft_state_dependencies"); ! error=TRUE; ! break; } soft_state_dependencies=(atoi(value)>0)?TRUE:FALSE; --- 781,791 ---- enable_predictive_service_dependency_checks=(atoi(value)>0)?TRUE:FALSE; else if(!strcmp(variable,"soft_state_dependencies")){ ! if (0 == strcasecmp (value, "true")) soft_state_dependencies=TRUE; ! else if (0 == strcasecmp (value, "false")) soft_state_dependencies=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for soft_state_dependencies"); ! return TRUE; } soft_state_dependencies=(atoi(value)>0)?TRUE:FALSE; *************** *** 823,840 **** else if(!strcmp(value,"m")) log_rotation_method=LOG_ROTATION_MONTHLY; else{ ! asprintf(&error_message,"Illegal value for log_rotation_method"); ! error=TRUE; ! break; } } else if(!strcmp(variable,"log_archive_path")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Log archive path too long"); ! error=TRUE; ! break; } my_free(log_archive_path); --- 803,818 ---- else if(!strcmp(value,"m")) log_rotation_method=LOG_ROTATION_MONTHLY; else{ ! asprintf(error_message,"Illegal value for log_rotation_method"); ! return TRUE; } } else if(!strcmp(variable,"log_archive_path")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Log archive path too long"); ! return TRUE; } my_free(log_archive_path); *************** *** 870,878 **** service_inter_check_delay_method=ICD_USER; scheduling_info.service_inter_check_delay=strtod(value,NULL); if(scheduling_info.service_inter_check_delay<=0.0){ ! asprintf(&error_message,"Illegal value for service_inter_check_delay_method"); ! error=TRUE; ! break; } } } --- 848,855 ---- service_inter_check_delay_method=ICD_USER; scheduling_info.service_inter_check_delay=strtod(value,NULL); if(scheduling_info.service_inter_check_delay<=0.0){ ! asprintf(error_message,"Illegal value for service_inter_check_delay_method"); ! return TRUE; } } } *************** *** 881,889 **** strip(value); max_service_check_spread=atoi(value); if(max_service_check_spread<1){ ! asprintf(&error_message,"Illegal value for max_service_check_spread"); ! error=TRUE; ! break; } } --- 858,865 ---- strip(value); max_service_check_spread=atoi(value); if(max_service_check_spread<1){ ! asprintf(error_message,"Illegal value for max_service_check_spread"); ! return TRUE; } } *************** *** 899,907 **** host_inter_check_delay_method=ICD_USER; scheduling_info.host_inter_check_delay=strtod(value,NULL); if(scheduling_info.host_inter_check_delay<=0.0){ ! asprintf(&error_message,"Illegal value for host_inter_check_delay_method"); ! error=TRUE; ! break; } } } --- 875,882 ---- host_inter_check_delay_method=ICD_USER; scheduling_info.host_inter_check_delay=strtod(value,NULL); if(scheduling_info.host_inter_check_delay<=0.0){ ! asprintf(error_message,"Illegal value for host_inter_check_delay_method"); ! return TRUE; } } } *************** *** 910,918 **** max_host_check_spread=atoi(value); if(max_host_check_spread<1){ ! asprintf(&error_message,"Illegal value for max_host_check_spread"); ! error=TRUE; ! break; } } --- 885,892 ---- max_host_check_spread=atoi(value); if(max_host_check_spread<1){ ! asprintf(error_message,"Illegal value for max_host_check_spread"); ! return TRUE; } } *************** *** 931,939 **** max_parallel_service_checks=atoi(value); if(max_parallel_service_checks<0){ ! asprintf(&error_message,"Illegal value for max_concurrent_checks"); ! error=TRUE; ! break; } } --- 905,912 ---- max_parallel_service_checks=atoi(value); if(max_parallel_service_checks<0){ ! asprintf(error_message,"Illegal value for max_concurrent_checks"); ! return TRUE; } } *************** *** 941,949 **** check_reaper_interval=atoi(value); if(check_reaper_interval<1){ ! asprintf(&error_message,"Illegal value for check_result_reaper_frequency"); ! error=TRUE; ! break; } } --- 914,921 ---- check_reaper_interval=atoi(value); if(check_reaper_interval<1){ ! asprintf(error_message,"Illegal value for check_result_reaper_frequency"); ! return TRUE; } } *************** *** 951,959 **** max_check_reaper_time=atoi(value); if(max_check_reaper_time<1){ ! asprintf(&error_message,"Illegal value for max_check_result_reaper_time"); ! error=TRUE; ! break; } } --- 923,930 ---- max_check_reaper_time=atoi(value); if(max_check_reaper_time<1){ ! asprintf(error_message,"Illegal value for max_check_result_reaper_time"); ! return TRUE; } } *************** *** 961,969 **** sleep_time=atof(value); if(sleep_time<=0.0){ ! asprintf(&error_message,"Illegal value for sleep_time"); ! error=TRUE; ! break; } } --- 932,939 ---- sleep_time=atof(value); if(sleep_time<=0.0){ ! asprintf(error_message,"Illegal value for sleep_time"); ! return TRUE; } } *************** *** 971,988 **** interval_length=atoi(value); if(interval_length<1){ ! asprintf(&error_message,"Illegal value for interval_length"); ! error=TRUE; ! break; } } else if(!strcmp(variable,"check_external_commands")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for check_external_commands"); ! error=TRUE; ! break; } check_external_commands=(atoi(value)>0)?TRUE:FALSE; --- 941,958 ---- interval_length=atoi(value); if(interval_length<1){ ! asprintf(error_message,"Illegal value for interval_length"); ! return TRUE; } } else if(!strcmp(variable,"check_external_commands")){ ! if (0 == strcasecmp (value, "true")) check_external_commands=TRUE; ! else if (0 == strcasecmp (value, "false")) check_external_commands=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for check_external_commands"); ! return TRUE; } check_external_commands=(atoi(value)>0)?TRUE:FALSE; *************** *** 990,1010 **** else if(!strcmp(variable,"command_check_interval")){ ! command_check_interval_is_seconds=(strstr(value,"s"))?TRUE:FALSE; command_check_interval=atoi(value); if(command_check_interval<-1 || command_check_interval==0){ ! asprintf(&error_message,"Illegal value for command_check_interval"); ! error=TRUE; ! break; } } else if(!strcmp(variable,"check_for_orphaned_services")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for check_for_orphaned_services"); ! error=TRUE; ! break; } check_orphaned_services=(atoi(value)>0)?TRUE:FALSE; --- 960,980 ---- else if(!strcmp(variable,"command_check_interval")){ ! *command_check_interval_is_seconds=(strstr(value,"s"))?TRUE:FALSE; command_check_interval=atoi(value); if(command_check_interval<-1 || command_check_interval==0){ ! asprintf(error_message,"Illegal value for command_check_interval"); ! return TRUE; } } else if(!strcmp(variable,"check_for_orphaned_services")){ ! if (0 == strcasecmp (value, "true")) check_orphaned_services=TRUE; ! else if (0 == strcasecmp (value, "false")) check_orphaned_services=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for check_for_orphaned_services"); ! return TRUE; } check_orphaned_services=(atoi(value)>0)?TRUE:FALSE; *************** *** 1012,1021 **** else if(!strcmp(variable,"check_for_orphaned_hosts")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for check_for_orphaned_hosts"); ! error=TRUE; ! break; } check_orphaned_hosts=(atoi(value)>0)?TRUE:FALSE; --- 982,992 ---- else if(!strcmp(variable,"check_for_orphaned_hosts")){ ! if (0 == strcasecmp (value, "true")) check_orphaned_hosts=TRUE; ! else if (0 == strcasecmp (value, "false")) check_orphaned_hosts=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for check_for_orphaned_hosts"); ! return TRUE; } check_orphaned_hosts=(atoi(value)>0)?TRUE:FALSE; *************** *** 1023,1032 **** else if(!strcmp(variable,"check_service_freshness")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for check_service_freshness"); ! error=TRUE; ! break; } check_service_freshness=(atoi(value)>0)?TRUE:FALSE; --- 994,1004 ---- else if(!strcmp(variable,"check_service_freshness")){ ! if (0 == strcasecmp (value, "true")) check_service_freshness=TRUE; ! else if (0 == strcasecmp (value, "false")) check_service_freshness=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for check_service_freshness"); ! return TRUE; } check_service_freshness=(atoi(value)>0)?TRUE:FALSE; *************** *** 1034,1043 **** else if(!strcmp(variable,"check_host_freshness")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for check_host_freshness"); ! error=TRUE; ! break; } check_host_freshness=(atoi(value)>0)?TRUE:FALSE; --- 1006,1016 ---- else if(!strcmp(variable,"check_host_freshness")){ ! if (0 == strcasecmp (value, "true")) check_host_freshness=TRUE; ! else if (0 == strcasecmp (value, "false")) check_host_freshness=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for check_host_freshness"); ! return TRUE; } check_host_freshness=(atoi(value)>0)?TRUE:FALSE; *************** *** 1047,1055 **** service_freshness_check_interval=atoi(value); if(service_freshness_check_interval<=0){ ! asprintf(&error_message,"Illegal value for service_freshness_check_interval"); ! error=TRUE; ! break; } } --- 1020,1027 ---- service_freshness_check_interval=atoi(value); if(service_freshness_check_interval<=0){ ! asprintf(error_message,"Illegal value for service_freshness_check_interval"); ! return TRUE; } } *************** *** 1057,1073 **** host_freshness_check_interval=atoi(value); if(host_freshness_check_interval<=0){ ! asprintf(&error_message,"Illegal value for host_freshness_check_interval"); ! error=TRUE; ! break; } } else if(!strcmp(variable,"auto_reschedule_checks")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for auto_reschedule_checks"); ! error=TRUE; ! break; } auto_reschedule_checks=(atoi(value)>0)?TRUE:FALSE; --- 1029,1045 ---- host_freshness_check_interval=atoi(value); if(host_freshness_check_interval<=0){ ! asprintf(error_message,"Illegal value for host_freshness_check_interval"); ! return TRUE; } } else if(!strcmp(variable,"auto_reschedule_checks")){ ! if (0 == strcasecmp (value, "true")) auto_reschedule_checks=TRUE; ! else if (0 == strcasecmp (value, "false")) auto_reschedule_checks=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for auto_reschedule_checks"); ! return TRUE; } auto_reschedule_checks=(atoi(value)>0)?TRUE:FALSE; *************** *** 1077,1085 **** auto_rescheduling_interval=atoi(value); if(auto_rescheduling_interval<=0){ ! asprintf(&error_message,"Illegal value for auto_rescheduling_interval"); ! error=TRUE; ! break; } } --- 1049,1056 ---- auto_rescheduling_interval=atoi(value); if(auto_rescheduling_interval<=0){ ! asprintf(error_message,"Illegal value for auto_rescheduling_interval"); ! return TRUE; } } *************** *** 1087,1095 **** auto_rescheduling_window=atoi(value); if(auto_rescheduling_window<=0){ ! asprintf(&error_message,"Illegal value for auto_rescheduling_window"); ! error=TRUE; ! break; } } --- 1058,1065 ---- auto_rescheduling_window=atoi(value); if(auto_rescheduling_window<=0){ ! asprintf(error_message,"Illegal value for auto_rescheduling_window"); ! return TRUE; } } *************** *** 1105,1113 **** status_update_interval=atoi(value); if(status_update_interval<=1){ ! asprintf(&error_message,"Illegal value for status_update_interval"); ! error=TRUE; ! break; } } --- 1075,1082 ---- status_update_interval=atoi(value); if(status_update_interval<=1){ ! asprintf(error_message,"Illegal value for status_update_interval"); ! return TRUE; } } *************** *** 1116,1124 **** time_change_threshold=atoi(value); if(time_change_threshold<=5){ ! asprintf(&error_message,"Illegal value for time_change_threshold"); ! error=TRUE; ! break; } } --- 1085,1092 ---- time_change_threshold=atoi(value); if(time_change_threshold<=5){ ! asprintf(error_message,"Illegal value for time_change_threshold"); ! return TRUE; } } *************** *** 1135,1143 **** low_service_flap_threshold=strtod(value,NULL); if(low_service_flap_threshold<=0.0 || low_service_flap_threshold>=100.0){ ! asprintf(&error_message,"Illegal value for low_service_flap_threshold"); ! error=TRUE; ! break; } } --- 1103,1110 ---- low_service_flap_threshold=strtod(value,NULL); if(low_service_flap_threshold<=0.0 || low_service_flap_threshold>=100.0){ ! asprintf(error_message,"Illegal value for low_service_flap_threshold"); ! return TRUE; } } *************** *** 1145,1153 **** high_service_flap_threshold=strtod(value,NULL); if(high_service_flap_threshold<=0.0 || high_service_flap_threshold>100.0){ ! asprintf(&error_message,"Illegal value for high_service_flap_threshold"); ! error=TRUE; ! break; } } --- 1112,1119 ---- high_service_flap_threshold=strtod(value,NULL); if(high_service_flap_threshold<=0.0 || high_service_flap_threshold>100.0){ ! asprintf(error_message,"Illegal value for high_service_flap_threshold"); ! return TRUE; } } *************** *** 1155,1163 **** low_host_flap_threshold=strtod(value,NULL); if(low_host_flap_threshold<=0.0 || low_host_flap_threshold>=100.0){ ! asprintf(&error_message,"Illegal value for low_host_flap_threshold"); ! error=TRUE; ! break; } } --- 1121,1128 ---- low_host_flap_threshold=strtod(value,NULL); if(low_host_flap_threshold<=0.0 || low_host_flap_threshold>=100.0){ ! asprintf(error_message,"Illegal value for low_host_flap_threshold"); ! return TRUE; } } *************** *** 1165,1173 **** high_host_flap_threshold=strtod(value,NULL); if(high_host_flap_threshold<=0.0 || high_host_flap_threshold>100.0){ ! asprintf(&error_message,"Illegal value for high_host_flap_threshold"); ! error=TRUE; ! break; } } --- 1130,1137 ---- high_host_flap_threshold=strtod(value,NULL); if(high_host_flap_threshold<=0.0 || high_host_flap_threshold>100.0){ ! asprintf(error_message,"Illegal value for high_host_flap_threshold"); ! return TRUE; } } *************** *** 1191,1199 **** else if(!strcmp(variable,"p1_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"P1 file is too long"); ! error=TRUE; ! break; } my_free(p1_file); --- 1155,1162 ---- else if(!strcmp(variable,"p1_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"P1 file is too long"); ! return TRUE; } my_free(p1_file); *************** *** 1231,1240 **** else if(!strcmp(variable,"daemon_dumps_core")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for daemon_dumps_core"); ! error=TRUE; ! break; } daemon_dumps_core=(atoi(value)>0)?TRUE:FALSE; --- 1194,1204 ---- else if(!strcmp(variable,"daemon_dumps_core")){ ! if (0 == strcasecmp (value, "true")) daemon_dumps_core=TRUE; ! else if (0 == strcasecmp (value, "false")) daemon_dumps_core=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for daemon_dumps_core"); ! return TRUE; } daemon_dumps_core=(atoi(value)>0)?TRUE:FALSE; *************** *** 1242,1251 **** else if(!strcmp(variable,"use_large_installation_tweaks")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for use_large_installation_tweaks "); ! error=TRUE; ! break; } use_large_installation_tweaks=(atoi(value)>0)?TRUE:FALSE; --- 1206,1216 ---- else if(!strcmp(variable,"use_large_installation_tweaks")){ ! if (0 == strcasecmp (value, "true")) use_large_installation_tweaks=TRUE; ! else if (0 == strcasecmp (value, "false")) use_large_installation_tweaks=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for use_large_installation_tweaks "); ! return TRUE; } use_large_installation_tweaks=(atoi(value)>0)?TRUE:FALSE; *************** *** 1262,1271 **** else if(!strcmp(variable,"enable_embedded_perl")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for enable_embedded_perl"); ! error=TRUE; ! break; } enable_embedded_perl=(atoi(value)>0)?TRUE:FALSE; --- 1227,1237 ---- else if(!strcmp(variable,"enable_embedded_perl")){ ! if (0 == strcasecmp (value, "true")) enable_embedded_perl=TRUE; ! else if (0 == strcasecmp (value, "false")) enable_embedded_perl=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for enable_embedded_perl"); ! return TRUE; } enable_embedded_perl=(atoi(value)>0)?TRUE:FALSE; *************** *** 1273,1282 **** else if(!strcmp(variable,"use_embedded_perl_implicitly")){ ! if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(&error_message,"Illegal value for use_embedded_perl_implicitly"); ! error=TRUE; ! break; } use_embedded_perl_implicitly=(atoi(value)>0)?TRUE:FALSE; --- 1239,1249 ---- else if(!strcmp(variable,"use_embedded_perl_implicitly")){ ! if (0 == strcasecmp (value, "true")) use_embedded_perl_implicitly=TRUE; ! else if (0 == strcasecmp (value, "false")) use_embedded_perl_implicitly=FALSE; ! else if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ ! asprintf(error_message,"Illegal value for use_embedded_perl_implicitly"); ! return TRUE; } use_embedded_perl_implicitly=(atoi(value)>0)?TRUE:FALSE; *************** *** 1295,1303 **** else if(!strcmp(variable,"auth_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(&error_message,"Auth file is too long"); ! error=TRUE; ! break; } my_free(auth_file); --- 1262,1269 ---- else if(!strcmp(variable,"auth_file")){ if(strlen(value)>MAX_FILENAME_LENGTH-1){ ! asprintf(error_message,"Auth file is too long"); ! return TRUE; } my_free(auth_file); *************** *** 1313,1348 **** } /* skip external data directives */ ! else if(strstr(input,"x")==input) ! continue; /* ignore external variables */ else if(!strcmp(variable,"status_file")) ! continue; else if(!strcmp(variable,"perfdata_timeout")) ! continue; else if(strstr(variable,"host_perfdata")==variable) ! continue; else if(strstr(variable,"service_perfdata")==variable) ! continue; ! else if(strstr(input,"cfg_file=")==input || strstr(input,"cfg_dir=")==input) ! continue; ! else if(strstr(input,"state_retention_file=")==input) ! continue; ! else if(strstr(input,"object_cache_file=")==input) ! continue; ! else if(strstr(input,"precached_object_file=")==input) ! continue; /* we don't know what this variable is... */ else{ ! asprintf(&error_message,"UNKNOWN VARIABLE"); error=TRUE; break; } } /* adjust timezone values */ if(use_timezone!=NULL) set_environment_var("TZ",use_timezone,1); --- 1279,1612 ---- } /* skip external data directives */ ! else if(strstr(variable,"x")==variable) ! return FALSE; /* ignore external variables */ else if(!strcmp(variable,"status_file")) ! return FALSE; else if(!strcmp(variable,"perfdata_timeout")) ! return FALSE; else if(strstr(variable,"host_perfdata")==variable) ! return FALSE; else if(strstr(variable,"service_perfdata")==variable) ! return FALSE; ! else if(!strcmp(variable,"cfg_file") || !strcmp(variable,"cfg_dir")) ! return FALSE; ! else if(!strcmp(variable,"state_retention_file")) ! return FALSE; ! else if(!strcmp(variable,"object_cache_file")) ! return FALSE; ! else if(!strcmp(variable,"precached_object_file")) ! return FALSE; /* we don't know what this variable is... */ else{ ! asprintf(error_message,"UNKNOWN VARIABLE"); ! return TRUE; ! } ! ! return FALSE; ! } ! ! #ifdef HAVE_LDAP ! /** ! * read any monitorGroups that correspond to my uname() ! * ! * The actual logic here is to find the matching monitorGroups, and for each attribute: ! * - if it is a LDAP DN ! * - subtree: save for later like a cfg_file or cfg_dir to read ! * - manager or other attribute: ignore ! * - common attribute: store it in global config ! * ! * This function only uses the uname(). In theory, your different hosts have unique hostnames. ! * Also, adding or replacing a monitoring server (runs Nagios daemon) in the pool, simply put its ! * hostname here as a monitorFQDN. monitorFQDNs should probably match relativeName in a dNSZone. ! */ ! int read_ldap_monitor_groups(char **error_message, int *command_check_interval_is_seconds){ ! //printf ("Reading LDAP\n"); ! ! for (num_ldap_connected=0; num_ldap_connected < (sizeof(ldap_config)/sizeof(ldap_config[0])); num_ldap_connected++) ! { ! char uri[100]; ! int ldap_errno; ! ! if (NULL == ldap_config[num_ldap_connected]) ! continue; ! ! /* has to be an easier way... FIXME I'll find it */ ! snprintf (uri, sizeof(uri), "ldap://%s:%d/", ldap_config[num_ldap_connected]->lud_host, ldap_config[num_ldap_connected]->lud_port); ! ldap_errno = ldap_initialize (&ldap_connection, uri); ! //printf ("(LDAP monitorGroup connection (%s) (serial: %d) result %d)\n", uri, num_ldap_connected, ldap_errno); ! if (NULL == ldap_connection) ! fprintf (stderr, "LDAP connection (%s) failed (errno: %d)\n", uri, ldap_errno); ! else ! { ! LDAPMessage *lm=NULL, *i; ! ! /* ! * I'm sorry, but I have to list each of the items directly. I know it makes ! * for another disjoint place to maintain stuff, and it's 71 lines of cruft, ! * but I wanted to allow for the additional housekeeping (dn, cn, monitorFQDN) ! * and want to allow this LDAP object to be another objectClass as well. Because ! * of that, I have to list out only the attrs I want to see, and then ignore the ! * three housekeeping ones. Listing "all" attributes lets bad config variables ! * into the parser, which is bad. ! * ! * Might still be a formatting problem with Booleans being TRUE/FALSE => 0/1 ! */ ! char *attrs[] = { ! "dn", /* Distinguished Name of monitorGroup */ ! "cn", /* Common Name of monitorGroup */ ! "monitorFQDN", /* hosts who monitor this group */ ! "nagios-user", ! "nagios-group", ! "check-external-commands", ! "command-check-interval", ! "external-command-buffer-slots", ! "event-broker-options", ! "log-rotation-method", ! "log-archive-path", ! "use-syslog", ! "log-notifications", ! "log-service-retries", ! "illegal-object-name-chars", ! "illegal-macro-output-chars", ! "use-regexp-matching", ! "use-true-regexp-matching", ! "admin-email", ! "admin-pager", ! "daemon-dumps-core", ! "log-host-retries", ! "log-event-handlers", ! "log-initial-states", ! "log-external-commands", ! "log-passive-checks", ! "service-inter-check-delay-method", ! "max-service-check-spread", ! "service-interleave-factor", ! "host-inter-check-delay-method", ! "max-host-check-spread", ! "max-concurrent-checks", ! "service-reaper-frequency", ! "check-result-buffer-slots", ! "check-result-path", ! "auto-reschedule-checks", ! "auto-rescheduling-interval", ! "auto-rescheduling-window", ! "sleep-time", ! "service-check-timeout", ! "host-check-timeout", ! "event-handler-timeout", ! "notification-timeout", ! "ocsp-timeout", ! "perfdata-timeout", ! "retain-state-information", ! "retention-update-interval", ! "use-retained-program-state", ! "use-retained-scheduling-info", ! "interval-length", ! "use-aggressive-host-checking", ! "execute-service-checks", ! "accept-passive-service-checks", ! "execute-host-checks", ! "accept-passive-host-checks", ! "enable-notifications", ! "enable-event-handlers", ! "process-performance-data", ! "obsess-over-services", ! "check-for-orphaned-services", ! "check-service-freshness", ! "service-freshness-check-interval", ! "check-host-freshness", ! "host-freshness-check-interval", ! "status-update-interval", ! "enable-flap-detection", ! "low-service-flap-threshold", ! "high-service-flap-threshold", ! "low-host-flap-threshold", ! "high-host-flap-threshold", ! "date-format", ! NULL }; ! char work[200], wk_ghn[256], wk_gdn[256]; ! ! /* ldap */ ! ldap_bind(ldap_connection, NULL, NULL, LDAP_AUTH_NONE); ! if (0 != (ldap_errno = gethostname(wk_ghn, sizeof(wk_ghn)))) ! fprintf (stderr, "(LDAP monitorGroup connection (%s) gethostname() result (errno: %d))\n", uri, ldap_errno); ! ! /* FIXME : still only uname, not FQDN */ ! snprintf(work, sizeof(work),"(&(objectClass=monitorGroup)(monitorFQDN=%s))", wk_ghn); ! //printf ("(LDAP monitorGroup connection (%s) filter %s )\n", uri, work); ! ! /* not using ldap_url_search_s because I cannot control sub, attrs, or filter */ ! ldap_search_s (ldap_connection, ldap_config[num_ldap_connected]->lud_dn, LDAP_SCOPE_SUB, work, attrs, 0 /* not just attrs */, &lm); ! ! if (NULL == lm) ! printf ("(LDAP monitorGroup connection (%s) filter %s )\n", uri, work); ! else ! for (i = ldap_first_entry (ldap_connection, lm); NULL != i; i = ldap_next_entry (ldap_connection, i)) ! { ! BerElement *be; ! char *a; ! xodtemplate_ldapinc_filter *temp; ! ! char *dn = ldap_get_dn(ldap_connection, i); ! //printf ("(LDAP monitorGroup connection (%s) filter %s dn: %s)\n", uri, work, dn); ! printf ("(LDAP %s?dn=%s)\n", uri, dn); ! ! if (NULL != (temp = malloc (sizeof(xodtemplate_ldapinc_filter)))) ! { ! extern xodtemplate_ldapinc_filter *ldap_xod_filter_list; ! extern xodtemplate_ldapinc_filter *ldap_xod_filter_list_tail; ! ! asprintf(&temp->filter, "(monitorGroup=%s)", dn); ! temp->next = NULL; ! //printf ("(%s@%d LDAP monitorGroup connection (%s) filter %s dn: %s :: %s)\n", __FILE__, __LINE__, uri, work, dn, temp->filter); ! /* save the DN for later use as a cfg_file */ ! if (NULL == ldap_xod_filter_list) ! { ! ldap_xod_filter_list = temp; ! ldap_xod_filter_list_tail = temp; ! } ! else ! { ! ldap_xod_filter_list_tail->next = temp; ! ldap_xod_filter_list_tail = temp; ! } ! } ! ldap_memfree (dn); ! ! for (a = ldap_first_attribute(ldap_connection, i, &be); NULL != a; a = ldap_next_attribute(ldap_connection, i, be)) ! { ! char **v = ldap_get_values (ldap_connection, i, a); ! ! //printf ("(LDAP monitorGroup connection (%s) filter %s dn: %s :: %s)\n", uri, work, dn, a); ! if (0 == strcmp (a, "cn")) ! continue; ! if (0 == strcmp (a, "monitorFQDN")) ! continue; ! ! /* borrow dn to convert the LDAP-compatible '-' to the Nagios '_' format */ ! for (dn = a; dn && *dn; dn++) if ('-' == *dn) *dn = '_'; ! ! //printf ("(LDAP monitorGroup connection (%s) filter %s %s)\n", uri, work, a); ! /* ! * even though we'll rarely get duplicates, I still process as though there will be so that the ! * code is reused and perhaps less maintenance ! */ ! for (; NULL != v && NULL != *v; v++) ! if (process_config_variable_value(a, *v, error_message, command_check_interval_is_seconds)) ! { ! //printf ("(LDAP monitorGroup connection (%s) filter %s %s=%s)\n", uri, work, a, *v); ! ldap_value_free (v); ! return TRUE; ! } ! ! /* so... ah.. I thought I would need to free the values, but when I do, I get a double-free. Not cool. */ ! //ldap_value_free (v); ! } ! ! return FALSE; ! } ! } ! } ! ! return FALSE; ! } ! #endif /* HAVE_LDAP */ ! ! ! /* process the main configuration file */ ! int read_main_config_file(char *main_config_file){ ! char *input=NULL; ! char *variable=NULL; ! char *value=NULL; ! char *error_message=NULL; ! char *temp_ptr=NULL; ! mmapfile *thefile=NULL; ! int current_line=0; ! int error=FALSE; ! int command_check_interval_is_seconds=FALSE; ! ! ! /* 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; ! } ! ! /* save the main config file macro */ ! my_free(macro_x[MACRO_MAINCONFIGFILE]); ! if((macro_x[MACRO_MAINCONFIGFILE]=(char *)strdup(main_config_file))) ! strip(macro_x[MACRO_MAINCONFIGFILE]); ! ! /* process all lines in the config file */ ! while(1){ ! ! /* free memory */ ! my_free(input); ! my_free(variable); ! my_free(value); ! ! /* read the next line */ ! if((input=mmap_fgets_multiline(thefile))==NULL) ! break; ! ! current_line=thefile->current_line; ! ! strip(input); ! ! /* skip blank lines and comments */ ! if(input[0]=='\x0' || input[0]=='#') ! continue; ! ! /* get the variable name */ ! if((temp_ptr=my_strtok(input,"="))==NULL){ ! asprintf(&error_message,"NULL variable"); error=TRUE; break; } + if((variable=(char *)strdup(temp_ptr))==NULL){ + asprintf(&error_message,"malloc() error"); + error=TRUE; + break; + } + /* get the value */ + if((temp_ptr=my_strtok(NULL,"\n"))==NULL){ + asprintf(&error_message,"NULL value"); + error=TRUE; + break; + } + if((value=(char *)strdup(temp_ptr))==NULL){ + asprintf(&error_message,"malloc() error"); + error=TRUE; + break; + } + strip(variable); + strip(value); + + /* process the variable/value */ + if (TRUE == (error = process_config_variable_value(variable, value, &error_message, &command_check_interval_is_seconds))) + break; } + #ifdef HAVE_LDAP + /* OK, smart-guy, now we've got the same config as before, but what if we have an LDAP server? Shall we go a-browsing? */ + if (0 == num_ldap_config) + printf ("Not reading LDAP\n"); + else + { + /* reading the monitor groups is really querying ldap and sending the results through process_config_variable_value */ + read_ldap_monitor_groups(&error_message, &command_check_interval_is_seconds); + + /* read_known_host_templates() */ + /* read_known_service_templates() */ + /* read_known_contact_templates() */ + } + #endif /* HAVE_LDAP */ + /* adjust timezone values */ if(use_timezone!=NULL) set_environment_var("TZ",use_timezone,1); Only in nagios-3.2.0-new/base: .#config.c.1.114 Only in nagios-3.2.0-new/base: .#config.c.1.115 Only in nagios-3.2.0-new/base: .#config.c.1.118 Only in nagios-3.2.0-new/base: Makefile diff --exclude=CVS -cr nagios-3.2.0/base/Makefile.in nagios-3.2.0-new/base/Makefile.in *** nagios-3.2.0/base/Makefile.in 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/base/Makefile.in 2009-08-09 19:01:41.000000000 -0400 *************** *** 52,57 **** --- 52,58 ---- SOCKETLIBS=@SOCKETLIBS@ THREADLIBS=@THREADLIBS@ BROKERLIBS=@BROKERLIBS@ + LDAPLIBS=@LDAPLIBS@ BROKER_LDFLAGS=@BROKER_LDFLAGS@ *************** *** 177,183 **** ########## NAGIOS ########## nagios: nagios.c $(OBJS) $(OBJDEPS) $(SRC_INCLUDE)/nagios.h $(SRC_INCLUDE)/locations.h ! $(CC) $(CFLAGS) -o $@ nagios.c $(OBJS) $(BROKER_LDFLAGS) $(LDFLAGS) $(PERLLIBS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LIBS) nagiostats: nagiostats.c $(SRC_INCLUDE)/locations.h $(CC) $(CFLAGS) -o $@ nagiostats.c $(LDFLAGS) $(MATHLIBS) $(LIBS) --- 178,184 ---- ########## NAGIOS ########## nagios: nagios.c $(OBJS) $(OBJDEPS) $(SRC_INCLUDE)/nagios.h $(SRC_INCLUDE)/locations.h ! $(CC) $(CFLAGS) -o $@ nagios.c $(OBJS) $(BROKER_LDFLAGS) $(LDFLAGS) $(PERLLIBS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LDAPLIBS) $(LIBS) nagiostats: nagiostats.c $(SRC_INCLUDE)/locations.h $(CC) $(CFLAGS) -o $@ nagiostats.c $(LDFLAGS) $(MATHLIBS) $(LIBS) Only in nagios-3.2.0-new/base: .#Makefile.in.1.30 Only in nagios-3.2.0-new/base: .#Makefile.in.1.31 Only in nagios-3.2.0-new/base: .#Makefile.in.1.32 diff --exclude=CVS -cr nagios-3.2.0/base/nagios.c nagios-3.2.0-new/base/nagios.c *** nagios-3.2.0/base/nagios.c 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/base/nagios.c 2009-08-14 19:53:18.000000000 -0400 *************** *** 237,242 **** --- 237,247 ---- int date_format=DATE_FORMAT_US; char *use_timezone=NULL; + #ifdef HAVE_LDAP + LDAPURLDesc *ldap_config[] = { NULL, NULL, NULL, NULL, NULL, NULL }; + int num_ldap_config = 0; + int num_ldap_connected=0; + #endif int command_file_fd; FILE *command_file_fp; Only in nagios-3.2.0-new/base: .#nagios.c.1.153 Only in nagios-3.2.0-new/base: .#nagios.c.1.156 Only in nagios-3.2.0-new/base: .#nagios.c.1.167 Only in nagios-3.2.0-new/base: .#nagios.c.1.172 Only in nagios-3.2.0-new/cgi: Makefile diff --exclude=CVS -cr nagios-3.2.0/cgi/Makefile.in nagios-3.2.0-new/cgi/Makefile.in *** nagios-3.2.0/cgi/Makefile.in 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/cgi/Makefile.in 2009-08-09 19:01:41.000000000 -0400 *************** *** 83,88 **** --- 83,89 ---- MATHLIBS=-lm GDLIBS=@GDLIBS@ + LDAPLIBS=@LDAPLIBS@ all cgis: $(CGIS) *************** *** 125,182 **** ########## CGIS ########## avail.cgi: avail.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ avail.c $(CGILIBS) $(LIBS) checksanity.cgi: checksanity.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ checksanity.c $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS) cmd.cgi: cmd.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS) extcmd_list.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ cmd.c extcmd_list.o $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS) config.cgi: config.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ config.c $(CGILIBS) $(LIBS) extinfo.cgi: extinfo.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ extinfo.c $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS) history.cgi: history.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ history.c $(CGILIBS) $(LIBS) ministatus.cgi: ministatus.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ ministatus.c $(CGILIBS) $(LIBS) notifications.cgi: notifications.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ notifications.c $(CGILIBS) $(LIBS) outages.cgi: outages.c $(CGIDEPS) $(CDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ outages.c $(CGILIBS) $(CDATALIBS) $(LIBS) showlog.cgi: showlog.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ showlog.c $(CGILIBS) $(LIBS) status.cgi: status.c $(CGIDEPS) $(CDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ status.c $(CGILIBS) $(CDATALIBS) $(LIBS) statuswml.cgi: statuswml.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswml.c $(CGILIBS) $(LIBS) statusmap.cgi: statusmap.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ statusmap.c $(CGILIBS) $(GDLIBS) $(LIBS) statuswrl.cgi: statuswrl.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswrl.c $(CGILIBS) $(MATHLIBS) $(LIBS) summary.cgi: summary.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ summary.c $(CGILIBS) $(LIBS) tac.cgi: tac.c $(CGIDEPS) $(CDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ tac.c $(CGILIBS) $(CDATALIBS) $(LIBS) trends.cgi: trends.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ trends.c $(CGILIBS) $(GDLIBS) $(LIBS) histogram.cgi: histogram.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ histogram.c $(CGILIBS) $(GDLIBS) $(LIBS) clean: rm -f $(CGIS) --- 126,183 ---- ########## CGIS ########## avail.cgi: avail.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ avail.c $(CGILIBS) $(LDAPLIBS) $(LIBS) checksanity.cgi: checksanity.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ checksanity.c $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LDAPLIBS) $(LIBS) cmd.cgi: cmd.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS) extcmd_list.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ cmd.c extcmd_list.o $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS) config.cgi: config.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ config.c $(CGILIBS) $(LDAPLIBS) $(LIBS) extinfo.cgi: extinfo.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ extinfo.c $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LDAPLIBS) $(LIBS) history.cgi: history.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ history.c $(CGILIBS) $(LDAPLIBS) $(LIBS) ministatus.cgi: ministatus.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ ministatus.c $(CGILIBS) $(LDAPLIBS) $(LIBS) notifications.cgi: notifications.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ notifications.c $(CGILIBS) $(LDAPLIBS) $(LIBS) outages.cgi: outages.c $(CGIDEPS) $(CDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ outages.c $(CGILIBS) $(CDATALIBS) $(LDAPLIBS) $(LIBS) showlog.cgi: showlog.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ showlog.c $(CGILIBS) $(LDAPLIBS) $(LIBS) status.cgi: status.c $(CGIDEPS) $(CDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ status.c $(CGILIBS) $(CDATALIBS) $(LDAPLIBS) $(LIBS) statuswml.cgi: statuswml.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswml.c $(CGILIBS) $(LDAPLIBS) $(LIBS) statusmap.cgi: statusmap.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ statusmap.c $(CGILIBS) $(GDLIBS) $(LDAPLIBS) $(LIBS) statuswrl.cgi: statuswrl.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswrl.c $(CGILIBS) $(MATHLIBS) $(LDAPLIBS) $(LIBS) summary.cgi: summary.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ summary.c $(CGILIBS) $(LDAPLIBS) $(LIBS) tac.cgi: tac.c $(CGIDEPS) $(CDATADEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ tac.c $(CGILIBS) $(CDATALIBS) $(LDAPLIBS) $(LIBS) trends.cgi: trends.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ trends.c $(CGILIBS) $(GDLIBS) $(LDAPLIBS) $(LIBS) histogram.cgi: histogram.c $(CGIDEPS) ! $(CC) $(CFLAGS) $(LDFLAGS) -o $@ histogram.c $(CGILIBS) $(GDLIBS) $(LDAPLIBS) $(LIBS) clean: rm -f $(CGIS) Only in nagios-3.2.0-new/cgi: .#Makefile.in.1.15 Only in nagios-3.2.0-new/cgi: .#Makefile.in.1.16 Only in nagios-3.2.0-new/cgi: .#Makefile.in.1.17 Only in nagios-3.2.0-new/common: Makefile diff --exclude=CVS -cr nagios-3.2.0/common/objects.c nagios-3.2.0-new/common/objects.c *** nagios-3.2.0/common/objects.c 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/common/objects.c 2009-08-09 19:01:13.000000000 -0400 *************** *** 70,77 **** /******************************************************************/ ! /* read all host configuration data from external source */ ! int read_object_config_data(char *main_config_file, int options, int cache, int precache){ int result=OK; /* initialize object skiplists */ --- 70,77 ---- /******************************************************************/ ! /** read all host configuration data from external source */ ! int read_object_config_data (char *main_config_file, int options, int cache, int precache){ int result=OK; /* initialize object skiplists */ Only in nagios-3.2.0-new/common: .#objects.c.1.116 Only in nagios-3.2.0-new/common: .#objects.c.1.117 Only in nagios-3.2.0-new/common: .#objects.c.1.119 Only in nagios-3.2.0-new: config.log Only in nagios-3.2.0-new: config.status diff --exclude=CVS -cr nagios-3.2.0/configure nagios-3.2.0-new/configure *** nagios-3.2.0/configure 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/configure 2009-08-14 19:53:18.000000000 -0400 *************** *** 311,317 **** #endif" ac_subdirs_all="$ac_subdirs_all tap" ! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA INSTALL build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT SET_MAKE STRIP CPP EGREP SNPRINTF_O SOCKETLIBS THREADLIBS nagios_user nagios_grp INSTALL_OPTS command_user command_grp COMMAND_OPTS MAIL_PROG HTTPD_CONF CHECKRESULTDIR TMPDIR init_dir lockfile XSDC XSDH XCDC XCDH XRDC XRDH XODC XODH XPDC XPDH XDDC XDDH htmurl cgiurl BROKER_LDFLAGS BROKERLIBS MOD_CFLAGS MOD_LDFLAGS BROKER_O BROKER_H nagios_name nagiostats_name PATH_TO_TRACEROUTE PACKDIR VERSION subdirs USE_LIBTAP CGIEXTRAS GDLIBS PERLLIBS PERLDIR PERLXSI_O BASEEXTRALIBS INITDIR INSTALLPERLSTUFF USE_EVENTBROKER PERL LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. --- 311,317 ---- #endif" ac_subdirs_all="$ac_subdirs_all tap" ! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA INSTALL build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT SET_MAKE STRIP CPP EGREP SNPRINTF_O SOCKETLIBS THREADLIBS nagios_user nagios_grp INSTALL_OPTS command_user command_grp COMMAND_OPTS MAIL_PROG HTTPD_CONF CHECKRESULTDIR TMPDIR init_dir lockfile XSDC XSDH XCDC XCDH XRDC XRDH XODC XODH XPDC XPDH XDDC XDDH htmurl cgiurl BROKER_LDFLAGS BROKERLIBS MOD_CFLAGS MOD_LDFLAGS BROKER_O BROKER_H USE_LDAP LDAPLIBS nagios_name nagiostats_name PATH_TO_TRACEROUTE PACKDIR VERSION subdirs USE_LIBTAP CGIEXTRAS GDLIBS PERLLIBS PERLDIR PERLXSI_O BASEEXTRALIBS INITDIR INSTALLPERLSTUFF USE_EVENTBROKER PERL LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. *************** *** 850,855 **** --- 850,856 ---- --disable-statuswrl=disables compilation of statuswrl (VRML) CGI --enable-nanosleep enables use of nanosleep (instead sleep) in event timing --enable-event-broker enables integration of event broker routines + --enable-ldap enables integration of event broker routines --enable-embedded-perl will enable embedded Perl interpreter --enable-cygwin enables building under the CYGWIN environment --enable-libtap Enable built-in libtap for unit-testing (default: *************** *** 3286,3291 **** --- 3287,3442 ---- done + for ac_header in ldap.h + do + as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` + if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 + echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 + if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + fi + echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 + echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + else + # Is the header compilable? + echo "$as_me:$LINENO: checking $ac_header usability" >&5 + echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF + cat confdefs.h >>conftest.$ac_ext + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + $ac_includes_default + #include <$ac_header> + _ACEOF + rm -f conftest.$ac_objext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes + else + echo "$as_me: failed program was:" >&5 + sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no + fi + rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 + echo "${ECHO_T}$ac_header_compiler" >&6 + + # Is the header present? + echo "$as_me:$LINENO: checking $ac_header presence" >&5 + echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF + cat confdefs.h >>conftest.$ac_ext + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + #include <$ac_header> + _ACEOF + if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi + else + ac_cpp_err=yes + fi + if test -z "$ac_cpp_err"; then + ac_header_preproc=yes + else + echo "$as_me: failed program was:" >&5 + sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no + fi + rm -f conftest.err conftest.$ac_ext + echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 + echo "${ECHO_T}$ac_header_preproc" >&6 + + # So? What about this header? + case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 + echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 + echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 + echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 + echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 + echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 + echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 + echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 + echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX + ## ------------------------------------------ ## + ## Report this to the AC_PACKAGE_NAME lists. ## + ## ------------------------------------------ ## + _ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + esac + echo "$as_me:$LINENO: checking for $ac_header" >&5 + echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 + if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + else + eval "$as_ac_Header=\$ac_header_preproc" + fi + echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 + echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + + fi + if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF + #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 + _ACEOF + + fi + + done + + echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 if test "${ac_cv_c_const+set}" = set; then *************** *** 6866,6871 **** --- 7017,7043 ---- fi + # Check whether --enable-ldap or --disable-ldap was given. + if test "${enable_ldap+set}" = set; then + enableval="$enable_ldap" + USE_LDAP=$enableval + else + USE_LDAP=no + fi; + + if test x$USE_LDAP = xyes; then + cat >>confdefs.h <<_ACEOF + #define HAVE_LDAP 1 + _ACEOF + + #LDAP_LDFLAGS="" + LDAPLIBS="-llber -lldap" + else + #LDAP_LDFLAGS="" + LDAPLIBS=""; + fi + + USEPERL=no; INSTALLPERLSTUFF=no; *************** *** 7788,7793 **** --- 7960,7967 ---- s,@MOD_LDFLAGS@,$MOD_LDFLAGS,;t t s,@BROKER_O@,$BROKER_O,;t t s,@BROKER_H@,$BROKER_H,;t t + s,@USE_LDAP@,$USE_LDAP,;t t + s,@LDAPLIBS@,$LDAPLIBS,;t t s,@nagios_name@,$nagios_name,;t t s,@nagiostats_name@,$nagiostats_name,;t t s,@PATH_TO_TRACEROUTE@,$PATH_TO_TRACEROUTE,;t t *************** *** 8537,8542 **** --- 8711,8724 ---- echo "$as_me:$LINENO: result: Event Broker: no" >&5 echo "${ECHO_T} Event Broker: no" >&6 fi + if test x$USE_LDAP = xyes; then + echo "$as_me:$LINENO: result: LDAP Config: ${ac_cv_header_ldap_h}" >&5 + echo "${ECHO_T} LDAP Config: ${ac_cv_header_ldap_h}" >&6 + else + echo "$as_me:$LINENO: result: LDAP Config: no" >&5 + echo "${ECHO_T} LDAP Config: no" >&6 + HAVE_LDAP=no + fi echo "$as_me:$LINENO: result: Install \${prefix}: $prefix" >&5 echo "${ECHO_T} Install \${prefix}: $prefix" >&6 echo "$as_me:$LINENO: result: Lock file: $lockfile" >&5 Only in nagios-3.2.0-new: .#configure.1.127 Only in nagios-3.2.0-new: .#configure.1.130 Only in nagios-3.2.0-new: .#configure.1.138 Only in nagios-3.2.0-new: .#configure.1.140 diff --exclude=CVS -cr nagios-3.2.0/configure.in nagios-3.2.0-new/configure.in *** nagios-3.2.0/configure.in 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/configure.in 2009-08-14 19:53:18.000000000 -0400 *************** *** 30,35 **** --- 30,36 ---- AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(arpa/inet.h ctype.h dirent.h errno.h fcntl.h getopt.h grp.h libgen.h limits.h math.h netdb.h netinet/in.h pthread.h pthreads.h pwd.h regex.h signal.h socket.h stdarg.h string.h strings.h sys/mman.h sys/types.h sys/time.h sys/resource.h sys/wait.h sys/socket.h sys/stat.h sys/timeb.h sys/un.h sys/ipc.h sys/msg.h sys/poll.h syslog.h uio.h unistd.h) + AC_CHECK_HEADERS(ldap.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST *************** *** 641,646 **** --- 642,659 ---- AC_SUBST(BROKER_H) fi + AC_ARG_ENABLE(ldap,AC_HELP_STRING([--enable-ldap],[enables integration of event broker routines]),[USE_LDAP=$enableval],[USE_LDAP=no]) + AC_SUBST(USE_LDAP) + if test x$USE_LDAP = xyes; then + AC_DEFINE_UNQUOTED(HAVE_LDAP) + #LDAP_LDFLAGS="" + LDAPLIBS="-llber -lldap" + else + #LDAP_LDFLAGS="" + LDAPLIBS=""; + fi + AC_SUBST(LDAPLIBS) + USEPERL=no; INSTALLPERLSTUFF=no; *************** *** 841,846 **** --- 854,865 ---- else AC_MSG_RESULT([ Event Broker: no]) fi + if test x$USE_LDAP = xyes; then + AC_MSG_RESULT([ LDAP Config: ${ac_cv_header_ldap_h}]) + else + AC_MSG_RESULT([ LDAP Config: no]) + HAVE_LDAP=no + fi AC_MSG_RESULT([ Install \${prefix}: $prefix]) AC_MSG_RESULT([ Lock file: $lockfile]) AC_MSG_RESULT([ Check result directory: $CHECKRESULTDIR]) Only in nagios-3.2.0-new: .#configure.in.1.128 Only in nagios-3.2.0-new: .#configure.in.1.131 Only in nagios-3.2.0-new: .#configure.in.1.139 Only in nagios-3.2.0-new: .#configure.in.1.141 Only in nagios-3.2.0-new/contrib: Makefile Only in nagios-3.2.0-new: daemon-init Only in nagios-3.2.0-new/html: Makefile Only in nagios-3.2.0-new/include: cgiutils.h Only in nagios-3.2.0-new/include: config.h diff --exclude=CVS -cr nagios-3.2.0/include/config.h.in nagios-3.2.0-new/include/config.h.in *** nagios-3.2.0/include/config.h.in 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/include/config.h.in 2009-08-09 19:01:42.000000000 -0400 *************** *** 288,293 **** --- 288,299 ---- #include #endif + #undef HAVE_LDAP_H + #undef HAVE_LDAP + #if (defined HAVE_LDAP_H) && (defined HAVE_LDAP) + #include + #endif + #undef HAVE_LINUX_MODULE_H #ifdef HAVE_LINUX_MODULE_H #include Only in nagios-3.2.0-new/include: .#config.h.in.1.20 Only in nagios-3.2.0-new/include: .#config.h.in.1.22 Only in nagios-3.2.0-new/include: .#config.h.in.1.23 Only in nagios-3.2.0-new/include: locations.h diff --exclude=CVS -cr nagios-3.2.0/include/nagios.h nagios-3.2.0-new/include/nagios.h *** nagios-3.2.0/include/nagios.h 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/include/nagios.h 2009-08-09 19:01:12.000000000 -0400 *************** *** 462,467 **** --- 462,473 ---- time_t last_update; }check_stats; + /* linked-list of filters to include for LDAP XOD's -- like the CUSTOMVARIABLESMEMBER structure but different scope */ + typedef struct xodtemplate_ldapinc_filter_struct{ + char *filter; + struct xodtemplate_ldapinc_filter_struct *next; + }xodtemplate_ldapinc_filter; + /******************* THREAD STUFF ********************/ Only in nagios-3.2.0-new/include: .#nagios.h.1.13 Only in nagios-3.2.0-new/include: .#nagios.h.1.14 Only in nagios-3.2.0-new/include: snprintf.h Only in nagios-3.2.0-new: Makefile diff --exclude=CVS -cr nagios-3.2.0/Makefile.in nagios-3.2.0-new/Makefile.in *** nagios-3.2.0/Makefile.in 2009-08-14 20:03:10.000000000 -0400 --- nagios-3.2.0-new/Makefile.in 2009-08-09 19:01:41.000000000 -0400 *************** *** 336,338 **** --- 336,341 ---- pkgclean: rm -rf pkg Prototype nagios.SPARC.pkg.tar.gz + + check: nagios + Only in nagios-3.2.0-new: .#Makefile.in.1.34 Only in nagios-3.2.0-new: .#Makefile.in.1.35 Only in nagios-3.2.0-new: .#Makefile.in.1.38 Only in nagios-3.2.0-new/module: Makefile diff --exclude=CVS -cr nagios-3.2.0/nagios.spec nagios-3.2.0-new/nagios.spec *** nagios-3.2.0/nagios.spec 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/nagios.spec 2009-08-14 20:00:57.000000000 -0400 *************** *** 1,6 **** %define name nagios %define version 3.2.0 ! %define release 1 %define nsusr nagios %define nsgrp nagios %define cmdgrp nagiocmd --- 1,6 ---- %define name nagios %define version 3.2.0 ! %define release 20090814 %define nsusr nagios %define nsgrp nagios %define cmdgrp nagiocmd *************** *** 20,35 **** --- 20,49 ---- # in the rpm command-line to enable it %{!?EMBPERL: %define EMBPERL 0} + # Trigger LDAP extension + # --define 'LDAP 1' + # in the rpm command-line to enable it + %{!?LDAP: %define LDAP 0} + + # Trigger Event Broker extension + # --define 'BROKER 1' + # in the rpm command-line to enable it + %{!?BROKER: %define BROKER 0} + # Macro that print mesages to syslog at package (un)install time %define nnmmsg logger -t %{name}/rpm Summary: Host/service/network monitoring program Name: %{name} Version: %{version} + %{?EPOCH:Epoch: %{EPOCH}} Release: %{release} License: GPL Group: Application/System Source0: %{name}-%{version}.tar.gz + Source1: dhcp.schema + Source2: dnszone.schema + Source3: nagios.schema BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} Prefix: /etc/init.d *************** *** 56,65 **** documentation, and development files are built as separate packages %package www Group: Application/System Summary: Provides the HTML and CGI files for the Nagios web interface. ! Requires: %{name} = %{version} Requires: webserver --- 70,104 ---- documentation, and development files are built as separate packages + %if %{LDAP} + %package ldap + Group: Application/System + Summary: Provides the LDAP schema files understood by Nagios for OpenLDAP Installations + Requires: %{name} = %{?EPOCH:%{EPOCH}:}%{version} + Requires: openldap-servers + + + %description ldap + Nagios is a program that will monitor hosts and services on your + network. It has the ability to email or page you when a problem arises + and when a problem is resolved. Nagios is written in C and is + designed to run under Linux (and some other *NIX variants) as a + background process, intermittently running checks on various services + that you specify. + + This version of Nagios is compiled to read configuration data from LDAP. + This means that all LDAP servers carrying that subtree need to have these + schema files, even if Nagios is not running nor reading from them directly, + only if they hold the data or else you'll have a sync failure in a + secondary. To facilitate that, these schema files are included in a + separate package that only requires the openldap-servers package. + %endif + + %package www Group: Application/System Summary: Provides the HTML and CGI files for the Nagios web interface. ! Requires: %{name} = %{?EPOCH:%{EPOCH}:}%{version} Requires: webserver *************** *** 81,87 **** %package devel Group: Application/System Summary: Provides include files that Nagios-related applications may compile against. ! Requires: %{name} = %{version} %description devel Nagios is a program that will monitor hosts and services on your --- 120,126 ---- %package devel Group: Application/System Summary: Provides include files that Nagios-related applications may compile against. ! Requires: %{name} = %{?EPOCH:%{EPOCH}:}%{version} %description devel Nagios is a program that will monitor hosts and services on your *************** *** 201,206 **** --- 240,251 ---- --datadir=%{_prefix}/share/nagios \ --sysconfdir=/etc/nagios \ --localstatedir=/var/log/nagios \ + %if %{BROKER} + --enable-event-broker \ + %endif + %if %{LDAP} + --enable-ldap \ + %endif %if ! %{PERF_EXTERNAL} --with-file-perfdata \ %endif *************** *** 248,253 **** --- 293,304 ---- make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" install make DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" INIT_OPTS="" install-daemoninit + %if %{LDAP} + install -d -m 0755 ${RPM_BUILD_ROOT}/etc/openldap/schema + install -m 0644 %{SOURCE1} ${RPM_BUILD_ROOT}/etc/openldap/schema + install -m 0644 %{SOURCE2} ${RPM_BUILD_ROOT}/etc/openldap/schema + install -m 0644 %{SOURCE3} ${RPM_BUILD_ROOT}/etc/openldap/schema + %endif # install templated configuration files cd sample-config for f in {nagios,cgi}.cfg ; do *************** *** 321,326 **** --- 372,386 ---- %doc Changelog INSTALLING LICENSE README UPGRADING + %if %{LDAP} + %files ldap + %defattr(755,root,root) + /etc/openldap/schema/dhcp.schema + /etc/openldap/schema/dnszone.schema + /etc/openldap/schema/nagios.schema + %endif + + %files www %defattr(755,root,root) %dir %{_prefix}/lib/nagios/cgi *************** *** 338,343 **** --- 398,412 ---- %changelog + * Sun Aug 9 2009 Allan Clark 3.1.2 + - upgrade to 3.1.2, no changes to LDAP portion + + * Sun Jul 13 2008 Allan Clark 3.0.1 + - simple expansion to LDAP extension to get hosts from (dhcp.schema::) dhcpHost + + * Fri May 9 2008 Allan Clark 3.0.1 + - activate LDAP extension to get hosts from (nis.schema::) ipHost + * Tue Nov 22 2005 Andreas Kasenides - packaged %{_prefix}/sbin/new_mini_epn - moved resource.cfg in /etc/nagios Only in nagios-3.2.0-new: .#nagios.spec.1.57 Only in nagios-3.2.0-new: .#nagios.spec.1.59 Only in nagios-3.2.0-new: .#nagios.spec.1.67 Only in nagios-3.2.0-new: pkginfo Only in nagios-3.2.0-new/sample-config: cgi.cfg Only in nagios-3.2.0-new/sample-config: httpd.conf Only in nagios-3.2.0-new/sample-config: mrtg.cfg Only in nagios-3.2.0-new/sample-config: nagios.cfg Only in nagios-3.2.0-new/sample-config: resource.cfg Only in nagios-3.2.0-new/sample-config/template-object: commands.cfg Only in nagios-3.2.0-new/sample-config/template-object: contacts.cfg Only in nagios-3.2.0-new/sample-config/template-object: localhost.cfg Only in nagios-3.2.0-new/sample-config/template-object: printer.cfg Only in nagios-3.2.0-new/sample-config/template-object: switch.cfg Only in nagios-3.2.0-new/sample-config/template-object: templates.cfg Only in nagios-3.2.0-new/sample-config/template-object: timeperiods.cfg Only in nagios-3.2.0-new/sample-config/template-object: windows.cfg Only in nagios-3.2.0-new: subst Only in nagios-3.2.0-new/xdata: Makefile diff --exclude=CVS -cr nagios-3.2.0/xdata/xodtemplate.c nagios-3.2.0-new/xdata/xodtemplate.c *** nagios-3.2.0/xdata/xodtemplate.c 2009-08-14 20:03:11.000000000 -0400 --- nagios-3.2.0-new/xdata/xodtemplate.c 2009-08-09 19:01:43.000000000 -0400 *************** *** 76,81 **** --- 76,88 ---- extern int verify_config; extern int test_scheduling; extern int use_precached_objects; + + /* NSCORE controls inclusion of nagios.h which defines this struct */ + #ifdef HAVE_LDAP + xodtemplate_ldapinc_filter *ldap_xod_filter_list=NULL; + xodtemplate_ldapinc_filter *ldap_xod_filter_list_tail=NULL; + LDAP *ldap_connection=NULL; + #endif #endif xodtemplate_timeperiod *xodtemplate_timeperiod_list=NULL; *************** *** 216,221 **** --- 223,231 ---- /* process object config files normally... */ else{ + #ifdef HAVE_LDAP + xodtemplate_ldapinc_filter *ldapx; + #endif /* determine the directory of the main config file */ if((config_file=(char *)strdup(main_config_file))==NULL){ *************** *** 309,314 **** --- 319,331 ---- my_free(config_base_dir); my_free(input); mmap_fclose(thefile); + + #ifdef HAVE_LDAP + for (ldapx = ldap_xod_filter_list; (OK == result) && (NULL != ldapx); ldapx=ldapx->next) { + result=xodtemplate_process_ldap_host(ldapx->filter,options); + result=xodtemplate_process_ldap_services(ldapx->filter,options); + } + #endif } if(test_scheduling==TRUE) *************** *** 483,489 **** --- 500,718 ---- return result; } + int xodtemplate_process_ldap_seenthat_dn (char *dn) + { + int i; + + /* allanc@chickenandporn.com NOTE this is also used to track LDAP OID/DNs -- a whole lotta "files -- for update checks */ + for (i = 0; i < xodtemplate_current_config_file; i++) + if (0 == strcasecmp (xodtemplate_config_files[i], dn)) + return 1; /* already read in */ + + return 0; + } + + /* pre-pending NSCORE means the internal one 16 lines down is redundant. need to clean that up */ + #ifdef NSCORE + #ifdef HAVE_LDAP + int xodtemplate_process_ldap_host(char *ldap_filter /* was config file */, int options) + { + extern LDAP *ldap_connection; /**< set up during read_ldap_monitor_groups() */ + extern LDAPURLDesc *ldap_config[]; /**< set up during read_ldap_monitor_groups() */ + extern int num_ldap_connected; /**< set up during read_ldap_monitor_groups() */ + + /* + * As an initial implementation (FIXME) I'll assume that the sun is shining, birds singing, + * and that we're still connected to the LDAP server. A bit lazy to do the reconnection + * logic at this point until this implementation starts saving me some work. + */ + if (NULL == ldap_connection) + { + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: LDAP connection is NULL in filter '%s'\n",ldap_filter); + #endif + return ERROR; + } + else + { + LDAPMessage *lm=NULL, *i; + + /* + * I'm sorry, but I have to list each of the items directly. I know it makes for + * another disjoint place to maintain stuff, and it's 71 lines of cruft, but this + * is the same as I wrote in base/config.h: it lets me use these objects as + * multiple near-overlapping objectClasses in the same object, so that editing an + * object is in a single place. Also, I don't want to depend on the schema. My + * self-test will catch mismatches (and I can always add test-cases -- just toss + * me an email with a slapcat of a config that should work, but doesn't) so I + * list the attributes here in full. + * + * some DHCP stuff added: allanc@chickenandporn.com in conversation with Vitor Antunes, + * who seems like a nice guy. + * + * http://tools.ietf.org/draft/draft-ietf-dhc-ldap-schema/state + * http://tools.ietf.org/html/draft-ietf-dhc-ldap-schema-00 + * http://www.ietf.org/internet-drafts/draft-ietf-dhc-ldap-schema-00.txt + * https://datatracker.ietf.org/drafts/draft-ietf-dhc-ldap-schema/ + * + */ + char *attrs[] = { + "dn", /* Distinguished Name of the (host) instance */ + "cn", /* Common Name of the (host) instance */ + "objectClass", /* Can I do that? */ + /* objectClass: monitoredHost */ + /* objectClass: monitoredDhcpHost */ + /* objectClass: dNSZone */ + /* objectClass: ipHost */ + /* objectClass: top */ + /* monitorMemberOf: cn=Prod,ou=West,dc=example,dc=com */ + "ipHostNumber", /* address, taken from nis.schema */ + "dhcpStatements", /* address, MAC, everything else, taken from dhcp.schema */ + /* zoneName - taken from dnszone.schema, not currently used */ + "relativeDomainName", /* taken from dnszone.schema, becomes alias */ + "nagios-use", /* based on what template? "use" property, a bt more verbose */ + "check-command", + NULL }; + char work[200], wk_ghn[256], wk_gdn[256]; + + /* ldap -- we're optimistic that we're still connected from the main-config read */ + snprintf(work, sizeof(work),"(&(|(objectClass=monitoredHost)(objectClass=monitoredDhcpHost))%s)", ldap_filter); + //allanc@chickenandporn.com: printf ("(LDAP monitoredHost filter (%s) filter %s )\n", ldap_filter, work); + + /* If we have a connection (NULL != ldap_connection) then num_ldap_connected is a valid config item # */ + ldap_search_s (ldap_connection, ldap_config[num_ldap_connected]->lud_dn, LDAP_SCOPE_SUB, work, attrs, 0 /* not just attrs */, &lm); + + if (NULL == lm) + { + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: LDAP search for %s filter %s should return at least one result\n",ldap_filter, work); + #endif + return ERROR; + } + + /* hosts are loaded, can iterate them now. I'm a bit concerned about search limits. Warning on exactly 500 results? */ + for (i = ldap_first_entry (ldap_connection, lm); NULL != i; i = ldap_next_entry (ldap_connection, i)) + { + int current_line = 0; + BerElement *be; + char *dn = ldap_get_dn(ldap_connection, i); /* dn replaces config_file */ + char *attr; + + /* skip "files" (DNs) we've seen/parsed -- can merge it to a find_hosts? */ + if (xodtemplate_process_ldap_seenthat_dn(dn)) continue; + + xodtemplate_config_files[xodtemplate_current_config_file++]=(char *)strdup(dn); + + /* reallocate memory for config files */ + if(!(xodtemplate_current_config_file%256)){ + xodtemplate_config_files=(char **)realloc(xodtemplate_config_files,(xodtemplate_current_config_file+256)*sizeof(char **)); + if(xodtemplate_config_files==NULL) + return ERROR; + } + + /* alright. Create the host object */ + if(xodtemplate_begin_object_definition("host",options,xodtemplate_current_config_file,current_line)==ERROR) + { + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not add object definition in file '%s' on line %d.\n",dn,current_line); + #endif + /* here, I should be cleaning up, but because we're instantly bailing and choking, quitting, and dying, it's not much use */ + return ERROR; + } + + /* OK, skim out the properties */ + for (attr = ldap_first_attribute(ldap_connection, i, &be); NULL != attr; attr = ldap_next_attribute(ldap_connection, i, be)) + { + int iter, force_skiplists=FALSE; + #ifdef NSCORE + if(use_precached_objects==TRUE) + force_skiplists=TRUE; + #else + force_skiplists=TRUE; + #endif + char **v, *vv; + v = (char **) ldap_get_values (ldap_connection, i, attr); + + /* late at night, double-pointers failing .. FIXME need to simplify */ + for (iter = 0; iter < ldap_count_values(v); iter++) + { + current_line++; + + //allanc@chickenandporn.com: printf ("(LDAP filter %s object \"host\" dn: %s :: %s=%s)\n", work, dn, attr,v[iter]); + if (0 == strcmp (attr, "cn")) + { + if (ERROR == xodtemplate_add_object_property_vv("host_name", v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + else if (0 == strcmp (attr, "objectClass")) + continue; + else if (0 == strcmp (attr, "ipHostNumber")) + { + if (ERROR == xodtemplate_add_object_property_vv("address", v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + /* + * Is this where I complain some more? :( The problem with the DHCP re-use is that the IP Address is hidden + * inside some dhcpStatements such as the following. Some additional chopping to find the fixed-address. + * + * dn: cn=server-test2,cn=Servers,ou=Computers,dc=example,dc=com + * cn: server-test2 + * objectClass: top + * objectClass: dhcpHost + * dhcpHWAddress: ethernet ff:ff:ff:ff:ff:50 + * dhcpStatements: fixed-address 192.168.1.11 + * + * Instead, since the bottom of the loop has no "else" to catch unmatched entries, I'm doubling up the boolean + */ + + else if ((0 == strcmp (attr, "dhcpStatements")) && (0 == strncmp (v[iter], "fixed-address ", /* strlen (fixed-address ) */ 14)) ) + { + if (ERROR == xodtemplate_add_object_property_vv("address", v[iter] + 14 /* strlen (fixed-address ) */, options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + else if (0 == strcmp (attr, "relativeDomainName")) + { + if (ERROR == xodtemplate_add_object_property_vv("alias", v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + else if (0 == strcmp (attr, "nagios-use")) + { + if (ERROR == xodtemplate_add_object_property_vv(attr+7, v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + else /* check-command et al. this is a very accepting boolean, but the attrs above keep us safe from random attrs*/ + /* "check-command", */ + { + char *b; + + for (b = attr; b && *b; b++) if ('-' == *b) *b = '_'; + if (ERROR == xodtemplate_add_object_property_vv(attr, v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + } + } + + /* close out current definition */ + if(xodtemplate_end_object_definition(options)==ERROR){ + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not complete object definition in object '%s' on line %d.\n",dn,current_line); + #endif + return ERROR; + } + ldap_memfree (dn); + } + } // a whole lotta work if the ldap is not null + return OK; + } + #endif /* HAVE LDAP */ + #endif /* redundant NSCORE because the connection struct is in the wrong header */ /* grab config variable from main config file */ int xodtemplate_grab_config_info(char *main_config_file){ *************** *** 552,557 **** --- 781,947 ---- } + /* pre-pending NSCORE means the internal one 17 lines down is redundant. need to clean that up */ + #ifdef NSCORE + #ifdef HAVE_LDAP + /** + * Implement as a copy of xodtemplate_process_ldap_host() first, then look at combining the two for reuse when implementing the templates-reading, contacts-reading, etc + */ + int xodtemplate_process_ldap_services(char *ldap_filter /* was config file */, int options) + { + extern LDAP *ldap_connection; /**< set up during read_ldap_monitor_groups() */ + extern LDAPURLDesc *ldap_config[]; /**< set up during read_ldap_monitor_groups() */ + extern int num_ldap_connected; /**< set up during read_ldap_monitor_groups() */ + + /* + * As an initial implementation (FIXME) I'll assume that the sun is shining, birds singing, + * and that we're still connected to the LDAP server. A bit lazy to do the reconnection + * logic at this point until this implementation starts saving me some work. + */ + if (NULL == ldap_connection) + { + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: LDAP connection is NULL in filter '%s'\n",ldap_filter); + #endif + return ERROR; + } + else + { + LDAPMessage *lm=NULL, *i; + + /* + * I'm sorry, but I have to list each of the items directly. I know it makes for + * another disjoint place to maintain stuff, and it's 71 lines of cruft, but this + * is the same as I wrote in base/config.h: it lets me use these objects as + * multiple near-overlapping objectClasses in the same object, so that editing an + * object is in a single place. Also, I don't want to depend on the schema. My + * self-test will catch mismatches (and I can always add test-cases -- just toss + * me an email with a slapcat of a config that should work, but doesn't) so I + * list the attributes here in full. + */ + char *attrs[] = { + "dn", /* Distinguished Name of the (host) instance */ + "cn", /* Common Name of the (host) instance */ + "objectClass", /* Can I do that? */ + /* objectClass: monitoredService */ + /* objectClass: top */ + /* monitorMemberOf: cn=Prod,ou=West,dc=example,dc=com */ + "nagios-use", /* based on what template? "use" property, a bt more verbose */ + "check-command", + "description", + "host-name", + NULL }; + char work[200], wk_ghn[256], wk_gdn[256]; + + /* ldap -- we're optimistic that we're still connected from the main-config read */ + snprintf(work, sizeof(work),"(&(objectClass=monitoredService)%s)", ldap_filter); + //allanc@chickenandporn.com: printf ("(LDAP monitoredService filter (%s) filter %s )\n", ldap_filter, work); + + /* If we have a connection (NULL != ldap_connection) then num_ldap_connected is a valid config item # */ + ldap_search_s (ldap_connection, ldap_config[num_ldap_connected]->lud_dn, LDAP_SCOPE_SUB, work, attrs, 0 /* not just attrs */, &lm); + + if (NULL == lm) + { + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: LDAP search for %s filter %s should return at least one result\n",ldap_filter, work); + #endif + return ERROR; + } + + /* services are loaded, can iterate them now. I'm a bit concerned about search limits. Warning on exactly 500 results? */ + for (i = ldap_first_entry (ldap_connection, lm); NULL != i; i = ldap_next_entry (ldap_connection, i)) + { + int current_line = 0; + BerElement *be; + char *dn = ldap_get_dn(ldap_connection, i); /* dn replaces config_file */ + char *attr; + + /* skip "files" (DNs) we've seen/parsed -- can merge it to a find_hosts? */ + if (xodtemplate_process_ldap_seenthat_dn(dn)) continue; + + xodtemplate_config_files[xodtemplate_current_config_file++]=(char *)strdup(dn); + + /* reallocate memory for config files */ + if(!(xodtemplate_current_config_file%256)){ + xodtemplate_config_files=(char **)realloc(xodtemplate_config_files,(xodtemplate_current_config_file+256)*sizeof(char **)); + if(xodtemplate_config_files==NULL) + return ERROR; + } + + /* alright. Create the service object */ + if(xodtemplate_begin_object_definition("service",options,xodtemplate_current_config_file,current_line)==ERROR) + { + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not add object definition in file '%s' on line %d.\n",dn,current_line); + #endif + /* here, I should be cleaning up, but because we're instantly bailing and choking, quitting, and dying, it's not much use */ + return ERROR; + } + + /* OK, skim out the properties */ + for (attr = ldap_first_attribute(ldap_connection, i, &be); NULL != attr; attr = ldap_next_attribute(ldap_connection, i, be)) + { + int iter, force_skiplists=FALSE; + #ifdef NSCORE + if(use_precached_objects==TRUE) + force_skiplists=TRUE; + #else + force_skiplists=TRUE; + #endif + char **v, *vv; + v = (char **) ldap_get_values (ldap_connection, i, attr); + + /* late at night, double-pointers failing .. FIXME need to simplify */ + for (iter = 0; iter < ldap_count_values(v); iter++) + { + current_line++; + + //allanc@chickenandporn.com: printf ("(LDAP filter %s object \"service\" dn: %s :: %s=%s)\n", work, dn, attr,v[iter]); + if (0 == strcmp (attr, "description")) + { + if (ERROR == xodtemplate_add_object_property_vv("service_description", v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + else if (0 == strcmp (attr, "objectClass")) + continue; + else if (0 == strcmp (attr, "cn")) /* FIXME: need to convert the host_name focus to a dn-based focus */ + continue; + else if (0 == strcmp (attr, "nagios-use")) + { + if (ERROR == xodtemplate_add_object_property_vv(attr+7, v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + else /* check-command et al. this is a very accepting boolean, but the attrs above keep us safe from random attrs*/ + /* "check-command", host-name, description */ + { + char *b; + + for (b = attr; b && *b; b++) if ('-' == *b) *b = '_'; + if (ERROR == xodtemplate_add_object_property_vv(attr, v[iter], options, force_skiplists)) + /* I should free dn, perhaps v, but we're fleeing here and quitting anyways, it's pointless */ + return ERROR; + } + } + } + + /* close out current definition */ + if(xodtemplate_end_object_definition(options)==ERROR){ + #ifdef NSCORE + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not complete object definition in object '%s' on line %d.\n",dn,current_line); + #endif + return ERROR; + } + ldap_memfree (dn); + } + } // a whole lotta work if the ldap is not null + + return OK; + } + #endif /* HAVE LDAP */ + #endif /* redundant NSCORE because the connection struct is in the wrong header */ + /* process all files in a specific config directory */ int xodtemplate_process_config_dir(char *dirname, int options){ *************** *** 654,659 **** --- 1044,1050 ---- #endif /* save config file name */ + /* allanc@chickenandporn.com NOTE this is also used to track LDAP OID/DNs -- a wholt lotta "files -- for update checks */ xodtemplate_config_files[xodtemplate_current_config_file++]=(char *)strdup(filename); /* reallocate memory for config files */ *************** *** 2037,2063 **** int result=OK; char *variable=NULL; char *value=NULL; ! char *temp_ptr=NULL; ! char *customvarname=NULL; ! char *customvarvalue=NULL; ! xodtemplate_timeperiod *temp_timeperiod=NULL; ! xodtemplate_command *temp_command=NULL; ! xodtemplate_contactgroup *temp_contactgroup=NULL; ! xodtemplate_hostgroup *temp_hostgroup=NULL; ! xodtemplate_servicegroup *temp_servicegroup=NULL; ! xodtemplate_servicedependency *temp_servicedependency=NULL; ! xodtemplate_serviceescalation *temp_serviceescalation=NULL; ! xodtemplate_contact *temp_contact=NULL; ! xodtemplate_host *temp_host=NULL; ! xodtemplate_service *temp_service=NULL; ! xodtemplate_hostdependency *temp_hostdependency=NULL; ! xodtemplate_hostescalation *temp_hostescalation=NULL; ! xodtemplate_hostextinfo *temp_hostextinfo=NULL; ! xodtemplate_serviceextinfo *temp_serviceextinfo=NULL; register int x=0; register int y=0; - int force_skiplists=FALSE; - /* should some object definitions be added to skiplists immediately? */ #ifdef NSCORE --- 2428,2436 ---- int result=OK; char *variable=NULL; char *value=NULL; ! int force_skiplists=FALSE; register int x=0; register int y=0; /* should some object definitions be added to skiplists immediately? */ #ifdef NSCORE *************** *** 2148,2154 **** --- 2521,2558 ---- } strip(value); + result=xodtemplate_add_object_property_vv(variable, value, options, force_skiplists); + /* free memory */ + my_free(variable); + my_free(value); + + return result; + } + + /** splitting this from xodtemplate_add_object_property() allows me to use it with split variable/value */ + int xodtemplate_add_object_property_vv(char *variable, char *value, int options, int force_skiplists){ + int result=OK; + char *temp_ptr=NULL; + char *customvarname=NULL; + char *customvarvalue=NULL; + xodtemplate_timeperiod *temp_timeperiod=NULL; + xodtemplate_command *temp_command=NULL; + xodtemplate_contactgroup *temp_contactgroup=NULL; + xodtemplate_hostgroup *temp_hostgroup=NULL; + xodtemplate_servicegroup *temp_servicegroup=NULL; + xodtemplate_servicedependency *temp_servicedependency=NULL; + xodtemplate_serviceescalation *temp_serviceescalation=NULL; + xodtemplate_contact *temp_contact=NULL; + xodtemplate_host *temp_host=NULL; + xodtemplate_service *temp_service=NULL; + xodtemplate_hostdependency *temp_hostdependency=NULL; + xodtemplate_hostescalation *temp_hostescalation=NULL; + xodtemplate_hostextinfo *temp_hostextinfo=NULL; + xodtemplate_serviceextinfo *temp_serviceextinfo=NULL; + register int x=0; + + //allanc@chickenandporn.com: printf ("(%s@%d: %s=%s)\n", __FUNCTION__, __LINE__, variable, value); switch(xodtemplate_current_object_type){ case XODTEMPLATE_TIMEPERIOD: *************** *** 4740,4749 **** break; } - /* free memory */ - my_free(variable); - my_free(value); - return result; } --- 5144,5149 ---- Only in nagios-3.2.0-new/xdata: .#xodtemplate.c.1.179 Only in nagios-3.2.0-new/xdata: .#xodtemplate.c.1.181 Only in nagios-3.2.0-new/xdata: .#xodtemplate.c.1.185 Only in nagios-3.2.0-new/xdata: .#xodtemplate.c.1.189