[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: controlling library load
- From: Viacheslav Usov <via.usov@...>
- Date: Sat, 24 Sep 2022 16:00:42 +0200
On Sat, Sep 24, 2022 at 2:51 AM Sean Conner <sean@conman.org> wrote:
> So I suppose you have something like:
>
> do
> local lua_require = require
> local function new_require(modname)
> if allowed_module(modname) then
> return lua_require(modname)
> else
> error(string.format("module %s not allowed\n",modname))
> end
> end
> require = new_require
> end
Not really, as I explained in another message, but I can have that, too.
Just to make sure I understand your idea, I will rephrase it:
The normal environment has 'require' that applies policy A.
If it decides that the require request for X should be satisfied, it
loads X with a modified environment, whose 'require' will apply policy
B.
Correct?
It seems that I should also separate 'package.loaded', otherwise Y
(loaded by X) may become loadable by the main script (see my other
email to Egor that describes the main/X/Y example setup).
Cheers,
V.