1
0
mirror of https://github.com/Yubico/yubico-pam.git synced 2025-01-19 07:52:23 +01:00

switch pam_modutils_getpwnam()/getpwnam() to always use getpwnam_r()

This commit is contained in:
Klas Lindfors 2016-03-31 09:35:46 +02:00
parent b7e7da494a
commit 051dd2a5b2
2 changed files with 13 additions and 15 deletions

View File

@ -49,7 +49,6 @@ AC_CHECK_HEADERS([security/pam_modules.h security/_pam_macros.h security/pam_mod
AC_CHECK_LIB([pam], [pam_start], [AC_SUBST([LIBPAM], ["-lpam"])])
AC_SEARCH_LIBS([pam_modutil_drop_priv], ["pam"], [AC_DEFINE([HAVE_PAM_MODUTIL_DROP_PRIV], [1])])
AC_SEARCH_LIBS([pam_modutil_getpwnam], ["pam"], [AC_DEFINE([HAVE_PAM_MODUTIL_GETPWNAM], [1])])
AC_ARG_WITH([ldap],
[AS_HELP_STRING([--without-ldap],

View File

@ -157,16 +157,15 @@ authorize_user_token (struct cfg *cfg,
else
{
char *userfile = NULL;
struct passwd *p;
struct passwd pass, *p;
char buf[1024];
size_t buflen = sizeof(buf);
int pwres;
PAM_MODUTIL_DEF_PRIVS(privs);
#ifdef HAVE_PAM_MODUTIL_GETPWNAM
p = pam_modutil_getpwnam (pamh, username);
#else
p = getpwnam (username);
#endif
pwres = getpwnam_r (username, &pass, buf, buflen, &p);
if (p == NULL) {
DBG (("getpwnam: %s", strerror(errno)));
DBG (("getpwnam_r: %s", strerror(pwres)));
return 0;
}
@ -447,7 +446,11 @@ do_challenge_response(pam_handle_t *pamh, struct cfg *cfg, const char *username)
const char *errstr = NULL;
struct passwd *p;
struct passwd pass, *p;
char pwbuf[1024];
size_t pwbuflen = sizeof(pwbuf);
int pwres;
struct stat st;
/* we must declare two sepparate privs structures as they can't be reused */
@ -466,13 +469,9 @@ do_challenge_response(pam_handle_t *pamh, struct cfg *cfg, const char *username)
goto out;
}
#ifdef HAVE_PAM_MODUTIL_GETPWNAM
p = pam_modutil_getpwnam (pamh, username);
#else
p = getpwnam (username);
#endif
pwres = getpwnam_r (username, &pass, pwbuf, pwbuflen, &p);
if (p == NULL) {
DBG (("getpwnam: %s", strerror(errno)));
DBG (("getpwnam_r: %s", strerror(pwres)));
goto out;
}