summaryrefslogtreecommitdiffstats
path: root/server/monitor
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-03-19 21:28:41 -0400
committerSimo Sorce <ssorce@redhat.com>2009-03-20 11:14:56 -0400
commit7d5bf9a11d60e5330e12d5d94ebba8d6a4606eb0 (patch)
tree529b945482192d47f230f9ddc42a4b91ea4c5e0c /server/monitor
parent3efbdeae89d67fac737ac7500616054b92693685 (diff)
downloadsssd-7d5bf9a11d60e5330e12d5d94ebba8d6a4606eb0.tar.gz
sssd-7d5bf9a11d60e5330e12d5d94ebba8d6a4606eb0.tar.xz
sssd-7d5bf9a11d60e5330e12d5d94ebba8d6a4606eb0.zip
Simplify default configuration
Make confdb load a base ldif like sysdb to initialize the db, makes it simpler to understand at first sight what is the default configuration. Make the parameter "command" optional. Derive the default command from available information. Make the debug level a global by default so that enabling debug for all components is as easy as passing just -d X to the sssd binary.
Diffstat (limited to 'server/monitor')
-rw-r--r--server/monitor/monitor.c76
1 files changed, 65 insertions, 11 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index d797ae0e2..4a6abdc99 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -50,8 +50,10 @@ struct mt_svc {
struct mt_conn *mt_conn;
struct mt_ctx *mt_ctx;
+ char *provider;
char *command;
char *name;
+ char *identity;
pid_t pid;
int ping_time;
@@ -59,6 +61,8 @@ struct mt_svc {
int restarts;
time_t last_restart;
time_t last_pong;
+
+ int debug_level;
};
struct mt_ctx {
@@ -412,22 +416,44 @@ int monitor_process_init(TALLOC_CTX *mem_ctx,
talloc_free(ctx);
return ENOMEM;
}
- svc->name = ctx->services[i];
svc->mt_ctx = ctx;
+ svc->name = talloc_strdup(svc, ctx->services[i]);
+ if (!svc->name) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+
+ svc->identity = talloc_strdup(svc, ctx->services[i]);
+ if (!svc->identity) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+
path = talloc_asprintf(svc, "config/services/%s", svc->name);
if (!path) {
talloc_free(ctx);
return ENOMEM;
}
- ret = confdb_get_string(cdb, svc, path, "command", NULL, &svc->command);
+ ret = confdb_get_string(cdb, svc, path, "command",
+ NULL, &svc->command);
if (ret != EOK) {
DEBUG(0,("Failed to start service '%s'\n", svc->name));
talloc_free(svc);
continue;
}
+ if (!svc->command) {
+ svc->command = talloc_asprintf(svc, "%s/sssd_%s -d %d",
+ SSSD_LIBEXEC_PATH, svc->name,
+ debug_level);
+ if (!svc->command) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+ }
+
ret = confdb_get_int(cdb, svc, path, "timeout",
MONITOR_DEF_PING_TIME, &svc->ping_time);
if (ret != EOK) {
@@ -463,18 +489,38 @@ int monitor_process_init(TALLOC_CTX *mem_ctx,
talloc_free(ctx);
return ENOMEM;
}
- svc->name = talloc_asprintf(svc, "%%BE_%s", doms[i]);
svc->mt_ctx = ctx;
+ svc->name = talloc_strdup(svc, doms[i]);
+ if (!svc->name) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+
+ svc->identity = talloc_asprintf(svc, "%%BE_%s", svc->name);
+ if (!svc->identity) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+
path = talloc_asprintf(svc, "config/domains/%s", doms[i]);
if (!path) {
talloc_free(ctx);
return ENOMEM;
}
+
+ ret = confdb_get_string(cdb, svc, path,
+ "provider", NULL, &svc->provider);
+ if (ret != EOK) {
+ DEBUG(0, ("Failed to find provider from [%s] configuration\n", doms[i]));
+ talloc_free(svc);
+ continue;
+ }
+
ret = confdb_get_string(cdb, svc, path,
"command", NULL, &svc->command);
if (ret != EOK) {
- DEBUG(0, ("Failed to find provider [%s] configuration\n", doms[i]));
+ DEBUG(0, ("Failed to find command from [%s] configuration\n", doms[i]));
talloc_free(svc);
continue;
}
@@ -489,16 +535,24 @@ int monitor_process_init(TALLOC_CTX *mem_ctx,
talloc_free(path);
- /* if no command is present do not run the domain */
- if (svc->command == NULL) {
- /* the LOCAL domain does not need a backend at the moment */
- if (strcasecmp(doms[i], "LOCAL") != 0) {
- DEBUG(0, ("Missing command to run provider\n"));
- }
+ /* if no provider is present do not run the domain */
+ if (!svc->provider) {
talloc_free(svc);
continue;
}
+ /* if there are no custom commands, build a default one */
+ if (!svc->command) {
+ svc->command = talloc_asprintf(svc,
+ "%s/sssd_be -d %d --provider %s --domain %s",
+ SSSD_LIBEXEC_PATH, debug_level,
+ svc->provider, svc->name);
+ if (!svc->command) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+ }
+
ret = start_service(svc);
if (ret != EOK) {
DEBUG(0,("Failed to start provider for '%s'\n", doms[i]));
@@ -657,7 +711,7 @@ static void identity_check(DBusPendingCall *pending, void *data)
/* search this service in the list */
svc = fake_svc->mt_ctx->svc_list;
while (svc) {
- ret = strcasecmp(svc->name, svc_name);
+ ret = strcasecmp(svc->identity, svc_name);
if (ret == 0) {
break;
}