X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-sysdeps-util-unix.c;h=6053265b6f69aeacdbd88dcaa5a1bcbcdda4ae5d;hb=7e1820aa89f6242fdf96e96352e4f27cbd8ccf60;hp=6cff3fe20de4443d2c110e98e0875e82104516cb;hpb=5847982adb42243993859d8814037ab00ce7ac7b;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 6cff3fe..6053265 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -49,12 +49,17 @@ #include #include #include + +#ifdef HAVE_SYSLOG_H #include +#endif #ifdef HAVE_SYS_SYSLIMITS_H #include #endif +#include "sd-daemon.h" + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -376,13 +381,13 @@ _dbus_change_to_daemon_user (const char *user, /** * Attempt to ensure that the current process can open - * at least @limit file descriptors. + * at least @p limit file descriptors. * - * If @limit is lower than the current, it will not be + * If @p limit is lower than the current, it will not be * lowered. No error is returned if the request can * not be satisfied. * - * @limit Number of file descriptors + * @param limit number of file descriptors */ void _dbus_request_file_descriptor_limit (unsigned int limit) @@ -423,12 +428,19 @@ _dbus_request_file_descriptor_limit (unsigned int limit) } void -_dbus_init_system_log (void) +_dbus_init_system_log (dbus_bool_t is_daemon) { +#ifdef HAVE_SYSLOG_H + int logopts = LOG_PID; + #if HAVE_DECL_LOG_PERROR - openlog ("dbus", LOG_PID | LOG_PERROR, LOG_DAEMON); -#else - openlog ("dbus", LOG_PID, LOG_DAEMON); +#ifdef HAVE_SYSTEMD + if (!is_daemon || sd_booted () <= 0) +#endif + logopts |= LOG_PERROR; +#endif + + openlog ("dbus", logopts, LOG_DAEMON); #endif } @@ -465,6 +477,8 @@ _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) void _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args) { + va_list tmp; +#ifdef HAVE_SYSLOG_H int flags; switch (severity) { @@ -481,11 +495,14 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args return; } -#ifndef HAVE_DECL_LOG_PERROR + DBUS_VA_COPY (tmp, args); + vsyslog (flags, msg, tmp); + va_end (tmp); +#endif + +#if !defined(HAVE_SYSLOG_H) || !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); @@ -494,8 +511,6 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args } #endif - vsyslog (flags, msg, args); - if (severity == DBUS_SYSTEM_LOG_FATAL) exit (1); }