Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX(client): Permission for settings.json and backup was too open #6667

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/mumble/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QByteArray>
#include <QDataStream>
#include <QFileDevice>
#include <QFileInfo>
#include <QImageReader>
#include <QMessageBox>
Expand Down Expand Up @@ -139,7 +140,6 @@ bool operator!=(const OverlaySettings &lhs, const OverlaySettings &rhs) {
return !(lhs == rhs);
}


void Settings::save(const QString &path) const {
// Our saving procedure is a 4-step process:
// 1. Write the settings that are to be saved to a temporary file
Expand Down Expand Up @@ -183,6 +183,11 @@ void Settings::save(const QString &path) const {
qUtf8Printable(targetFile.errorString()));
}

// Set permissions to 600 for the backup file
if (!backupFile.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner)) {
qWarning("Failed to set permissions for backup file: %s", qUtf8Printable(backupFile.errorString()));
}

createdSettingsBackup = true;
} else {
// The current instance of Mumble has already created a settings backup while it was running. Thus
Expand All @@ -206,8 +211,14 @@ void Settings::save(const QString &path) const {
qWarning("Failed at moving settings from %s to %s - reason: %s", qUtf8Printable(tmpFile.fileName()),
qUtf8Printable(path), qUtf8Printable(tmpFile.errorString()));
}

// Set permissions to 600 for the main file
if (!targetFile.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner)) {
qWarning("Failed to set permissions for main settings file: %s", qUtf8Printable(targetFile.errorString()));
}
}


void Settings::save() const {
if (settingsLocation.isEmpty()) {
save(findSettingsLocation());
Expand Down
Loading