diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-21 13:37:03 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-21 13:37:03 +0000 |
commit | 50ec6ec314e224b9d94aec0ac185eaca122f5040 (patch) | |
tree | bb348c486c7d27e1e489238a1a261f94007f5081 /src/lua/lua_cfg_file.c | |
parent | a0569dfc529599362a30eec96272c20b14680e8b (diff) | |
download | rspamd-50ec6ec314e224b9d94aec0ac185eaca122f5040.tar.gz rspamd-50ec6ec314e224b9d94aec0ac185eaca122f5040.zip |
[Minor] Remove obsoleted functions
Diffstat (limited to 'src/lua/lua_cfg_file.c')
-rw-r--r-- | src/lua/lua_cfg_file.c | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c index 5133a4882..acf7e32b1 100644 --- a/src/lua/lua_cfg_file.c +++ b/src/lua/lua_cfg_file.c @@ -201,93 +201,3 @@ rspamd_lua_post_load_config (struct rspamd_config *cfg) lua_settop (L, 0); } - -/* Handle lua dynamic config param */ -gboolean -rspamd_lua_handle_param (struct rspamd_task *task, - gchar *mname, - gchar *optname, - enum lua_var_type expected_type, - gpointer *res) -{ - /* xxx: Adopt this for rcl */ - - /* Option not found */ - *res = NULL; - return FALSE; -} - -#define FAKE_RES_VAR "rspamd_res" -gboolean -rspamd_lua_check_condition (struct rspamd_config *cfg, const gchar *condition) -{ - lua_State *L = cfg->lua_state; - gchar *hostbuf, *condbuf; - gsize hostlen; - gboolean res; -#ifdef HAVE_SYS_UTSNAME_H - struct utsname uts; -#endif - - /* Set some globals for condition */ - /* XXX: think what other variables can be useful */ - hostlen = sysconf (_SC_HOST_NAME_MAX) + 1; - hostbuf = alloca (hostlen); - gethostname (hostbuf, hostlen); - hostbuf[hostlen - 1] = '\0'; - - /* Hostname */ - lua_pushstring (L, hostbuf); - lua_setglobal (L, "hostname"); - /* Config file name */ - lua_pushstring (L, cfg->cfg_name); - lua_setglobal (L, "cfg_name"); - /* Check for uname */ -#ifdef HAVE_SYS_UTSNAME_H - uname (&uts); - lua_pushstring (L, uts.sysname); - lua_setglobal (L, "osname"); - lua_pushstring (L, uts.release); - lua_setglobal (L, "osrelease"); -#else - lua_pushstring (L, "unknown"); - lua_setglobal (L, "osname"); - lua_pushstring (L, ""); - lua_setglobal (L, "osrelease"); -#endif - - /* Rspamd paths */ - lua_newtable (L); - rspamd_lua_table_set (L, "confdir", RSPAMD_CONFDIR); - rspamd_lua_table_set (L, "rundir", RSPAMD_RUNDIR); - rspamd_lua_table_set (L, "dbdir", RSPAMD_DBDIR); - rspamd_lua_table_set (L, "logdir", RSPAMD_LOGDIR); - rspamd_lua_table_set (L, "pluginsdir", RSPAMD_PLUGINSDIR); - rspamd_lua_table_set (L, "prefix", RSPAMD_PREFIX); - lua_setglobal (L, "rspamd_paths"); - - /* Make fake string */ - hostlen = sizeof (FAKE_RES_VAR "=") + strlen (condition); - condbuf = g_malloc (hostlen); - rspamd_strlcpy (condbuf, FAKE_RES_VAR "=", sizeof (FAKE_RES_VAR "=")); - g_strlcat (condbuf, condition, hostlen); - /* Evaluate condition */ - if (luaL_dostring (L, condbuf) != 0) { - msg_err_config("eval of '%s' failed: '%s'", condition, lua_tostring (L, -1)); - g_free (condbuf); - return FALSE; - } - /* Get global variable res to get result */ - lua_getglobal (L, FAKE_RES_VAR); - if (!lua_isboolean (L, -1)) { - msg_err_config("bad string evaluated: %s, type: %s", condbuf, - lua_typename (L, lua_type (L, -1))); - g_free (condbuf); - return FALSE; - } - - res = lua_toboolean (L, -1); - g_free (condbuf); - - return res; -} |