From e59940eb61b318c8d751c8e777e9d50f5ba537da Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 9 Mar 2021 10:50:00 +0100 Subject: [PATCH] plugin: Abort early if we have a misconfiguration in the plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were reporting the failure immediately but still continuing with the startup. This could happen if an important plugin ends up in a race with another plugin (important or not) for a contended resource (CLI option or RPC method name). We would eventually notice that we were supposed to abort, but at that point we already processed a couple of blocks, loaded the entire state, etc. This just aborts early with a sane error message. Changelog-Added: plugin: If there is a misconfiguration with important plugins we now abort early with a more descriptive error message. Reported-by: PsySc0rpi0n Reported-by: Ján Sáreník <@jsarenik> --- lightningd/lightningd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 2bd055735..3aa98da41 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -907,6 +907,16 @@ int main(int argc, char *argv[]) * options registration). */ plugins_init(ld->plugins); + /*~ If the plugis are misconfigured we don't want to proceed. A + * misconfiguration could for example be a plugin marked as important + * not working correctly or a plugin squatting something an important + * plugin needs to register, such as a method or CLI option. If we are + * going to shut down immediately again, we shouldn't spend too much + * effort in starting up. + */ + if (ld->exit_code) + fatal("Could not initialize the plugins, see above for details."); + /*~ Handle options and config. */ handle_opts(ld, argc, argv);