Closed Pillar1989 closed 3 years ago
Juci allows you to export ubus calls. It is used for things like uci.
Example here: https://github.com/mkschreder/orangerpcd/blob/master/plugins/system.lua
Basically create a lua object that then exports a wraper for the ubus objects. Then you can do rpc access control for these the same way as for the other lua objects. It works pretty well.
I opened your send console.log. But I still cannt do your example.
Wow, I get a bad feeling. I need to do :
/etc/init.d/orange restart
/etc/init.d/rpcd restart
then I'll get the right result. why ?? How to check the orange and rpcd runtime log ? so I can feedback more to you.
Hello again. I had added a lua script.
root@mylinkit:/usr/lib/orange/api# cat wireless.lua
#!/usr/bin/lua
-- JUCI Lua Backend Server API
-- Copyright (c) 2016 Martin Schröder <mkschreder.uk@gmail.com>. All rights reserved.
-- This module is distributed under GNU GPLv3 with additional permission for signed images.
-- See LICENSE file for more details.
local ubus = require("orange/ubus");
return ubus.bind("iwinfo", { "scan", "info" });
But when I call it.
$rpc.wireless.scan({"device":"ra0"}) 50-juci-jquery-console.js:3 websocket > {"jsonrpc":"2.0","id":25,"method":"call","params":["0e3447488782c7b175ad39ac98516bb8","/wireless","scan",{"device":"ra0"}]}
Object {} 50-juci-jquery-console.js:3 {"jsonrpc":"2.0","id":25,"error":{"code":1,"str":"Permission denied"}}
So How add admin authority to my lua script.
You need to define permissions in an acl
rpc /iwinfo scan x rpc /iwinfo info x
and then add that filename (or wildcard) to the user in etc/config/orange. Then restart the server and you should be able to access your functions.
On 5 Oct 2016 17:05, "Baozhu Zuo" notifications@github.com wrote:
Hello again. I had added a lua script.
root@mylinkit:/usr/lib/orange/api# cat wireless.lua #!/usr/bin/lua -- JUCI Lua Backend Server API-- Copyright (c) 2016 Martin Schröder mkschreder.uk@gmail.com. All rights reserved. -- This module is distributed under GNU GPLv3 with additional permission for signed images.-- See LICENSE file for more details. local ubus = require("orange/ubus"); return ubus.bind("iwinfo", { "scan", "info" });
But when I call it.
$rpc.wireless.scan({"device":"ra0"}) 50-juci-jquery-console.js:3 websocket > {"jsonrpc":"2.0","id":25," method":"call","params":["0e3447488782c7b175ad39ac98516b b8","/wireless","scan",{"device":"ra0"}]}
Object {} 50-juci-jquery-console.js:3 {"jsonrpc":"2.0","id":25," error":{"code":1,"str":"Permission denied"}}
So How add admin authority to my lua script.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mkschreder/juci/issues/63#issuecomment-251702154, or mute the thread https://github.com/notifications/unsubscribe-auth/AERqiXB6L9c63jfxR99ZcFSBt9TW_m2sks5qw7y5gaJpZM4KI5f4 .
It seem JUCI only allow call lua api now. How to use rpc call ubus interface? eg: