File 0002-Ensure-the-salt-file-is-indeed-a-regular-file.patch of Package pam_kwallet
From beec1b39db5985eab486866b6a6d5ac0d8e9bbb3 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Mon, 21 May 2018 10:44:11 +0200
Subject: [PATCH 2/4] Ensure the salt file is indeed a regular file
Summary:
If it's not a regular file we try to re-create it
if we can't for some reason, we bail out
Reviewers: fvogt, mgerstner
Reviewed By: fvogt
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D12991
---
pam_kwallet.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/pam_kwallet.c b/pam_kwallet.c
index 07b357d..ecee6b3 100644
--- a/pam_kwallet.c
+++ b/pam_kwallet.c
@@ -723,10 +723,16 @@ int kwallet_hash(pam_handle_t *pamh, const char *passphrase, struct passwd *user
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));
--
2.17.1