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

clear check_user_challenge_file

This commit is contained in:
Larhard 2017-06-23 20:07:00 +00:00
parent ff87bf0ac4
commit d3f50c43ac

13
util.c
View File

@ -290,7 +290,7 @@ check_user_challenge_file(const char *chalresp_path, const struct passwd *user,
* *
* Returns one of AUTH_FOUND, AUTH_NOT_FOUND, AUTH_ERROR * Returns one of AUTH_FOUND, AUTH_NOT_FOUND, AUTH_ERROR
*/ */
int len; size_t len;
int r; int r;
int ret = AUTH_NOT_FOUND; int ret = AUTH_NOT_FOUND;
char *userfile = NULL; char *userfile = NULL;
@ -304,8 +304,10 @@ check_user_challenge_file(const char *chalresp_path, const struct passwd *user,
filename = user->pw_name; filename = user->pw_name;
} }
/* check for userfile challenge files */
r = get_user_cfgfile_path(chalresp_path, filename, user, &userfile); r = get_user_cfgfile_path(chalresp_path, filename, user, &userfile);
if (!r) { if (!r) {
D (debug_file, "Failed to get user cfgfile path");
ret = AUTH_ERROR; ret = AUTH_ERROR;
goto out; goto out;
} }
@ -315,8 +317,11 @@ check_user_challenge_file(const char *chalresp_path, const struct passwd *user,
goto out; goto out;
} }
/* check for userfile-* challenge files */
len = strlen(userfile) + 2 + 1; len = strlen(userfile) + 2 + 1;
if ((userfile_pattern = malloc(len)) == NULL) { if ((userfile_pattern = malloc(len)) == NULL) {
D (debug_file, "Failed to allocate memory for userfile pattern: %s", strerror(errno));
ret = AUTH_ERROR;
goto out; goto out;
} }
snprintf(userfile_pattern, len, "%s-*", userfile); snprintf(userfile_pattern, len, "%s-*", userfile);
@ -324,12 +329,14 @@ check_user_challenge_file(const char *chalresp_path, const struct passwd *user,
r = glob(userfile_pattern, 0, NULL, &userfile_glob); r = glob(userfile_pattern, 0, NULL, &userfile_glob);
globfree(&userfile_glob); globfree(&userfile_glob);
switch (r) { switch (r) {
case GLOB_NOMATCH:
/* No matches found, so continue */
break;
case 0: case 0:
ret = AUTH_FOUND; ret = AUTH_FOUND;
goto out; goto out;
case GLOB_NOMATCH:
break;
default: default:
D (debug_file, "Error while checking for %s challenge files: %s", userfile_pattern, strerror(errno));
ret = AUTH_ERROR; ret = AUTH_ERROR;
goto out; goto out;
} }