diff options
-rw-r--r-- | server/infopipe/infopipe.c | 24 | ||||
-rw-r--r-- | server/infopipe/infopipe_private.h | 3 | ||||
-rw-r--r-- | server/infopipe/infopipe_users.c | 80 |
3 files changed, 43 insertions, 64 deletions
diff --git a/server/infopipe/infopipe.c b/server/infopipe/infopipe.c index 2972b565..09ffcbdf 100644 --- a/server/infopipe/infopipe.c +++ b/server/infopipe/infopipe.c @@ -247,6 +247,30 @@ done: return ret; } +struct infp_req_ctx *infp_req_init(TALLOC_CTX *mem_ctx, DBusMessage *message, struct sbus_conn_ctx *sconn) +{ + struct infp_req_ctx *infp_req; + + /* Create an infp_req_ctx */ + infp_req = talloc_zero(mem_ctx, struct infp_req_ctx); + if (infp_req == NULL) { + return NULL; + } + + infp_req->infp = talloc_get_type(sbus_conn_get_private_data(sconn), struct infp_ctx); + infp_req->sconn = sconn; + infp_req->req_message = message; + infp_req->caller = sysbus_get_caller(infp_req, + infp_req->req_message, + infp_req->sconn); + if (infp_req->caller == NULL) { + talloc_free(infp_req); + return NULL; + } + + return infp_req; +} + static int infp_process_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct confdb_ctx *cdb) diff --git a/server/infopipe/infopipe_private.h b/server/infopipe/infopipe_private.h index bd3e8733..0f523c00 100644 --- a/server/infopipe/infopipe_private.h +++ b/server/infopipe/infopipe_private.h @@ -38,7 +38,6 @@ struct infp_req_ctx { struct infp_ctx *infp; struct sbus_conn_ctx *sconn; DBusMessage *req_message; - bool check_provider; struct sss_domain_info *domain; char *caller; }; @@ -90,4 +89,6 @@ struct sss_domain_info *infp_get_domain_obj(struct infp_ctx *infp, const char *d int infp_get_ldb_val_from_dbus(TALLOC_CTX *mem_ctx, DBusMessageIter *iter, struct ldb_val **value, int dbus_type, int subtype); +struct infp_req_ctx *infp_req_init(TALLOC_CTX *mem_ctx, DBusMessage *message, struct sbus_conn_ctx *sconn); + #endif /* INFOPIPE_PRIVATE_H_ */ diff --git a/server/infopipe/infopipe_users.c b/server/infopipe/infopipe_users.c index d6c00e5c..f8291b83 100644 --- a/server/infopipe/infopipe_users.c +++ b/server/infopipe/infopipe_users.c @@ -118,21 +118,9 @@ int infp_users_get_cached(DBusMessage *message, struct sbus_conn_ctx *sconn) } /* Create an infp_req_ctx */ - infp_getcached_req->infp_req = - talloc_zero(infp_getcached_req, struct infp_req_ctx); - if (infp_getcached_req == NULL) { - ret = ENOMEM; - goto error; - } - infp_getcached_req->infp_req->infp = - talloc_get_type(sbus_conn_get_private_data(sconn), struct infp_ctx); - infp_getcached_req->infp_req->sconn = sconn; - infp_getcached_req->infp_req->req_message = message; - infp_getcached_req->infp_req->caller = - sysbus_get_caller(infp_getcached_req->infp_req, - infp_getcached_req->infp_req->req_message, - infp_getcached_req->infp_req->sconn); - if (infp_getcached_req->infp_req->caller == NULL) { + infp_getcached_req->infp_req = infp_req_init(infp_getcached_req, + message, sconn); + if (infp_getcached_req->infp_req == NULL) { ret = EIO; goto error; } @@ -301,18 +289,9 @@ int infp_users_create(DBusMessage *message, struct sbus_conn_ctx *sconn) } /* Create an infp_req_ctx */ - infp_createuser_req->infp_req = talloc_zero(infp_createuser_req, struct infp_req_ctx); - if (infp_createuser_req == NULL) { - ret = ENOMEM; - goto error; - } - infp_createuser_req->infp_req->infp = talloc_get_type(sbus_conn_get_private_data(sconn), struct infp_ctx); - infp_createuser_req->infp_req->sconn = sconn; - infp_createuser_req->infp_req->req_message = message; - infp_createuser_req->infp_req->caller = sysbus_get_caller(infp_createuser_req->infp_req, - infp_createuser_req->infp_req->req_message, - infp_createuser_req->infp_req->sconn); - if (infp_createuser_req->infp_req->caller == NULL) { + infp_createuser_req->infp_req = infp_req_init(infp_createuser_req, + message, sconn); + if (infp_createuser_req->infp_req == NULL) { ret = EIO; goto error; } @@ -1044,14 +1023,13 @@ int infp_users_get_attr(DBusMessage *message, struct sbus_conn_ctx *sconn) } /* Create an infp_req_ctx */ - infp_getattr_req->infp_req = talloc_zero(infp_getattr_req, struct infp_req_ctx); - if (infp_getattr_req == NULL) { - ret = ENOMEM; + infp_getattr_req->infp_req = infp_req_init(infp_getattr_req, + message, sconn); + if (infp_getattr_req->infp_req == NULL) { + ret = EIO; goto end; } - infp_getattr_req->infp_req->infp = talloc_get_type(sbus_conn_get_private_data(sconn), struct infp_ctx); - infp_getattr_req->infp_req->sconn = sconn; - infp_getattr_req->infp_req->req_message = message; + infp_getattr_req->infp_req->domain = btreemap_get_value(infp_getattr_req->infp_req->infp->domain_map, (const void *)domain); infp_getattr_req->check_provider = strcasecmp(domain, "LOCAL"); @@ -1103,12 +1081,6 @@ int infp_users_get_attr(DBusMessage *message, struct sbus_conn_ctx *sconn) infp_getattr_req->index = 0; - infp_getattr_req->infp_req->caller = sysbus_get_caller(infp_getattr_req->infp_req, message, sconn); - if (infp_getattr_req->infp_req->caller == NULL) { - ret = EIO; - goto end; - } - /* Prepare the result list */ infp_getattr_req->results = talloc_array(infp_getattr_req, struct btreemap *, attr_count); if (infp_getattr_req->results == NULL) { @@ -1247,18 +1219,9 @@ int infp_users_set_attr(DBusMessage *message, struct sbus_conn_ctx *sconn) } /* Create an infp_req_ctx */ - infp_setattr_req->infp_req = talloc_zero(infp_setattr_req, struct infp_req_ctx); - if (infp_setattr_req == NULL) { - ret = ENOMEM; - goto error; - } - infp_setattr_req->infp_req->infp = talloc_get_type(sbus_conn_get_private_data(sconn), struct infp_ctx); - infp_setattr_req->infp_req->sconn = sconn; - infp_setattr_req->infp_req->req_message = message; - - /* Get the caller's identity */ - infp_setattr_req->infp_req->caller = sysbus_get_caller(infp_setattr_req->infp_req, message, sconn); - if (infp_setattr_req->infp_req->caller == NULL) { + infp_setattr_req->infp_req = infp_req_init(infp_setattr_req, + message, sconn); + if (infp_setattr_req->infp_req == NULL) { ret = EIO; goto error; } @@ -1607,18 +1570,9 @@ int infp_users_set_uid(DBusMessage *message, struct sbus_conn_ctx *sconn) } /* Create an infp_req_ctx */ - infp_setuid_req->infp_req = talloc_zero(infp_setuid_req, struct infp_req_ctx); - if (infp_setuid_req == NULL) { - ret = ENOMEM; - goto error; - } - infp_setuid_req->infp_req->infp = talloc_get_type(sbus_conn_get_private_data(sconn), struct infp_ctx); - infp_setuid_req->infp_req->sconn = sconn; - infp_setuid_req->infp_req->req_message = message; - infp_setuid_req->infp_req->caller = sysbus_get_caller(infp_setuid_req->infp_req, - infp_setuid_req->infp_req->req_message, - infp_setuid_req->infp_req->sconn); - if (infp_setuid_req->infp_req->caller == NULL) { + infp_setuid_req->infp_req = infp_req_init(infp_setuid_req, + message, sconn); + if (infp_setuid_req->infp_req == NULL) { ret = EIO; goto error; } |