summaryrefslogtreecommitdiff
path: root/server/providers
diff options
context:
space:
mode:
Diffstat (limited to 'server/providers')
-rw-r--r--server/providers/data_provider.c68
-rw-r--r--server/providers/data_provider.h6
2 files changed, 52 insertions, 22 deletions
diff --git a/server/providers/data_provider.c b/server/providers/data_provider.c
index cc78c38c..0af17a7a 100644
--- a/server/providers/data_provider.c
+++ b/server/providers/data_provider.c
@@ -108,27 +108,45 @@ static int dp_monitor_init(struct dp_ctx *dpctx)
static int dp_db_init(struct dp_ctx *dpctx)
{
+ TALLOC_CTX *ctx;
char *ldb_file;
+ char *default_db_file;
int ret;
- ret = confdb_get_string(dpctx->cdb, dpctx,
+ ctx = talloc_new(dpctx);
+ if(ctx == NULL) {
+ return ENOMEM;
+ }
+
+ default_db_file = talloc_asprintf(ctx, "%s/%s", DB_PATH, DATA_PROVIDER_DB_FILE);
+ if (default_db_file == NULL) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+
+ ret = confdb_get_string(dpctx->cdb, ctx,
DATA_PROVIDER_DB_CONF_SEC, "ldbFile",
- DATA_PROVIDER_DEF_DB_FILE, &ldb_file);
+ default_db_file, &ldb_file);
if (ret != EOK) {
+ talloc_free(ctx);
return ret;
}
- dpctx->ldb = ldb_init(dpctx, dpctx->ev);
+ dpctx->ldb = ldb_init(ctx, dpctx->ev);
if (!dpctx->ldb) {
+ talloc_free(ctx);
return EIO;
}
ret = ldb_connect(dpctx->ldb, ldb_file, 0, NULL);
if (ret != LDB_SUCCESS) {
- talloc_free(dpctx->ldb);
+ talloc_free(ctx);
return EIO;
}
+ talloc_steal(dpctx,dpctx->ldb);
+ talloc_free(ctx);
+
return EOK;
}
@@ -173,44 +191,58 @@ static int dbus_dp_init(struct sbus_conn_ctx *conn_ctx, void *data)
* Set up the monitor service as a D-BUS Server */
static int dp_srv_init(struct dp_ctx *dpctx)
{
+ TALLOC_CTX *tmp_ctx;
struct sbus_method_ctx *sd_ctx;
char *dpbus_address;
+ char *default_dp_address;
int ret;
+ tmp_ctx = talloc_new(dpctx);
+ if (tmp_ctx == NULL) {
+ return ENOMEM;
+ }
+
DEBUG(3, ("Initializing Data Provider D-BUS Server\n"));
+ default_dp_address = talloc_asprintf(tmp_ctx, "unix:path=%s/%s", PIPE_PATH, DATA_PROVIDER_PIPE);
+ if (default_dp_address == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
- ret = confdb_get_string(dpctx->cdb, dpctx,
+ ret = confdb_get_string(dpctx->cdb, tmp_ctx,
"config/services/dataprovider", "dpbusAddress",
- DATA_PROVIDER_ADDRESS, &dpbus_address);
- if (ret != EOK) {
- return ret;
- }
+ default_dp_address, &dpbus_address);
+ if (ret != EOK) goto done;
- sd_ctx = talloc_zero(dpctx, struct sbus_method_ctx);
+ sd_ctx = talloc_zero(tmp_ctx, struct sbus_method_ctx);
if (!sd_ctx) {
- talloc_free(dpbus_address);
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
/* Set up globally-available D-BUS methods */
sd_ctx->interface = talloc_strdup(sd_ctx, DATA_PROVIDER_DBUS_INTERFACE);
if (!sd_ctx->interface) {
- talloc_free(dpbus_address);
- talloc_free(sd_ctx);
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
sd_ctx->path = talloc_strdup(sd_ctx, DATA_PROVIDER_DBUS_PATH);
if (!sd_ctx->path) {
- talloc_free(dpbus_address);
- talloc_free(sd_ctx);
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
sd_ctx->methods = dp_sbus_methods;
sd_ctx->message_handler = sbus_message_handler;
ret = sbus_new_server(dpctx->ev, sd_ctx, dpbus_address,
dbus_dp_init, dpctx);
+ if (ret != EOK) {
+ goto done;
+ }
+ talloc_steal(dpctx, sd_ctx);
+done:
+ talloc_free(tmp_ctx);
return ret;
}
diff --git a/server/providers/data_provider.h b/server/providers/data_provider.h
index be00d51d..7df2ce10 100644
--- a/server/providers/data_provider.h
+++ b/server/providers/data_provider.h
@@ -30,13 +30,11 @@
#define DATA_PROVIDER_VERSION 0x0001
#define DATA_PROVIDER_SERVICE_NAME "dp"
-#define DATA_PROVIDER_ADDRESS "unix:path=/var/lib/sss/pipes/private/dbus-dp"
+#define DATA_PROVIDER_PIPE "sbus-dp"
-#define DATA_PROVIDER_DEF_DB_FILE "/var/lib/sss/db/sssd.ldb"
+#define DATA_PROVIDER_DB_FILE "sssd.ldb"
#define DATA_PROVIDER_DB_CONF_SEC "config/services/nss"
-#define DATA_PROVIDER_PLUGINS_PATH "/usr/lib/sssd"
-
struct dp_mod_ops {
int (*check_online)(void *pvt_data, int *reply);
};