drop module 'package'
Just like with `require`, we don't we don't know how to sandbox it. (Though we still have `require` because standard libraries outside apps need it. I need to make sure apps can't invoke `require`..)
This commit is contained in:
parent
b79d6be383
commit
8a9efc1b91
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
static const luaL_Reg lualibs[] = {
|
static const luaL_Reg lualibs[] = {
|
||||||
{"", luaopen_base},
|
{"", luaopen_base},
|
||||||
{LUA_LOADLIBNAME, luaopen_package},
|
|
||||||
{LUA_TABLIBNAME, luaopen_table},
|
{LUA_TABLIBNAME, luaopen_table},
|
||||||
{LUA_IOLIBNAME, luaopen_io},
|
{LUA_IOLIBNAME, luaopen_io},
|
||||||
{LUA_OSLIBNAME, luaopen_os},
|
{LUA_OSLIBNAME, luaopen_os},
|
||||||
|
|
|
@ -306,22 +306,6 @@ static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ll_loadlib (lua_State *L) {
|
|
||||||
const char *path = luaL_checkstring(L, 1);
|
|
||||||
const char *init = luaL_checkstring(L, 2);
|
|
||||||
int stat = ll_loadfunc(L, path, init);
|
|
||||||
if (stat == 0) /* no errors? */
|
|
||||||
return 1; /* return the loaded function */
|
|
||||||
else { /* error; error message is on stack top */
|
|
||||||
lua_pushnil(L);
|
|
||||||
lua_insert(L, -2);
|
|
||||||
lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init");
|
|
||||||
return 3; /* return nil, error message, and where */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** {======================================================
|
** {======================================================
|
||||||
** 'require' function
|
** 'require' function
|
||||||
|
@ -569,19 +553,6 @@ static int ll_module (lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ll_seeall (lua_State *L) {
|
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
|
||||||
if (!lua_getmetatable(L, 1)) {
|
|
||||||
lua_createtable(L, 0, 1); /* create new metatable */
|
|
||||||
lua_pushvalue(L, -1);
|
|
||||||
lua_setmetatable(L, 1);
|
|
||||||
}
|
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
|
||||||
lua_setfield(L, -2, "__index"); /* mt.__index = _G */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
||||||
|
@ -606,13 +577,6 @@ static void setpath (lua_State *L, const char *fieldname, const char *envname,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const luaL_Reg pk_funcs[] = {
|
|
||||||
{"loadlib", ll_loadlib},
|
|
||||||
{"seeall", ll_seeall},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const luaL_Reg ll_funcs[] = {
|
static const luaL_Reg ll_funcs[] = {
|
||||||
{"module", ll_module},
|
{"module", ll_module},
|
||||||
{"require", ll_require},
|
{"require", ll_require},
|
||||||
|
@ -630,8 +594,6 @@ LUALIB_API int luaopen_package (lua_State *L) {
|
||||||
luaL_newmetatable(L, "_LOADLIB");
|
luaL_newmetatable(L, "_LOADLIB");
|
||||||
lua_pushcfunction(L, gctm);
|
lua_pushcfunction(L, gctm);
|
||||||
lua_setfield(L, -2, "__gc");
|
lua_setfield(L, -2, "__gc");
|
||||||
/* create `package' table */
|
|
||||||
luaL_register(L, LUA_LOADLIBNAME, pk_funcs);
|
|
||||||
#if defined(LUA_COMPAT_LOADLIB)
|
#if defined(LUA_COMPAT_LOADLIB)
|
||||||
lua_getfield(L, -1, "loadlib");
|
lua_getfield(L, -1, "loadlib");
|
||||||
lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
|
lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
|
||||||
|
|
|
@ -267,13 +267,6 @@
|
||||||
*/
|
*/
|
||||||
#undef LUA_COMPAT_GETN
|
#undef LUA_COMPAT_GETN
|
||||||
|
|
||||||
/*
|
|
||||||
@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
|
|
||||||
** CHANGE it to undefined as soon as you do not need a global 'loadlib'
|
|
||||||
** function (the function is still available as 'package.loadlib').
|
|
||||||
*/
|
|
||||||
#undef LUA_COMPAT_LOADLIB
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
|
@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
|
||||||
** CHANGE it to undefined as soon as your programs use only '...' to
|
** CHANGE it to undefined as soon as your programs use only '...' to
|
||||||
|
|
|
@ -60,9 +60,6 @@ LUALIB_API int (luaopen_ssl_config) (lua_State *L);
|
||||||
#define LUA_DBLIBNAME "debug"
|
#define LUA_DBLIBNAME "debug"
|
||||||
LUALIB_API int (luaopen_debug) (lua_State *L);
|
LUALIB_API int (luaopen_debug) (lua_State *L);
|
||||||
|
|
||||||
#define LUA_LOADLIBNAME "package"
|
|
||||||
LUALIB_API int (luaopen_package) (lua_State *L);
|
|
||||||
|
|
||||||
|
|
||||||
/* open all previous libraries */
|
/* open all previous libraries */
|
||||||
LUALIB_API void (luaL_openlibs) (lua_State *L);
|
LUALIB_API void (luaL_openlibs) (lua_State *L);
|
||||||
|
|
Loading…
Reference in New Issue