diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 2ac05de04..c00e8865b 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1248,11 +1248,14 @@ static void plugin_manifest_timeout(struct plugin *plugin) static const char *plugin_parse_getmanifest_response(const char *buffer, const jsmntok_t *toks, const jsmntok_t *idtok, - struct plugin *plugin) + struct plugin *plugin, + const char **disabled) { const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok; const char *err; + *disabled = NULL; + resulttok = json_get_member(buffer, toks, "result"); if (!resulttok || resulttok->type != JSMN_OBJECT) return tal_fmt(plugin, "Invalid/missing result tok in '%.*s'", @@ -1262,12 +1265,10 @@ static const char *plugin_parse_getmanifest_response(const char *buffer, /* Plugin can disable itself: returns why it's disabled. */ tok = json_get_member(buffer, resulttok, "disable"); if (tok) { - log_debug(plugin->log, "disabled itself: %.*s", - json_tok_full_len(tok), - json_tok_full(buffer, tok)); /* Don't get upset if this was a built-in! */ plugin->important = false; - return json_strdup(plugin, buffer, tok); + *disabled = json_strdup(plugin, buffer, tok); + return NULL; } dynamictok = json_get_member(buffer, resulttok, "dynamic"); @@ -1368,12 +1369,17 @@ static void plugin_manifest_cb(const char *buffer, const jsmntok_t *idtok, struct plugin *plugin) { - const char *err; - err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin); + const char *err, *disabled; + err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin, &disabled); - /* FIXME: log debug if it disabled *itself*! */ if (err) { - plugin_kill(plugin, LOG_INFORM, "%s", err); + plugin_kill(plugin, LOG_UNUSUAL, "%s", err); + return; + } + + if (disabled) { + plugin_kill(plugin, LOG_DBG, + "disabled itself: %s", disabled); return; } @@ -1620,11 +1626,11 @@ static void plugin_config_cb(const char *buffer, /* Plugin can also disable itself at this stage. */ if (json_scan(tmpctx, buffer, toks, "{result:{disable:%}}", JSON_SCAN_TAL(tmpctx, json_strdup, &disable)) == NULL) { - log_debug(plugin->log, "disabled itself at init: %s", - disable); /* Don't get upset if this was a built-in! */ plugin->important = false; - plugin_kill(plugin, LOG_DBG, disable); + plugin_kill(plugin, LOG_DBG, + "disabled itself at init: %s", + disable); return; } diff --git a/tests/test_plugin.py b/tests/test_plugin.py index ce0287727..baec3e09c 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -2374,8 +2374,8 @@ def test_self_disable(node_factory): # Could happen before it gets set up. l1.daemon.logsearch_start = 0 - l1.daemon.wait_for_logs(['test_selfdisable_after_getmanifest: disabled itself: "Self-disable test after getmanifest"', - 'test_libplugin: disabled itself at init: Disabled via selfdisable option']) + l1.daemon.wait_for_logs(['test_selfdisable_after_getmanifest: .* disabled itself: Self-disable test after getmanifest', + 'test_libplugin: .* disabled itself at init: Disabled via selfdisable option']) assert p1 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']] assert p2 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]