How to use --unsafe-scripts?
Moderator: Forum Moderators
-
- Posts: 481
- Joined: August 4th, 2019, 5:27 pm
How to use --unsafe-scripts?
Hi! I found in man wesnoth that there is --unsafe-scripts option. It says "--unsafe-scripts makes the package package available to lua scripts, so that they can load arbitrary packages."
Can somebody guide me what exactly it unlocks and how would be possible to use, let's say, file io if this is enabled? I wanted to make a testing addon for me to carry experiments in Wesnoth, and arranging file io right from the lua code would be a nice addition to that
Can somebody guide me what exactly it unlocks and how would be possible to use, let's say, file io if this is enabled? I wanted to make a testing addon for me to carry experiments in Wesnoth, and arranging file io right from the lua code would be a nice addition to that
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
- Celtic_Minstrel
- Developer
- Posts: 2166
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to use --unsafe-scripts?
Unfortunately, it doesn't expose the
io
module (although arguably it probably should). All it does is add a require
global function, which will allow you to load binary Lua modules written in C or modules installed on your system. It's disabled by default because it would allow an addon to execute arbitrary code on your computer.-
- Posts: 481
- Joined: August 4th, 2019, 5:27 pm
Re: How to use --unsafe-scripts?
Would I be able then to compile io as a C lib and require it then?Celtic_Minstrel wrote: ↑June 29th, 2022, 2:13 am Unfortunately, it doesn't expose theio
module (although arguably it probably should). All it does is add arequire
global function, which will allow you to load binary Lua modules written in C or modules installed on your system. It's disabled by default because it would allow an addon to execute arbitrary code on your computer.
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
- Celtic_Minstrel
- Developer
- Posts: 2166
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to use --unsafe-scripts?
I guess? I can't guarantee it'll work cleanly, as Wesnoth's build of Lua is slightly customized, so errors in C libs built for standard Lua might crash the program in the worst case… but I have no reason to believe it wouldn't work at all. And if you're building it yourself anyway you could just apply the same customizations that Wesnoth does.