From b1dace0cd47fd5071683bb53ace47bd17651e804 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 3 Aug 2021 16:54:11 +0930 Subject: [PATCH] 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 --- commando/commando.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/commando/commando.py b/commando/commando.py index 042ae99..2d14770 100755 --- a/commando/commando.py +++ b/commando/commando.py @@ -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)}