MCPcopy Create free account
hub / github.com/ElementsProject/lightning / find_subdaemons_and_plugins

Function find_subdaemons_and_plugins

lightningd/lightningd.c:574–600  ·  view source on GitHub ↗

Determine the correct daemon dir. */

Source from the content-addressed store, hash-verified

572
573/* Determine the correct daemon dir. */
574static void find_subdaemons_and_plugins(struct lightningd *ld, const char *argv0)
575{
576 const char *my_path = find_my_directory(tmpctx, argv0);
577 const char *rel;
578
579 /* If we're running in-tree, all the subdaemons are with lightningd. */
580 if (has_all_subdaemons(my_path)) {
581 /* In this case, look for built-in plugins in ../plugins */
582 plugins_set_builtin_plugins_dir(ld->plugins,
583 path_join(tmpctx,
584 my_path,
585 "../plugins"));
586 ld->subdaemon_dir = tal_steal(ld, my_path);
587 return;
588 }
589
590 /* OK, we're running the installed version? But we used to allow
591 * running in an arbitrary subtree, and people still do (plus,
592 * installcheck does this). So we use relative paths here. path_rel
593 * doesn't work if the paths don't exist, so we use our own function. */
594 rel = relative(NULL, BINDIR, PKGLIBEXECDIR);
595 ld->subdaemon_dir = path_join(ld, my_path, take(rel));
596
597 rel = relative(NULL, BINDIR, PLUGINDIR);
598 plugins_set_builtin_plugins_dir(ld->plugins,
599 path_join(tmpctx, my_path, take(rel)));
600}
601
602/*~ We like to free everything on exit, so valgrind doesn't complain (valgrind
603 * is an awesome runtime memory usage detector for C and C++ programs). In

Callers 1

mainFunction · 0.85

Calls 5

find_my_directoryFunction · 0.85
has_all_subdaemonsFunction · 0.85
path_joinFunction · 0.85
relativeFunction · 0.85

Tested by

no test coverage detected