libimcv: Disable default syslog() logging if not supported
This commit is contained in:
+24
-16
@@ -20,7 +20,9 @@
|
|||||||
#include <utils/utils.h>
|
#include <utils/utils.h>
|
||||||
#include <pen/pen.h>
|
#include <pen/pen.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define IMCV_DEBUG_LEVEL 1
|
#define IMCV_DEBUG_LEVEL 1
|
||||||
#define IMCV_DEFAULT_POLICY_SCRIPT "ipsec _imv_policy"
|
#define IMCV_DEFAULT_POLICY_SCRIPT "ipsec _imv_policy"
|
||||||
@@ -62,9 +64,6 @@ static bool imcv_stderr_quiet;
|
|||||||
*/
|
*/
|
||||||
static void imcv_dbg(debug_t group, level_t level, char *fmt, ...)
|
static void imcv_dbg(debug_t group, level_t level, char *fmt, ...)
|
||||||
{
|
{
|
||||||
int priority = LOG_INFO;
|
|
||||||
char buffer[8192];
|
|
||||||
char *current = buffer, *next;
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
if (level <= imcv_debug_level)
|
if (level <= imcv_debug_level)
|
||||||
@@ -78,22 +77,30 @@ static void imcv_dbg(debug_t group, level_t level, char *fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write in memory buffer first */
|
#ifdef HAVE_SYSLOG
|
||||||
va_start(args, fmt);
|
|
||||||
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
/* do a syslog with every line */
|
|
||||||
while (current)
|
|
||||||
{
|
{
|
||||||
next = strchr(current, '\n');
|
int priority = LOG_INFO;
|
||||||
if (next)
|
char buffer[8192];
|
||||||
|
char *current = buffer, *next;
|
||||||
|
|
||||||
|
/* write in memory buffer first */
|
||||||
|
va_start(args, fmt);
|
||||||
|
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
/* do a syslog with every line */
|
||||||
|
while (current)
|
||||||
{
|
{
|
||||||
*(next++) = '\0';
|
next = strchr(current, '\n');
|
||||||
|
if (next)
|
||||||
|
{
|
||||||
|
*(next++) = '\0';
|
||||||
|
}
|
||||||
|
syslog(priority, "[HSR] %s\n", current);
|
||||||
|
current = next;
|
||||||
}
|
}
|
||||||
syslog(priority, "[HSR] %s\n", current);
|
|
||||||
current = next;
|
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SYSLOG */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +134,9 @@ bool libimcv_init(bool is_imv)
|
|||||||
|
|
||||||
/* activate the imcv debugging hook */
|
/* activate the imcv debugging hook */
|
||||||
dbg = imcv_dbg;
|
dbg = imcv_dbg;
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
openlog("imcv", 0, LOG_DAEMON);
|
openlog("imcv", 0, LOG_DAEMON);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!lib->plugins->load(lib->plugins,
|
if (!lib->plugins->load(lib->plugins,
|
||||||
lib->settings->get_str(lib->settings, "libimcv.load",
|
lib->settings->get_str(lib->settings, "libimcv.load",
|
||||||
@@ -197,4 +206,3 @@ void libimcv_deinit(void)
|
|||||||
library_deinit();
|
library_deinit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user