From 5730c6aac0263416f46e32f1536eb8124c4dd1a3 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 30 Nov 2009 14:18:58 +0100 Subject: Check the services started against a list of known services Fixes: #241 --- server/monitor/monitor.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'server') diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c index 65b9475c8..d47b3a80a 100644 --- a/server/monitor/monitor.c +++ b/server/monitor/monitor.c @@ -913,10 +913,33 @@ static int check_local_domain_unique(struct sss_domain_info *domains) return EOK; } +static char *check_services(char **services) +{ + const char *known_services[] = { "nss", "pam", NULL }; + int i; + int ii; + + /* Check if services we are about to start are in the list if known */ + for (i = 0; services[i]; i++) { + for (ii=0; known_services[ii]; ii++) { + if (strcasecmp(services[i], known_services[ii]) == 0) { + break; + } + } + + if (known_services[ii] == NULL) { + return services[i]; + } + } + + return NULL; +} + int get_monitor_config(struct mt_ctx *ctx) { int ret; int timeout_seconds; + char *badsrv = NULL; ret = confdb_get_int(ctx->cdb, ctx, CONFDB_MONITOR_CONF_ENTRY, @@ -941,6 +964,12 @@ int get_monitor_config(struct mt_ctx *ctx) return EINVAL; } + badsrv = check_services(ctx->services); + if (badsrv != NULL) { + DEBUG(0, ("Invalid service %s\n", badsrv)); + return EINVAL; + } + ctx->domain_ctx = talloc_new(ctx); if(!ctx->domain_ctx) { return ENOMEM; -- cgit