summaryrefslogtreecommitdiffstats
path: root/src/providers/proxy
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-02-18 14:32:54 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-03-14 13:42:20 +0100
commit07e941c1bbdc752142bbd3b838c540bc7ecd0ed7 (patch)
tree56453ab3ece875a6f80fc374fadaef07584484b7 /src/providers/proxy
parentd9577dbd92555b0755881e37724019ef9c578404 (diff)
downloadsssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.tar.gz
sssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.tar.xz
sssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.zip
sbus: Refactor how we export DBus interfaces
Most importantly, stop using per connection private data. This doesn't scale when you have more than one thing exporting or exported on a connection. Remove struct sbus_interface and expand sbus_conn_add_interface() function. Remove various struct sbus_interface args to connection initialization functions and make callers use sbus_conn_add_interface() directly. The old method was optimized for exporting one interface on a connection. We'll have connections that export zero, one or more interfaces. To export an interface on a DBus server, call sbus_conn_add_interface() from within the sbus_server_conn_init_fn. To export an interface on a DBus client, call sbus_conn_add_interface() after sbus_new_connection() returns. As before struct sbus_interface represents an object exported via DBus. However it is now talloc allocated. One can set instance data on the struct sbus_interface. This instance data is passed to the various handlers and used in their implementation. However, we now have type safe interface exporting in the various high level sss_process_init() sss_monitor_init() and so on. Introspection support was not in use, and is now gone until we implement it using the metadata (future patch). Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/providers/proxy')
-rw-r--r--src/providers/proxy/proxy_child.c32
-rw-r--r--src/providers/proxy/proxy_init.c22
2 files changed, 24 insertions, 30 deletions
diff --git a/src/providers/proxy/proxy_child.c b/src/providers/proxy/proxy_child.c
index eb47ae1e0..6bee1c7f6 100644
--- a/src/providers/proxy/proxy_child.c
+++ b/src/providers/proxy/proxy_child.c
@@ -47,7 +47,7 @@
#include "providers/dp_backend.h"
-static int pc_pam_handler(struct sbus_request *dbus_req);
+static int pc_pam_handler(struct sbus_request *dbus_req, void *user_data);
struct data_provider_iface pc_methods = {
{ &data_provider_iface_meta, 0 },
@@ -60,12 +60,6 @@ struct data_provider_iface pc_methods = {
.getAccountInfo = NULL,
};
-struct sbus_interface pc_interface = {
- DP_PATH,
- &pc_methods.vtable,
- NULL
-};
-
struct pc_ctx {
struct tevent_context *ev;
struct confdb_ctx *cdb;
@@ -310,20 +304,14 @@ fail:
return ret;
}
-static int pc_pam_handler(struct sbus_request *dbus_req)
+static int pc_pam_handler(struct sbus_request *dbus_req, void *user_data)
{
DBusError dbus_error;
DBusMessage *reply;
struct pc_ctx *pc_ctx;
errno_t ret;
- void *user_data;
struct pam_data *pd = NULL;
- user_data = sbus_conn_get_private_data(dbus_req->conn);
- if (!user_data) {
- ret = EINVAL;
- goto done;
- }
pc_ctx = talloc_get_type(user_data, struct pc_ctx);
if (!pc_ctx) {
ret = EINVAL;
@@ -393,6 +381,7 @@ int proxy_child_send_id(struct sbus_connection *conn,
uint32_t id);
static int proxy_cli_init(struct pc_ctx *ctx)
{
+ struct sbus_interface *intf;
char *sbus_address;
int ret;
@@ -404,14 +393,23 @@ static int proxy_cli_init(struct pc_ctx *ctx)
return ENOMEM;
}
- ret = sbus_client_init(ctx, ctx->ev, sbus_address,
- &pc_interface, &ctx->conn,
- NULL, ctx);
+ ret = sbus_client_init(ctx, ctx->ev, sbus_address, &ctx->conn);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, "sbus_client_init failed.\n");
return ret;
}
+ intf = sbus_new_interface(ctx, DP_PATH, &pc_methods.vtable, ctx);
+ if (!intf) {
+ ret = ENOMEM;
+ } else {
+ ret = sbus_conn_add_interface(ctx->conn, intf);
+ }
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export proxy.\n");
+ return ret;
+ }
+
ret = proxy_child_send_id(ctx->conn, DATA_PROVIDER_VERSION, ctx->id);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "dp_common_send_id failed.\n");
diff --git a/src/providers/proxy/proxy_init.c b/src/providers/proxy/proxy_init.c
index 70fe337cd..0206ec15b 100644
--- a/src/providers/proxy/proxy_init.c
+++ b/src/providers/proxy/proxy_init.c
@@ -27,7 +27,7 @@
#include "util/sss_format.h"
#include "providers/proxy/proxy.h"
-static int client_registration(struct sbus_request *dbus_req);
+static int client_registration(struct sbus_request *dbus_req, void *data);
static struct data_provider_iface proxy_methods = {
{ &data_provider_iface_meta, 0 },
@@ -40,12 +40,6 @@ static struct data_provider_iface proxy_methods = {
.getAccountInfo = NULL,
};
-struct sbus_interface proxy_interface = {
- DP_PATH,
- &proxy_methods.vtable,
- NULL
-};
-
static void proxy_shutdown(struct be_req *req)
{
/* TODO: Clean up any internal data */
@@ -337,6 +331,7 @@ static int proxy_client_init(struct sbus_connection *conn, void *data)
{
struct proxy_auth_ctx *proxy_auth_ctx;
struct proxy_client *proxy_cli;
+ struct sbus_interface *intf;
struct timeval tv;
proxy_auth_ctx = talloc_get_type(data, struct proxy_auth_ctx);
@@ -369,9 +364,12 @@ static int proxy_client_init(struct sbus_connection *conn, void *data)
/* Attach the client context to the connection context, so that it is
* always available when we need to manage the connection. */
- sbus_conn_set_private_data(conn, proxy_cli);
+ intf = sbus_new_interface(conn, DP_PATH, &proxy_methods.vtable, proxy_cli);
+ if (!intf) {
+ return ENOMEM;
+ }
- return EOK;
+ return sbus_conn_add_interface(conn, intf);
}
static void init_timeout(struct tevent_context *ev,
@@ -394,7 +392,7 @@ static void init_timeout(struct tevent_context *ev,
*/
}
-static int client_registration(struct sbus_request *dbus_req)
+static int client_registration(struct sbus_request *dbus_req, void *data)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
struct sbus_connection *conn;
@@ -403,7 +401,6 @@ static int client_registration(struct sbus_request *dbus_req)
dbus_uint16_t cli_ver;
uint32_t cli_id;
dbus_bool_t dbret;
- void *data;
int hret;
hash_key_t key;
hash_value_t value;
@@ -413,7 +410,6 @@ static int client_registration(struct sbus_request *dbus_req)
int ret;
conn = dbus_req->conn;
- data = sbus_conn_get_private_data(conn);
proxy_cli = talloc_get_type(data, struct proxy_client);
if (!proxy_cli) {
DEBUG(SSSDBG_FATAL_FAILURE, "Connection holds no valid init data\n");
@@ -535,7 +531,7 @@ int sssm_proxy_auth_init(struct be_ctx *bectx,
goto done;
}
- ret = sbus_new_server(ctx, bectx->ev, sbus_address, &proxy_interface,
+ ret = sbus_new_server(ctx, bectx->ev, sbus_address,
false, &ctx->sbus_srv, proxy_client_init, ctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Could not set up sbus server.\n");