From 222f2f71ef1694350e0ba190e2b80a6993056110 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 29 Apr 2013 22:15:32 +0200 Subject: [PATCH] Startup check if IOrules/fgValidatePath are working properly --- src/Main/fg_init.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index c0dfa0225..486fbdd40 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -112,6 +112,7 @@ #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();