[Nagios-devel] Config.c Patch to check if temp_path is writeable

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Config.c Patch to check if temp_path is writeable

Post by Guest »

This is a multi-part message in MIME format.
--------------000502000309060006090307
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

Hi List,

again a small patch to config.c agains lates cvs code.

within the pre_flight_check this patch tries to write to the temp_path
directiv and sets an error if it wasn't able to write.

After successfull write I hope it's cleaning up properly.

Best regards,
Hendrik


--------------000502000309060006090307
Content-Type: text/x-patch;
name="config.c.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="config.c.patch"

--- nagios3-clean/base/config.c 2007-04-11 19:00:55.000000000 +0200
+++ nagios3/base/config.c 2007-04-11 21:25:29.000000000 +0200
@@ -1940,6 +1940,22 @@
if(verify_config==TRUE)
printf("Checking misc settings...\n");

+ /* check if we can write to temp_path */
+ int temp_path_fp;
+ char *test_temp_path = NULL;
+ asprintf(&test_temp_path, "%s/nagiosXXXXXX", temp_path);
+ if ( (temp_path_fp=mkstemp(test_temp_path)) == -1 ) {
+ asprintf (&temp_buffer, "\tError while attempting to write to temp_path ('%s') - %s\n", temp_path, strerror(errno));
+ write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_WARNING,TRUE);
+ errors++;
+ my_free((void **)&temp_buffer);
+ }
+ else {
+ close(temp_path_fp);
+ remove(test_temp_path);
+ }
+
+
/* warn if user didn't specify any illegal macro output chars */
if(illegal_output_chars==NULL){
asprintf(&temp_buffer,"%s","Warning: Nothing specified for illegal_macro_output_chars variable!\n");

--------------000502000309060006090307--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked