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_shells/pam_shells.c | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'modules/pam_shells') diff --git a/modules/pam_shells/pam_shells.c b/modules/pam_shells/pam_shells.c index 3e639ed0..d5f8ec35 100644 --- a/modules/pam_shells/pam_shells.c +++ b/modules/pam_shells/pam_shells.c @@ -118,6 +118,7 @@ static int perform_check(pam_handle_t *pamh) #else FILE *shellFile; char *p = NULL; + size_t n = 0; if (!check_file(SHELL_FILE, pamh)) return PAM_AUTH_ERR; @@ -130,16 +131,7 @@ static int perform_check(pam_handle_t *pamh) retval = 1; -#if defined(HAVE_GETLINE) || defined (HAVE_GETDELIM) - size_t n = 0; - - while (retval && -#if defined(HAVE_GETLINE) - getline(&p, &n, shellFile) -#elif defined (HAVE_GETDELIM) - getdelim(&p, &n, '\n', shellFile) -#endif - != -1) { + while (retval && getline(&p, &n, shellFile) != -1) { p[strcspn(p, "\n")] = '\0'; if (p[0] != '/') { @@ -149,28 +141,6 @@ static int perform_check(pam_handle_t *pamh) } free(p); -#else - char buf[PATH_MAX + 2]; - int ignore = 0; - - while (retval && fgets(buf, sizeof(buf), shellFile) != NULL) { - p = strchr(buf, '\n'); - if (p == NULL) { - ignore = 1; - continue; - } else if (ignore) { - ignore = 0; - continue; - } - *p = '\0'; - - if (buf[0] != '/') { - continue; - } - retval = strcmp(buf, userShell); - } -#endif - fclose(shellFile); #endif -- cgit v1.2.3