Use roken_get_*() instead of getpwuuid()

Using non-reentrant getpwuid() (or getpwnam(), or getspnam())  can be
dangerous.  We had a report of a login application / PAM that calls
those, and Heimdal, by calling them too, clobbered the cached struct
passwd used by the login app / PAM.
This commit is contained in:
Nicolas Williams
2017-10-12 12:24:05 -05:00
committed by Nico Williams
parent 95eb83c424
commit 620862049e
7 changed files with 42 additions and 145 deletions

View File

@@ -569,6 +569,7 @@ krb5_config_parse_file_multi (krb5_context context,
if (ISTILDE(fname[0]) && ISPATHSEP(fname[1])) {
#ifndef KRB5_USE_PATH_TOKENS
const char *home = NULL;
char homebuf[MAX_PATH];
if (!_krb5_homedir_access(context)) {
context->config_include_depth--;
@@ -577,12 +578,7 @@ krb5_config_parse_file_multi (krb5_context context,
return EPERM;
}
home = secure_getenv("HOME");
if (home == NULL) {
struct passwd *pw = getpwuid(getuid());
if(pw != NULL)
home = pw->pw_dir;
}
home = roken_get_appdatadir(homebuf, sizeof(homebuf));
if (home) {
int aret;