From 564d34d1ebb91fdd976aa3e06b2d23202b263fbe Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Aug 2011 16:10:03 +0100 Subject: [PATCH 1/2] Cope with Unixes that don't have LOG_PERROR, like Solaris 10 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39987 --- configure.ac | 5 +++++ dbus/dbus-sysdeps-util-unix.c | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index ad046e0..864303f 100644 --- a/configure.ac +++ b/configure.ac @@ -520,6 +520,11 @@ AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull) +AC_CHECK_HEADERS([syslog.h]) +if test "x$ac_cv_header_syslog_h" = "xyes"; then + AC_CHECK_DECLS([LOG_PERROR], [], [], [[#include ]]) +fi + #### Check for broken poll; taken from Glib's configure AC_MSG_CHECKING([for broken poll]) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index a80f643..d57e6aa 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -422,11 +422,16 @@ _dbus_request_file_descriptor_limit (unsigned int limit) #endif } -void +void _dbus_init_system_log (void) { +#ifdef HAVE_DECL_LOG_PERROR openlog ("dbus", LOG_PID | LOG_PERROR, LOG_DAEMON); +#else + openlog ("dbus", LOG_PID, LOG_DAEMON); +#endif } + /** * Log a message to the system log file (e.g. syslog on Unix). * @@ -476,6 +481,19 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args return; } +#ifndef HAVE_DECL_LOG_PERROR + { + /* vsyslog() won't write to stderr, so we'd better do it */ + va_list tmp; + + DBUS_VA_COPY (tmp, args); + fprintf (stderr, "dbus[" DBUS_PID_FORMAT "]: ", _dbus_getpid ()); + vfprintf (stderr, msg, tmp); + fputc ('\n', stderr); + va_end (tmp); + } +#endif + vsyslog (flags, msg, args); if (severity == DBUS_SYSTEM_LOG_FATAL) -- 1.7.5.4