Skip to content

Commit

Permalink
check if user file exists before trying to open
Browse files Browse the repository at this point in the history
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
  • Loading branch information
klali committed Jun 24, 2019
1 parent fcfcba6 commit f300115
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pam_yubico.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
Expand Down

0 comments on commit f300115

Please sign in to comment.