| 1894 | } |
| 1895 | |
| 1896 | char *add_plugin_dir(struct plugins *plugins, const char *dir, bool error_ok) |
| 1897 | { |
| 1898 | struct dirent *di; |
| 1899 | DIR *d = opendir(dir); |
| 1900 | struct plugin *p; |
| 1901 | |
| 1902 | if (!d) { |
| 1903 | if (!error_ok && errno == ENOENT) |
| 1904 | return NULL; |
| 1905 | return tal_fmt(tmpctx, "Failed to open plugin-dir %s: %s", |
| 1906 | dir, strerror(errno)); |
| 1907 | } |
| 1908 | |
| 1909 | while ((di = readdir(d)) != NULL) { |
| 1910 | const char *fullpath; |
| 1911 | |
| 1912 | if (streq(di->d_name, ".") || streq(di->d_name, "..")) |
| 1913 | continue; |
| 1914 | fullpath = plugin_fullpath(tmpctx, dir, di->d_name); |
| 1915 | if (!fullpath) |
| 1916 | continue; |
| 1917 | if (plugin_blacklisted(plugins, fullpath)) { |
| 1918 | log_info(plugins->log, "%s: disabled via disable-plugin", |
| 1919 | fullpath); |
| 1920 | } else { |
| 1921 | p = plugin_register(plugins, fullpath, NULL, false, |
| 1922 | NULL, NULL); |
| 1923 | if (!p && !error_ok) { |
| 1924 | closedir(d); |
| 1925 | return tal_fmt(tmpctx, "Failed to register %s: %s", |
| 1926 | fullpath, strerror(errno)); |
| 1927 | } |
| 1928 | } |
| 1929 | } |
| 1930 | closedir(d); |
| 1931 | return NULL; |
| 1932 | } |
| 1933 | |
| 1934 | void clear_plugins(struct plugins *plugins) |
| 1935 | { |
no test coverage detected