From: Daniel Albers Date: Wed, 22 Feb 2012 00:40:00 +0000 (+0100) Subject: let CMake check for umask() X-Git-Tag: 0.8.0~6 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=26ab99ecabdbff2c7b66dc28039fe904bbce0520 let CMake check for umask() Fixes #1139 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ddaf668..291e21c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -398,6 +398,11 @@ if(HAVE_INDICATEQT) add_definitions(-DXDG_APPS_INSTALL_DIR=${XDG_APPS_INSTALL_DIR}) endif(HAVE_INDICATEQT) +CHECK_FUNCTION_EXISTS(umask HAVE_UMASK) +if(HAVE_UMASK) + add_definitions(-DHAVE_UMASK) +endif(HAVE_UMASK) + # We need to create a version.gen # For this, we create our genversion binary and make sure it is run every time. add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp) diff --git a/src/core/core.cpp b/src/core/core.cpp index 2b4b6a3e..6dc4fa70 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -41,11 +41,10 @@ # include #endif /* Q_OS_WIN32 */ -// umask -#ifndef Q_OS_WIN32 +#ifdef HAVE_UMASK # include # include -#endif /* Q_OS_WIN32 */ +#endif /* HAVE_UMASK */ // ============================== // Custom Events @@ -80,9 +79,9 @@ void Core::destroy() { Core::Core() : _storage(0) { -#ifndef Q_OS_WIN32 +#ifdef HAVE_UMASK umask(S_IRWXG | S_IRWXO); -#endif /* Q_OS_WIN32 */ +#endif _startTime = QDateTime::currentDateTime().toUTC(); // for uptime :) Quassel::loadTranslation(QLocale::system()); diff --git a/src/core/oidentdconfiggenerator.cpp b/src/core/oidentdconfiggenerator.cpp index fac6dcd9..8f65f50b 100644 --- a/src/core/oidentdconfiggenerator.cpp +++ b/src/core/oidentdconfiggenerator.cpp @@ -103,9 +103,13 @@ bool OidentdConfigGenerator::parseConfig(bool readQuasselStanzas) { } bool OidentdConfigGenerator::writeConfig() { +#ifdef HAVE_UMASK mode_t prev_umask = umask(S_IXUSR | S_IWGRP | S_IXGRP | S_IWOTH | S_IXOTH); // == 0133, rw-r--r-- +#endif bool not_open = (!_configFile->isOpen() && !_configFile->open(QIODevice::ReadWrite | QIODevice::Text)); +#ifdef HAVE_UMASK umask(prev_umask); +#endif if (not_open) return false; diff --git a/src/core/oidentdconfiggenerator.h b/src/core/oidentdconfiggenerator.h index 55c06caf..0636a514 100644 --- a/src/core/oidentdconfiggenerator.h +++ b/src/core/oidentdconfiggenerator.h @@ -29,10 +29,10 @@ #include #include -#ifndef Q_OS_WIN32 +#ifdef HAVE_UMASK # include # include -#endif /* Q_OS_WIN32 */ +#endif /* HAVE_UMASK */ #include "quassel.h" #include "coreidentity.h"