[Nagios-checkins] nagios/xdata xsddefault.c,1.29,1.30
Nagios network monitoring software is enterprise server monitoring
Brought to you by:
egalstad,
sawolf-nagios
From: Ethan G. <ega...@us...> - 2005-11-26 07:05:44
|
Update of /cvsroot/nagios/nagios/xdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3373/xdata Modified Files: xsddefault.c Log Message: Sanity checks for full partitions during status file update Index: xsddefault.c =================================================================== RCS file: /cvsroot/nagios/nagios/xdata/xsddefault.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** xsddefault.c 16 Nov 2005 08:49:35 -0000 1.29 --- xsddefault.c 26 Nov 2005 07:05:36 -0000 1.30 *************** *** 4,8 **** * * Copyright (c) 2000-2005 Ethan Galstad (na...@na...) ! * Last Modified: 05-25-2005 * * License: --- 4,8 ---- * * Copyright (c) 2000-2005 Ethan Galstad (na...@na...) ! * Last Modified: 11-25-2005 * * License: *************** *** 290,293 **** --- 290,294 ---- /* write all status data to file */ int xsddefault_save_status_data(void){ + char temp_buffer[MAX_INPUT_BUFFER]; host *temp_host; service *temp_service; *************** *** 299,308 **** snprintf(xsddefault_aggregate_temp_file,sizeof(xsddefault_aggregate_temp_file)-1,"%sXXXXXX",xsddefault_temp_file); xsddefault_aggregate_temp_file[sizeof(xsddefault_aggregate_temp_file)-1]='\x0'; ! if((fd=mkstemp(xsddefault_aggregate_temp_file))==-1) return ERROR; fp=fdopen(fd,"w"); if(fp==NULL){ close(fd); unlink(xsddefault_aggregate_temp_file); return ERROR; } --- 300,323 ---- snprintf(xsddefault_aggregate_temp_file,sizeof(xsddefault_aggregate_temp_file)-1,"%sXXXXXX",xsddefault_temp_file); xsddefault_aggregate_temp_file[sizeof(xsddefault_aggregate_temp_file)-1]='\x0'; ! if((fd=mkstemp(xsddefault_aggregate_temp_file))==-1){ ! ! /* log an error */ ! snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to create temp file for writing status data!\n"); ! temp_buffer[sizeof(temp_buffer)-1]='\x0'; ! write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE); ! return ERROR; + } fp=fdopen(fd,"w"); if(fp==NULL){ + close(fd); unlink(xsddefault_aggregate_temp_file); + + /* log an error */ + snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to open temp file '%s' for writing status data!\n",xsddefault_aggregate_temp_file); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE); + return ERROR; } *************** *** 469,474 **** /* move the temp file to the status log (overwrite the old status log) */ ! if(my_rename(xsddefault_aggregate_temp_file,xsddefault_status_log)) return ERROR; return OK; --- 484,496 ---- /* move the temp file to the status log (overwrite the old status log) */ ! if(my_rename(xsddefault_aggregate_temp_file,xsddefault_status_log)){ ! ! /* log an error */ ! snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to update status data file '%s'!\n",xsddefault_status_log); ! temp_buffer[sizeof(temp_buffer)-1]='\x0'; ! write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE); ! return ERROR; + } return OK; |