From 118df982f1f6e960b36794366d829a4bfa2ae706 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Thu, 17 Jun 2021 10:52:25 +0200 Subject: [PATCH] GetObjectConfigPath: only truncate and hash comment and downtime filenames This partially reverts 68a0079c26686363b6202a8abd2712d2bf96d9f2 and keeps the fix only for comment and downtime objects for now. For reasoning, please see the comment in the code. --- lib/remote/configobjectutility.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index df9aa24cc..02e81a19f 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -39,9 +39,21 @@ String ConfigObjectUtility::GetObjectConfigPath(const Type::Ptr& type, const Str String escapedName = EscapeName(fullName); - String old = prefix + escapedName + ".conf"; - if (Utility::PathExists(old)) { - return std::move(old); + String longPath = prefix + escapedName + ".conf"; + + /* + * The long path may cause trouble due to exceeding the allowed filename length of the filesystem. Therefore, the + * preferred solution would be to use the truncated and hashed version as returned at the end of this function. + * However, for compatibility reasons, we have to keep the old long version in some cases. Notably, this could lead + * to the creation of objects that can't be synced to child nodes if they are running an older version. Thus, for + * now, the fix is only enabled for comments and downtimes, as these are the object types for which the issue is + * most likely triggered but can't be worked around easily (you'd have to rename the host and/or service in order to + * be able to schedule a downtime or add an acknowledgement, which is not feasible) and the impact of not syncing + * these objects through the whole cluster is limited. For other object types, we currently prefer to fail the + * creation early so that configuration inconsistencies throughout the cluster are avoided. + */ + if ((type->GetName() != "Comment" && type->GetName() != "Downtime") || Utility::PathExists(longPath)) { + return std::move(longPath); } /* Maximum length 80 bytes object name + 3 bytes "..." + 40 bytes SHA1 (hex-encoded) */