ResourceManager::findPath(): remove the first validate() call and warning

- Remove the SGPath::validate() call added in commit
  22779ee2c4 (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.
next
Florent Rougon 2 years ago
parent f906d82213
commit cc3fab04a3

@ -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;
}
}

Loading…
Cancel
Save