diff --git a/util.c b/util.c index f6997f0..6cb4a79 100644 --- a/util.c +++ b/util.c @@ -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 */ - int len; + size_t len; int r; int ret = AUTH_NOT_FOUND; char *userfile = NULL; @@ -304,8 +304,10 @@ check_user_challenge_file(const char *chalresp_path, const struct passwd *user, filename = user->pw_name; } + /* check for userfile challenge files */ r = get_user_cfgfile_path(chalresp_path, filename, user, &userfile); if (!r) { + D (debug_file, "Failed to get user cfgfile path"); ret = AUTH_ERROR; goto out; } @@ -315,8 +317,11 @@ check_user_challenge_file(const char *chalresp_path, const struct passwd *user, goto out; } + /* check for userfile-* challenge files */ len = strlen(userfile) + 2 + 1; if ((userfile_pattern = malloc(len)) == NULL) { + D (debug_file, "Failed to allocate memory for userfile pattern: %s", strerror(errno)); + ret = AUTH_ERROR; goto out; } 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); globfree(&userfile_glob); switch (r) { + case GLOB_NOMATCH: + /* No matches found, so continue */ + break; case 0: ret = AUTH_FOUND; goto out; - case GLOB_NOMATCH: - break; default: + D (debug_file, "Error while checking for %s challenge files: %s", userfile_pattern, strerror(errno)); ret = AUTH_ERROR; goto out; }