diff --git a/src/Main/nasal-bin.cxx b/src/Main/nasal-bin.cxx index 980039a71..19fcfb77c 100644 --- a/src/Main/nasal-bin.cxx +++ b/src/Main/nasal-bin.cxx @@ -12,6 +12,7 @@ #endif #include +#include #define HAVE_SQLITE 1 @@ -43,6 +44,16 @@ static naRef print(naContext c, naRef me, int argc, naRef* args) return naNil(); } +void initAllowedPaths() +{ + SGPath::clearListOfAllowedPaths(false); // clear list of read-allowed paths + SGPath::clearListOfAllowedPaths(true); // clear list of write-allowed paths + + // Allow reading and writing anywhere + SGPath::addAllowedPathPattern("*", false); // read operations + SGPath::addAllowedPathPattern("*", true); // write operations +} + #define MAX_PATH_LEN 1024 #define NASTR(s) naStr_fromdata(naNewString(ctx), (s), strlen((s))) int main(int argc, char** argv) @@ -59,6 +70,9 @@ int main(int argc, char** argv) fprintf(stderr, "nasal: must specify a script to run\n"); exit(1); } + + initAllowedPaths(); // for SGPath::validate() + script = argv[1]; // Read the contents of the file into a buffer in memory.