diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-01-19 13:33:28 -0500 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2009-01-27 08:39:48 -0500 |
commit | d9f203e045c63c853ae60b47fb8013e92600c9f9 (patch) | |
tree | 7351223712002fdb31ce1787ad59ea65e051bb53 /server/monitor/monitor_sbus.c | |
parent | f52c3c6a93f673ba422f5eee1788e2f5b70b3a6a (diff) | |
download | sssd-d9f203e045c63c853ae60b47fb8013e92600c9f9.tar.gz sssd-d9f203e045c63c853ae60b47fb8013e92600c9f9.tar.xz sssd-d9f203e045c63c853ae60b47fb8013e92600c9f9.zip |
Refactoring the monitor code and SBUS utility functions.
Diffstat (limited to 'server/monitor/monitor_sbus.c')
-rw-r--r-- | server/monitor/monitor_sbus.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/server/monitor/monitor_sbus.c b/server/monitor/monitor_sbus.c new file mode 100644 index 000000000..7a9c8b094 --- /dev/null +++ b/server/monitor/monitor_sbus.c @@ -0,0 +1,97 @@ +/* + SSSD + + Data Provider Helpers + + Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "util/util.h" +#include "confdb/confdb.h" +#include "sbus/sssd_dbus.h" +#include "monitor/monitor_sbus.h" +#include "monitor/monitor_interfaces.h" + +int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, struct confdb_ctx *confdb, char **address) +{ + int ret; + char *default_address; + + *address = NULL; + default_address = talloc_asprintf(mem_ctx, "unix:path=%s/%s", + PIPE_PATH, SSSD_SERVICE_PIPE); + if (default_address == NULL) { + 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; +} + +int monitor_init_sbus_methods(TALLOC_CTX *mem_ctx, struct sbus_method *methods, + struct sbus_method_ctx **sm_ctx) +{ + int ret; + TALLOC_CTX *tmp_ctx; + struct sbus_method_ctx *method_ctx; + + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + return ENOMEM; + } + + method_ctx = talloc_zero(tmp_ctx, struct sbus_method_ctx); + if (method_ctx == NULL) { + ret = ENOMEM; + goto done; + } + + method_ctx->interface = talloc_strdup(method_ctx, SERVICE_INTERFACE); + if (method_ctx->interface == NULL) { + ret = ENOMEM; + goto done; + } + + method_ctx->path = talloc_strdup(method_ctx, SERVICE_PATH); + if (method_ctx->path == NULL) { + ret = ENOMEM; + goto done; + } + + method_ctx->methods = methods; + method_ctx->message_handler = sbus_message_handler; + + *sm_ctx = method_ctx; + talloc_steal(mem_ctx, method_ctx); + ret = EOK; + +done: + talloc_free(tmp_ctx); + return ret; +} |