Blame SOURCES/pam-1.3.1-unix-improve-logging.patch

a46dbe
From a6845905869ccabb5eb802be37241eabec085dc7 Mon Sep 17 00:00:00 2001
a46dbe
From: Tomas Mraz <tmraz@fedoraproject.org>
a46dbe
Date: Mon, 14 Oct 2019 16:52:46 +0200
a46dbe
Subject: [PATCH] pam_unix: Add logging useful for debugging problems
a46dbe
a46dbe
Two messages added about obtaining the username are guarded
a46dbe
by the debug option as these should not be normally
a46dbe
logged - they can be useful for debugging but they do not
a46dbe
indicate any special condition.
a46dbe
a46dbe
The message about authenticating user with blank password is
a46dbe
still just LOG_DEBUG priority but it is logged unconditionally
a46dbe
because it is somewhat extraordinary condition to have an user
a46dbe
with blank password.
a46dbe
a46dbe
* modules/pam_unix/pam_unix_auth.c (pam_sm_authenticate): Replace
a46dbe
  D() macro calls which are not enabled on production builds with
a46dbe
  regular pam_syslog() calls.
a46dbe
---
a46dbe
 modules/pam_unix/pam_unix_auth.c | 7 ++++---
a46dbe
 1 file changed, 4 insertions(+), 3 deletions(-)
a46dbe
a46dbe
diff --git a/modules/pam_unix/pam_unix_auth.c b/modules/pam_unix/pam_unix_auth.c
a46dbe
index 681e49d..3fca945 100644
a46dbe
--- a/modules/pam_unix/pam_unix_auth.c
a46dbe
+++ b/modules/pam_unix/pam_unix_auth.c
a46dbe
@@ -130,15 +130,16 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv)
a46dbe
 			AUTH_RETURN;
a46dbe
 		}
a46dbe
 		if (on(UNIX_DEBUG, ctrl))
a46dbe
-			D(("username [%s] obtained", name));
a46dbe
+			pam_syslog(pamh, LOG_DEBUG, "username [%s] obtained", name);
a46dbe
 	} else {
a46dbe
-		D(("trouble reading username"));
a46dbe
 		if (retval == PAM_CONV_AGAIN) {
a46dbe
 			D(("pam_get_user/conv() function is not ready yet"));
a46dbe
 			/* it is safe to resume this function so we translate this
a46dbe
 			 * retval to the value that indicates we're happy to resume.
a46dbe
 			 */
a46dbe
 			retval = PAM_INCOMPLETE;
a46dbe
+		} else if (on(UNIX_DEBUG, ctrl)) {
a46dbe
+			pam_syslog(pamh, LOG_DEBUG, "could not obtain username");
a46dbe
 		}
a46dbe
 		AUTH_RETURN;
a46dbe
 	}
a46dbe
@@ -146,7 +147,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv)
a46dbe
 	/* if this user does not have a password... */
a46dbe
 
a46dbe
 	if (_unix_blankpasswd(pamh, ctrl, name)) {
a46dbe
-		D(("user '%s' has blank passwd", name));
a46dbe
+		pam_syslog(pamh, LOG_DEBUG, "user [%s] has blank password; authenticated without it", name);
a46dbe
 		name = NULL;
a46dbe
 		retval = PAM_SUCCESS;
a46dbe
 		AUTH_RETURN;
a46dbe
-- 
a46dbe
2.20.1
a46dbe