diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-04-06 18:37:11 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-04-06 18:37:11 (GMT) |
commit | f26865e394b69b46fded45abd1b2e63230564f2e (patch) | |
tree | d14dfb0019a4045368ca9cebef837ca4878dcdb0 /Swift/QtUI | |
parent | f878cba32a8205971b780f5e39c65a7e5ed8293a (diff) | |
download | swift-f26865e394b69b46fded45abd1b2e63230564f2e.zip swift-f26865e394b69b46fded45abd1b2e63230564f2e.tar.bz2 |
Force settings permissions to be group and world unreadable.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtSettingsProvider.cpp | 13 | ||||
-rw-r--r-- | Swift/QtUI/QtSettingsProvider.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp index b563af1..a5642d7 100644 --- a/Swift/QtUI/QtSettingsProvider.cpp +++ b/Swift/QtUI/QtSettingsProvider.cpp @@ -7,6 +7,7 @@ #include "QtSettingsProvider.h" #include <QStringList> +#include <QFile> namespace Swift { @@ -24,6 +25,7 @@ std::string QtSettingsProvider::getStringSetting(const std::string &settingPath) void QtSettingsProvider::storeString(const std::string &settingPath, const std::string &settingValue) { settings_.setValue(settingPath.c_str(), settingValue.c_str()); + updatePermissions(); } bool QtSettingsProvider::getBoolSetting(const std::string &settingPath, bool defaultValue) { @@ -33,6 +35,7 @@ bool QtSettingsProvider::getBoolSetting(const std::string &settingPath, bool def void QtSettingsProvider::storeBool(const std::string &settingPath, bool settingValue) { settings_.setValue(settingPath.c_str(), settingValue); + updatePermissions(); } int QtSettingsProvider::getIntSetting(const std::string &settingPath, int defaultValue) { @@ -42,6 +45,7 @@ int QtSettingsProvider::getIntSetting(const std::string &settingPath, int defaul void QtSettingsProvider::storeInt(const std::string &settingPath, int settingValue) { settings_.setValue(settingPath.c_str(), settingValue); + updatePermissions(); } std::vector<std::string> QtSettingsProvider::getAvailableProfiles() { @@ -57,6 +61,7 @@ void QtSettingsProvider::createProfile(const std::string& profile) { QStringList stringList = settings_.value("profileList").toStringList(); stringList.append(profile.c_str()); settings_.setValue("profileList", stringList); + updatePermissions(); } void QtSettingsProvider::removeProfile(const std::string& profile) { @@ -69,11 +74,19 @@ void QtSettingsProvider::removeProfile(const std::string& profile) { QStringList stringList = settings_.value("profileList").toStringList(); stringList.removeAll(profile.c_str()); settings_.setValue("profileList", stringList); + updatePermissions(); } QSettings* QtSettingsProvider::getQSettings() { return &settings_; } +void QtSettingsProvider::updatePermissions() { + QFile file(settings_.fileName()); + if (file.exists()) { + file.setPermissions(QFile::ReadOwner|QFile::WriteOwner); + } +} + } diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h index ca05fe1..8eeb854 100644 --- a/Swift/QtUI/QtSettingsProvider.h +++ b/Swift/QtUI/QtSettingsProvider.h @@ -27,6 +27,10 @@ class QtSettingsProvider : public SettingsProvider { virtual void createProfile(const std::string& profile); virtual void removeProfile(const std::string& profile); QSettings* getQSettings(); + + private: + void updatePermissions(); + private: QSettings settings_; }; |