From cc3fab04a396a5bec09051183d45a17cf5fbc019 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Sun, 28 Aug 2022 14:31:08 +0200 Subject: [PATCH] ResourceManager::findPath(): remove the first validate() call and warning - Remove the SGPath::validate() call added in commit 22779ee2c4c8d99485b95aebf4c8e1a2ca1c6bc5 (first part of findPath(): when it is called with a non-null second argument). - Remove the warning printed when the assembled path is absolute and fails the SGPath::validate() read permission test (this caused too much noise and confusion). - Keep the behavior or accepting absolute, existing paths that pass the SGPath::validate() read permission test. This way, the 'play-audio-sample' FGCommand will continue to work with absolute paths. If/when the built-in launcher is updated to set up the read-allowed paths early enough, maybe we can revert FG commits 3ee54cbd72bd8f and 896be707ae558 and re-add the SGPath::validate() call in the first part of findPath()---assuming it is deemed useful. --- simgear/misc/ResourceManager.cxx | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/simgear/misc/ResourceManager.cxx b/simgear/misc/ResourceManager.cxx index fe00b2e8..9c3b6f2e 100644 --- a/simgear/misc/ResourceManager.cxx +++ b/simgear/misc/ResourceManager.cxx @@ -129,23 +129,14 @@ SGPath ResourceManager::findPath(const std::string& aResource, SGPath aContext) { const SGPath completePath(aContext, aResource); - if (!aContext.isNull()) { - const SGPath r = completePath.validate(false); // read access - if (!r.isNull() && r.exists()) { - return r; - } + if (!aContext.isNull() && completePath.exists()) { + return completePath; } - // If the path is absolute and SGPath::validate() grants read access -> OK + // Absolute, existing path and SGPath::validate() grants read access -> OK if (completePath.isAbsolute()) { const auto authorizedPath = completePath.validate(false); - if (authorizedPath.isNull()) { - const auto msg = "ResourceManager::findPath(): access refused " - "because of the SGPath::validate() security policy: '" + - completePath.utf8Str() + "' (maybe a path relative to $FG_ROOT " - "that incorrectly starts with a '/'?)"; - SG_LOG(SG_GENERAL, SG_WARN, msg); - } else if (authorizedPath.exists()) { + if (!authorizedPath.isNull() && authorizedPath.exists()) { return authorizedPath; } }