[luci] issue with jsonrpc "uci" endpoint
Andrew Peebles
peebles at cortina-systems.com
Sun Aug 22 01:47:00 CEST 2010
I believe there is a problem with how the /cgi-bin/luci/rpc/uci endpoint
get handled. RPC calls to the following would fail:
method => get_all
args => [ 'network' ]
method => get_all
args => [ 'network', 'lan' ]
But the following call would succeed:
method => get_all
args => [ 'network', 'lan', 'proto' ]
The error, when it occurs, is "bad argument #3 to \'get_all\' (string
expected, got nil)". The other jsonrpc endpoints (fs, sys, etc) have no
problems.
I believe the issue is in luci-0.9.0/libs/core/luasrc/util.lua, in the
"coroutine-safe drop-in replacement for Lua's "pcall"-function"
routines, where they pass arg1, arg2, arg3, arg4, arg5 around, instead
of "...". This causes a fixed number of arguments to get passed into
uci-12012009.5/lua/uci.c, which is designed to accept a variable number
of non-nil arguments.
I discovered this issue using OpenWRT 10.03. It seems the following
patch fixes the problem:
diff -Naur luci-0.9.0/libs/core/luasrc/util.lua
luci-0.9.0-new/libs/core/luasrc/util.lua
--- luci-0.9.0/libs/core/luasrc/util.lua 2010-04-05
10:48:51.000000000 -0700
+++ luci-0.9.0-new/libs/core/luasrc/util.lua 2010-08-21
16:30:55.000000000 -0700
@@ -771,19 +771,19 @@
end
-- Handle return value of protected call
-function handleReturnValue(err, co, status, arg1, arg2, arg3, arg4, arg5)
+function handleReturnValue(err, co, status, ...)
if not status then
- return false, err(debug.traceback(co, arg1), arg1, arg2,
arg3, arg4, arg5)
+ return false, err(debug.traceback(co, arg1), ...)
end
if coroutine.status(co) ~= 'suspended' then
- return true, arg1, arg2, arg3, arg4, arg5
+ return true, ...
end
- return performResume(err, co, coroutine.yield(arg1, arg2, arg3,
arg4, arg5))
+ return performResume(err, co, coroutine.yield(...))
end
-- Resume execution of protected function call
-function performResume(err, co, arg1, arg2, arg3, arg4, arg5)
- return handleReturnValue(err, co, coroutine.resume(co, arg1,
arg2, arg3, arg4, arg5))
+function performResume(err, co, ...)
+ return handleReturnValue(err, co, coroutine.resume(co, ...))
end
Or, am I missing something here?
a
More information about the luci
mailing list