From 27df512ce272d88cf85b854f6bfb3f1c7ba4a65c Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 29 May 2018 23:15:57 +0200 Subject: [PATCH] common: Set umask in main() instead of Core::init() Ensure that a restricted umask is set for all binaries, before creating any files. This fixes the fact that client-side configuration files, including the configuration directory itself, were created with world-readable permissions if the system's umask was set accordingly. --- src/common/main.cpp | 9 +++++++++ src/core/core.cpp | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/common/main.cpp b/src/common/main.cpp index accffc60..93932c2d 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -21,6 +21,11 @@ #include #include +#ifdef HAVE_UMASK +# include +# include +#endif /* HAVE_UMASK */ + #include #ifdef BUILD_CORE @@ -68,6 +73,10 @@ Q_IMPORT_PLUGIN(qgif) int main(int argc, char **argv) { +#ifdef HAVE_UMASK + umask(S_IRWXG | S_IRWXO); +#endif + #if QT_VERSION < 0x050000 // All our source files are in UTF-8, and Qt5 even requires that QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); diff --git a/src/core/core.cpp b/src/core/core.cpp index f7938551..80646c03 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -49,11 +49,6 @@ # include #endif /* Q_OS_WIN */ -#ifdef HAVE_UMASK -# include -# include -#endif /* HAVE_UMASK */ - // ============================== // Custom Events // ============================== @@ -91,9 +86,6 @@ void Core::destroy() Core::Core() { -#ifdef HAVE_UMASK - umask(S_IRWXG | S_IRWXO); -#endif _startTime = QDateTime::currentDateTime().toUTC(); // for uptime :) Quassel::loadTranslation(QLocale::system()); -- 2.20.1