| 1618 | } |
| 1619 | |
| 1620 | char *add_plugin_dir(struct plugins *plugins, const char *dir, bool error_ok) |
| 1621 | { |
| 1622 | struct dirent *di; |
| 1623 | DIR *d = opendir(dir); |
| 1624 | struct plugin *p; |
| 1625 | |
| 1626 | if (!d) { |
| 1627 | if (!error_ok && errno == ENOENT) |
| 1628 | return NULL; |
| 1629 | return tal_fmt(NULL, "Failed to open plugin-dir %s: %s", |
| 1630 | dir, strerror(errno)); |
| 1631 | } |
| 1632 | |
| 1633 | while ((di = readdir(d)) != NULL) { |
| 1634 | const char *fullpath; |
| 1635 | |
| 1636 | if (streq(di->d_name, ".") || streq(di->d_name, "..")) |
| 1637 | continue; |
| 1638 | fullpath = plugin_fullpath(tmpctx, dir, di->d_name); |
| 1639 | if (!fullpath) |
| 1640 | continue; |
| 1641 | if (plugin_blacklisted(plugins, fullpath)) { |
| 1642 | log_info(plugins->log, "%s: disabled via disable-plugin", |
| 1643 | fullpath); |
| 1644 | } else { |
| 1645 | p = plugin_register(plugins, fullpath, NULL, false, |
| 1646 | NULL, NULL); |
| 1647 | if (!p && !error_ok) |
| 1648 | return tal_fmt(NULL, "Failed to register %s: %s", |
| 1649 | fullpath, strerror(errno)); |
| 1650 | } |
| 1651 | } |
| 1652 | closedir(d); |
| 1653 | return NULL; |
| 1654 | } |
| 1655 | |
| 1656 | void clear_plugins(struct plugins *plugins) |
| 1657 | { |
no test coverage detected