Skip to content

Commit

Permalink
FIX(client): Permission for settings.json and backup was too open
Browse files Browse the repository at this point in the history
Changes permission for settings.json and corresponding backup file to 600.

Fixes mumble-voip#6652
  • Loading branch information
admin authored and admin committed Dec 14, 2024
1 parent edd4588 commit ce07223
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit ce07223

Please sign in to comment.