diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 397ce48d6..fc8a80714 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -469,9 +469,9 @@ static const char *find_my_pkglibexec_path(struct lightningd *ld, /*~ The plugin dir is in ../libexec/c-lightning/plugins, which (unlike * those given on the command line) does not need to exist. */ - add_plugin_dir(ld->plugins, - path_join(tmpctx, pkglibexecdir, "plugins"), - true); + plugins_set_builtin_plugins_dir(ld->plugins, + path_join(tmpctx, + pkglibexecdir, "plugins")); /*~ Sometimes take() can be more efficient, since the routine can * manipulate the string in place. This is the case here. */ @@ -484,10 +484,11 @@ static const char *find_daemon_dir(struct lightningd *ld, const char *argv0) const char *my_path = find_my_directory(ld, argv0); /* If we're running in-tree, all the subdaemons are with lightningd. */ if (has_all_subdaemons(my_path)) { - /* In this case, look in ../plugins */ - add_plugin_dir(ld->plugins, - path_join(tmpctx, my_path, "../plugins"), - true); + /* In this case, look for built-in plugins in ../plugins */ + plugins_set_builtin_plugins_dir(ld->plugins, + path_join(tmpctx, + my_path, + "../plugins")); return my_path; } diff --git a/lightningd/plugin.c b/lightningd/plugin.c index b21a127f1..dc8b577d1 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1526,6 +1526,16 @@ struct log *plugin_get_log(struct plugin *plugin) return plugin->log; } +void plugins_set_builtin_plugins_dir(struct plugins *plugins, + const char *dir) +{ + /*~ The builtin-plugins dir does not need to exist, but + * we would error those anyway for our important built-in + * plugins. + */ + add_plugin_dir(plugins, dir, true); +} + struct plugin_destroyed { const struct plugin *plugin; }; @@ -1536,6 +1546,7 @@ static void mark_plugin_destroyed(const struct plugin *unused, pd->plugin = NULL; } + struct plugin_destroyed *plugin_detect_destruction(const struct plugin *plugin) { struct plugin_destroyed *pd = tal(NULL, struct plugin_destroyed); diff --git a/lightningd/plugin.h b/lightningd/plugin.h index 0b1442cec..5dc98346f 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -334,6 +334,12 @@ struct io_plan *plugin_stdout_conn_init(struct io_conn *conn, */ struct log *plugin_get_log(struct plugin *plugin); +/** + * Tells the plugin system the directory for builtin plugins. + */ +void plugins_set_builtin_plugins_dir(struct plugins *plugins, + const char *dir); + /* Pair of functions to detect if plugin destroys itself: must always * call both! */ struct plugin_destroyed *plugin_detect_destruction(const struct plugin *plugin); diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index f62e15697..1e9a73fe9 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -207,6 +207,9 @@ void plugins_init(struct plugins *plugins UNNEEDED) struct plugins *plugins_new(const tal_t *ctx UNNEEDED, struct log_book *log_book UNNEEDED, struct lightningd *ld UNNEEDED) { fprintf(stderr, "plugins_new called!\n"); abort(); } +void plugins_set_builtin_plugins_dir(struct plugins *plugins UNNEEDED, + const char *dir UNNEEDED) +{ fprintf(stderr, "plugins_set_builtin_plugins_dir called!\n"); abort(); } /* Generated stub for setup_color_and_alias */ void setup_color_and_alias(struct lightningd *ld UNNEEDED) { fprintf(stderr, "setup_color_and_alias called!\n"); abort(); }