summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-09-16 14:33:16 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-06-11 17:48:03 +0300
commite3307250cef5efb0c7f27f4bd7451a4bb294adfa (patch)
treea31d22def54e5bd4fb3768559f09c1a37e65bc3c
parent81228b7becb2612321adc779755facb4d93596e4 (diff)
downloadlibrpm-tizen-e3307250cef5efb0c7f27f4bd7451a4bb294adfa.tar.gz
librpm-tizen-e3307250cef5efb0c7f27f4bd7451a4bb294adfa.tar.bz2
librpm-tizen-e3307250cef5efb0c7f27f4bd7451a4bb294adfa.zip
lua: Enable Lua
However, disable the "io" and "os" standard libraries and only enable the access() function from the "posix" extension library. Change-Id: If3b5f0776f6684af4ebaeb7bff742ab9a2123221 Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--luaext/lposix.c4
-rw-r--r--rpmio/rpmlua.c14
2 files changed, 9 insertions, 9 deletions
diff --git a/luaext/lposix.c b/luaext/lposix.c
index f3c787eab..4d5269a4f 100644
--- a/luaext/lposix.c
+++ b/luaext/lposix.c
@@ -813,7 +813,7 @@ static int Pmkstemp(lua_State *L)
static const luaL_Reg R[] =
{
{"access", Paccess},
- {"chdir", Pchdir},
+/* {"chdir", Pchdir},
{"chmod", Pchmod},
{"chown", Pchown},
{"ctermid", Pctermid},
@@ -851,7 +851,7 @@ static const luaL_Reg R[] =
{"utime", Putime},
{"wait", Pwait},
{"setenv", Psetenv},
- {"unsetenv", Punsetenv},
+ {"unsetenv", Punsetenv},*/
{NULL, NULL}
};
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index 49ae7a0aa..8e6841d4e 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -72,7 +72,7 @@ rpmlua rpmluaNew()
{"posix", luaopen_posix},
{"rex", luaopen_rex},
{"rpm", luaopen_rpm},
- {"os", luaopen_rpm_os},
+ /*{"os", luaopen_rpm_os},*/
{NULL, NULL},
};
@@ -86,6 +86,12 @@ rpmlua rpmluaNew()
lua_call(L, 1, 0);
lua_settop(L, 0);
}
+ /* Disable os and io standard libraries */
+ lua_pushnil (L);
+ lua_setglobal(L, "os");
+ lua_pushnil (L);
+ lua_setglobal(L, "io");
+
#ifndef LUA_GLOBALSINDEX
lua_pushglobaltable(L);
#endif
@@ -516,11 +522,6 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
INITSTATE(_lua, lua);
lua_State *L = lua->L;
int ret = 0;
-#define LUA_OUTPUT "UNEXPANDEDLUASCRIPT"
- rpmlog(RPMLOG_WARNING, _("Refusing to run lua code: %s\n"), script);
- lua->printbuf->buf = xcalloc(1, sizeof(LUA_OUTPUT));
- strcpy(lua->printbuf->buf, LUA_OUTPUT);
-#if 0
if (name == NULL)
name = "<lua>";
if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
@@ -534,7 +535,6 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
lua_pop(L, 1);
ret = -1;
}
-#endif
return ret;
}