mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-23 03:05:48 +03:00
57 lines
1.8 KiB
Diff
57 lines
1.8 KiB
Diff
--- 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
|