summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/monitor/monitor.c23
-rw-r--r--src/monitor/monitor_interfaces.h6
-rw-r--r--src/monitor/monitor_sbus.c22
-rw-r--r--src/providers/data_provider_be.c107
-rw-r--r--src/providers/proxy/proxy_child.c32
-rw-r--r--src/providers/proxy/proxy_init.c22
-rw-r--r--src/responder/autofs/autofssrv.c23
-rw-r--r--src/responder/common/responder.h18
-rw-r--r--src/responder/common/responder_common.c27
-rw-r--r--src/responder/nss/nsssrv.c41
-rw-r--r--src/responder/pac/pacsrv.c17
-rw-r--r--src/responder/pam/pamsrv.c17
-rw-r--r--src/responder/ssh/sshsrv.c16
-rw-r--r--src/responder/sudo/sudosrv.c16
-rw-r--r--src/sbus/sbus_client.c11
-rw-r--r--src/sbus/sbus_client.h5
-rw-r--r--src/sbus/sssd_dbus.h32
-rw-r--r--src/sbus/sssd_dbus_connection.c96
-rw-r--r--src/sbus/sssd_dbus_private.h4
-rw-r--r--src/sbus/sssd_dbus_server.c8
-rw-r--r--src/tests/sbus_codegen_tests.c4
21 files changed, 199 insertions, 348 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 2e0f5230f..9470075b5 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -217,7 +217,7 @@ static void network_status_change_cb(void *cb_data)
/* dbus_get_monitor_version
* Return the monitor version over D-BUS */
-static int get_monitor_version(struct sbus_request *dbus_req)
+static int get_monitor_version(struct sbus_request *dbus_req, void *data)
{
dbus_uint16_t version = MONITOR_VERSION;
@@ -236,19 +236,17 @@ static int add_svc_conn_spy(struct mt_svc *svc);
/* registers a new client.
* if operation is successful also sends back the Monitor version */
-static int client_registration(struct sbus_request *dbus_req)
+static int client_registration(struct sbus_request *dbus_req, void *data)
{
dbus_uint16_t version = MONITOR_VERSION;
struct mon_init_conn *mini;
struct mt_svc *svc;
- void *data;
DBusError dbus_error;
dbus_uint16_t svc_ver;
char *svc_name;
dbus_bool_t dbret;
int ret;
- data = sbus_conn_get_private_data(dbus_req->conn);
mini = talloc_get_type(data, struct mon_init_conn);
if (!mini) {
DEBUG(SSSDBG_FATAL_FAILURE, "Connection holds no valid init data\n");
@@ -503,12 +501,6 @@ struct mon_srv_iface monitor_methods = {
.RegisterService = client_registration,
};
-struct sbus_interface monitor_server_interface = {
- MON_SRV_PATH,
- &monitor_methods.vtable,
- NULL
-};
-
/* monitor_dbus_init
* Set up the monitor service as a D-BUS Server */
static int monitor_dbus_init(struct mt_ctx *ctx)
@@ -521,8 +513,7 @@ static int monitor_dbus_init(struct mt_ctx *ctx)
return ret;
}
- ret = sbus_new_server(ctx, ctx->ev,
- monitor_address, &monitor_server_interface,
+ ret = sbus_new_server(ctx, ctx->ev, monitor_address,
false, &ctx->sbus_srv, monitor_service_init, ctx);
talloc_free(monitor_address);
@@ -2309,6 +2300,7 @@ 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;
@@ -2336,9 +2328,12 @@ static int monitor_service_init(struct sbus_connection *conn, void *data)
return ENOMEM;
}
- sbus_conn_set_private_data(conn, mini);
+ intf = sbus_new_interface(conn, MON_SRV_PATH, &monitor_methods.vtable, mini);
+ if (!intf) {
+ return ENOMEM;
+ }
- return EOK;
+ return sbus_conn_add_interface(conn, intf);
}
/* service_send_ping
diff --git a/src/monitor/monitor_interfaces.h b/src/monitor/monitor_interfaces.h
index 2970251df..c015fbc66 100644
--- a/src/monitor/monitor_interfaces.h
+++ b/src/monitor/monitor_interfaces.h
@@ -38,14 +38,14 @@
int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, char **address);
int monitor_common_send_id(struct sbus_connection *conn,
const char *name, uint16_t version);
-int monitor_common_pong(struct sbus_request *dbus_req);
-int monitor_common_res_init(struct sbus_request *dbus_req);
+int monitor_common_pong(struct sbus_request *dbus_req, void *data);
+int monitor_common_res_init(struct sbus_request *dbus_req, void *data);
int monitor_common_rotate_logs(struct confdb_ctx *confdb,
const char *conf_entry);
errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct sbus_interface *intf,
+ struct mon_cli_iface *mon_iface,
const char *svc_name,
uint16_t svc_version,
void *pvt,
diff --git a/src/monitor/monitor_sbus.c b/src/monitor/monitor_sbus.c
index 92d483233..544407ca2 100644
--- a/src/monitor/monitor_sbus.c
+++ b/src/monitor/monitor_sbus.c
@@ -144,12 +144,12 @@ int monitor_common_send_id(struct sbus_connection *conn,
return retval;
}
-int monitor_common_pong(struct sbus_request *dbus_req)
+int monitor_common_pong(struct sbus_request *dbus_req, void *data)
{
return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
}
-int monitor_common_res_init(struct sbus_request *dbus_req)
+int monitor_common_res_init(struct sbus_request *dbus_req, void *data)
{
int ret;
@@ -198,7 +198,7 @@ errno_t monitor_common_rotate_logs(struct confdb_ctx *confdb,
errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct sbus_interface *intf,
+ struct mon_cli_iface *mon_iface,
const char *svc_name,
uint16_t svc_version,
void *pvt,
@@ -206,6 +206,7 @@ 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 */
@@ -215,9 +216,7 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
return ret;
}
- ret = sbus_client_init(mem_ctx, ev, sbus_address,
- intf, &conn,
- NULL, pvt);
+ ret = sbus_client_init(mem_ctx, ev, sbus_address, &conn);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Failed to connect to monitor services.\n");
talloc_free(sbus_address);
@@ -225,6 +224,17 @@ 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);
+ }
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export monitor client.\n");
+ return ret;
+ }
+
/* Identify ourselves to the monitor */
ret = monitor_common_send_id(conn, svc_name, svc_version);
if (ret != EOK) {
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index cd51bd81c..6c0a82360 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -54,10 +54,10 @@
#define ACCESS_DENY "deny"
#define NO_PROVIDER "none"
-static int data_provider_res_init(struct sbus_request *dbus_req);
-static int data_provider_go_offline(struct sbus_request *dbus_req);
-static int data_provider_reset_offline(struct sbus_request *dbus_req);
-static int data_provider_logrotate(struct sbus_request *dbus_req);
+static int data_provider_res_init(struct sbus_request *dbus_req, void *data);
+static int data_provider_go_offline(struct sbus_request *dbus_req, void *data);
+static int data_provider_reset_offline(struct sbus_request *dbus_req, void *data);
+static int data_provider_logrotate(struct sbus_request *dbus_req, void *data);
struct mon_cli_iface monitor_be_methods = {
{ &mon_cli_iface_meta, 0 },
@@ -71,19 +71,13 @@ struct mon_cli_iface monitor_be_methods = {
.clearEnumCache = NULL,
};
-struct sbus_interface monitor_be_interface = {
- MONITOR_PATH,
- &monitor_be_methods.vtable,
- NULL
-};
-
-static int client_registration(struct sbus_request *dbus_req);
-static int be_get_account_info(struct sbus_request *dbus_req);
-static int be_pam_handler(struct sbus_request *dbus_req);
-static int be_sudo_handler(struct sbus_request *dbus_req);
-static int be_autofs_handler(struct sbus_request *dbus_req);
-static int be_host_handler(struct sbus_request *dbus_req);
-static int be_get_subdomains(struct sbus_request *dbus_req);
+static int client_registration(struct sbus_request *dbus_req, void *data);
+static int be_get_account_info(struct sbus_request *dbus_req, void *user_data);
+static int be_pam_handler(struct sbus_request *dbus_req, void *user_data);
+static int be_sudo_handler(struct sbus_request *dbus_req, void *user_data);
+static int be_autofs_handler(struct sbus_request *dbus_req, void *user_data);
+static int be_host_handler(struct sbus_request *dbus_req, void *user_data);
+static int be_get_subdomains(struct sbus_request *dbus_req, void *user_data);
struct data_provider_iface be_methods = {
{ &data_provider_iface_meta, 0 },
@@ -96,12 +90,6 @@ struct data_provider_iface be_methods = {
.getAccountInfo = be_get_account_info,
};
-struct sbus_interface be_interface = {
- DP_PATH,
- &be_methods.vtable,
- NULL
-};
-
static struct bet_data bet_data[] = {
{BET_NULL, NULL, NULL},
{BET_ID, CONFDB_DOMAIN_ID_PROVIDER, "sssm_%s_id_init"},
@@ -571,13 +559,12 @@ static void get_subdomains_callback(struct be_req *req,
talloc_free(req);
}
-static int be_get_subdomains(struct sbus_request *dbus_req)
+static int be_get_subdomains(struct sbus_request *dbus_req, void *user_data)
{
struct be_subdom_req *req;
struct be_req *be_req = NULL;
struct be_client *becli;
DBusError dbus_error;
- void *user_data;
dbus_bool_t force;
char *domain_hint;
dbus_uint16_t err_maj;
@@ -585,8 +572,6 @@ static int be_get_subdomains(struct sbus_request *dbus_req)
const char *err_msg;
int ret;
- user_data = sbus_conn_get_private_data(dbus_req->conn);
- if (!user_data) return EINVAL;
becli = talloc_get_type(user_data, struct be_client);
if (!becli) return EINVAL;
@@ -1052,13 +1037,12 @@ errno_t be_get_account_info_recv(struct tevent_req *req,
return EOK;
}
-static int be_get_account_info(struct sbus_request *dbus_req)
+static int be_get_account_info(struct sbus_request *dbus_req, void *user_data)
{
struct be_acct_req *req;
struct be_req *be_req;
struct be_client *becli;
DBusError dbus_error;
- void *user_data;
uint32_t type;
char *filter;
char *domain;
@@ -1070,8 +1054,6 @@ static int be_get_account_info(struct sbus_request *dbus_req)
be_req = NULL;
- user_data = sbus_conn_get_private_data(dbus_req->conn);
- if (!user_data) return EINVAL;
becli = talloc_get_type(user_data, struct be_client);
if (!becli) return EINVAL;
@@ -1309,19 +1291,16 @@ done:
talloc_free(req);
}
-static int be_pam_handler(struct sbus_request *dbus_req)
+static int be_pam_handler(struct sbus_request *dbus_req, void *user_data)
{
DBusError dbus_error;
DBusMessage *reply;
struct be_client *becli;
dbus_bool_t ret;
- void *user_data;
struct pam_data *pd = NULL;
struct be_req *be_req = NULL;
enum bet_type target = BET_NULL;
- user_data = sbus_conn_get_private_data(dbus_req->conn);
- if (!user_data) return EINVAL;
becli = talloc_get_type(user_data, struct be_client);
if (!becli) return EINVAL;
@@ -1471,7 +1450,7 @@ static void be_sudo_handler_callback(struct be_req *req,
talloc_free(req);
}
-static int be_sudo_handler(struct sbus_request *dbus_req)
+static int be_sudo_handler(struct sbus_request *dbus_req, void *user_data)
{
DBusError dbus_error;
DBusMessageIter iter;
@@ -1479,7 +1458,6 @@ static int be_sudo_handler(struct sbus_request *dbus_req)
struct be_client *be_cli = NULL;
struct be_req *be_req = NULL;
struct be_sudo_req *sudo_req = NULL;
- void *user_data = NULL;
int ret = 0;
uint32_t type;
uint32_t rules_num = 0;
@@ -1489,11 +1467,6 @@ static int be_sudo_handler(struct sbus_request *dbus_req)
DEBUG(SSSDBG_TRACE_FUNC, "Entering be_sudo_handler()\n");
- user_data = sbus_conn_get_private_data(dbus_req->conn);
- if (user_data == NULL) {
- return EINVAL;
- }
-
be_cli = talloc_get_type(user_data, struct be_client);
if (be_cli == NULL) {
return EINVAL;
@@ -1638,13 +1611,12 @@ static void be_autofs_handler_callback(struct be_req *req,
int errnum,
const char *errstr);
-static int be_autofs_handler(struct sbus_request *dbus_req)
+static int be_autofs_handler(struct sbus_request *dbus_req, void *user_data)
{
DBusError dbus_error;
struct be_client *be_cli = NULL;
struct be_req *be_req = NULL;
struct be_autofs_req *be_autofs_req = NULL;
- void *user_data = NULL;
int ret = 0;
uint32_t type;
char *filter;
@@ -1655,12 +1627,6 @@ static int be_autofs_handler(struct sbus_request *dbus_req)
DEBUG(SSSDBG_TRACE_FUNC, "Entering be_autofs_handler()\n");
- user_data = sbus_conn_get_private_data(dbus_req->conn);
- if (user_data == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE, "Cannot get SBUS private data\n");
- return EINVAL;
- }
-
be_cli = talloc_get_type(user_data, struct be_client);
if (be_cli == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Cannot get back end client context\n");
@@ -1846,13 +1812,12 @@ static void be_autofs_handler_callback(struct be_req *req,
talloc_free(req);
}
-static int be_host_handler(struct sbus_request *dbus_req)
+static int be_host_handler(struct sbus_request *dbus_req, void *user_data)
{
struct be_host_req *req;
struct be_req *be_req;
struct be_client *becli;
DBusError dbus_error;
- void *user_data;
uint32_t flags;
char *filter;
int ret;
@@ -1862,8 +1827,6 @@ static int be_host_handler(struct sbus_request *dbus_req)
be_req = NULL;
- user_data = sbus_conn_get_private_data(dbus_req->conn);
- if (!user_data) return EINVAL;
becli = talloc_get_type(user_data, struct be_client);
if (!becli) return EINVAL;
@@ -2029,7 +1992,7 @@ static int be_client_destructor(void *ctx)
return 0;
}
-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;
@@ -2038,11 +2001,9 @@ static int client_registration(struct sbus_request *dbus_req)
dbus_uint16_t cli_ver;
char *cli_name;
dbus_bool_t dbret;
- void *data;
int ret;
conn = dbus_req->conn;
- data = sbus_conn_get_private_data(conn);
becli = talloc_get_type(data, struct be_client);
if (!becli) {
DEBUG(SSSDBG_FATAL_FAILURE, "Connection holds no valid init data\n");
@@ -2229,6 +2190,7 @@ 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;
@@ -2263,9 +2225,12 @@ static int be_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, becli);
+ intf = sbus_new_interface(conn, DP_PATH, &be_methods.vtable, becli);
+ if (!intf) {
+ return ENOMEM;
+ }
- return EOK;
+ return sbus_conn_add_interface(conn, intf);
}
/* be_srv_init
@@ -2283,8 +2248,7 @@ static int be_srv_init(struct be_ctx *ctx)
}
ret = sbus_new_server(ctx, ctx->ev, sbus_address,
- &be_interface, true, &ctx->sbus_srv,
- be_client_init, ctx);
+ true, &ctx->sbus_srv, be_client_init, ctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Could not set up sbus server.\n");
return ret;
@@ -2598,7 +2562,7 @@ int be_process_init(TALLOC_CTX *mem_ctx,
goto fail;
}
- ret = sss_monitor_init(ctx, ctx->ev, &monitor_be_interface,
+ ret = sss_monitor_init(ctx, ctx->ev, &monitor_be_methods,
ctx->identity, DATA_PROVIDER_VERSION,
ctx, &ctx->mon_conn);
if (ret != EOK) {
@@ -2884,38 +2848,37 @@ int main(int argc, const char *argv[])
}
#endif
-static int data_provider_res_init(struct sbus_request *dbus_req)
+static int data_provider_res_init(struct sbus_request *dbus_req, void *data)
{
struct be_ctx *be_ctx;
- be_ctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), struct be_ctx);
+ be_ctx = talloc_get_type(data, struct be_ctx);
resolv_reread_configuration(be_ctx->be_res->resolv);
check_if_online(be_ctx);
- return monitor_common_res_init(dbus_req);
+ return monitor_common_res_init(dbus_req, data);
}
-static int data_provider_go_offline(struct sbus_request *dbus_req)
+static int data_provider_go_offline(struct sbus_request *dbus_req, void *data)
{
struct be_ctx *be_ctx;
- be_ctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), struct be_ctx);
+ be_ctx = talloc_get_type(data, struct be_ctx);
be_mark_offline(be_ctx);
return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
}
-static int data_provider_reset_offline(struct sbus_request *dbus_req)
+static int data_provider_reset_offline(struct sbus_request *dbus_req, void *data)
{
struct be_ctx *be_ctx;
- be_ctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), struct be_ctx);
+ be_ctx = talloc_get_type(data, struct be_ctx);
check_if_online(be_ctx);
return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
}
-static int data_provider_logrotate(struct sbus_request *dbus_req)
+static int data_provider_logrotate(struct sbus_request *dbus_req, void *data)
{
errno_t ret;
- struct be_ctx *be_ctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn),
- struct be_ctx);
+ struct be_ctx *be_ctx = talloc_get_type(data, struct be_ctx);
ret = monitor_common_rotate_logs(be_ctx->cdb, be_ctx->conf_path);
if (ret != EOK) return ret;
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");
diff --git a/src/responder/autofs/autofssrv.c b/src/responder/autofs/autofssrv.c
index b447a0634..9b5aa02dd 100644
--- a/src/responder/autofs/autofssrv.c
+++ b/src/responder/autofs/autofssrv.c
@@ -29,7 +29,7 @@
#include "providers/data_provider.h"
#include "responder/autofs/autofs_private.h"
-static int autofs_clean_hash_table(struct sbus_request *dbus_req);
+static int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data);
struct mon_cli_iface monitor_autofs_methods = {
{ &mon_cli_iface_meta, 0 },
@@ -43,12 +43,6 @@ struct mon_cli_iface monitor_autofs_methods = {
.clearEnumCache = autofs_clean_hash_table,
};
-struct sbus_interface monitor_autofs_interface = {
- MONITOR_PATH,
- &monitor_autofs_methods.vtable,
- NULL
-};
-
static struct data_provider_iface autofs_dp_methods = {
{ &data_provider_iface_meta, 0 },
.RegisterService = NULL,
@@ -60,12 +54,6 @@ static struct data_provider_iface autofs_dp_methods = {
.getAccountInfo = NULL,
};
-struct sbus_interface autofs_dp_interface = {
- DP_PATH,
- &autofs_dp_methods.vtable,
- NULL
-};
-
static errno_t
autofs_get_config(struct autofs_ctx *actx,
struct confdb_ctx *cdb)
@@ -111,10 +99,9 @@ autofs_dp_reconnect_init(struct sbus_connection *conn,
be_conn->domain->name);
}
-static int autofs_clean_hash_table(struct sbus_request *dbus_req)
+static int autofs_clean_hash_table(struct sbus_request *dbus_req, void *data)
{
- struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn),
- struct resp_ctx);
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
struct autofs_ctx *actx =
talloc_get_type(rctx->pvt_ctx, struct autofs_ctx);
errno_t ret;
@@ -148,9 +135,9 @@ autofs_process_init(TALLOC_CTX *mem_ctx,
CONFDB_AUTOFS_CONF_ENTRY,
SSS_AUTOFS_SBUS_SERVICE_NAME,
SSS_AUTOFS_SBUS_SERVICE_VERSION,
- &monitor_autofs_interface,
+ &monitor_autofs_methods,
"autofs",
- &autofs_dp_interface,
+ &autofs_dp_methods.vtable,
&rctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index 3cf801516..479cd4c5e 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -70,7 +70,6 @@ struct be_conn {
struct sss_domain_info *domain;
char *sbus_address;
- struct sbus_interface *intf;
struct sbus_connection *conn;
};
@@ -144,7 +143,16 @@ struct sss_cmd_table {
int (*fn)(struct cli_ctx *cctx);
};
-/* responder_common.c */
+/* from generated code */
+struct mon_cli_iface;
+
+/*
+ * responder_common.c
+ *
+ * NOTE: We would like to use more strong typing for the @dp_vtable argument
+ * but can't since it accepts either a struct data_provider_iface
+ * or struct data_provider_rev_iface. So pass the base struct: sbus_vtable
+ */
int sss_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb,
@@ -154,9 +162,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
const char *confdb_service_path,
const char *svc_name,
uint16_t svc_version,
- struct sbus_interface *monitor_intf,
+ struct mon_cli_iface *monitor_intf,
const char *cli_name,
- struct sbus_interface *dp_intf,
+ struct sbus_vtable *dp_intf,
struct resp_ctx **responder_ctx);
int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain,
@@ -207,7 +215,7 @@ struct dp_callback_ctx {
void handle_requests_after_reconnect(struct resp_ctx *rctx);
-int responder_logrotate(struct sbus_request *dbus_req);
+int responder_logrotate(struct sbus_request *dbus_req, void *data);
/* Each responder-specific request must create a constructor
* function that creates a DBus Message that would be sent to
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 209bf5b01..9abda18d0 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -535,10 +535,11 @@ static void idle_handler(struct tevent_context *ev,
}
static int sss_dp_init(struct resp_ctx *rctx,
- struct sbus_interface *intf,
+ struct sbus_vtable *dp_intf,
const char *cli_name,
struct sss_domain_info *domain)
{
+ struct sbus_interface *intf;
struct be_conn *be_conn;
int ret;
@@ -547,7 +548,6 @@ static int sss_dp_init(struct resp_ctx *rctx,
be_conn->cli_name = cli_name;
be_conn->domain = domain;
- be_conn->intf = intf;
be_conn->rctx = rctx;
/* Set up SBUS connection to the monitor */
@@ -558,13 +558,23 @@ static int sss_dp_init(struct resp_ctx *rctx,
}
ret = sbus_client_init(rctx, rctx->ev,
be_conn->sbus_address,
- intf, &be_conn->conn,
- NULL, rctx);
+ &be_conn->conn);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Failed to connect to monitor services.\n");
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);
+ }
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export data provider.\n");
+ return ret;
+ }
+
DLIST_ADD_END(rctx->be_conns, be_conn, struct be_conn *);
/* Identify ourselves to the DP */
@@ -763,9 +773,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
const char *confdb_service_path,
const char *svc_name,
uint16_t svc_version,
- struct sbus_interface *monitor_intf,
+ struct mon_cli_iface *monitor_intf,
const char *cli_name,
- struct sbus_interface *dp_intf,
+ struct sbus_vtable *dp_intf,
struct resp_ctx **responder_ctx)
{
struct resp_ctx *rctx;
@@ -990,11 +1000,10 @@ done:
return ret;
}
-int responder_logrotate(struct sbus_request *dbus_req)
+int responder_logrotate(struct sbus_request *dbus_req, void *data)
{
errno_t ret;
- struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn),
- struct resp_ctx);
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
ret = monitor_common_rotate_logs(rctx->cdb, rctx->confdb_service_path);
if (ret != EOK) return ret;
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 05bcdda07..ca4fbfd02 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -55,8 +55,8 @@
#define SHELL_REALLOC_INCREMENT 5
#define SHELL_REALLOC_MAX 50
-static int nss_clear_memcache(struct sbus_request *dbus_req);
-static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req);
+static int nss_clear_memcache(struct sbus_request *dbus_req, void *data);
+static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req, void *data);
struct mon_cli_iface monitor_nss_methods = {
{ &mon_cli_iface_meta, 0 },
@@ -70,18 +70,11 @@ struct mon_cli_iface monitor_nss_methods = {
.clearEnumCache = nss_clear_netgroup_hash_table
};
-struct sbus_interface monitor_nss_interface = {
- MONITOR_PATH,
- &monitor_nss_methods.vtable,
- NULL,
-};
-
-static int nss_clear_memcache(struct sbus_request *dbus_req)
+static int nss_clear_memcache(struct sbus_request *dbus_req, void *data)
{
errno_t ret;
int memcache_timeout;
- struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn),
- struct resp_ctx);
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
struct nss_ctx *nctx = (struct nss_ctx*) rctx->pvt_ctx;
ret = unlink(SSS_NSS_MCACHE_DIR"/"CLEAR_MC_FLAG);
@@ -134,11 +127,10 @@ done:
return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
}
-static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req)
+static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req, void *data)
{
errno_t ret;
- struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn),
- struct resp_ctx);
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
struct nss_ctx *nctx = (struct nss_ctx*) rctx->pvt_ctx;
ret = nss_orphan_netgroups(nctx);
@@ -304,10 +296,9 @@ done:
return ret;
}
-static int nss_update_memcache(struct sbus_request *dbus_req)
+static int nss_update_memcache(struct sbus_request *dbus_req, void *data)
{
- struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn),
- struct resp_ctx);
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx);
nss_update_pw_memcache(nctx);
@@ -316,10 +307,9 @@ static int nss_update_memcache(struct sbus_request *dbus_req)
return EOK;
}
-static int nss_memcache_initgr_check(struct sbus_request *dbus_req)
+static int nss_memcache_initgr_check(struct sbus_request *dbus_req, void *data)
{
- struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn),
- struct resp_ctx);
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx);
DBusError dbus_error;
dbus_bool_t dbret;
@@ -359,13 +349,6 @@ static struct data_provider_rev_iface nss_dp_methods = {
.initgrCheck = nss_memcache_initgr_check
};
-struct sbus_interface nss_dp_interface = {
- DP_PATH,
- &nss_dp_methods.vtable,
- NULL
-};
-
-
static void nss_dp_reconnect_init(struct sbus_connection *conn,
int status, void *pvt)
{
@@ -417,8 +400,8 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
CONFDB_NSS_CONF_ENTRY,
NSS_SBUS_SERVICE_NAME,
NSS_SBUS_SERVICE_VERSION,
- &monitor_nss_interface,
- "NSS", &nss_dp_interface,
+ &monitor_nss_methods,
+ "NSS", &nss_dp_methods.vtable,
&rctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
diff --git a/src/responder/pac/pacsrv.c b/src/responder/pac/pacsrv.c
index 04a6200e0..bff15058a 100644
--- a/src/responder/pac/pacsrv.c
+++ b/src/responder/pac/pacsrv.c
@@ -60,12 +60,6 @@ struct mon_cli_iface monitor_pac_methods = {
.clearEnumCache = NULL,
};
-struct sbus_interface monitor_pac_interface = {
- MONITOR_PATH,
- &monitor_pac_methods.vtable,
- NULL
-};
-
static struct data_provider_iface pac_dp_methods = {
{ &data_provider_iface_meta, 0 },
.RegisterService = NULL,
@@ -77,13 +71,6 @@ static struct data_provider_iface pac_dp_methods = {
.getAccountInfo = NULL,
};
-struct sbus_interface pac_dp_interface = {
- DP_PATH,
- &pac_dp_methods.vtable,
- NULL
-};
-
-
/* TODO: check if this can be made generic for all responders */
static void pac_dp_reconnect_init(struct sbus_connection *conn,
int status, void *pvt)
@@ -135,8 +122,8 @@ int pac_process_init(TALLOC_CTX *mem_ctx,
CONFDB_PAC_CONF_ENTRY,
PAC_SBUS_SERVICE_NAME,
PAC_SBUS_SERVICE_VERSION,
- &monitor_pac_interface,
- "PAC", &pac_dp_interface,
+ &monitor_pac_methods,
+ "PAC", &pac_dp_methods.vtable,
&rctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
index 1fc9f6282..2823f01a0 100644
--- a/src/responder/pam/pamsrv.c
+++ b/src/responder/pam/pamsrv.c
@@ -59,12 +59,6 @@ struct mon_cli_iface monitor_pam_methods = {
.clearEnumCache = NULL,
};
-struct sbus_interface monitor_pam_interface = {
- MONITOR_PATH,
- &monitor_pam_methods.vtable,
- NULL
-};
-
static struct data_provider_iface pam_dp_methods = {
{ &data_provider_iface_meta, 0 },
.RegisterService = NULL,
@@ -76,13 +70,6 @@ static struct data_provider_iface pam_dp_methods = {
.getAccountInfo = NULL,
};
-struct sbus_interface pam_dp_interface = {
- DP_PATH,
- &pam_dp_methods.vtable,
- NULL
-};
-
-
static void pam_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt)
{
struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
@@ -131,8 +118,8 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
CONFDB_PAM_CONF_ENTRY,
SSS_PAM_SBUS_SERVICE_NAME,
SSS_PAM_SBUS_SERVICE_VERSION,
- &monitor_pam_interface,
- "PAM", &pam_dp_interface,
+ &monitor_pam_methods,
+ "PAM", &pam_dp_methods.vtable,
&rctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
diff --git a/src/responder/ssh/sshsrv.c b/src/responder/ssh/sshsrv.c
index fb0738f6c..30142ae0d 100644
--- a/src/responder/ssh/sshsrv.c
+++ b/src/responder/ssh/sshsrv.c
@@ -40,12 +40,6 @@ struct mon_cli_iface monitor_ssh_methods = {
.clearEnumCache = NULL,
};
-struct sbus_interface monitor_ssh_interface = {
- MONITOR_PATH,
- &monitor_ssh_methods.vtable,
- NULL
-};
-
static struct data_provider_iface ssh_dp_methods = {
{ &data_provider_iface_meta, 0 },
.RegisterService = NULL,
@@ -57,12 +51,6 @@ static struct data_provider_iface ssh_dp_methods = {
.getAccountInfo = NULL,
};
-struct sbus_interface ssh_dp_interface = {
- DP_PATH,
- &ssh_dp_methods.vtable,
- NULL
-};
-
static void ssh_dp_reconnect_init(struct sbus_connection *conn,
int status, void *pvt)
{
@@ -107,9 +95,9 @@ int ssh_process_init(TALLOC_CTX *mem_ctx,
CONFDB_SSH_CONF_ENTRY,
SSS_SSH_SBUS_SERVICE_NAME,
SSS_SSH_SBUS_SERVICE_VERSION,
- &monitor_ssh_interface,
+ &monitor_ssh_methods,
"SSH",
- &ssh_dp_interface,
+ &ssh_dp_methods.vtable,
&rctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
diff --git a/src/responder/sudo/sudosrv.c b/src/responder/sudo/sudosrv.c
index 1ad260b35..a70d944a9 100644
--- a/src/responder/sudo/sudosrv.c
+++ b/src/responder/sudo/sudosrv.c
@@ -40,12 +40,6 @@ struct mon_cli_iface monitor_sudo_methods = {
.clearEnumCache = NULL,
};
-struct sbus_interface monitor_sudo_interface = {
- MONITOR_PATH,
- &monitor_sudo_methods.vtable,
- NULL
-};
-
static struct data_provider_iface sudo_dp_methods = {
{ &data_provider_iface_meta, 0 },
.RegisterService = NULL,
@@ -57,12 +51,6 @@ static struct data_provider_iface sudo_dp_methods = {
.getAccountInfo = NULL,
};
-struct sbus_interface sudo_dp_interface = {
- DP_PATH,
- &sudo_dp_methods.vtable,
- NULL
-};
-
static void sudo_dp_reconnect_init(struct sbus_connection *conn,
int status,
void *pvt)
@@ -108,9 +96,9 @@ int sudo_process_init(TALLOC_CTX *mem_ctx,
CONFDB_SUDO_CONF_ENTRY,
SSS_SUDO_SBUS_SERVICE_NAME,
SSS_SUDO_SBUS_SERVICE_VERSION,
- &monitor_sudo_interface,
+ &monitor_sudo_methods,
"SUDO",
- &sudo_dp_interface,
+ &sudo_dp_methods.vtable,
&rctx);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n");
diff --git a/src/sbus/sbus_client.c b/src/sbus/sbus_client.c
index 19627af14..41cada5a1 100644
--- a/src/sbus/sbus_client.c
+++ b/src/sbus/sbus_client.c
@@ -27,10 +27,7 @@
int sbus_client_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *server_address,
- struct sbus_interface *intf,
- struct sbus_connection **_conn,
- sbus_conn_destructor_fn destructor,
- void *conn_pvt_data)
+ struct sbus_connection **_conn)
{
struct sbus_connection *conn = NULL;
int ret;
@@ -54,15 +51,11 @@ int sbus_client_init(TALLOC_CTX *mem_ctx,
return EIO;
}
- ret = sbus_new_connection(mem_ctx, ev, server_address, intf, &conn);
+ ret = sbus_new_connection(mem_ctx, ev, server_address, &conn);
if (ret != EOK) {
goto fail;
}
- /* Set connection destructor and private data */
- sbus_conn_set_destructor(conn, destructor);
- sbus_conn_set_private_data(conn, conn_pvt_data);
-
*_conn = conn;
return EOK;
diff --git a/src/sbus/sbus_client.h b/src/sbus/sbus_client.h
index ff322e451..f76b40ec4 100644
--- a/src/sbus/sbus_client.h
+++ b/src/sbus/sbus_client.h
@@ -28,9 +28,6 @@
int sbus_client_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *server_address,
- struct sbus_interface *intf,
- struct sbus_connection **_conn,
- sbus_conn_destructor_fn destructor,
- void *conn_pvt_data);
+ struct sbus_connection **_conn);
#endif /* SBUS_CLIENT_H_ */
diff --git a/src/sbus/sssd_dbus.h b/src/sbus/sssd_dbus.h
index dcb669079..ef728bd30 100644
--- a/src/sbus/sssd_dbus.h
+++ b/src/sbus/sssd_dbus.h
@@ -23,12 +23,13 @@
#define _SSSD_DBUS_H_
struct sbus_connection;
-
+struct sbus_interface;
struct sbus_request;
#include <dbus/dbus.h>
-typedef int (*sbus_msg_handler_fn)(struct sbus_request *dbus_req);
+typedef int (*sbus_msg_handler_fn)(struct sbus_request *dbus_req,
+ void *instance_data);
/*
* sbus_conn_destructor_fn
@@ -79,14 +80,28 @@ struct sbus_vtable {
struct sbus_interface {
const char *path;
struct sbus_vtable *vtable;
- sbus_msg_handler_fn introspect_fn;
+ 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,
const char *address,
- struct sbus_interface *intf,
bool use_symlink,
struct sbus_connection **server,
sbus_server_conn_init_fn init_fn, void *init_pvt_data);
@@ -103,7 +118,6 @@ int sbus_new_server(TALLOC_CTX *mem_ctx,
int sbus_new_connection(TALLOC_CTX *ctx,
struct tevent_context *ev,
const char *address,
- struct sbus_interface *intf,
struct sbus_connection **conn);
/* sbus_add_connection
@@ -121,19 +135,11 @@ int sbus_new_connection(TALLOC_CTX *ctx,
int sbus_init_connection(TALLOC_CTX *ctx,
struct tevent_context *ev,
DBusConnection *dbus_conn,
- struct sbus_interface *intf,
int connection_type,
struct sbus_connection **_conn);
-void sbus_conn_set_destructor(struct sbus_connection *conn,
- sbus_conn_destructor_fn destructor);
-
-int sbus_default_connection_destructor(void *ctx);
-
DBusConnection *sbus_get_connection(struct sbus_connection *conn);
void sbus_disconnect(struct sbus_connection *conn);
-void sbus_conn_set_private_data(struct sbus_connection *conn, void *pvt_data);
-void *sbus_conn_get_private_data(struct sbus_connection *conn);
int sbus_conn_add_interface(struct sbus_connection *conn,
struct sbus_interface *intf);
bool sbus_conn_disconnecting(struct sbus_connection *conn);
diff --git a/src/sbus/sssd_dbus_connection.c b/src/sbus/sssd_dbus_connection.c
index 5faf24949..150b5469e 100644
--- a/src/sbus/sssd_dbus_connection.c
+++ b/src/sbus/sssd_dbus_connection.c
@@ -160,7 +160,6 @@ static int sbus_conn_set_fns(struct sbus_connection *conn);
int sbus_init_connection(TALLOC_CTX *ctx,
struct tevent_context *ev,
DBusConnection *dbus_conn,
- struct sbus_interface *intf,
int connection_type,
struct sbus_connection **_conn)
{
@@ -175,12 +174,6 @@ int sbus_init_connection(TALLOC_CTX *ctx,
conn->dbus.conn = dbus_conn;
conn->connection_type = connection_type;
- ret = sbus_conn_add_interface(conn, intf);
- if (ret != EOK) {
- talloc_free(conn);
- return ret;
- }
-
ret = sbus_conn_set_fns(conn);
if (ret != EOK) {
talloc_free(conn);
@@ -195,13 +188,6 @@ static int sbus_conn_set_fns(struct sbus_connection *conn)
{
dbus_bool_t dbret;
- /*
- * Set the default destructor
- * Connections can override this with
- * sbus_conn_set_destructor
- */
- sbus_conn_set_destructor(conn, NULL);
-
/* Set up DBusWatch functions */
dbret = dbus_connection_set_watch_functions(conn->dbus.conn,
sbus_add_watch,
@@ -245,8 +231,7 @@ static int sbus_conn_set_fns(struct sbus_connection *conn)
}
int sbus_new_connection(TALLOC_CTX *ctx, struct tevent_context *ev,
- const char *address, struct sbus_interface *intf,
- struct sbus_connection **_conn)
+ const char *address, struct sbus_connection **_conn)
{
struct sbus_connection *conn;
DBusConnection *dbus_conn;
@@ -265,8 +250,7 @@ int sbus_new_connection(TALLOC_CTX *ctx, struct tevent_context *ev,
return EIO;
}
- ret = sbus_init_connection(ctx, ev, dbus_conn, intf,
- SBUS_CONN_TYPE_SHARED, &conn);
+ ret = sbus_init_connection(ctx, ev, dbus_conn, SBUS_CONN_TYPE_SHARED, &conn);
if (ret != EOK) {
/* FIXME: release resources */
}
@@ -280,26 +264,7 @@ int sbus_new_connection(TALLOC_CTX *ctx, struct tevent_context *ev,
return ret;
}
-/*
- * sbus_conn_set_destructor
- * Configures a callback to clean up this connection when it
- * is finalized.
- * @param conn The sbus_connection created
- * when this connection was established
- * @param destructor The destructor function that should be
- * called when the connection is finalized. If passed NULL,
- * this will reset the connection to the default destructor.
- */
-void sbus_conn_set_destructor(struct sbus_connection *conn,
- sbus_conn_destructor_fn destructor)
-{
- if (!conn) return;
-
- conn->destructor = destructor;
- /* TODO: Should we try to handle the talloc_destructor too? */
-}
-
-int sbus_default_connection_destructor(void *ctx)
+static int connection_destructor(void *ctx)
{
struct sbus_connection *conn;
conn = talloc_get_type(ctx, struct sbus_connection);
@@ -351,11 +316,6 @@ void sbus_disconnect (struct sbus_connection *conn)
conn->disconnect = 1;
- /* Invoke the custom destructor, if it exists */
- if (conn->destructor) {
- conn->destructor(conn);
- }
-
/* Unregister object paths */
sbus_unreg_object_paths(conn);
@@ -377,7 +337,7 @@ void sbus_disconnect (struct sbus_connection *conn)
NULL, NULL, NULL);
/* Finalize the connection */
- sbus_default_connection_destructor(conn);
+ connection_destructor(conn);
dbus_connection_unref(conn->dbus.conn);
/* Unreferenced conn->dbus_conn *
@@ -466,16 +426,6 @@ DBusHandlerResult sbus_message_handler(DBusConnection *dbus_conn,
result = DBUS_HANDLER_RESULT_HANDLED;
}
}
- else {
- /* Special case: check for Introspection request
- * This is usually only useful for system bus connections
- */
- if (strcmp(msg_interface, DBUS_INTROSPECT_INTERFACE) == 0 &&
- strcmp(msg_method, DBUS_INTROSPECT_METHOD) == 0)
- {
- handler_fn = intf_p->intf->introspect_fn;
- }
- }
if (handler_fn) {
dbus_req = sbus_new_request(intf_p->conn, intf_p->intf, message);
@@ -483,7 +433,7 @@ DBusHandlerResult sbus_message_handler(DBusConnection *dbus_conn,
ret = ENOMEM;
} else {
dbus_req->method = method;
- ret = handler_fn(dbus_req);
+ ret = handler_fn(dbus_req, intf_p->intf->instance_data);
}
if (ret != EOK) {
if (dbus_req)
@@ -497,6 +447,32 @@ DBusHandlerResult sbus_message_handler(DBusConnection *dbus_conn,
return result;
}
+struct sbus_interface *
+sbus_new_interface(TALLOC_CTX *mem_ctx,
+ const char *object_path,
+ struct sbus_vtable *iface_vtable,
+ void *instance_data)
+{
+ struct sbus_interface *intf;
+
+ intf = talloc_zero(mem_ctx, struct sbus_interface);
+ if (intf == NULL) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "Cannot allocate a new sbus_interface.\n");
+ return NULL;
+ }
+
+ intf->path = talloc_strdup(intf, object_path);
+ if (intf->path == NULL) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "Cannot duplicate object path.\n");
+ talloc_free(intf);
+ return NULL;
+ }
+
+ intf->vtable = iface_vtable;
+ intf->instance_data = instance_data;
+ return intf;
+}
+
/* Adds a new D-BUS path message handler to the connection
* Note: this must be a unique path.
*/
@@ -570,16 +546,6 @@ static void sbus_unreg_object_paths(struct sbus_connection *conn)
}
}
-void sbus_conn_set_private_data(struct sbus_connection *conn, void *pvt_data)
-{
- conn->pvt_data = pvt_data;
-}
-
-void *sbus_conn_get_private_data(struct sbus_connection *conn)
-{
- return conn->pvt_data;
-}
-
static void sbus_reconnect(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval tv, void *data)
diff --git a/src/sbus/sssd_dbus_private.h b/src/sbus/sssd_dbus_private.h
index eca5c8380..88230cfca 100644
--- a/src/sbus/sssd_dbus_private.h
+++ b/src/sbus/sssd_dbus_private.h
@@ -44,9 +44,6 @@ struct sbus_connection {
int connection_type;
int disconnect;
- sbus_conn_destructor_fn destructor;
- void *pvt_data; /* Private data for this connection */
-
/* dbus tables and handlers */
struct sbus_interface_p *intf_list;
@@ -59,7 +56,6 @@ struct sbus_connection {
/* server related stuff */
char *symlink;
- struct sbus_interface *server_intf;
sbus_server_conn_init_fn srv_init_fn;
void *srv_init_data;
diff --git a/src/sbus/sssd_dbus_server.c b/src/sbus/sssd_dbus_server.c
index 8281158f1..b84df2d0f 100644
--- a/src/sbus/sssd_dbus_server.c
+++ b/src/sbus/sssd_dbus_server.c
@@ -52,8 +52,7 @@ static void sbus_server_init_new_connection(DBusServer *dbus_server,
}
DEBUG(SSSDBG_FUNC_DATA,"Adding connection %p.\n", dbus_conn);
- ret = sbus_init_connection(server, server->ev,
- dbus_conn, server->server_intf,
+ ret = sbus_init_connection(server, server->ev, dbus_conn,
SBUS_CONN_TYPE_PRIVATE, &conn);
if (ret != 0) {
dbus_connection_close(dbus_conn);
@@ -67,9 +66,6 @@ static void sbus_server_init_new_connection(DBusServer *dbus_server,
/*
* Initialize connection-specific features
- * This may set a more detailed destructor, but
- * the default destructor will always be chained
- * to handle connection cleanup.
* This function (or its callbacks) should also
* set up connection-specific methods.
*/
@@ -185,7 +181,6 @@ remove_socket_symlink(const char *symlink_name)
int sbus_new_server(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *address,
- struct sbus_interface *intf,
bool use_symlink,
struct sbus_connection **_server,
sbus_server_conn_init_fn init_fn,
@@ -285,7 +280,6 @@ int sbus_new_server(TALLOC_CTX *mem_ctx,
server->ev = ev;
server->type = SBUS_SERVER;
server->dbus.server = dbus_server;
- server->server_intf = intf;
server->srv_init_fn = init_fn;
server->srv_init_data = init_pvt_data;
diff --git a/src/tests/sbus_codegen_tests.c b/src/tests/sbus_codegen_tests.c
index 146e18a85..decff339d 100644
--- a/src/tests/sbus_codegen_tests.c
+++ b/src/tests/sbus_codegen_tests.c
@@ -113,14 +113,14 @@ START_TEST(test_signals)
END_TEST
static int
-mock_move_universe(struct sbus_request *dbus_req)
+mock_move_universe(struct sbus_request *dbus_req, void *data)
{
/* not called */
return 0;
}
static int
-mock_crash_now(struct sbus_request *dbus_req)
+mock_crash_now(struct sbus_request *dbus_req, void *data)
{
/* not called */
return 0;