Группа :: Мониторинг
Пакет: xymon
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: xymon.mkdir.patch
Скачать
Скачать
diff -Nur xymon-4.3.29.bak/web/report.c xymon-4.3.29/web/report.c
--- xymon-4.3.29.bak/web/report.c 2019-07-23 18:46:51.000000000 +0400
+++ xymon-4.3.29/web/report.c 2019-09-11 16:30:00.782507811 +0400
@@ -264,13 +264,17 @@
snprintf(dirid, sizeof(dirid), "%lu-%u", (unsigned long)getpid(), (unsigned int)getcurrenttime(NULL));
if (!csvoutput) {
snprintf(outdir, outdir_buflen, "%s/%s", xgetenv("XYMONREPDIR"), dirid);
- mkdir(outdir, 0755);
+ if (mkdir(outdir, 0755) == -1) {
+ if (xgetenv("XYMONREPDIR") && mkdir(xgetenv("XYMONREPDIR"), 0755) != -1) dbgprintf("Created %s\n", xgetenv("XYMONREPDIR"));
+ if (mkdir(outdir, 0755) == -1) errormsg("Cannot create output directory");
+ }
xymongen_argv[newargi++] = outdir;
snprintf(xymonwebenv, xymonwebenv_buflen, "XYMONWEB=%s/%s", xgetenv("XYMONREPURL"), dirid);
putenv(xymonwebenv);
}
else {
snprintf(outdir, outdir_buflen, "--csv=%s/%s.csv", xgetenv("XYMONREPDIR"), dirid);
+ if (xgetenv("XYMONREPDIR")) mkdir(xgetenv("XYMONREPDIR"), 0755); // superfluous, but handled here
xymongen_argv[newargi++] = outdir;
snprintf(csvdelimopt, sizeof(csvdelimopt), "--csvdelim=%c", csvdelim);
xymongen_argv[newargi++] = csvdelimopt;
diff -Nur xymon-4.3.29.bak/web/snapshot.c xymon-4.3.29/web/snapshot.c
--- xymon-4.3.29.bak/web/snapshot.c 2019-07-23 18:46:51.000000000 +0400
+++ xymon-4.3.29/web/snapshot.c 2019-09-11 16:34:50.864687549 +0400
@@ -200,7 +200,10 @@
snprintf(dirid, sizeof(dirid), "%lu-%u", (unsigned long)getpid(), (unsigned int)getcurrenttime(NULL));
snprintf(outdir, sizeof(outdir), "%s/%s", xgetenv("XYMONSNAPDIR"), dirid);
- if (mkdir(outdir, 0755) == -1) errormsg("Cannot create output directory");
+ if (mkdir(outdir, 0755) == -1) {
+ if (xgetenv("XYMONSNAPDIR") && mkdir(xgetenv("XYMONSNAPDIR"), 0755) != -1) dbgprintf("Created %s\n", xgetenv("XYMONSNAPDIR"));
+ if (mkdir(outdir, 0755) == -1) errormsg("Cannot create output directory");
+ }
snprintf(xymonwebenv, xymonwebenv_buflen, "XYMONWEB=%s/%s", xgetenv("XYMONSNAPURL"), dirid);
putenv(xymonwebenv);
diff -Nur xymon-4.3.29.bak/xymond/xymond_filestore.c xymon-4.3.29/xymond/xymond_filestore.c
--- xymon-4.3.29.bak/xymond/xymond_filestore.c 2015-10-01 18:42:42.000000000 +0400
+++ xymon-4.3.29/xymond/xymond_filestore.c 2019-09-11 16:30:00.783507825 +0400
@@ -16,6 +16,7 @@
static char rcsid[] = "$Id: xymond_filestore.c 7678 2015-10-01 14:42:42Z jccleaver $";
+#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -57,6 +58,11 @@
}
logfd = fopen(tmpfn, mode);
+ if (!logfd) {
+ errprintf("Could not open '%s' as '%s', mode %s: %s\n", fn, tmpfn, mode, strerror(errno));
+ MEMUNDEFINE(tmpfn);
+ return;
+ }
fwrite(msg, strlen(msg), 1, logfd);
if (sender) fprintf(logfd, "\n\nMessage received from %s\n", sender);
if (timesincechange >= 0) {
@@ -253,6 +259,8 @@
errprintf("No directory given, aborting\n");
return 1;
}
+ if (filedir && mkdir(filedir, 0755) != -1) dbgprintf("Created %s\n", filedir);
+ if (htmldir && mkdir(htmldir, 0755) != -1) dbgprintf("Created %s\n", htmldir);
/* For picking up lost children */
setup_signalhandler("xymond_filestore");
@@ -356,7 +364,7 @@
/* @@notes|timestamp|sender|hostname */
hostname = metadata[3];
statusdata = msg_data(statusdata, 0); if (*statusdata == '\n') statusdata++;
- sprintf(logfn, "%s/%s", basename(filedir), hostname);
+ sprintf(logfn, "%s/%s", filedir, basename(hostname));
expiretime = 0;
update_file(logfn, "w", statusdata, expiretime, NULL, -1, seq);
}