From c004ea96111a4407324a2de7188bb463ba84d28f Mon Sep 17 00:00:00 2001
From: Florent Rougon <f.rougon@free.fr>
Date: Sat, 26 Aug 2017 17:49:30 +0200
Subject: [PATCH] Call fgInitAllowedPaths() earlier: after
Options::processOptions()
Call fgInitAllowedPaths() right after Options::processOptions() (which,
among other things, determines $FG_ROOT and processes
--allow-nasal-read). This way, fgInitAllowedPaths() can be used in much
more code, such as when initializing subsystems.
(cherry picked from commit c7a2aef59979af3e9ff22daabb37bdaadb91cd75)
---
src/Main/fg_init.cxx | 7 ++++++-
src/Main/main.cxx | 5 +++++
src/Scripting/NasalSys.cxx | 4 ----
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
index edb464ef2..ff261870a 100644
--- a/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
@@ -1117,7 +1117,12 @@ void fgStartNewReset()
fgInitGeneral(); // all of this?
flightgear::Options::sharedInstance()->processOptions();
-
+
+ // Rebuild the lists of allowed paths for cases where a path comes from an
+ // untrusted source, such as the global property tree (this uses $FG_HOME
+ // and other paths set by Options::processOptions()).
+ fgInitAllowedPaths();
+
// PRESERVED properties over-write state from options, intentionally
if ( copyProperties(preserved, globals->get_props()) ) {
SG_LOG( SG_GENERAL, SG_INFO, "Preserved state restored successfully" );
diff --git a/src/Main/main.cxx b/src/Main/main.cxx
index b7ee1e67e..ec5ca1bbb 100644
--- a/src/Main/main.cxx
+++ b/src/Main/main.cxx
@@ -537,6 +537,11 @@ int fgMainInit( int argc, char **argv )
return EXIT_SUCCESS;
}
+ // Set the lists of allowed paths for cases where a path comes from an
+ // untrusted source, such as the global property tree (this uses $FG_HOME
+ // and other paths set by Options::processOptions()).
+ fgInitAllowedPaths();
+
// Initialize the Window/Graphics environment.
fgOSInit(&argc, argv);
_bootstrap_OSInit++;
diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx
index 36657a970..7b808981a 100644
--- a/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
@@ -911,10 +911,6 @@ void FGNasalSys::init()
.member("simulatedTime", &TimerObj::isSimTime, &f_timerObj_setSimTime)
.member("isRunning", &TimerObj::isRunning);
-
- // Set allowed paths for Nasal I/O
- fgInitAllowedPaths();
-
// Now load the various source files in the Nasal directory
simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal"));
loadScriptDirectory(nasalDir);
--
2.13.5