From 68a0079c26686363b6202a8abd2712d2bf96d9f2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 Jan 2021 18:03:22 +0100 Subject: [PATCH] ConfigObjectUtility::GetObjectConfigPath(): hash names of not already existing objects ... to avoid too long file names. refs #8022 --- lib/remote/configobjectutility.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index 69762a637..ae6bc1d1a 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -8,11 +8,13 @@ #include "base/configwriter.hpp" #include "base/exception.hpp" #include "base/dependencygraph.hpp" +#include "base/tlsutility.hpp" #include "base/utility.hpp" #include #include #include #include +#include using namespace icinga; @@ -35,8 +37,13 @@ String ConfigObjectUtility::GetObjectConfigPath(const Type::Ptr& type, const Str /* This may throw an exception the caller above must handle. */ String prefix = GetConfigDir(); - return prefix + "/conf.d/" + typeDir + - "/" + EscapeName(fullName) + ".conf"; + auto old (prefix + "/conf.d/" + typeDir + "/" + EscapeName(fullName) + ".conf"); + + if (fullName.GetLength() <= 80u + 3u /* "..." */ + 40u /* hex SHA1 */ || Utility::PathExists(old)) { + return std::move(old); + } + + return prefix + "/conf.d/" + typeDir + "/" + fullName.SubStr(0, 80) + "..." + SHA1(fullName) + ".conf"; } void ConfigObjectUtility::RepairPackage(const String& package)