For Qt-only Linux builds, set file permissions of config file so that others cannot read the file - as MPD, Magnatune, or DigitallyImported passwords will be saved here.

This commit is contained in:
craig.p.drummond
2013-08-19 17:51:15 +00:00
parent 2a3ad22f56
commit f5ba46870f
2 changed files with 22 additions and 0 deletions

View File

@@ -3,6 +3,9 @@
1. Fix crash in settings dialog if current connection name is removed from
config file.
2. Fix starting of per-user MPD instance.
3. For Qt-only Linux builds, set file permissions of config file so that others
cannot read the file - as MPD, Magnatune, or DigitallyImported passwords
will be saved here.
1.1.0
-----

View File

@@ -33,6 +33,8 @@
#include <QTextCodec>
#include <QLibraryInfo>
#include <QDir>
#include <QFile>
#include <QSettings>
#endif
#include "utils.h"
#include "config.h"
@@ -205,6 +207,23 @@ int main(int argc, char *argv[])
loadTranslation("cantata", INSTALL_PREFIX"/share/cantata/translations/", langEnv);
#endif
// Set the permissions on the config file on Unix - it can contain passwords
// for internet services so it's important that other users can't read it.
// On Windows these are stored in the registry instead.
#ifdef Q_OS_UNIX
QSettings s;
// Create the file if it doesn't exist already
if (!QFile::exists(s.fileName())) {
QFile file(s.fileName());
file.open(QIODevice::WriteOnly);
}
// Set -rw-------
QFile::setPermissions(s.fileName(), QFile::ReadOwner | QFile::WriteOwner);
#endif
if (Settings::self()->firstRun()) {
InitialSettingsWizard wz;
if (QDialog::Rejected==wz.exec()) {