* will be looked up in the global table.
*
*/
-static int fr_lua_get_field(lua_State *L, request_t *request, char const *field)
+static int fr_lua_get_field(module_ctx_t const *mctx, lua_State *L, request_t *request, char const *field)
{
char buff[512];
char const *p = field, *q;
lua_getglobal(L, p);
if (lua_isnil(L, -1)) {
does_not_exist:
- REMARKER(field, p - field, "Field does not exist");
+ if (request) {
+ REMARKER(field, p - field, "Field does not exist");
+ } else {
+ EMARKER(field, p - field, "Field does not exist");
+ }
return -1;
}
return 0;
if ((size_t) (q - p) >= sizeof(buff)) {
too_long:
- REDEBUG("Field name too long, expected < %zu, got %zu", q - p, sizeof(buff));
+ ROPTIONAL(REDEBUG, ERROR, "Field name too long, expected < %zu, got %zu", q - p, sizeof(buff));
return -1;
}
/*
* Get the function were going to be calling
*/
- if (fr_lua_get_field(L, request, funcname) < 0) {
+ if (fr_lua_get_field(mctx, L, request, funcname) < 0) {
error:
fr_lua_util_set_mctx(NULL);
fr_lua_util_set_request(NULL);