Skip to content
Snippets Groups Projects
Commit c2bec59e authored by Thermi's avatar Thermi Committed by Rasmus Thomsen
Browse files

libpwquality: Fix bug with incorrect linking and issue with _pam_parse...

libpwquality: Fix bug with incorrect linking and issue with _pam_parse (replace internals with pam helper function)
parent ec52eb80
No related branches found
No related tags found
1 merge request!20623libpwquality: Fix bug with incorrect linking and issue with _pam_parse...
Pipeline #83212 passed
--- a/src/pam_pwquality.c 2021-04-14 22:11:31.763901505 +0200
+++ b/src/pam_pwquality.c 2021-04-14 22:14:18.145189196 +0200
@@ -43,8 +43,6 @@
#define CO_RETRY_TIMES 1
-#define PATH_PASSWD "/etc/passwd"
-
static int
_pam_parse (pam_handle_t *pamh, struct module_options *opt,
int argc, const char **argv)
@@ -98,44 +96,7 @@
check_local_user (pam_handle_t *pamh,
const char *user)
{
- struct passwd pw, *pwp;
- char buf[4096];
- int found = 0;
- FILE *fp;
- int errn;
-
- fp = fopen(PATH_PASSWD, "r");
- if (fp == NULL) {
- pam_syslog(pamh, LOG_ERR, "unable to open %s: %s",
- PATH_PASSWD, pam_strerror(pamh, errno));
- return -1;
- }
-
- for (;;) {
- errn = fgetpwent_r(fp, &pw, buf, sizeof (buf), &pwp);
- if (errn == ERANGE) {
- pam_syslog(pamh, LOG_WARNING, "%s contains very long lines; corrupted?",
- PATH_PASSWD);
- /* we can continue here as next call will read further */
- continue;
- }
- if (errn != 0)
- break;
- if (strcmp(pwp->pw_name, user) == 0) {
- found = 1;
- break;
- }
- }
-
- fclose (fp);
-
- if (errn != 0 && errn != ENOENT) {
- pam_syslog(pamh, LOG_ERR, "unable to enumerate local accounts: %s",
- pam_strerror(pamh, errn));
- return -1;
- } else {
- return found;
- }
+ return pam_modutil_check_user_in_passwd(pamh, user, NULL) == PAM_SUCCESS;
}
PAM_EXTERN int
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=libpwquality
pkgver=1.4.4
pkgrel=1
pkgrel=2
pkgdesc="Password quality checking library"
url="https://github.com/libpwquality/libpwquality"
arch="all"
......@@ -10,9 +10,12 @@ depends="cracklib-words"
makedepends="cracklib-dev python3-dev linux-pam-dev"
options="!check" # no tests
subpackages="$pkgname-static $pkgname-dev $pkgname-doc py3-$pkgname:_py3 $pkgname-lang"
source="https://github.com/libpwquality/libpwquality/releases/download/libpwquality-$pkgver/libpwquality-$pkgver.tar.bz2"
source="https://github.com/libpwquality/libpwquality/releases/download/libpwquality-$pkgver/libpwquality-$pkgver.tar.bz2
0001-fix-musl-build.patch
"
build() {
LDFLAGS="$LDFLAGS -lintl" \
./configure \
--build=$CBUILD \
--host=$CHOST \
......@@ -39,4 +42,5 @@ _py3() {
mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}
sha512sums="2d49b79105361663f009f7183fde9123e6f1e63bd678dfe5418143f611e763af8dd44374b826b3c22a00e721047c539741dc44d99a2289b9ab229791768d6e76 libpwquality-1.4.4.tar.bz2"
sha512sums="2d49b79105361663f009f7183fde9123e6f1e63bd678dfe5418143f611e763af8dd44374b826b3c22a00e721047c539741dc44d99a2289b9ab229791768d6e76 libpwquality-1.4.4.tar.bz2
c0b01bbb798a13b706668bdad028334ca6b4bb384dee5d6aefabbd0f4c1946c7e73e50197ced65c959655623570660ed06ef760599e02b770f1d4e4042117912 0001-fix-musl-build.patch"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment