787d6d
From ea3910e561f043f5a131a846862955c77169da1b Mon Sep 17 00:00:00 2001
787d6d
From: Lennart Poettering <lennart@poettering.net>
787d6d
Date: Mon, 19 Nov 2018 11:39:45 +0100
787d6d
Subject: [PATCH] pam_systemd: suppress LOG_DEBUG log messages if debugging is
787d6d
 off
787d6d
787d6d
In the PAM module we need to suppress LOG_DEBUG messages manually, if
787d6d
debug logging is not on, as PAM won't do this for us. We did this
787d6d
correctly for most log messages already, but two were missing. Let's fix
787d6d
those too.
787d6d
787d6d
Fixes: #10822
787d6d
(cherry picked from commit 2675747f3cdd6f1e6236bbb2f79abfa53fb307f1)
787d6d
787d6d
Resolves: #2170084
787d6d
---
787d6d
 src/login/pam_systemd.c | 6 ++++--
787d6d
 1 file changed, 4 insertions(+), 2 deletions(-)
787d6d
787d6d
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
787d6d
index 64e1b4d1bf..c87e980b18 100644
787d6d
--- a/src/login/pam_systemd.c
787d6d
+++ b/src/login/pam_systemd.c
787d6d
@@ -476,7 +476,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
787d6d
         }
787d6d
 
787d6d
         if (seat && !streq(seat, "seat0") && vtnr != 0) {
787d6d
-                pam_syslog(handle, LOG_DEBUG, "Ignoring vtnr %"PRIu32" for %s which is not seat0", vtnr, seat);
787d6d
+                if (debug)
787d6d
+                        pam_syslog(handle, LOG_DEBUG, "Ignoring vtnr %"PRIu32" for %s which is not seat0", vtnr, seat);
787d6d
                 vtnr = 0;
787d6d
         }
787d6d
 
787d6d
@@ -577,7 +578,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
787d6d
         r = sd_bus_call(bus, m, 0, &error, &reply);
787d6d
         if (r < 0) {
787d6d
                 if (sd_bus_error_has_name(&error, BUS_ERROR_SESSION_BUSY)) {
787d6d
-                        pam_syslog(handle, LOG_DEBUG, "Cannot create session: %s", bus_error_message(&error, r));
787d6d
+                        if (debug)
787d6d
+                                pam_syslog(handle, LOG_DEBUG, "Cannot create session: %s", bus_error_message(&error, r));
787d6d
                         return PAM_SUCCESS;
787d6d
                 } else {
787d6d
                         pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error, r));