diff options
author | Jude Melton-Houghton <jwmhjwmh@gmail.com> | 2022-11-28 07:21:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 07:21:43 -0500 |
commit | d0a118f5b1a2cada1d46d4acac55a998e268154d (patch) | |
tree | 72e38e81f8f9ef0d89a6deafa74daa6a261ad49e /src/script/cpp_api | |
parent | 3fd5bff128cacb068c0758d0b33b425dc88beed7 (diff) | |
download | minetest-d0a118f5b1a2cada1d46d4acac55a998e268154d.tar.xz |
Add `minetest.get_game_info` and allow reading `game.conf` (#12989)
Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_security.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp index 0d989ae04..09e971007 100644 --- a/src/script/cpp_api/s_security.cpp +++ b/src/script/cpp_api/s_security.cpp @@ -579,6 +579,17 @@ bool ScriptApiSecurity::checkPath(lua_State *L, const char *path, } lua_pop(L, 1); // Pop mod name + // Allow read-only access to game directory + if (!write_required) { + const SubgameSpec *game_spec = gamedef->getGameSpec(); + if (game_spec && !game_spec->path.empty()) { + str = fs::AbsolutePath(game_spec->path); + if (!str.empty() && fs::PathStartsWith(abs_path, str)) { + return true; + } + } + } + // Allow read-only access to all mod directories if (!write_required) { const std::vector<ModSpec> &mods = gamedef->getMods(); |