Code

core: Make the plugin directory configurable.
[sysdb.git] / src / tools / sysdbd / configfile.c
index 95276264ae104174c2fde573560cc0bf700253cb..8dc4394f7abfce9450b82a6b01c69f6aa32eb74e 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #include "tools/sysdbd/configfile.h"
 
 #include "sysdb.h"
@@ -129,15 +133,15 @@ daemon_add_listener(oconfig_item_t *ci)
                return -1;
        }
 
-       tmp[listen_addresses_num] = strdup(address);
-       if (! tmp[listen_addresses_num]) {
+       listen_addresses = tmp;
+       listen_addresses[listen_addresses_num] = strdup(address);
+       if (! listen_addresses[listen_addresses_num]) {
                char buf[1024];
                sdb_log(SDB_LOG_ERR, "config: Failed to allocate memory: %s",
                                sdb_strerror(errno, buf, sizeof(buf)));
                return -1;
        }
 
-       listen_addresses = tmp;
        ++listen_addresses_num;
        return 0;
 } /* daemon_add_listener */
@@ -172,7 +176,7 @@ daemon_load_plugin(oconfig_item_t *ci)
        }
 
        /* returns a negative value on error */
-       return sdb_plugin_load(name, NULL);
+       return sdb_plugin_load(NULL, name, NULL);
 } /* daemon_load_plugin */
 
 static int
@@ -211,7 +215,7 @@ daemon_load_backend(oconfig_item_t *ci)
                }
        }
 
-       return sdb_plugin_load(plugin_name, &ctx);
+       return sdb_plugin_load(NULL, plugin_name, &ctx);
 } /* daemon_load_backend */
 
 static int
@@ -224,8 +228,8 @@ daemon_configure_plugin(oconfig_item_t *ci)
        if (oconfig_get_string(ci, &name)) {
                sdb_log(SDB_LOG_ERR, "config: %s requires a single "
                                "string argument\n"
-                               "\tUsage: LoadBackend BACKEND",
-                               ci->key);
+                               "\tUsage: <%s NAME>...</%s>",
+                               ci->key, ci->key, ci->key);
                return ERR_INVALID_ARG;
        }
 
@@ -246,6 +250,22 @@ static token_parser_t token_parser_list[] = {
  * public API
  */
 
+void
+daemon_free_listen_addresses(void)
+{
+       size_t i;
+
+       if (! listen_addresses)
+               return;
+
+       for (i = 0; i < listen_addresses_num; ++i)
+               free(listen_addresses[i]);
+       free(listen_addresses);
+
+       listen_addresses = NULL;
+       listen_addresses_num = 0;
+} /* daemon_free_listen_addresses */
+
 int
 daemon_parse_config(const char *filename)
 {
@@ -277,6 +297,9 @@ daemon_parse_config(const char *filename)
                        retval = status;
                }
        }
+
+       oconfig_free(ci);
+       free(ci);
        return retval;
 } /* daemon_parse_config */