From d59e21d709da7360f621b7f3fffcfc79818310a9 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sat, 1 Oct 2011 17:15:12 +0100 Subject: [PATCH] Set permissions on Clementine's config file to 0600 --- src/main.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index baaeda10e..b9d12d9d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -342,6 +342,24 @@ int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, true); #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 + // Resources Q_INIT_RESOURCE(data); Q_INIT_RESOURCE(translations);