]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Changed Lua library support from all to partial 22705/head
authorTsung-Ju Lii <usefulalgorithm@gmail.com>
Mon, 2 Jul 2018 01:42:32 +0000 (09:42 +0800)
committerTsung-Ju Lii <usefulalgorithm@gmail.com>
Mon, 2 Jul 2018 01:42:32 +0000 (09:42 +0800)
Changed luaL_openlibs, which enables the user to use *all* of the
Lua standard libraries, to various calls of luaL_requiref* so that
only a subset of Lua standard libraries is supported.

Signed-off-by: Tsung-Ju (Andy Lii) <usefulalgorithm@gmail.com>
src/mds/Mantle.cc

index 8bf79c4c00d339438c82b4bb98bd2b4e681d85c2..f03808485b1a609cc83af92be8859e212411630f 100644 (file)
@@ -119,7 +119,21 @@ Mantle::Mantle (void)
   }
 
   /* balancer policies can use basic Lua functions */
-  luaL_openlibs(L);
+  static const luaL_Reg loadedlibs[] = {
+    {"_G", luaopen_base},
+    {LUA_COLIBNAME, luaopen_coroutine},
+    {LUA_STRLIBNAME, luaopen_string},
+    {LUA_MATHLIBNAME, luaopen_math},
+    {LUA_TABLIBNAME, luaopen_table},
+    {LUA_UTF8LIBNAME, luaopen_utf8},
+    {NULL, NULL}
+  };
+
+  const luaL_Reg *lib;
+  for (lib = loadedlibs; lib->func; lib++) {
+      luaL_requiref(L, lib->name, lib->func, 1);
+      lua_pop(L, 1);  /* remove lib */
+  }
 
   /* setup debugging */
   lua_register(L, "BAL_LOG", dout_wrapper);