Nasal standalone interpreter: make SGPath::validate() accept everything
Allow the standalone Nasal interpreter to read and write files or directories everywhere, as long as permitted by the operating system.
This commit is contained in:
parent
484f1da20e
commit
7ddb78a648
1 changed files with 14 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/nasal/nasal.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#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.
|
||||
|
|
Loading…
Reference in a new issue