]> git.mxchange.org Git - flightgear.git/commitdiff
- allow users to set fg-home dir via FG_HOME environment variable, but
authormfranz <mfranz>
Fri, 13 Jun 2008 10:52:47 +0000 (10:52 +0000)
committermfranz <mfranz>
Fri, 13 Jun 2008 10:52:47 +0000 (10:52 +0000)
- don't allow to do that from any XML file. This is to prevent malign
  code from writing a new fg-home in ~/.fgfs/autosave.xml or other files
  in ~/.fgfs/.

src/Main/fg_init.cxx

index 0c6c42ca3546a05423920860423453e99d81231b..9c94fd2e7dac18d9a8605b4524e30ee88e77b5a3 100644 (file)
@@ -607,7 +607,18 @@ bool fgInitConfig ( int argc, char **argv ) {
         SGPath config( homedir );
         config.append( ".fgfs" );
 #endif
-        fgSetString("/sim/fg-home", config.c_str());
+        const char *fg_home = getenv("FG_HOME");
+        if (fg_home)
+            config = fg_home;
+
+        // Set /sim/fg-home and don't allow malign code to override it until
+        // Nasal security is set up.  Use FG_HOME if necessary.
+        SGPropertyNode *home = fgGetNode("/sim", true);
+        home->removeChild("fg-home", 0, false);
+        home = home->getChild("fg-home", 0, true);
+        home->setStringValue(config.c_str());
+        home->setAttribute(SGPropertyNode::WRITE, false);
+
         config.append( "autosave.xml" );
         SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << config.str());
         try {