|
|
388d42 |
From 75ea1d31c17f4bb3a73590167658310bc9f67149 Mon Sep 17 00:00:00 2001
|
|
|
388d42 |
From: Quentin Armitage <quentin@armitage.org.uk>
|
|
|
388d42 |
Date: Mon, 18 Jan 2021 14:57:30 +0000
|
|
|
388d42 |
Subject: [PATCH 2/2] all: log to LOG_DAEMON facility by default
|
|
|
388d42 |
|
|
|
388d42 |
keepalived(8) man page states that the default log facility is LOG_DAEMON.
|
|
|
388d42 |
Commit db3bcf7 - "Explicitly set LOG_USER log facility when syslogging"
|
|
|
388d42 |
incorrectly set the facility to LOG_USER, and that has now been reverted.
|
|
|
388d42 |
However, with that reverted, by default the VRRP process logs to LOG_LOCAL1
|
|
|
388d42 |
and the checker and BFD processes log to LOG_LOCAL2, contrary to the
|
|
|
388d42 |
documentation.
|
|
|
388d42 |
|
|
|
388d42 |
Since no-one has commented that logs were not going to LOG_LOCAL1/2 since
|
|
|
388d42 |
commit db3bcf7 (April 28 2020), it is safe to assume that no-one was relying
|
|
|
388d42 |
on that. This commit therefore reverts to the documentation and by default
|
|
|
388d42 |
logs everything to the LOG_DAEMON facility.
|
|
|
388d42 |
|
|
|
388d42 |
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
|
|
|
388d42 |
---
|
|
|
388d42 |
keepalived/bfd/bfd_daemon.c | 3 +--
|
|
|
388d42 |
keepalived/check/check_daemon.c | 3 +--
|
|
|
388d42 |
keepalived/core/main.c | 7 +++----
|
|
|
388d42 |
keepalived/include/main.h | 1 -
|
|
|
388d42 |
keepalived/vrrp/vrrp_daemon.c | 3 +--
|
|
|
388d42 |
lib/logger.c | 2 ++
|
|
|
388d42 |
lib/logger.h | 10 ++++++++++
|
|
|
388d42 |
7 files changed, 18 insertions(+), 11 deletions(-)
|
|
|
388d42 |
|
|
|
388d42 |
diff --git a/keepalived/bfd/bfd_daemon.c b/keepalived/bfd/bfd_daemon.c
|
|
|
388d42 |
index cf74eee3..47d87892 100644
|
|
|
388d42 |
--- a/keepalived/bfd/bfd_daemon.c
|
|
|
388d42 |
+++ b/keepalived/bfd/bfd_daemon.c
|
|
|
388d42 |
@@ -396,8 +396,7 @@ start_bfd_child(void)
|
|
|
388d42 |
|
|
|
388d42 |
/* Opening local BFD syslog channel */
|
|
|
388d42 |
if (!__test_bit(NO_SYSLOG_BIT, &debug))
|
|
|
388d42 |
- openlog(syslog_ident, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0)
|
|
|
388d42 |
- , (log_facility==LOG_DAEMON) ? LOG_LOCAL2 : log_facility);
|
|
|
388d42 |
+ open_syslog(syslog_ident);
|
|
|
388d42 |
|
|
|
388d42 |
#ifdef ENABLE_LOG_TO_FILE
|
|
|
388d42 |
if (log_file_name)
|
|
|
388d42 |
diff --git a/keepalived/check/check_daemon.c b/keepalived/check/check_daemon.c
|
|
|
388d42 |
index 5e03cc4c..63bdf07b 100644
|
|
|
388d42 |
--- a/keepalived/check/check_daemon.c
|
|
|
388d42 |
+++ b/keepalived/check/check_daemon.c
|
|
|
388d42 |
@@ -689,8 +689,7 @@ start_check_child(void)
|
|
|
388d42 |
|
|
|
388d42 |
/* Opening local CHECK syslog channel */
|
|
|
388d42 |
if (!__test_bit(NO_SYSLOG_BIT, &debug))
|
|
|
388d42 |
- openlog(syslog_ident, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0)
|
|
|
388d42 |
- , (log_facility==LOG_DAEMON) ? LOG_LOCAL2 : log_facility);
|
|
|
388d42 |
+ open_syslog(syslog_ident);
|
|
|
388d42 |
|
|
|
388d42 |
#ifdef ENABLE_LOG_TO_FILE
|
|
|
388d42 |
if (log_file_name)
|
|
|
388d42 |
diff --git a/keepalived/core/main.c b/keepalived/core/main.c
|
|
|
388d42 |
index be4488ea..756b2f12 100644
|
|
|
388d42 |
--- a/keepalived/core/main.c
|
|
|
388d42 |
+++ b/keepalived/core/main.c
|
|
|
388d42 |
@@ -149,7 +149,6 @@ static const struct child_term children_term[] = {
|
|
|
388d42 |
/* global var */
|
|
|
388d42 |
const char *version_string = VERSION_STRING; /* keepalived version */
|
|
|
388d42 |
const char *conf_file = KEEPALIVED_CONFIG_FILE; /* Configuration file */
|
|
|
388d42 |
-int log_facility = LOG_DAEMON; /* Optional logging facilities */
|
|
|
388d42 |
bool reload; /* Set during a reload */
|
|
|
388d42 |
const char *main_pidfile; /* overrule default pidfile */
|
|
|
388d42 |
static bool free_main_pidfile;
|
|
|
388d42 |
@@ -2087,7 +2086,7 @@ keepalived_main(int argc, char **argv)
|
|
|
388d42 |
umask(umask_val);
|
|
|
388d42 |
|
|
|
388d42 |
/* Open log with default settings so we can log initially */
|
|
|
388d42 |
- openlog(PACKAGE_NAME, LOG_PID, log_facility);
|
|
|
388d42 |
+ open_syslog(PACKAGE_NAME);
|
|
|
388d42 |
|
|
|
388d42 |
#ifdef _MEM_CHECK_
|
|
|
388d42 |
mem_log_init(PACKAGE_NAME, "Parent process");
|
|
|
388d42 |
@@ -2128,7 +2127,7 @@ keepalived_main(int argc, char **argv)
|
|
|
388d42 |
if (parse_cmdline(argc, argv)) {
|
|
|
388d42 |
closelog();
|
|
|
388d42 |
if (!__test_bit(NO_SYSLOG_BIT, &debug))
|
|
|
388d42 |
- openlog(PACKAGE_NAME, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0) , log_facility);
|
|
|
388d42 |
+ open_syslog(PACKAGE_NAME);
|
|
|
388d42 |
}
|
|
|
388d42 |
|
|
|
388d42 |
if (__test_bit(LOG_CONSOLE_BIT, &debug))
|
|
|
388d42 |
@@ -2212,7 +2211,7 @@ keepalived_main(int argc, char **argv)
|
|
|
388d42 |
if ((syslog_ident = make_syslog_ident(PACKAGE_NAME))) {
|
|
|
388d42 |
log_message(LOG_INFO, "Changing syslog ident to %s", syslog_ident);
|
|
|
388d42 |
closelog();
|
|
|
388d42 |
- openlog(syslog_ident, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0), log_facility);
|
|
|
388d42 |
+ open_syslog(syslog_ident);
|
|
|
388d42 |
}
|
|
|
388d42 |
else
|
|
|
388d42 |
log_message(LOG_INFO, "Unable to change syslog ident");
|
|
|
388d42 |
diff --git a/keepalived/include/main.h b/keepalived/include/main.h
|
|
|
388d42 |
index 3e013bb6..6a34797b 100644
|
|
|
388d42 |
--- a/keepalived/include/main.h
|
|
|
388d42 |
+++ b/keepalived/include/main.h
|
|
|
388d42 |
@@ -51,7 +51,6 @@ enum daemon_bits {
|
|
|
388d42 |
extern const char *version_string; /* keepalived version */
|
|
|
388d42 |
extern unsigned long daemon_mode; /* Which child processes are run */
|
|
|
388d42 |
extern const char *conf_file; /* Configuration file */
|
|
|
388d42 |
-extern int log_facility; /* Optional logging facilities */
|
|
|
388d42 |
#ifdef _WITH_VRRP_
|
|
|
388d42 |
extern pid_t vrrp_child; /* VRRP child process ID */
|
|
|
388d42 |
extern const char *vrrp_pidfile; /* overrule default pidfile */
|
|
|
388d42 |
diff --git a/keepalived/vrrp/vrrp_daemon.c b/keepalived/vrrp/vrrp_daemon.c
|
|
|
388d42 |
index baa5f5f2..e22f8a81 100644
|
|
|
388d42 |
--- a/keepalived/vrrp/vrrp_daemon.c
|
|
|
388d42 |
+++ b/keepalived/vrrp/vrrp_daemon.c
|
|
|
388d42 |
@@ -974,8 +974,7 @@ start_vrrp_child(void)
|
|
|
388d42 |
syslog_ident = PROG_VRRP;
|
|
|
388d42 |
|
|
|
388d42 |
if (!__test_bit(NO_SYSLOG_BIT, &debug))
|
|
|
388d42 |
- openlog(syslog_ident, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0)
|
|
|
388d42 |
- , (log_facility==LOG_DAEMON) ? LOG_LOCAL1 : log_facility);
|
|
|
388d42 |
+ open_syslog(syslog_ident);
|
|
|
388d42 |
|
|
|
388d42 |
#ifdef ENABLE_LOG_TO_FILE
|
|
|
388d42 |
if (log_file_name)
|
|
|
388d42 |
diff --git a/lib/logger.c b/lib/logger.c
|
|
|
388d42 |
index 34c83f32..7fad8ac6 100644
|
|
|
388d42 |
--- a/lib/logger.c
|
|
|
388d42 |
+++ b/lib/logger.c
|
|
|
388d42 |
@@ -40,6 +40,8 @@
|
|
|
388d42 |
/* Boolean flag - send messages to console as well as syslog */
|
|
|
388d42 |
static bool log_console = false;
|
|
|
388d42 |
|
|
|
388d42 |
+int log_facility = LOG_DAEMON; /* Optional logging facilities */
|
|
|
388d42 |
+
|
|
|
388d42 |
#ifdef ENABLE_LOG_TO_FILE
|
|
|
388d42 |
/* File to write log messages to */
|
|
|
388d42 |
const char *log_file_name;
|
|
|
388d42 |
diff --git a/lib/logger.h b/lib/logger.h
|
|
|
388d42 |
index 20b2a7e4..c6f29138 100644
|
|
|
388d42 |
--- a/lib/logger.h
|
|
|
388d42 |
+++ b/lib/logger.h
|
|
|
388d42 |
@@ -30,8 +30,13 @@
|
|
|
388d42 |
#include <sys/stat.h>
|
|
|
388d42 |
#endif
|
|
|
388d42 |
|
|
|
388d42 |
+#include "bitops.h"
|
|
|
388d42 |
+#include "utils.h"
|
|
|
388d42 |
+
|
|
|
388d42 |
#define MAX_LOG_MSG 255
|
|
|
388d42 |
|
|
|
388d42 |
+extern int log_facility; /* Optional logging facilities */
|
|
|
388d42 |
+
|
|
|
388d42 |
#ifdef ENABLE_LOG_TO_FILE
|
|
|
388d42 |
extern const char *log_file_name;
|
|
|
388d42 |
#endif
|
|
|
388d42 |
@@ -51,4 +56,9 @@ extern void log_message(int priority, const char* format, ...)
|
|
|
388d42 |
extern void conf_write(FILE *fp, const char *format, ...)
|
|
|
388d42 |
__attribute__ ((format (printf, 2, 3)));
|
|
|
388d42 |
|
|
|
388d42 |
+static inline void
|
|
|
388d42 |
+open_syslog(const char *ident)
|
|
|
388d42 |
+{
|
|
|
388d42 |
+ openlog(ident, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0), log_facility);
|
|
|
388d42 |
+}
|
|
|
388d42 |
#endif
|
|
|
388d42 |
--
|
|
|
388d42 |
2.31.1
|
|
|
388d42 |
|