mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-02-17 21:54:15 +01:00
check if user file exists before trying to open
and return AUTH_NO_TOKENS if file doesn't exist. This fixes issues in the nullok case where this user should just be skipped over, handle other issues with user file as an AUTH_ERROR. fixes #194
This commit is contained in:
parent
fcfcba6c2f
commit
f300115a64
@ -181,6 +181,7 @@ authorize_user_token (struct cfg *cfg,
|
||||
size_t buflen = sizeof(buf);
|
||||
int pwres;
|
||||
PAM_MODUTIL_DEF_PRIVS(privs);
|
||||
struct stat st;
|
||||
|
||||
pwres = getpwnam_r (username, &pass, buf, buflen, &p);
|
||||
if (p == NULL) {
|
||||
@ -206,7 +207,11 @@ authorize_user_token (struct cfg *cfg,
|
||||
goto free_out;
|
||||
}
|
||||
|
||||
retval = check_user_token (userfile, username, otp_id, cfg->debug, cfg->debug_file);
|
||||
if (stat (userfile, &st) != 0 && errno == ENOENT) {
|
||||
retval = AUTH_NO_TOKENS;
|
||||
} else {
|
||||
retval = check_user_token (userfile, username, otp_id, cfg->debug, cfg->debug_file);
|
||||
}
|
||||
|
||||
if(pam_modutil_regain_priv(pamh, &privs)) {
|
||||
DBG ("could not restore privileges");
|
||||
|
Loading…
x
Reference in New Issue
Block a user