]> git.mxchange.org Git - flightgear.git/commitdiff
Startup check if IOrules/fgValidatePath are working properly
authorThomas Geymayer <tomgey@gmail.com>
Mon, 29 Apr 2013 20:15:32 +0000 (22:15 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 29 Apr 2013 20:16:51 +0000 (22:16 +0200)
src/Main/fg_init.cxx

index c0dfa0225b185183cabf71e7c56f824dcc766e97..486fbdd407307a2c6bf0997e878b101b1c0c5fdf 100644 (file)
 #include "logger.hxx"
 #include "main.hxx"
 #include "positioninit.hxx"
+#include "util.hxx"
 
 using std::string;
 using std::endl;
@@ -771,6 +772,29 @@ void fgPostInitSubsystems()
     globals->add_subsystem("nasal", nasal, SGSubsystemMgr::INIT);
     nasal->init();
     SG_LOG(SG_GENERAL, SG_INFO, "Nasal init took:" << st.elapsedMSec());
+
+    // Ensure IOrules and path validation are working properly by trying to
+    // access a folder/file which should never be accessible.
+    const char* no_access_path =
+#ifdef _WIN32
+      "Z:"
+#endif
+      "/do-not-access";
+
+    if( fgValidatePath(no_access_path, true) )
+      SG_LOG
+      (
+        SG_GENERAL,
+        SG_ALERT,
+        "Check your IOrules! (write to '" << no_access_path << "' is allowed)"
+      );
+    if( fgValidatePath(no_access_path, false) )
+      SG_LOG
+      (
+        SG_GENERAL,
+        SG_ALERT,
+        "Check your IOrules! (read from '" << no_access_path << "' is allowed)"
+      );
   
     // initialize methods that depend on other subsystems.
     st.stamp();