dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0004-DEBUG-fixes-program-identifier-as-seen-in-syslog.patch

bf7bd7
From 18233532b72e62452eac6886652fa633ba055d8c Mon Sep 17 00:00:00 2001
bf7bd7
From: Alexey Tikhonov <atikhono@redhat.com>
bf7bd7
Date: Wed, 21 Oct 2020 19:20:03 +0200
bf7bd7
Subject: [PATCH 4/4] DEBUG: fixes program identifier as seen in syslog
bf7bd7
MIME-Version: 1.0
bf7bd7
Content-Type: text/plain; charset=UTF-8
bf7bd7
Content-Transfer-Encoding: 8bit
bf7bd7
bf7bd7
Commit 225fe9950f2807d5fb226f6b3be1ff4cefd731f0 changed `debug_prg_name`
bf7bd7
to accomodate needs of own SSSD logs, but this affected journal/syslog
bf7bd7
as well.
bf7bd7
bf7bd7
This patch amends situation:
bf7bd7
 - journal messages gets "umbrella" identifier "sssd[]"
bf7bd7
 - syslog uses default which is program name
bf7bd7
bf7bd7
Resolves: https://github.com/SSSD/sssd/issues/5384
bf7bd7
bf7bd7
Reviewed-by: Tomáš Halman <thalman@redhat.com>
bf7bd7
---
bf7bd7
 src/util/debug.c   |  2 +-
bf7bd7
 src/util/sss_log.c | 12 +++---------
bf7bd7
 2 files changed, 4 insertions(+), 10 deletions(-)
bf7bd7
bf7bd7
diff --git a/src/util/debug.c b/src/util/debug.c
bf7bd7
index c162987b9..f05b26500 100644
bf7bd7
--- a/src/util/debug.c
bf7bd7
+++ b/src/util/debug.c
bf7bd7
@@ -250,7 +250,7 @@ static errno_t journal_send(const char *file,
bf7bd7
             "MESSAGE=%s", message,
bf7bd7
             "PRIORITY=%i", LOG_DEBUG,
bf7bd7
             "SSSD_DOMAIN=%s", domain,
bf7bd7
-            "SSSD_PRG_NAME=%s", debug_prg_name,
bf7bd7
+            "SSSD_PRG_NAME=sssd[%s]", debug_prg_name,
bf7bd7
             "SSSD_DEBUG_LEVEL=%x", level,
bf7bd7
             NULL);
bf7bd7
     ret = -res;
bf7bd7
diff --git a/src/util/sss_log.c b/src/util/sss_log.c
bf7bd7
index 48e73dbea..c6b7435c6 100644
bf7bd7
--- a/src/util/sss_log.c
bf7bd7
+++ b/src/util/sss_log.c
bf7bd7
@@ -107,7 +107,7 @@ static void sss_log_internal(int priority, int facility, const char *format,
bf7bd7
                     "SSSD_DOMAIN=%s", domain,
bf7bd7
                     "PRIORITY=%i", syslog_priority,
bf7bd7
                     "SYSLOG_FACILITY=%i", LOG_FAC(facility),
bf7bd7
-                    "SYSLOG_IDENTIFIER=%s", debug_prg_name,
bf7bd7
+                    "SYSLOG_IDENTIFIER=sssd[%s]", debug_prg_name,
bf7bd7
                     NULL);
bf7bd7
 
bf7bd7
     free(message);
bf7bd7
@@ -118,15 +118,9 @@ static void sss_log_internal(int priority, int facility, const char *format,
bf7bd7
 static void sss_log_internal(int priority, int facility, const char *format,
bf7bd7
                             va_list ap)
bf7bd7
 {
bf7bd7
-    int syslog_priority;
bf7bd7
-
bf7bd7
-    syslog_priority = sss_to_syslog(priority);
bf7bd7
-
bf7bd7
-    openlog(debug_prg_name, 0, facility);
bf7bd7
-
bf7bd7
-    vsyslog(syslog_priority, format, ap);
bf7bd7
+    int syslog_priority = sss_to_syslog(priority);
bf7bd7
 
bf7bd7
-    closelog();
bf7bd7
+    vsyslog(facility|syslog_priority, format, ap);
bf7bd7
 }
bf7bd7
 
bf7bd7
 #endif /* WITH_JOURNALD */
bf7bd7
-- 
bf7bd7
2.21.3
bf7bd7