summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/monitor/monitor.c9
-rw-r--r--src/monitor/monitor_sbus.c8
-rw-r--r--src/providers/data_provider_be.c10
-rw-r--r--src/providers/proxy/proxy_child.c8
-rw-r--r--src/providers/proxy/proxy_init.c11
-rw-r--r--src/responder/common/responder_common.c8
-rw-r--r--src/responder/ifp/ifpsrv.c15
-rw-r--r--src/sbus/sssd_dbus.h31
-rw-r--r--src/sbus/sssd_dbus_connection.c19
-rw-r--r--src/tests/sbus_codegen_tests.c6
-rw-r--r--src/tests/sbus_tests.c12
11 files changed, 43 insertions, 94 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index afefe7f11..fef1a120f 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -2443,7 +2443,6 @@ static void init_timeout(struct tevent_context *ev,
*/
static int monitor_service_init(struct sbus_connection *conn, void *data)
{
- struct sbus_interface *intf;
struct mt_ctx *ctx;
struct mon_init_conn *mini;
struct timeval tv;
@@ -2474,12 +2473,8 @@ static int monitor_service_init(struct sbus_connection *conn, void *data)
return ENOMEM;
}
- intf = sbus_new_interface(conn, MON_SRV_PATH, &monitor_methods.vtable, mini);
- if (!intf) {
- return ENOMEM;
- }
-
- return sbus_conn_add_interface(conn, intf);
+ return sbus_conn_register_iface(conn, &monitor_methods.vtable,
+ MON_SRV_PATH, mini);
}
/* service_send_ping
diff --git a/src/monitor/monitor_sbus.c b/src/monitor/monitor_sbus.c
index 3e6fbff9b..426f02997 100644
--- a/src/monitor/monitor_sbus.c
+++ b/src/monitor/monitor_sbus.c
@@ -172,7 +172,6 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
{
errno_t ret;
char *sbus_address;
- struct sbus_interface *intf;
struct sbus_connection *conn;
/* Set up SBUS connection to the monitor */
@@ -190,12 +189,7 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
}
talloc_free(sbus_address);
- intf = sbus_new_interface(mem_ctx, MONITOR_PATH, &mon_iface->vtable, pvt);
- if (!intf) {
- ret = ENOMEM;
- } else {
- ret = sbus_conn_add_interface(conn, intf);
- }
+ ret = sbus_conn_register_iface(conn, &mon_iface->vtable, MONITOR_PATH, pvt);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export monitor client.\n");
return ret;
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index 95df2d9c6..53a0be258 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -2216,7 +2216,6 @@ static void init_timeout(struct tevent_context *ev,
static int be_client_init(struct sbus_connection *conn, void *data)
{
- struct sbus_interface *intf;
struct be_ctx *bectx;
struct be_client *becli;
struct timeval tv;
@@ -2252,14 +2251,7 @@ static int be_client_init(struct sbus_connection *conn, void *data)
DEBUG(SSSDBG_CONF_SETTINGS,
"Set-up Backend ID timeout [%p]\n", becli->timeout);
- /* Attach the client context to the connection context, so that it is
- * always available when we need to manage the connection. */
- intf = sbus_new_interface(conn, DP_PATH, &be_methods.vtable, becli);
- if (!intf) {
- return ENOMEM;
- }
-
- return sbus_conn_add_interface(conn, intf);
+ return sbus_conn_register_iface(conn, &be_methods.vtable, DP_PATH, becli);
}
/* be_srv_init
diff --git a/src/providers/proxy/proxy_child.c b/src/providers/proxy/proxy_child.c
index e261b2f58..9876b9328 100644
--- a/src/providers/proxy/proxy_child.c
+++ b/src/providers/proxy/proxy_child.c
@@ -381,7 +381,6 @@ 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;
@@ -399,12 +398,7 @@ static int proxy_cli_init(struct pc_ctx *ctx)
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);
- }
+ ret = sbus_conn_register_iface(ctx->conn, &pc_methods.vtable, DP_PATH, ctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export proxy.\n");
return ret;
diff --git a/src/providers/proxy/proxy_init.c b/src/providers/proxy/proxy_init.c
index 1e7345117..f76ad02ae 100644
--- a/src/providers/proxy/proxy_init.c
+++ b/src/providers/proxy/proxy_init.c
@@ -331,7 +331,6 @@ 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);
@@ -362,14 +361,8 @@ static int proxy_client_init(struct sbus_connection *conn, void *data)
DEBUG(SSSDBG_CONF_SETTINGS,
"Set-up proxy client ID timeout [%p]\n", proxy_cli->timeout);
- /* Attach the client context to the connection context, so that it is
- * always available when we need to manage the connection. */
- intf = sbus_new_interface(conn, DP_PATH, &proxy_methods.vtable, proxy_cli);
- if (!intf) {
- return ENOMEM;
- }
-
- return sbus_conn_add_interface(conn, intf);
+ return sbus_conn_register_iface(conn, &proxy_methods.vtable,
+ DP_PATH, proxy_cli);
}
static void init_timeout(struct tevent_context *ev,
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 666abe610..36e7f1594 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -514,7 +514,6 @@ static int sss_dp_init(struct resp_ctx *rctx,
const char *cli_name,
struct sss_domain_info *domain)
{
- struct sbus_interface *intf;
struct be_conn *be_conn;
int ret;
@@ -539,12 +538,7 @@ static int sss_dp_init(struct resp_ctx *rctx,
return ret;
}
- intf = sbus_new_interface(rctx, DP_PATH, dp_intf, rctx);
- if (!intf) {
- ret = ENOMEM;
- } else {
- ret = sbus_conn_add_interface(be_conn->conn, intf);
- }
+ ret = sbus_conn_register_iface(be_conn->conn, dp_intf, DP_PATH, rctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export data provider.\n");
return ret;
diff --git a/src/responder/ifp/ifpsrv.c b/src/responder/ifp/ifpsrv.c
index 0c333bc07..5b7f26ca1 100644
--- a/src/responder/ifp/ifpsrv.c
+++ b/src/responder/ifp/ifpsrv.c
@@ -178,7 +178,6 @@ sysbus_init(TALLOC_CTX *mem_ctx,
DBusError dbus_error;
DBusConnection *conn = NULL;
struct sysbus_ctx *system_bus = NULL;
- struct sbus_interface *sif;
int i;
errno_t ret;
@@ -226,17 +225,9 @@ sysbus_init(TALLOC_CTX *mem_ctx,
}
for (i = 0; sysbus_ifaces[i].path != NULL; i++) {
- sif = sbus_new_interface(system_bus->conn,
- sysbus_ifaces[i].path,
- sysbus_ifaces[i].iface_vtable,
- pvt);
- if (sif == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- "Could not add the sbus interface\n");
- goto fail;
- }
-
- ret = sbus_conn_add_interface(system_bus->conn, sif);
+ ret = sbus_conn_register_iface(system_bus->conn,
+ sysbus_ifaces[i].iface_vtable,
+ sysbus_ifaces[i].path, pvt);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Could not add the interface\n");
diff --git a/src/sbus/sssd_dbus.h b/src/sbus/sssd_dbus.h
index 5b128eaed..7552fbcf1 100644
--- a/src/sbus/sssd_dbus.h
+++ b/src/sbus/sssd_dbus.h
@@ -113,21 +113,6 @@ struct sbus_interface {
void *instance_data;
};
-/*
- * Creates a new struct sbus_interface instance to be exported by a DBus
- * service.
- *
- * Pass the result to sbus_conn_add_interface(). The interface
- * will be exported at @object_path. The method handlers are represented by
- * @iface_vtable. @instance_data contains additional caller specific data
- * which is made available to handlers.
- */
-struct sbus_interface *
-sbus_new_interface(TALLOC_CTX *mem_ctx,
- const char *object_path,
- struct sbus_vtable *iface_vtable,
- void *instance_data);
-
/* Server Functions */
int sbus_new_server(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -170,9 +155,21 @@ int sbus_init_connection(TALLOC_CTX *ctx,
struct sbus_connection **_conn);
DBusConnection *sbus_get_connection(struct sbus_connection *conn);
+
void sbus_disconnect(struct sbus_connection *conn);
-int sbus_conn_add_interface(struct sbus_connection *conn,
- struct sbus_interface *intf);
+
+/*
+ * Register a new interface to be available at given object path.
+ *
+ * The interface will be exported at @object_path. The method handlers are
+ * represented by @iface_vtable. @pvt contains additional caller specific data
+ * which is made available to handlers.
+ */
+int sbus_conn_register_iface(struct sbus_connection *conn,
+ struct sbus_vtable *iface_vtable,
+ const char *object_path,
+ void *pvt);
+
bool sbus_conn_disconnecting(struct sbus_connection *conn);
/* max_retries < 0: retry forever
diff --git a/src/sbus/sssd_dbus_connection.c b/src/sbus/sssd_dbus_connection.c
index 6102ef9ae..7fded56bc 100644
--- a/src/sbus/sssd_dbus_connection.c
+++ b/src/sbus/sssd_dbus_connection.c
@@ -565,7 +565,7 @@ fail:
sbus_request_finish(dbus_req, reply);
}
-struct sbus_interface *
+static struct sbus_interface *
sbus_new_interface(TALLOC_CTX *mem_ctx,
const char *object_path,
struct sbus_vtable *iface_vtable,
@@ -606,18 +606,23 @@ static char *sbus_iface_get_reg_path(TALLOC_CTX *mem_ctx,
return reg_path;
}
-/* Adds a new D-BUS path message handler to the connection
- * Note: this must be a unique path.
- */
-int sbus_conn_add_interface(struct sbus_connection *conn,
- struct sbus_interface *intf)
+int sbus_conn_register_iface(struct sbus_connection *conn,
+ struct sbus_vtable *iface_vtable,
+ const char *object_path,
+ void *pvt)
{
struct sbus_interface_p *intf_p;
+ struct sbus_interface *intf;
dbus_bool_t dbret;
const char *path;
bool fallback;
- if (!conn || !intf || !intf->vtable || !intf->vtable->meta) {
+ intf = sbus_new_interface(conn, object_path, iface_vtable, pvt);
+ if (intf == NULL) {
+ return ENOMEM;
+ }
+
+ if (!conn || !intf->vtable || !intf->vtable->meta) {
return EINVAL;
}
diff --git a/src/tests/sbus_codegen_tests.c b/src/tests/sbus_codegen_tests.c
index d3d5d4680..dccb5e314 100644
--- a/src/tests/sbus_codegen_tests.c
+++ b/src/tests/sbus_codegen_tests.c
@@ -574,10 +574,8 @@ static int pilot_test_server_init(struct sbus_connection *server, void *unused)
{
int ret;
- ret = sbus_conn_add_interface(server,
- sbus_new_interface(server, "/test/leela",
- &pilot_iface.vtable,
- "Crash into the billboard"));
+ ret = sbus_conn_register_iface(server, &pilot_iface.vtable, "/test/leela",
+ "Crash into the billboard");
ck_assert_int_eq(ret, EOK);
return EOK;
diff --git a/src/tests/sbus_tests.c b/src/tests/sbus_tests.c
index 50c452e42..486e39221 100644
--- a/src/tests/sbus_tests.c
+++ b/src/tests/sbus_tests.c
@@ -178,17 +178,13 @@ static int pilot_test_server_init(struct sbus_connection *server, void *unused)
{
int ret;
- ret = sbus_conn_add_interface(server,
- sbus_new_interface(server, "/test/leela",
- &pilot_impl.vtable,
- "Crash into the billboard"));
+ ret = sbus_conn_register_iface(server, &pilot_impl.vtable, "/test/leela",
+ "Crash into the billboard");
ck_assert_int_eq(ret, EOK);
- ret = sbus_conn_add_interface(server,
- sbus_new_interface(server, "/test/fry",
- &pilot_impl.vtable,
- "Don't crash"));
+ ret = sbus_conn_register_iface(server, &pilot_impl.vtable, "/test/fry",
+ "Don't crash");
ck_assert_int_eq(ret, EOK);
return EOK;