commando: don't deadlock if the make us call into ourselves.

For now we only support calling into commando-rune, not chaining commando
commands!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-08-03 16:54:11 +09:30
parent ad27d4f624
commit b1dace0cd4

View File

@@ -143,6 +143,16 @@ def try_command(plugin, peer_id, idnum, method, params, runestr):
ok, failstr = check_rune(plugin, peer_id, runestr, method, params)
if not ok:
res = {'error': 'Not authorized: ' + failstr}
elif method in plugin.methods:
# Don't try to call indirectly into ourselves; we deadlock!
# But commando-rune is useful, so hardcode that.
if method == "commando-rune":
if isinstance(params, list):
res = {'result': commando_rune(plugin, *params)}
else:
res = {'result': commando_rune(plugin, **params)}
else:
res = {'error': 'FIXME: Refusing to call inside ourselves'}
else:
try:
res = {'result': plugin.rpc.call(method, params)}