summaryrefslogtreecommitdiffstats
path: root/server/monitor
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-09-22 09:47:41 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-09-25 09:03:29 -0400
commit8263230a0c543a737ab17a071a0ea964dcab4259 (patch)
tree373caef346d1b73f3dcf6d0d168402f3eecc4d23 /server/monitor
parentc65b34ae1d5794fc4456a25705163f56283047d2 (diff)
downloadsssd-8263230a0c543a737ab17a071a0ea964dcab4259.tar.gz
sssd-8263230a0c543a737ab17a071a0ea964dcab4259.tar.xz
sssd-8263230a0c543a737ab17a071a0ea964dcab4259.zip
Upgrade confdb to version 2
This converts a great many configuration options to the new standard format.
Diffstat (limited to 'server/monitor')
-rw-r--r--server/monitor/monitor.c37
-rw-r--r--server/monitor/monitor_interfaces.h3
-rw-r--r--server/monitor/monitor_sbus.c20
3 files changed, 25 insertions, 35 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index fa9eb0e82..b78a768c3 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -57,7 +57,6 @@
/* ping time cannot be less then once every few seconds or the
* monitor will get crazy hammering children with messages */
#define MONITOR_DEF_PING_TIME 10
-#define MONITOR_CONF_ENTRY "config/services/monitor"
struct svc_spy;
@@ -341,10 +340,9 @@ static int monitor_dbus_init(struct mt_ctx *ctx)
char *monitor_address;
int ret;
- monitor_address = talloc_asprintf(ctx, "unix:path=%s/%s",
- PIPE_PATH, SSSD_SERVICE_PIPE);
- if (!monitor_address) {
- return ENOMEM;
+ ret = monitor_get_sbus_address(ctx, &monitor_address);
+ if (ret != EOK) {
+ return ret;
}
ret = sbus_new_server(ctx, ctx->ev,
@@ -845,7 +843,8 @@ int get_monitor_config(struct mt_ctx *ctx)
int timeout_seconds;
ret = confdb_get_int(ctx->cdb, ctx,
- MONITOR_CONF_ENTRY, "sbusTimeout",
+ CONFDB_MONITOR_CONF_ENTRY,
+ CONFDB_MONITOR_SBUS_TIMEOUT,
10, &timeout_seconds);
if (ret != EOK) {
return ret;
@@ -858,7 +857,8 @@ int get_monitor_config(struct mt_ctx *ctx)
return ENOMEM;
}
ret = confdb_get_string_as_list(ctx->cdb, ctx->service_ctx,
- SERVICE_CONF_ENTRY, "activeServices",
+ CONFDB_MONITOR_CONF_ENTRY,
+ CONFDB_MONITOR_ACTIVE_SERVICES,
&ctx->services);
if (ret != EOK) {
DEBUG(0, ("No services configured!\n"));
@@ -922,13 +922,14 @@ static int get_service_config(struct mt_ctx *ctx, const char *name,
return ENOMEM;
}
- path = talloc_asprintf(svc, "config/services/%s", svc->name);
+ path = talloc_asprintf(svc, CONFDB_SERVICE_PATH_TMPL, svc->name);
if (!path) {
talloc_free(svc);
return ENOMEM;
}
- ret = confdb_get_string(ctx->cdb, svc, path, "command",
+ ret = confdb_get_string(ctx->cdb, svc, path,
+ CONFDB_SERVICE_COMMAND,
NULL, &svc->command);
if (ret != EOK) {
DEBUG(0,("Failed to start service '%s'\n", svc->name));
@@ -948,7 +949,8 @@ static int get_service_config(struct mt_ctx *ctx, const char *name,
}
}
- ret = confdb_get_int(ctx->cdb, svc, path, "timeout",
+ ret = confdb_get_int(ctx->cdb, svc, path,
+ CONFDB_SERVICE_TIMEOUT,
MONITOR_DEF_PING_TIME, &svc->ping_time);
if (ret != EOK) {
DEBUG(0,("Failed to start service '%s'\n", svc->name));
@@ -1007,29 +1009,32 @@ static int get_provider_config(struct mt_ctx *ctx, const char *name,
return ENOMEM;
}
- path = talloc_asprintf(svc, "config/domains/%s", name);
+ path = talloc_asprintf(svc, CONFDB_DOMAIN_PATH_TMPL, name);
if (!path) {
talloc_free(svc);
return ENOMEM;
}
ret = confdb_get_string(ctx->cdb, svc, path,
- "provider", NULL, &svc->provider);
+ CONFDB_DOMAIN_ID_PROVIDER,
+ NULL, &svc->provider);
if (ret != EOK) {
- DEBUG(0, ("Failed to find provider from [%s] configuration\n", name));
+ DEBUG(0, ("Failed to find ID provider from [%s] configuration\n", name));
talloc_free(svc);
return ret;
}
ret = confdb_get_string(ctx->cdb, svc, path,
- "command", NULL, &svc->command);
+ CONFDB_DOMAIN_COMMAND,
+ NULL, &svc->command);
if (ret != EOK) {
DEBUG(0, ("Failed to find command from [%s] configuration\n", name));
talloc_free(svc);
return ret;
}
- ret = confdb_get_int(ctx->cdb, svc, path, "timeout",
+ ret = confdb_get_int(ctx->cdb, svc, path,
+ CONFDB_DOMAIN_TIMEOUT,
MONITOR_DEF_PING_TIME, &svc->ping_time);
if (ret != EOK) {
DEBUG(0,("Failed to start service '%s'\n", svc->name));
@@ -2427,7 +2432,7 @@ int main(int argc, const char *argv[])
if (ret != EOK) return 4;
/* set up things like debug , signals, daemonization, etc... */
- ret = server_setup("sssd", flags, MONITOR_CONF_ENTRY, &main_ctx);
+ ret = server_setup("sssd", flags, CONFDB_MONITOR_CONF_ENTRY, &main_ctx);
if (ret != EOK) return 2;
monitor->ev = main_ctx->event_ctx;
diff --git a/server/monitor/monitor_interfaces.h b/server/monitor/monitor_interfaces.h
index 7d0390bfd..1835718f0 100644
--- a/server/monitor/monitor_interfaces.h
+++ b/server/monitor/monitor_interfaces.h
@@ -44,8 +44,7 @@
#define SSSD_SERVICE_PIPE "private/sbus-monitor"
-int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, struct confdb_ctx *confdb,
- char **address);
+int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, char **address);
int monitor_common_send_id(struct sbus_connection *conn,
const char *name, uint16_t version);
int monitor_common_pong(DBusMessage *message,
diff --git a/server/monitor/monitor_sbus.c b/server/monitor/monitor_sbus.c
index 9995986b8..3f73e84f7 100644
--- a/server/monitor/monitor_sbus.c
+++ b/server/monitor/monitor_sbus.c
@@ -29,9 +29,8 @@
#include "sbus/sssd_dbus.h"
#include "monitor/monitor_interfaces.h"
-int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, struct confdb_ctx *confdb, char **address)
+int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, char **address)
{
- int ret;
char *default_address;
*address = NULL;
@@ -41,21 +40,8 @@ int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, struct confdb_ctx *confdb, cha
return ENOMEM;
}
- if (confdb == NULL) {
- /* If the confdb isn't specified, fall to the default */
- *address = default_address;
- talloc_steal(mem_ctx, default_address);
- ret = EOK;
- goto done;
- }
-
- ret = confdb_get_string(confdb, mem_ctx,
- "config/services/monitor", "sbusAddress",
- default_address, address);
-
-done:
- talloc_free(default_address);
- return ret;
+ *address = default_address;
+ return EOK;
}
static void id_callback(DBusPendingCall *pending, void *ptr)