libpwquality: fix missing symbols fgetpwent_r

Close #40104
This commit is contained in:
Đoàn Trần Công Danh 2022-10-22 22:55:28 +07:00
parent 5cebbb410c
commit 701a7b11fa
3 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,49 @@
From 9084c1b032161cdb53d5f66132a91bdc207faecf Mon Sep 17 00:00:00 2001
From: Noel Kuntze <noel.kuntze@thermi.consulting>
Date: Mon, 24 May 2021 14:15:34 +0200
Subject: [PATCH] pam_pwquality.c: Use pam_modutil_check_user_in_passwd instead
of fgetpwent_r (not available on musl)
---
configure.ac | 5 +++++
src/pam_pwquality.c | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/configure.ac b/configure.ac
index 201a2e6..f995294 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,11 @@ if test "$enable_pam" != "no"; then
test $fail = 1 &&
AC_MSG_ERROR([You must install the PAM development package in order to compile libpwquality])
fi
+ AC_CHECK_FUNC(
+ [pam_modutil_check_user_in_passwd],
+ [AC_DEFINE([HAVE_PAM_CHECK_USER_IN_PASSWD], [], [have pam_modutil_check_user_in_passwd])],
+ []
+ )
fi
if test "$enable_pam" = "yes"; then
diff --git a/src/pam_pwquality.c b/src/pam_pwquality.c
index 53a9b66..5c09bc7 100644
--- a/src/pam_pwquality.c
+++ b/src/pam_pwquality.c
@@ -98,6 +98,9 @@ static int
check_local_user (pam_handle_t *pamh,
const char *user)
{
+#ifdef HAVE_PAM_CHECK_USER_IN_PASSWD
+ return pam_modutil_check_user_in_passwd(pamh, user, NULL) == PAM_SUCCESS;
+#else
struct passwd pw, *pwp;
char buf[4096];
int found = 0;
@@ -136,6 +139,7 @@ check_local_user (pam_handle_t *pamh,
} else {
return found;
}
+#endif
}
PAM_EXTERN int

View File

@ -0,0 +1,39 @@
From 25b7b37fd65df957c24c46ed06884ef19e2852cb Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Wed, 7 Sep 2022 05:42:17 +0100
Subject: [PATCH] pam_pwquality: add include for
pam_modutil_check_user_in_passwd
After 9084c1b032161cdb53d5f66132a91bdc207faecf, one gets:
```
pam_pwquality.c: In function 'check_local_user':
pam_pwquality.c:102:16: error: implicit declaration of function 'pam_modutil_check_user_in_passwd' [-Werror=implicit-function-declaration]
102 | return pam_modutil_check_user_in_passwd(pamh, user, NULL) == PAM_SUCCESS;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [Makefile:634: pam_pwquality.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
```
We need to include security/pam_modutil.h when appropriate.
Signed-off-by: Sam James <sam@gentoo.org>
---
src/pam_pwquality.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/pam_pwquality.c b/src/pam_pwquality.c
index 5c09bc7..d68118a 100644
--- a/src/pam_pwquality.c
+++ b/src/pam_pwquality.c
@@ -34,6 +34,10 @@
#include <security/_pam_macros.h>
#include <security/pam_ext.h>
+#ifdef HAVE_PAM_CHECK_USER_IN_PASSWD
+#include <security/pam_modutil.h>
+#endif
+
/* argument parsing */
#define PAM_DEBUG_ARG 0x0001

View File

@ -1,7 +1,7 @@
# Template file for 'libpwquality' # Template file for 'libpwquality'
pkgname=libpwquality pkgname=libpwquality
version=1.4.4 version=1.4.4
revision=1 revision=2
build_style=gnu-configure build_style=gnu-configure
build_helper=python3 build_helper=python3
configure_args="--disable-static --enable-pam --with-securedir=/usr/lib/security" configure_args="--disable-static --enable-pam --with-securedir=/usr/lib/security"