From cf492d0cedf10d4128c5cf211998dff2260acb6a Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 12 Dec 2023 08:00:00 +0000 Subject: treewide: assume getline exists Apparently, getline is being used unconditionally in pam_namespace and pam_sepermit. In pam_namespace, it is being used since 2006 when the module was introduced in the first place. Let's assume getline is universally available and let's use it unconditionally in other cases, too. * configure.ac (AC_CHECK_FUNCS): Remove getline and getdelim. * libpam/pam_modutil_searchkey.c (pam_modutil_search_key): Use getline unconditionally. * modules/pam_pwhistory/opasswd.c (check_old_pass, save_old_pass): Likewise. * modules/pam_shells/pam_shells.c (perform_check): Likewise. --- modules/pam_pwhistory/opasswd.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'modules/pam_pwhistory') diff --git a/modules/pam_pwhistory/opasswd.c b/modules/pam_pwhistory/opasswd.c index 6e44ed2a..5f577dfd 100644 --- a/modules/pam_pwhistory/opasswd.c +++ b/modules/pam_pwhistory/opasswd.c @@ -173,24 +173,8 @@ check_old_pass, const char *user, const char *newpass, const char *filename, int while (!feof (oldpf)) { char *cp, *tmp; -#if defined(HAVE_GETLINE) ssize_t n = getline (&buf, &buflen, oldpf); -#elif defined (HAVE_GETDELIM) - ssize_t n = getdelim (&buf, &buflen, '\n', oldpf); -#else - ssize_t n; - if (buf == NULL) - { - buflen = DEFAULT_BUFLEN; - buf = malloc (buflen); - if (buf == NULL) - return PAM_BUF_ERR; - } - buf[0] = '\0'; - fgets (buf, buflen - 1, oldpf); - n = strlen (buf); -#endif /* HAVE_GETLINE / HAVE_GETDELIM */ cp = buf; if (n < 1) @@ -380,29 +364,7 @@ save_old_pass, const char *user, int howmany, const char *filename, int debug UN while (!feof (oldpf)) { char *cp, *tmp, *save; -#if defined(HAVE_GETLINE) ssize_t n = getline (&buf, &buflen, oldpf); -#elif defined (HAVE_GETDELIM) - ssize_t n = getdelim (&buf, &buflen, '\n', oldpf); -#else - ssize_t n; - - if (buf == NULL) - { - buflen = DEFAULT_BUFLEN; - buf = malloc (buflen); - if (buf == NULL) - { - fclose (oldpf); - fclose (newpf); - retval = PAM_BUF_ERR; - goto error_opasswd; - } - } - buf[0] = '\0'; - fgets (buf, buflen - 1, oldpf); - n = strlen (buf); -#endif /* HAVE_GETLINE / HAVE_GETDELIM */ if (n < 1) break; -- cgit v1.2.3