Directory policy exception

For people working on the C++ code.
Post Reply
bzt
Member
Posts: 124
Joined: Tue Sep 24, 2019 14:26

Directory policy exception

by bzt » Post

Hi,

Would it be possible to add one exception to the security policy?

Normally Lua scripts can only access files under the world directory. This is very good and perfectly fine except for schematics. Would it be possible to add "schems" folder next to "world" and "mods" folder and add an exception so that Lua scripts could load and save files in this (only one) directory (which is "../../schems" from the world directory)?

Right now it is very problematic to load schematics into multiple worlds, users have to exit the game, create directory and copy files then restart the game. This exception would make it simple, and it poses no security risk (there would be no access to other worlds nor to the mods directory for example). WorldEdit, Schematic Editor etc. then could check for the MTS file in "world/(world)/schems/mtsfile", and if not found then try to load from "schems/mtsfile".

Cheers,
bzt

Sokomine
Member
Posts: 4191
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: Directory policy exception

by Sokomine » Post

You're not the only one with that problem. My handle_schematics mod was intended to offer schematics found in folders. But it can't do that because MT got too restrictive.
A list of my mods can be found here.

User avatar
Minix
Member
Posts: 93
Joined: Thu Nov 12, 2020 13:51
In-game: Minix

Re: Directory policy exception

by Minix » Post

Have you tried using symbolic links on Linux ? or if you use Windows I think there is a way to make links between files as well. I do not make mods so I do not know much about that, it is just a suggestion.

User avatar
philipbenr
Member
Posts: 1861
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi
Location: United States

Re: Directory policy exception

by philipbenr » Post

Windows since Vista (using NTFS specifically) has supported symlinks. Here's a good How2Geek article about it if that helps: https://www.howtogeek.com/howto/16226/c ... -or-linux/

bzt
Member
Posts: 124
Joined: Tue Sep 24, 2019 14:26

Re: Directory policy exception

by bzt » Post

If one could escape the Lua jail with a simple symbolic link, then the whole directory security policy is garbage and you could throw it out on the window.
Other than that, symlink is no good, because you have to create them manually outside of the game. Meaning
1. start MT
2. create world
3. exit MT
4. locate the world folder
5. create symlink
6. restart MT
7. load world
With that effort I could just simply copy the schem files, no need for symlink, and that's exactly what I try to avoid. The point is, players should be able to load schem files from a common folder without exiting the game after creating a world.

Cheers,
bzt

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests