Instead of hard-coding "dbus", report what the executable really is.
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
auth_mechanisms = NULL;
pidfile = NULL;
- _dbus_init_system_log (TRUE);
+ _dbus_init_system_log ("dbus-daemon", TRUE);
if (flags & BUS_CONTEXT_FLAG_SYSTEMD_ACTIVATION)
context->systemd_activation = TRUE;
errno = saved_errno;
}
+static const char *syslog_tag = "dbus";
+
+/**
+ * Initialize the system log.
+ *
+ * The "tag" is not copied, and must remain valid for the entire lifetime of
+ * the process or until _dbus_init_system_log() is called again. In practice
+ * it will normally be a constant.
+ *
+ * @param tag the name of the executable (syslog tag)
+ * @param is_daemon #TRUE if this is the dbus-daemon
+ */
void
-_dbus_init_system_log (dbus_bool_t is_daemon)
+_dbus_init_system_log (const char *tag,
+ dbus_bool_t is_daemon)
{
#ifdef HAVE_SYSLOG_H
int logopts = LOG_PID;
logopts |= LOG_PERROR;
#endif
- openlog ("dbus", logopts, LOG_DAEMON);
+ syslog_tag = tag;
+ openlog (tag, logopts, LOG_DAEMON);
#endif
}
{
/* vsyslog() won't write to stderr, so we'd better do it */
DBUS_VA_COPY (tmp, args);
- fprintf (stderr, "dbus[" DBUS_PID_FORMAT "]: ", _dbus_getpid ());
+ fprintf (stderr, "%s[" DBUS_PID_FORMAT "]: ", syslog_tag, _dbus_getpid ());
vfprintf (stderr, msg, tmp);
fputc ('\n', stderr);
va_end (tmp);
_dbus_win_set_errno (saved_errno);
}
+/**
+ * Initialize the system log.
+ *
+ * The "tag" is not copied, and must remain valid for the entire lifetime of
+ * the process or until _dbus_init_system_log() is called again. In practice
+ * it will normally be a constant.
+ *
+ * @param tag the name of the executable (syslog tag)
+ * @param is_daemon #TRUE if this is the dbus-daemon
+ */
void
-_dbus_init_system_log (dbus_bool_t is_daemon)
+_dbus_init_system_log (const char *tag,
+ dbus_bool_t is_daemon)
{
/* OutputDebugStringA doesn't need any special initialization, do nothing */
}
DBusError *error);
DBUS_PRIVATE_EXPORT
-void _dbus_init_system_log (dbus_bool_t is_daemon);
+void _dbus_init_system_log (const char *tag,
+ dbus_bool_t is_daemon);
typedef enum {
DBUS_SYSTEM_LOG_INFO,
#ifndef G_OS_WIN32
if (g_test_trap_fork (0, 0))
{
- _dbus_init_system_log (FALSE);
+ _dbus_init_system_log ("test-syslog", FALSE);
_dbus_system_log (DBUS_SYSTEM_LOG_FATAL, MESSAGE "%d", 23);
/* should not be reached: exit 0 so the assertion in the main process
* will fail */
if (g_test_trap_fork (0, 0))
{
- _dbus_init_system_log (FALSE);
+ _dbus_init_system_log ("test-syslog", FALSE);
_dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42);
_dbus_system_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45);
_dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666);
g_test_trap_assert_stderr ("*" MESSAGE "42\n*" MESSAGE "45\n*" MESSAGE "666\n*");
#endif
/* manual test (this is the best we can do on Windows) */
- _dbus_init_system_log (FALSE);
+ _dbus_init_system_log ("test-syslog", FALSE);
_dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42);
_dbus_system_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45);
_dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666);