Commit 62841819 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

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
parent 67794cc3
......@@ -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));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment