projects
/
platform
/
upstream
/
dbus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added NameList method handling, small improvemnets and cleanups
[platform/upstream/dbus.git]
/
dbus
/
dbus-sysdeps-util-unix.c
diff --git
a/dbus/dbus-sysdeps-util-unix.c
b/dbus/dbus-sysdeps-util-unix.c
index
ef86d73
..
6265e2b
100644
(file)
--- a/
dbus/dbus-sysdeps-util-unix.c
+++ b/
dbus/dbus-sysdeps-util-unix.c
@@
-49,12
+49,17
@@
#include <sys/socket.h>
#include <dirent.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <dirent.h>
#include <sys/un.h>
+
+#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#include <syslog.h>
+#endif
#ifdef HAVE_SYS_SYSLIMITS_H
#include <sys/syslimits.h>
#endif
#ifdef HAVE_SYS_SYSLIMITS_H
#include <sys/syslimits.h>
#endif
+#include "sd-daemon.h"
+
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@
-123,6
+128,7
@@
_dbus_become_daemon (const DBusString *pidfile,
dup2 (dev_null_fd, 2);
else
_dbus_verbose ("keeping stderr open due to DBUS_DEBUG_OUTPUT\n");
dup2 (dev_null_fd, 2);
else
_dbus_verbose ("keeping stderr open due to DBUS_DEBUG_OUTPUT\n");
+ close (dev_null_fd);
}
if (!keep_umask)
}
if (!keep_umask)
@@
-422,12
+428,19
@@
_dbus_request_file_descriptor_limit (unsigned int limit)
}
void
}
void
-_dbus_init_system_log (
void
)
+_dbus_init_system_log (
dbus_bool_t is_daemon
)
{
{
-#ifdef HAVE_DECL_LOG_PERROR
- openlog ("dbus", LOG_PID | LOG_PERROR, LOG_DAEMON);
-#else
- openlog ("dbus", LOG_PID, LOG_DAEMON);
+#ifdef HAVE_SYSLOG_H
+ int logopts = LOG_PID;
+
+#if HAVE_DECL_LOG_PERROR
+#ifdef HAVE_SYSTEMD
+ if (!is_daemon || sd_booted () <= 0)
+#endif
+ logopts |= LOG_PERROR;
+#endif
+
+ openlog ("dbus", logopts, LOG_DAEMON);
#endif
}
#endif
}
@@
-464,6
+477,8
@@
_dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...)
void
_dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args)
{
void
_dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args)
{
+ va_list tmp;
+#ifdef HAVE_SYSLOG_H
int flags;
switch (severity)
{
int flags;
switch (severity)
{
@@
-480,11
+495,14
@@
_dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args
return;
}
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 */
{
/* 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);
DBUS_VA_COPY (tmp, args);
fprintf (stderr, "dbus[" DBUS_PID_FORMAT "]: ", _dbus_getpid ());
vfprintf (stderr, msg, tmp);
@@
-493,8
+511,6
@@
_dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args
}
#endif
}
#endif
- vsyslog (flags, msg, args);
-
if (severity == DBUS_SYSTEM_LOG_FATAL)
exit (1);
}
if (severity == DBUS_SYSTEM_LOG_FATAL)
exit (1);
}
@@
-540,7
+556,7
@@
_dbus_user_at_console (const char *username,
DBusError *error)
{
DBusError *error)
{
- DBusString f;
+ DBusString
u,
f;
dbus_bool_t result;
result = FALSE;
dbus_bool_t result;
result = FALSE;
@@
-556,8
+572,9
@@
_dbus_user_at_console (const char *username,
goto out;
}
goto out;
}
+ _dbus_string_init_const (&u, username);
- if (!_dbus_
string_append (&f, username
))
+ if (!_dbus_
concat_dir_and_file (&f, &u
))
{
_DBUS_SET_OOM (error);
goto out;
{
_DBUS_SET_OOM (error);
goto out;