]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #72: configure --with-syslog-facility=LOCAL0-7 with default
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 9 Sep 2019 12:27:55 +0000 (14:27 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 9 Sep 2019 12:27:55 +0000 (14:27 +0200)
  LOG_DAEMON (as before) can set the syslog facility that the server
  uses to log messages.

config.h.in
configure
configure.ac
doc/Changelog
util/log.c

index 1bfe4426d1dec678554898b71115702cf05bd883..1e092fd5b2015a6d8da5e926ec27e5fd6dbe830a 100644 (file)
 /* Use win32 resources and API */
 #undef UB_ON_WINDOWS
 
+/* the SYSLOG_FACILITY to use, default LOG_DAEMON */
+#undef UB_SYSLOG_FACILITY
+
 /* default username */
 #undef UB_USERNAME
 
index 0ed190e67eb7b9072dfd6d86e869c24d55b7ec5f..cbbc177f2df9e9df032fbc94e01f01b6f5881011 100755 (executable)
--- a/configure
+++ b/configure
@@ -850,6 +850,7 @@ enable_alloc_lite
 enable_alloc_nonregional
 with_pthreads
 with_solaris_threads
+with_syslog_facility
 with_pyunbound
 with_pythonmodule
 enable_swig_version_check
@@ -1604,6 +1605,8 @@ Optional Packages:
   --with-pthreads         use pthreads library, or --without-pthreads to
                           disable threading support.
   --with-solaris-threads  use solaris native thread library.
+  --with-syslog-facility=LOCAL0 - LOCAL7
+                          set SYSLOG_FACILITY, default DAEMON
   --with-pyunbound        build PyUnbound, or --without-pyunbound to skip it.
                           (default=no)
   --with-pythonmodule     build Python module, or --without-pythonmodule to
 
 fi # end of non-mingw check of thread libraries
 
+# Check for SYSLOG_FACILITY
+
+# Check whether --with-syslog-facility was given.
+if test "${with_syslog_facility+set}" = set; then :
+  withval=$with_syslog_facility;  UNBOUND_SYSLOG_FACILITY="$withval"
+fi
+
+case "${UNBOUND_SYSLOG_FACILITY}" in
+
+  LOCAL[0-7]) UNBOUND_SYSLOG_FACILITY="LOG_${UNBOUND_SYSLOG_FACILITY}" ;;
+
+           *) UNBOUND_SYSLOG_FACILITY="LOG_DAEMON" ;;
+
+esac
+
+cat >>confdefs.h <<_ACEOF
+#define UB_SYSLOG_FACILITY ${UNBOUND_SYSLOG_FACILITY}
+_ACEOF
+
+
 # Check for PyUnbound
 
 # Check whether --with-pyunbound was given.
index 57f7039fbf1e78deb8e2ca8f5da695fd5068aaf3..daa521ceb421882b1e93d32f64f219974f2e67bf 100644 (file)
@@ -603,6 +603,18 @@ fi
 
 fi # end of non-mingw check of thread libraries
 
+# Check for SYSLOG_FACILITY
+AC_ARG_WITH(syslog-facility, AC_HELP_STRING([--with-syslog-facility=LOCAL0 - LOCAL7], [ set SYSLOG_FACILITY, default DAEMON ]),
+       [ UNBOUND_SYSLOG_FACILITY="$withval" ], [])
+case "${UNBOUND_SYSLOG_FACILITY}" in
+
+  LOCAL[[0-7]]) UNBOUND_SYSLOG_FACILITY="LOG_${UNBOUND_SYSLOG_FACILITY}" ;;
+
+           *) UNBOUND_SYSLOG_FACILITY="LOG_DAEMON" ;;
+
+esac
+AC_DEFINE_UNQUOTED(UB_SYSLOG_FACILITY,${UNBOUND_SYSLOG_FACILITY},[the SYSLOG_FACILITY to use, default LOG_DAEMON])
+
 # Check for PyUnbound
 AC_ARG_WITH(pyunbound,
    AC_HELP_STRING([--with-pyunbound],
index 3e5a4b703c0bddf29f2859b843754c508afdeba2..19d4e2d8d400747340df9671683a71aa5f040c35 100644 (file)
@@ -1,3 +1,8 @@
+9 September 2019: Wouter
+       - Fix #72: configure --with-syslog-facility=LOCAL0-7 with default
+         LOG_DAEMON (as before) can set the syslog facility that the server
+         uses to log messages.
+
 4 September 2019: Wouter
        - Fix #71: fix openssl error squelch commit compilation error.
 
index 318ff1d79107052d70dd0886de8596983d1817cd..63c42f10b83fe1430adfc7e1eeaa9d2d6935a786 100644 (file)
@@ -115,7 +115,9 @@ log_init(const char* filename, int use_syslog, const char* chrootdir)
        if(use_syslog) {
                /* do not delay opening until first write, because we may
                 * chroot and no longer be able to access dev/log and so on */
-               openlog(ident, LOG_NDELAY, LOG_DAEMON);
+               /* the facility is LOG_DAEMON by default, but
+                * --with-syslog-facility=LOCAL[0-7] can override it */
+               openlog(ident, LOG_NDELAY, UB_SYSLOG_FACILITY);
                logging_to_syslog = 1;
                lock_quick_unlock(&log_lock);
                return;