Browse Source

lightningd/plugin.c: Add specific function to give the directory for built-in plugins.

bump-pyln-proto
ZmnSCPxj jxPCSnmZ 4 years ago
committed by neil saitug
parent
commit
3df2333d5d
  1. 15
      lightningd/lightningd.c
  2. 11
      lightningd/plugin.c
  3. 6
      lightningd/plugin.h
  4. 3
      lightningd/test/run-find_my_abspath.c

15
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;
}

11
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);

6
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);

3
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(); }

Loading…
Cancel
Save