From 894aaaecb12a1e4a3f8d085dd0fc31b2aee208fc Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 24 Feb 2016 13:55:25 +0100 Subject: [PATCH] Ensure that config files are readable by the daemon refs #11212 refs #11211 --- lib/cli/apisetuputility.cpp | 2 +- lib/cli/nodesetupcommand.cpp | 4 ++-- lib/cli/nodeutility.cpp | 4 ++-- lib/cli/nodewizardcommand.cpp | 4 ++-- lib/cli/repositoryutility.cpp | 2 +- lib/compat/statusdatawriter.cpp | 4 ++-- lib/icinga/clusterevents.cpp | 2 +- lib/icinga/icingaapplication.cpp | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/cli/apisetuputility.cpp b/lib/cli/apisetuputility.cpp index 56011ca57..3af432356 100644 --- a/lib/cli/apisetuputility.cpp +++ b/lib/cli/apisetuputility.cpp @@ -171,7 +171,7 @@ bool ApiSetupUtility::SetupMasterApiUser(void) NodeUtility::CreateBackupFile(apiUsersPath); std::fstream fp; - String tempFilename = Utility::CreateTempFile(apiUsersPath + ".XXXXXX", 0640, fp); + String tempFilename = Utility::CreateTempFile(apiUsersPath + ".XXXXXX", 0644, fp); fp << "/**\n" << " * The APIUser objects are used for authentication against the API.\n" diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index 7d94353c3..cf185b335 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -170,7 +170,7 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v NodeUtility::CreateBackupFile(apipath); std::fstream fp; - String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0640, fp); + String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0644, fp); fp << "/**\n" << " * The API listener is used for distributed monitoring setups.\n" @@ -374,7 +374,7 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm, NodeUtility::CreateBackupFile(apipath); std::fstream fp; - String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0640, fp); + String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0644, fp); fp << "/**\n" << " * The API listener is used for distributed monitoring setups.\n" diff --git a/lib/cli/nodeutility.cpp b/lib/cli/nodeutility.cpp index 49741fe85..b096b2490 100644 --- a/lib/cli/nodeutility.cpp +++ b/lib/cli/nodeutility.cpp @@ -386,7 +386,7 @@ bool NodeUtility::WriteNodeConfigObjects(const String& filename, const Array::Pt } std::fstream fp; - String tempFilename = Utility::CreateTempFile(filename + ".XXXXXX", 0640, fp); + String tempFilename = Utility::CreateTempFile(filename + ".XXXXXX", 0644, fp); fp << "/*\n"; fp << " * Generated by Icinga 2 node setup commands\n"; @@ -640,7 +640,7 @@ void NodeUtility::UpdateConstant(const String& name, const String& value) std::ifstream ifp(constantsFile.CStr()); std::fstream ofp; - String tempFile = Utility::CreateTempFile(constantsFile + ".XXXXXX", 0640, ofp); + String tempFile = Utility::CreateTempFile(constantsFile + ".XXXXXX", 0644, ofp); bool found = false; diff --git a/lib/cli/nodewizardcommand.cpp b/lib/cli/nodewizardcommand.cpp index 87aeb4763..9c89196d0 100644 --- a/lib/cli/nodewizardcommand.cpp +++ b/lib/cli/nodewizardcommand.cpp @@ -413,7 +413,7 @@ wizard_ticket: NodeUtility::CreateBackupFile(apipath); std::fstream fp; - String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0640, fp); + String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0644, fp); fp << "/**\n" << " * The API listener is used for distributed monitoring setups.\n" @@ -538,7 +538,7 @@ wizard_ticket: std::fstream fp; - String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0640, fp); + String tempApiPath = Utility::CreateTempFile(apipath + ".XXXXXX", 0644, fp); fp << "/**\n" << " * The API listener is used for distributed monitoring setups.\n" diff --git a/lib/cli/repositoryutility.cpp b/lib/cli/repositoryutility.cpp index a4d43938e..f2dc51063 100644 --- a/lib/cli/repositoryutility.cpp +++ b/lib/cli/repositoryutility.cpp @@ -497,7 +497,7 @@ bool RepositoryUtility::WriteObjectToRepository(const String& path, const String CreateRepositoryPath(Utility::DirName(path)); std::fstream fp; - String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0640, fp); + String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0644, fp); SerializeObject(fp, name, type, item); fp << std::endl; diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp index 0986fdfdf..134174f70 100644 --- a/lib/compat/statusdatawriter.cpp +++ b/lib/compat/statusdatawriter.cpp @@ -539,7 +539,7 @@ void StatusDataWriter::UpdateObjectsCache(void) String objectsPath = GetObjectsPath(); std::fstream objectfp; - String tempObjectsPath = Utility::CreateTempFile(objectsPath + ".XXXXXX", 0640, objectfp); + String tempObjectsPath = Utility::CreateTempFile(objectsPath + ".XXXXXX", 0644, objectfp); objectfp << std::fixed; @@ -785,7 +785,7 @@ void StatusDataWriter::StatusTimerHandler(void) String statusPath = GetStatusPath(); std::fstream statusfp; - String tempStatusPath = Utility::CreateTempFile(statusPath + ".XXXXXX", 0640, statusfp); + String tempStatusPath = Utility::CreateTempFile(statusPath + ".XXXXXX", 0644, statusfp); statusfp << std::fixed; diff --git a/lib/icinga/clusterevents.cpp b/lib/icinga/clusterevents.cpp index eaf2e62ad..34ff84042 100644 --- a/lib/icinga/clusterevents.cpp +++ b/lib/icinga/clusterevents.cpp @@ -724,7 +724,7 @@ Value ClusterEvents::UpdateRepositoryAPIHandler(const MessageOrigin::Ptr& origin String repositoryFile = GetRepositoryDir() + SHA256(params->Get("endpoint")) + ".repo"; std::fstream fp; - String tempRepositoryFile = Utility::CreateTempFile(repositoryFile + ".XXXXXX", 0640, fp); + String tempRepositoryFile = Utility::CreateTempFile(repositoryFile + ".XXXXXX", 0644, fp); fp << JsonEncode(params); fp.close(); diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index 9bbd81583..26f41d0b2 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -175,7 +175,7 @@ void IcingaApplication::DumpModifiedAttributes(void) String path = GetModAttrPath(); std::fstream fp; - String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0640, fp); + String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0644, fp); ConfigObject::Ptr previousObject; ConfigObject::DumpModifiedAttributes(boost::bind(&PersistModAttrHelper, boost::ref(fp), boost::ref(previousObject), _1, _2, _3));