charon: Don't use syslog() if not supported
This commit is contained in:
+1
-1
@@ -568,7 +568,7 @@ AC_CHECK_FUNC(
|
|||||||
)
|
)
|
||||||
|
|
||||||
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom getpwnam_r getgrnam_r getpwuid_r)
|
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom getpwnam_r getgrnam_r getpwuid_r)
|
||||||
AC_CHECK_FUNCS(fmemopen funopen mmap memrchr)
|
AC_CHECK_FUNCS(fmemopen funopen mmap memrchr syslog)
|
||||||
|
|
||||||
AC_CHECK_HEADERS(sys/sockio.h glob.h net/if_tun.h linux/fib_rules.h)
|
AC_CHECK_HEADERS(sys/sockio.h glob.h net/if_tun.h linux/fib_rules.h)
|
||||||
AC_CHECK_HEADERS(net/pfkeyv2.h netipsec/ipsec.h netinet6/ipsec.h linux/udp.h)
|
AC_CHECK_HEADERS(net/pfkeyv2.h netipsec/ipsec.h netinet6/ipsec.h linux/udp.h)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ bus/bus.c bus/bus.h \
|
|||||||
bus/listeners/listener.h \
|
bus/listeners/listener.h \
|
||||||
bus/listeners/logger.h \
|
bus/listeners/logger.h \
|
||||||
bus/listeners/file_logger.c bus/listeners/file_logger.h \
|
bus/listeners/file_logger.c bus/listeners/file_logger.h \
|
||||||
bus/listeners/sys_logger.c bus/listeners/sys_logger.h \
|
|
||||||
config/backend_manager.c config/backend_manager.h config/backend.h \
|
config/backend_manager.c config/backend_manager.h config/backend.h \
|
||||||
config/child_cfg.c config/child_cfg.h \
|
config/child_cfg.c config/child_cfg.h \
|
||||||
config/ike_cfg.c config/ike_cfg.h \
|
config/ike_cfg.c config/ike_cfg.h \
|
||||||
@@ -144,6 +143,12 @@ libcharon_la_LIBADD = \
|
|||||||
$(top_builddir)/src/libhydra/libhydra.la \
|
$(top_builddir)/src/libhydra/libhydra.la \
|
||||||
-lm $(PTHREADLIB) $(DLLIB) $(SOCKLIB)
|
-lm $(PTHREADLIB) $(DLLIB) $(SOCKLIB)
|
||||||
|
|
||||||
|
if USE_WINDOWS
|
||||||
|
else
|
||||||
|
libcharon_la_SOURCES += \
|
||||||
|
bus/listeners/sys_logger.c bus/listeners/sys_logger.h
|
||||||
|
endif
|
||||||
|
|
||||||
EXTRA_DIST = Android.mk
|
EXTRA_DIST = Android.mk
|
||||||
|
|
||||||
# compile options
|
# compile options
|
||||||
|
|||||||
+23
-5
@@ -19,10 +19,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <syslog.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
|
#include <syslog.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
@@ -179,6 +182,7 @@ static bool logger_entry_match(logger_entry_t *this, char *target, bool *file)
|
|||||||
*/
|
*/
|
||||||
static void handle_syslog_identifier(private_daemon_t *this)
|
static void handle_syslog_identifier(private_daemon_t *this)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
char *identifier;
|
char *identifier;
|
||||||
|
|
||||||
identifier = lib->settings->get_str(lib->settings, "%s.syslog.identifier",
|
identifier = lib->settings->get_str(lib->settings, "%s.syslog.identifier",
|
||||||
@@ -198,6 +202,7 @@ static void handle_syslog_identifier(private_daemon_t *this)
|
|||||||
closelog();
|
closelog();
|
||||||
this->syslog_identifier = NULL;
|
this->syslog_identifier = NULL;
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SYSLOG */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,6 +211,7 @@ static void handle_syslog_identifier(private_daemon_t *this)
|
|||||||
*/
|
*/
|
||||||
static int get_syslog_facility(char *facility)
|
static int get_syslog_facility(char *facility)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
if (streq(facility, "daemon"))
|
if (streq(facility, "daemon"))
|
||||||
{
|
{
|
||||||
return LOG_DAEMON;
|
return LOG_DAEMON;
|
||||||
@@ -214,6 +220,7 @@ static int get_syslog_facility(char *facility)
|
|||||||
{
|
{
|
||||||
return LOG_AUTHPRIV;
|
return LOG_AUTHPRIV;
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SYSLOG */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,10 +244,12 @@ static logger_entry_t *get_logger_entry(char *target, bool is_file_logger,
|
|||||||
{
|
{
|
||||||
entry->logger.file = file_logger_create(target);
|
entry->logger.file = file_logger_create(target);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_SYSLOG
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entry->logger.sys = sys_logger_create(get_syslog_facility(target));
|
entry->logger.sys = sys_logger_create(get_syslog_facility(target));
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SYSLOG */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -381,18 +390,27 @@ METHOD(daemon_t, load_loggers, void,
|
|||||||
|
|
||||||
for (group = 0; group < DBG_MAX; group++)
|
for (group = 0; group < DBG_MAX; group++)
|
||||||
{
|
{
|
||||||
sys_logger->set_level(sys_logger, group, levels[group]);
|
if (sys_logger)
|
||||||
|
{
|
||||||
|
sys_logger->set_level(sys_logger, group, levels[group]);
|
||||||
|
}
|
||||||
if (to_stderr)
|
if (to_stderr)
|
||||||
{
|
{
|
||||||
file_logger->set_level(file_logger, group, levels[group]);
|
file_logger->set_level(file_logger, group, levels[group]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
charon->bus->add_logger(charon->bus, &sys_logger->logger);
|
if (sys_logger)
|
||||||
|
{
|
||||||
|
charon->bus->add_logger(charon->bus, &sys_logger->logger);
|
||||||
|
}
|
||||||
charon->bus->add_logger(charon->bus, &file_logger->logger);
|
charon->bus->add_logger(charon->bus, &file_logger->logger);
|
||||||
|
|
||||||
sys_logger = add_sys_logger(this, "auth", current_loggers);
|
sys_logger = add_sys_logger(this, "auth", current_loggers);
|
||||||
sys_logger->set_level(sys_logger, DBG_ANY, LEVEL_AUDIT);
|
if (sys_logger)
|
||||||
charon->bus->add_logger(charon->bus, &sys_logger->logger);
|
{
|
||||||
|
sys_logger->set_level(sys_logger, DBG_ANY, LEVEL_AUDIT);
|
||||||
|
charon->bus->add_logger(charon->bus, &sys_logger->logger);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* unregister and destroy any unused remaining loggers */
|
/* unregister and destroy any unused remaining loggers */
|
||||||
current_loggers->destroy_function(current_loggers,
|
current_loggers->destroy_function(current_loggers,
|
||||||
|
|||||||
Reference in New Issue
Block a user