94c0a4f
From d8d11db2cef65da5d2afa7acf21aa9c8cd88abed Mon Sep 17 00:00:00 2001
94c0a4f
From: Tomas Mraz <tmraz@fedoraproject.org>
94c0a4f
Date: Tue, 27 Nov 2018 16:11:03 +0100
94c0a4f
Subject: [PATCH] pam_unix: Use pam_syslog instead of helper_log_err.
94c0a4f
94c0a4f
* modules/pam_unix/passverify.c (verify_pwd_hash): Add pamh argument via
94c0a4f
 PAMH_ARG_DECL. Call pam_syslog() instead of helper_log_err().
94c0a4f
* modules/pam_unix/passverify.h: Adjust the declaration of verify_pwd_hash().
94c0a4f
* modules/pam_unix/support.c (_unix_verify_password): Add the pamh argument
94c0a4f
 to verify_pwd_hash() call.
94c0a4f
---
94c0a4f
 modules/pam_unix/passverify.c | 24 +++++++++++++-----------
94c0a4f
 modules/pam_unix/passverify.h |  6 +++---
94c0a4f
 modules/pam_unix/support.c    |  2 +-
94c0a4f
 3 files changed, 17 insertions(+), 15 deletions(-)
94c0a4f
94c0a4f
diff --git a/modules/pam_unix/passverify.c b/modules/pam_unix/passverify.c
94c0a4f
index 2c808eb5..80e32767 100644
94c0a4f
--- a/modules/pam_unix/passverify.c
94c0a4f
+++ b/modules/pam_unix/passverify.c
94c0a4f
@@ -65,8 +65,8 @@ strip_hpux_aging(char *hash)
94c0a4f
 	}
94c0a4f
 }
94c0a4f
 
94c0a4f
-int
94c0a4f
-verify_pwd_hash(const char *p, char *hash, unsigned int nullok)
94c0a4f
+PAMH_ARG_DECL(int verify_pwd_hash,
94c0a4f
+	const char *p, char *hash, unsigned int nullok)
94c0a4f
 {
94c0a4f
 	size_t hash_len;
94c0a4f
 	char *pp = NULL;
94c0a4f
@@ -116,11 +116,10 @@ verify_pwd_hash(const char *p, char *hash, unsigned int nullok)
94c0a4f
 				 * pam_syslog() needs a pam handle,
94c0a4f
 				 * but that's not available here.
94c0a4f
 				 */
94c0a4f
-				helper_log_err(LOG_ERR,
94c0a4f
-				  "pam_unix(verify_pwd_hash): The method "
94c0a4f
-				  "for computing the hash \"%.6s\" has been "
94c0a4f
-				  "disabled in libcrypt by the preset from "
94c0a4f
-				  "the system's vendor and/or administrator.",
94c0a4f
+				pam_syslog(pamh, LOG_ERR,
94c0a4f
+				  "The support for password hash \"%.6s\" "
94c0a4f
+				  "has been disabled in libcrypt "
94c0a4f
+				  "configuration.",
94c0a4f
 				  hash);
94c0a4f
 			}
94c0a4f
 			/*
94c0a4f
@@ -132,12 +131,15 @@ verify_pwd_hash(const char *p, char *hash, unsigned int nullok)
94c0a4f
 			 * recent implementations of libcrypt.
94c0a4f
 			 */
94c0a4f
 			if (retval_checksalt == CRYPT_SALT_INVALID) {
94c0a4f
-				helper_log_err(LOG_ERR,
94c0a4f
-				  "pam_unix(verify_pwd_hash): The hash \"%.6s\""
94c0a4f
-				  "does not use a method known by the version "
94c0a4f
-				  "of libcrypt this system is supplied with.",
94c0a4f
+				pam_syslog(pamh, LOG_ERR,
94c0a4f
+				  "The password hash \"%.6s\" is unknown to "
94c0a4f
+				  "libcrypt.",
94c0a4f
 				  hash);
94c0a4f
 			}
94c0a4f
+#else
94c0a4f
+#ifndef HELPER_COMPILE
94c0a4f
+			(void)pamh;
94c0a4f
+#endif
94c0a4f
 #endif
94c0a4f
 #ifdef HAVE_CRYPT_R
94c0a4f
 			struct crypt_data *cdata;
94c0a4f
diff --git a/modules/pam_unix/passverify.h b/modules/pam_unix/passverify.h
94c0a4f
index 086c28ac..e9a88fbf 100644
94c0a4f
--- a/modules/pam_unix/passverify.h
94c0a4f
+++ b/modules/pam_unix/passverify.h
94c0a4f
@@ -12,9 +12,6 @@
94c0a4f
 
94c0a4f
 #define OLD_PASSWORDS_FILE      "/etc/security/opasswd"
94c0a4f
 
94c0a4f
-int
94c0a4f
-verify_pwd_hash(const char *p, char *hash, unsigned int nullok);
94c0a4f
-
94c0a4f
 int
94c0a4f
 is_pwd_shadowed(const struct passwd *pwd);
94c0a4f
 
94c0a4f
@@ -65,6 +62,9 @@ read_passwords(int fd, int npass, char **passwords);
94c0a4f
 #define PAMH_ARG(...)			pamh, __VA_ARGS__
94c0a4f
 #endif
94c0a4f
 
94c0a4f
+PAMH_ARG_DECL(int verify_pwd_hash,
94c0a4f
+	const char *p, char *hash, unsigned int nullok);
94c0a4f
+
94c0a4f
 PAMH_ARG_DECL(char * create_password_hash,
94c0a4f
 	const char *password, unsigned long long ctrl, int rounds);
94c0a4f
 
94c0a4f
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c
94c0a4f
index 6894288d..ea5594d2 100644
94c0a4f
--- a/modules/pam_unix/support.c
94c0a4f
+++ b/modules/pam_unix/support.c
94c0a4f
@@ -770,7 +770,7 @@ int _unix_verify_password(pam_handle_t * pamh, const char *name
94c0a4f
 			}
94c0a4f
 		}
94c0a4f
 	} else {
94c0a4f
-		retval = verify_pwd_hash(p, salt, off(UNIX__NONULL, ctrl));
94c0a4f
+		retval = verify_pwd_hash(pamh, p, salt, off(UNIX__NONULL, ctrl));
94c0a4f
 	}
94c0a4f
 
94c0a4f
 	if (retval == PAM_SUCCESS) {