diff --git a/pam_kwallet.c b/pam_kwallet.c --- a/pam_kwallet.c +++ b/pam_kwallet.c @@ -723,10 +723,16 @@ sprintf(path, "%s/%s/%s", userInfo->pw_dir, kdehome, fixpath); char *salt = NULL; - if (stat(path, &info) != 0 || info.st_size == 0) { + if (stat(path, &info) != 0 || info.st_size == 0 || !S_ISREG(info.st_mode)) { createNewSalt(pamh, path, userInfo); } + if (stat(path, &info) != 0 || info.st_size == 0 || !S_ISREG(info.st_mode)) { + syslog(LOG_ERR, "%s: Failed to ensure %s looks like a salt file", logPrefix, path); + free(path); + return 1; + } + FILE *fd = fopen(path, "r"); if (fd == NULL) { syslog(LOG_ERR, "%s: Couldn't open file: %s because: %d-%s", logPrefix, path, errno, strerror(errno));