summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-08-11 12:03:01 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-08-11 13:27:30 -0400
commit2de7dab64517fcaee5198342e9b7890cdf1c7776 (patch)
treec9cd5373ccdccb3211dba7bdfe88324e2efd76e6
parentab9cfe72d18531ca0fc93c772582329a3b0c5dc9 (diff)
downloadsssd-2de7dab64517fcaee5198342e9b7890cdf1c7776.tar.gz
sssd-2de7dab64517fcaee5198342e9b7890cdf1c7776.tar.bz2
sssd-2de7dab64517fcaee5198342e9b7890cdf1c7776.zip
Change the why DP clients identify
Mirrors what we have done with the monitor.
-rw-r--r--server/Makefile.am1
-rw-r--r--server/providers/data_provider.c255
-rw-r--r--server/providers/data_provider.h7
-rw-r--r--server/providers/data_provider_be.c65
-rw-r--r--server/providers/dp_auth_util.c117
-rw-r--r--server/providers/dp_interfaces.h4
-rw-r--r--server/responder/common/responder.h8
-rw-r--r--server/responder/common/responder_common.c8
-rw-r--r--server/responder/common/responder_dp.c27
-rw-r--r--server/responder/nss/nsssrv.c18
-rw-r--r--server/responder/nss/nsssrv.h2
-rw-r--r--server/responder/nss/nsssrv_dp.c80
-rw-r--r--server/responder/pam/pamsrv.c19
-rw-r--r--server/responder/pam/pamsrv.h1
-rw-r--r--server/responder/pam/pamsrv_dp.c49
15 files changed, 340 insertions, 321 deletions
diff --git a/server/Makefile.am b/server/Makefile.am
index 2d2c65f1..9616a391 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -230,7 +230,6 @@ sssd_LDADD = \
sssd_nss_SOURCES = \
responder/nss/nsssrv.c \
responder/nss/nsssrv_cmd.c \
- responder/nss/nsssrv_dp.c \
responder/nss/nsssrv_nc.c \
$(SSSD_UTIL_OBJ) \
$(SSSD_RESPONDER_OBJ)
diff --git a/server/providers/data_provider.c b/server/providers/data_provider.c
index 7fcd168d..278f33be 100644
--- a/server/providers/data_provider.c
+++ b/server/providers/data_provider.c
@@ -58,6 +58,8 @@ struct dp_ctx {
struct dp_client {
struct dp_ctx *dpctx;
struct sbus_connection *conn;
+ struct tevent_timer *timeout;
+ bool initialized;
};
struct dp_backend {
@@ -96,18 +98,22 @@ struct sbus_interface monitor_dp_interface = {
NULL
};
-static int dp_get_account_info(DBusMessage *message, struct sbus_connection *conn);
+static int client_registration(DBusMessage *message,
+ struct sbus_connection *conn);
+static int dp_get_account_info(DBusMessage *message,
+ struct sbus_connection *conn);
static int dp_pamhandler(DBusMessage *message, struct sbus_connection *conn);
struct sbus_method dp_methods[] = {
+ { DP_SRV_METHOD_REGISTER, client_registration },
{ DP_SRV_METHOD_GETACCTINFO, dp_get_account_info },
{ DP_SRV_METHOD_PAMHANDLER, dp_pamhandler },
{ NULL, NULL }
};
struct sbus_interface dp_interface = {
- DATA_PROVIDER_INTERFACE,
- DATA_PROVIDER_PATH,
+ DP_SRV_INTERFACE,
+ DP_SRV_PATH,
SBUS_DEFAULT_VTABLE,
dp_methods,
NULL
@@ -171,20 +177,27 @@ static int dp_monitor_init(struct dp_ctx *dpctx)
return EOK;
}
-static void be_identity_check(DBusPendingCall *pending, void *data);
-static void be_got_account_info(DBusPendingCall *pending, void *data);
+static void init_timeout(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval t, void *ptr)
+{
+ struct dp_client *dpcli;
+
+ DEBUG(2, ("Client timed out before Identification!\n"));
+
+ dpcli = talloc_get_type(ptr, struct dp_client);
-static int dbus_dp_init(struct sbus_connection *conn, void *data)
+ sbus_disconnect(dpcli->conn);
+ talloc_zfree(dpcli);
+}
+
+static int dp_client_init(struct sbus_connection *conn, void *data)
{
struct dp_ctx *dpctx;
struct dp_client *dpcli;
- DBusMessage *msg;
- DBusPendingCall *pending_reply;
- DBusConnection *dbus_conn;
- dbus_bool_t dbret;
+ struct timeval tv;
dpctx = talloc_get_type(data, struct dp_ctx);
- dbus_conn = sbus_get_connection(conn);
/* hang off this memory to the connection so that when the connection
* is freed we can potentially call a destructor */
@@ -192,173 +205,153 @@ static int dbus_dp_init(struct sbus_connection *conn, void *data)
dpcli = talloc(conn, struct dp_client);
if (!dpcli) {
DEBUG(0,("Out of memory?!\n"));
- talloc_free(conn);
+ talloc_zfree(conn);
return ENOMEM;
}
dpcli->dpctx = dpctx;
dpcli->conn = conn;
+ dpcli->initialized = false;
- /* 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, dpcli);
+ /* 5 seconds should be plenty */
+ tv = tevent_timeval_current_ofs(5, 0);
- /* identify the connecting client */
- msg = dbus_message_new_method_call(NULL,
- DP_CLI_PATH,
- DP_CLI_INTERFACE,
- DP_CLI_METHOD_IDENTITY);
- if (msg == NULL) {
+ dpcli->timeout = tevent_add_timer(dpctx->ev, dpcli,
+ tv, init_timeout, dpcli);
+ if (!dpcli->timeout) {
DEBUG(0,("Out of memory?!\n"));
- talloc_free(conn);
+ talloc_zfree(conn);
return ENOMEM;
}
- dbret = dbus_connection_send_with_reply(dbus_conn, msg, &pending_reply,
- 600000 /* TODO: set timeout */);
- if (!dbret || pending_reply == NULL) {
- /*
- * Critical Failure
- * We can't communicate on this connection
- * We'll drop it using the default destructor.
- */
- DEBUG(0, ("D-BUS send failed.\n"));
- talloc_free(conn);
- dbus_message_unref(msg);
- return EIO;
- }
- /* Set up the reply handler */
- dbus_pending_call_set_notify(pending_reply, be_identity_check, dpcli, NULL);
- dbus_message_unref(msg);
+ /* 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, dpcli);
return EOK;
}
-static void be_identity_check(DBusPendingCall *pending, void *data)
+static int client_registration(DBusMessage *message,
+ struct sbus_connection *conn)
{
+ dbus_uint16_t version = DATA_PROVIDER_VERSION;
struct dp_backend *dpbe;
struct dp_frontend *dpfe;
struct dp_client *dpcli;
DBusMessage *reply;
- DBusConnection *dbus_conn;
DBusError dbus_error;
dbus_uint16_t cli_ver;
dbus_uint16_t cli_type;
char *cli_name;
char *cli_domain;
- dbus_bool_t ret;
- int type;
+ dbus_bool_t dbret;
+ void *data;
+ data = sbus_conn_get_private_data(conn);
dpcli = talloc_get_type(data, struct dp_client);
- dbus_conn = sbus_get_connection(dpcli->conn);
- dbus_error_init(&dbus_error);
-
- reply = dbus_pending_call_steal_reply(pending);
- if (!reply) {
- /* reply should never be null. This function shouldn't be called
- * until reply is valid or timeout has occurred. If reply is NULL
- * here, something is seriously wrong and we should bail out.
- */
- DEBUG(0, ("Severe error. A reply callback was called but no reply was received and no timeout occurred\n"));
-
- /* Destroy this connection */
- sbus_disconnect(dpcli->conn);
- goto done;
+ if (!dpcli) {
+ DEBUG(0, ("Connection holds no valid init data\n"));
+ return EINVAL;
}
- type = dbus_message_get_type(reply);
- switch (type) {
- case DBUS_MESSAGE_TYPE_METHOD_RETURN:
- ret = dbus_message_get_args(reply, &dbus_error,
- DBUS_TYPE_UINT16, &cli_type,
- DBUS_TYPE_UINT16, &cli_ver,
- DBUS_TYPE_STRING, &cli_name,
- DBUS_TYPE_STRING, &cli_domain,
- DBUS_TYPE_INVALID);
- if (!ret) {
- DEBUG(1,("be_identity_check failed, to parse message, killing connection\n"));
- if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
- sbus_disconnect(dpcli->conn);
- goto done;
- }
+ /* First thing, cancel the timeout */
+ talloc_zfree(dpcli->timeout);
- switch (cli_type & DP_CLI_TYPE_MASK) {
- case DP_CLI_BACKEND:
- dpbe = talloc_zero(dpcli->dpctx, struct dp_backend);
- if (!dpbe) {
- DEBUG(0, ("Out of memory!\n"));
- sbus_disconnect(dpcli->conn);
- goto done;
- }
+ dbus_error_init(&dbus_error);
- dpbe->name = talloc_strdup(dpbe, cli_name);
- dpbe->domain = talloc_strdup(dpbe, cli_domain);
- if (!dpbe->name || !dpbe->domain) {
- DEBUG(0, ("Out of memory!\n"));
- sbus_disconnect(dpcli->conn);
- goto done;
- }
+ dbret = dbus_message_get_args(message, &dbus_error,
+ DBUS_TYPE_UINT16, &cli_type,
+ DBUS_TYPE_UINT16, &cli_ver,
+ DBUS_TYPE_STRING, &cli_name,
+ DBUS_TYPE_STRING, &cli_domain,
+ DBUS_TYPE_INVALID);
+ if (!dbret) {
+ DEBUG(1, ("Failed to parse message, killing connection\n"));
+ if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
+ sbus_disconnect(conn);
+ /* FIXME: should we just talloc_zfree(conn) ? */
+ return EIO;
+ }
- dpbe->dpcli = dpcli;
+ switch (cli_type & DP_CLI_TYPE_MASK) {
+ case DP_CLI_BACKEND:
+ dpbe = talloc_zero(dpcli->dpctx, struct dp_backend);
+ if (!dpbe) {
+ DEBUG(0, ("Out of memory!\n"));
+ sbus_disconnect(conn);
+ return ENOMEM;
+ }
- DLIST_ADD(dpcli->dpctx->be_list, dpbe);
+ dpbe->name = talloc_strdup(dpbe, cli_name);
+ dpbe->domain = talloc_strdup(dpbe, cli_domain);
+ if (!dpbe->name || !dpbe->domain) {
+ DEBUG(0, ("Out of memory!\n"));
+ sbus_disconnect(conn);
+ return ENOMEM;
+ }
- DEBUG(4, ("Added Backend client [%s], for domain [%s]\n",
- dpbe->name, dpbe->domain));
+ dpbe->dpcli = dpcli;
- talloc_set_destructor((TALLOC_CTX *)dpbe, dp_backend_destructor);
- break;
+ DLIST_ADD(dpcli->dpctx->be_list, dpbe);
- case DP_CLI_FRONTEND:
- dpfe = talloc_zero(dpcli->dpctx, struct dp_frontend);
- if (!dpfe) {
- DEBUG(0, ("Out of memory!\n"));
- sbus_disconnect(dpcli->conn);
- goto done;
- }
+ DEBUG(4, ("Added Backend client [%s], for domain [%s]\n",
+ dpbe->name, dpbe->domain));
- dpfe->name = talloc_strdup(dpfe, cli_name);
- if (!dpfe->name) {
- DEBUG(0, ("Out of memory!\n"));
- sbus_disconnect(dpcli->conn);
- goto done;
- }
+ talloc_set_destructor((TALLOC_CTX *)dpbe, dp_backend_destructor);
+ break;
- dpfe->dpcli = dpcli;
+ case DP_CLI_FRONTEND:
+ dpfe = talloc_zero(dpcli->dpctx, struct dp_frontend);
+ if (!dpfe) {
+ DEBUG(0, ("Out of memory!\n"));
+ sbus_disconnect(conn);
+ return ENOMEM;
+ }
- DLIST_ADD(dpcli->dpctx->fe_list, dpfe);
+ dpfe->name = talloc_strdup(dpfe, cli_name);
+ if (!dpfe->name) {
+ DEBUG(0, ("Out of memory!\n"));
+ sbus_disconnect(conn);
+ return ENOMEM;
+ }
- DEBUG(4, ("Added Frontend client [%s]\n", dpfe->name));
+ dpfe->dpcli = dpcli;
- talloc_set_destructor((TALLOC_CTX *)dpfe, dp_frontend_destructor);
- break;
+ DLIST_ADD(dpcli->dpctx->fe_list, dpfe);
- default:
- DEBUG(1, ("Unknown client type, killing connection\n"));
- sbus_disconnect(dpcli->conn);
- goto done;
- }
+ DEBUG(4, ("Added Frontend client [%s]\n", dpfe->name));
- /* Set up the destructor for this service */
+ talloc_set_destructor((TALLOC_CTX *)dpfe, dp_frontend_destructor);
break;
- case DBUS_MESSAGE_TYPE_ERROR:
- DEBUG(0,("getIdentity returned an error [%s], closing connection.\n",
- dbus_message_get_error_name(reply)));
- /* Falling through to default intentionally*/
default:
- /*
- * Timeout or other error occurred or something
- * unexpected happened.
- * It doesn't matter which, because either way we
- * know that this connection isn't trustworthy.
- * We'll destroy it now.
- */
- sbus_disconnect(dpcli->conn);
+ DEBUG(1, ("Unknown client type, killing connection\n"));
+ sbus_disconnect(conn);
+ return EIO;
}
-done:
- dbus_pending_call_unref(pending);
+ /* reply that all is ok */
+ reply = dbus_message_new_method_return(message);
+ if (!reply) {
+ DEBUG(0, ("Dbus Out of memory!\n"));
+ return ENOMEM;
+ }
+
+ dbret = dbus_message_append_args(reply,
+ DBUS_TYPE_UINT16, &version,
+ DBUS_TYPE_INVALID);
+ if (!dbret) {
+ DEBUG(0, ("Failed to build dbus reply\n"));
+ dbus_message_unref(reply);
+ sbus_disconnect(conn);
+ return EIO;
+ }
+
+ /* send reply back */
+ sbus_conn_send_reply(conn, reply);
dbus_message_unref(reply);
+
+ dpcli->initialized = true;
+ return EOK;
}
static void be_got_account_info(DBusPendingCall *pending, void *data)
@@ -954,7 +947,7 @@ static int dp_srv_init(struct dp_ctx *dpctx)
ret = sbus_new_server(dpctx, dpctx->ev, dpbus_address,
&dp_interface, &dpctx->sbus_srv,
- dbus_dp_init, dpctx);
+ dp_client_init, dpctx);
if (ret != EOK) {
goto done;
}
diff --git a/server/providers/data_provider.h b/server/providers/data_provider.h
index b747e69b..9c93bfec 100644
--- a/server/providers/data_provider.h
+++ b/server/providers/data_provider.h
@@ -58,11 +58,11 @@
#define DP_CLI_PROVIDE_PAM (1<<9)
#define DP_CLI_PROVIDE_POLICY (1<<10)
-#define DP_CLI_METHOD_IDENTITY "getIdentity"
#define DP_CLI_METHOD_ONLINE "getOnline"
#define DP_CLI_METHOD_GETACCTINFO "getAccountInfo"
#define DP_CLI_METHOD_PAMHANDLER "pamHandler"
+#define DP_SRV_METHOD_REGISTER "RegisterService"
#define DP_SRV_METHOD_GETACCTINFO "getAccountInfo"
#define DP_SRV_METHOD_PAMHANDLER "pamHandler"
@@ -131,4 +131,9 @@ bool dp_unpack_pam_request(DBusMessage *msg, struct pam_data *pd, DBusError *dbu
bool dp_pack_pam_response(DBusMessage *msg, struct pam_data *pd);
bool dp_unpack_pam_response(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error);
+int dp_common_send_id(struct sbus_connection *conn,
+ uint16_t cli_type, uint16_t version,
+ const char *name, const char *domain);
+
+
#endif /* __DATA_PROVIDER_ */
diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c
index 46f8db51..c92289b6 100644
--- a/server/providers/data_provider_be.c
+++ b/server/providers/data_provider_be.c
@@ -62,13 +62,11 @@ struct sbus_interface monitor_be_interface = {
NULL
};
-static int be_identity(DBusMessage *message, struct sbus_connection *conn);
static int be_check_online(DBusMessage *message, struct sbus_connection *conn);
static int be_get_account_info(DBusMessage *message, struct sbus_connection *conn);
static int be_pam_handler(DBusMessage *message, struct sbus_connection *conn);
struct sbus_method be_methods[] = {
- { DP_CLI_METHOD_IDENTITY, be_identity },
{ DP_CLI_METHOD_ONLINE, be_check_online },
{ DP_CLI_METHOD_GETACCTINFO, be_get_account_info },
{ DP_CLI_METHOD_PAMHANDLER, be_pam_handler },
@@ -76,8 +74,8 @@ struct sbus_method be_methods[] = {
};
struct sbus_interface be_interface = {
- DATA_PROVIDER_INTERFACE,
- DATA_PROVIDER_PATH,
+ DP_CLI_INTERFACE,
+ DP_CLI_PATH,
SBUS_DEFAULT_VTABLE,
be_methods,
NULL
@@ -92,44 +90,6 @@ static struct bet_data bet_data[] = {
{BET_MAX, NULL, NULL}
};
-static int be_identity(DBusMessage *message, struct sbus_connection *conn)
-{
- dbus_uint16_t version = DATA_PROVIDER_VERSION;
- dbus_uint16_t clitype = DP_CLI_BACKEND;
- struct be_ctx *ctx;
- DBusMessage *reply;
- dbus_bool_t ret;
- void *user_data;
-
- user_data = sbus_conn_get_private_data(conn);
- if (!user_data) return EINVAL;
- ctx = talloc_get_type(user_data, struct be_ctx);
- if (!ctx) return EINVAL;
-
- DEBUG(4,("Sending ID reply: (%d,%d,%s,%s)\n",
- clitype, version, ctx->name, ctx->domain->name));
-
- reply = dbus_message_new_method_return(message);
- if (!reply) return ENOMEM;
-
- ret = dbus_message_append_args(reply,
- DBUS_TYPE_UINT16, &clitype,
- DBUS_TYPE_UINT16, &version,
- DBUS_TYPE_STRING, &ctx->name,
- DBUS_TYPE_STRING, &ctx->domain->name,
- DBUS_TYPE_INVALID);
- if (!ret) {
- dbus_message_unref(reply);
- return EIO;
- }
-
- /* send reply back */
- sbus_conn_send_reply(conn, reply);
- dbus_message_unref(reply);
-
- return EOK;
-}
-
struct be_async_req {
be_req_fn_t fn;
struct be_req *req;
@@ -661,6 +621,15 @@ static int be_cli_init(struct be_ctx *ctx)
return ret;
}
+ /* Identify ourselves to the data provider */
+ ret = dp_common_send_id(ctx->dp_conn,
+ DP_CLI_BACKEND, DATA_PROVIDER_VERSION,
+ ctx->name, ctx->domain->name);
+ if (ret != EOK) {
+ DEBUG(0, ("Failed to identify to the data provider!\n"));
+ return ret;
+ }
+
/* Enable automatic reconnection to the Data Provider */
ret = confdb_get_int(ctx->cdb, ctx, SERVICE_CONF_ENTRY,
"reconnection_retries", 3, &max_retries);
@@ -686,11 +655,21 @@ static void be_cli_reconnect_init(struct sbus_connection *conn, int status, void
/* Did we reconnect successfully? */
if (status == SBUS_RECONNECT_SUCCESS) {
DEBUG(1, ("Reconnected to the Data Provider.\n"));
- return;
+
+ /* Identify ourselves to the data provider */
+ ret = dp_common_send_id(be_ctx->dp_conn,
+ DP_CLI_BACKEND, DATA_PROVIDER_VERSION,
+ be_ctx->name, be_ctx->domain->name);
+ if (ret != EOK) {
+ DEBUG(0, ("Failed to send id to the data provider!\n"));
+ } else {
+ return;
+ }
}
/* Handle failure */
DEBUG(0, ("Could not reconnect to data provider.\n"));
+
/* Kill the backend and let the monitor restart it */
ret = be_finalize(be_ctx);
if (ret != EOK) {
diff --git a/server/providers/dp_auth_util.c b/server/providers/dp_auth_util.c
index 7219917d..492ac7cf 100644
--- a/server/providers/dp_auth_util.c
+++ b/server/providers/dp_auth_util.c
@@ -222,3 +222,120 @@ bool dp_unpack_pam_response(DBusMessage *msg, struct pam_data *pd, DBusError *db
return true;
}
+static void id_callback(DBusPendingCall *pending, void *ptr)
+{
+ DBusMessage *reply;
+ DBusError dbus_error;
+ dbus_bool_t ret;
+ dbus_uint16_t dp_ver;
+ int type;
+
+ dbus_error_init(&dbus_error);
+
+ reply = dbus_pending_call_steal_reply(pending);
+ if (!reply) {
+ /* reply should never be null. This function shouldn't be called
+ * until reply is valid or timeout has occurred. If reply is NULL
+ * here, something is seriously wrong and we should bail out.
+ */
+ DEBUG(0, ("Severe error. A reply callback was called but no"
+ " reply was received and no timeout occurred\n"));
+
+ /* FIXME: Destroy this connection ? */
+ goto done;
+ }
+
+ type = dbus_message_get_type(reply);
+ switch (type) {
+ case DBUS_MESSAGE_TYPE_METHOD_RETURN:
+ ret = dbus_message_get_args(reply, &dbus_error,
+ DBUS_TYPE_UINT16, &dp_ver,
+ DBUS_TYPE_INVALID);
+ if (!ret) {
+ DEBUG(1, ("Failed to parse message\n"));
+ if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
+ /* FIXME: Destroy this connection ? */
+ goto done;
+ }
+
+ DEBUG(4, ("Got id ack and version (%d) from DP\n", dp_ver));
+
+ break;
+
+ case DBUS_MESSAGE_TYPE_ERROR:
+ DEBUG(0,("The Monitor returned an error [%s]\n",
+ dbus_message_get_error_name(reply)));
+ /* Falling through to default intentionally*/
+ default:
+ /*
+ * Timeout or other error occurred or something
+ * unexpected happened.
+ * It doesn't matter which, because either way we
+ * know that this connection isn't trustworthy.
+ * We'll destroy it now.
+ */
+
+ /* FIXME: Destroy this connection ? */
+ break;
+ }
+
+done:
+ dbus_pending_call_unref(pending);
+ dbus_message_unref(reply);
+}
+
+int dp_common_send_id(struct sbus_connection *conn,
+ uint16_t cli_type, uint16_t version,
+ const char *name, const char *domain)
+{
+ DBusPendingCall *pending_reply;
+ DBusConnection *dbus_conn;
+ DBusMessage *msg;
+ dbus_bool_t ret;
+
+ dbus_conn = sbus_get_connection(conn);
+
+ /* create the message */
+ msg = dbus_message_new_method_call(NULL,
+ DP_SRV_PATH,
+ DP_SRV_INTERFACE,
+ DP_SRV_METHOD_REGISTER);
+ if (msg == NULL) {
+ DEBUG(0, ("Out of memory?!\n"));
+ return ENOMEM;
+ }
+
+ DEBUG(4, ("Sending ID to DP: (%d,%d,%s,%s)\n",
+ cli_type, version, name, domain));
+
+ ret = dbus_message_append_args(msg,
+ DBUS_TYPE_UINT16, &cli_type,
+ DBUS_TYPE_UINT16, &version,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_INVALID);
+ if (!ret) {
+ DEBUG(1, ("Failed to build message\n"));
+ return EIO;
+ }
+
+ ret = dbus_connection_send_with_reply(dbus_conn, msg, &pending_reply,
+ 30000 /* TODO: set timeout */);
+ if (!ret || !pending_reply) {
+ /*
+ * Critical Failure
+ * We can't communicate on this connection
+ * We'll drop it using the default destructor.
+ */
+ DEBUG(0, ("D-BUS send failed.\n"));
+ dbus_message_unref(msg);
+ return EIO;
+ }
+
+ /* Set up the reply handler */
+ dbus_pending_call_set_notify(pending_reply, id_callback, NULL, NULL);
+ dbus_message_unref(msg);
+
+ return EOK;
+}
+
diff --git a/server/providers/dp_interfaces.h b/server/providers/dp_interfaces.h
index faba00c5..0b75f083 100644
--- a/server/providers/dp_interfaces.h
+++ b/server/providers/dp_interfaces.h
@@ -24,8 +24,8 @@
/* Data Provider */
-#define DATA_PROVIDER_INTERFACE "org.freedesktop.sssd.dataprovider"
-#define DATA_PROVIDER_PATH "/org/freedesktop/sssd/dataprovider"
+#define DP_SRV_INTERFACE "org.freedesktop.sssd.dataprovider"
+#define DP_SRV_PATH "/org/freedesktop/sssd/dataprovider"
#define DP_METHOD_CHECK_ONLINE "isOnline"
diff --git a/server/responder/common/responder.h b/server/responder/common/responder.h
index f4187650..881c3306 100644
--- a/server/responder/common/responder.h
+++ b/server/responder/common/responder.h
@@ -104,8 +104,10 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
const char *confdb_service_path,
const char *svc_name,
uint16_t svc_version,
- struct sbus_interface *dp_intf,
struct sbus_interface *monitor_intf,
+ uint16_t cli_type, uint16_t cli_version,
+ const char *cli_name, const char *cli_domain,
+ struct sbus_interface *dp_intf,
struct resp_ctx **responder_ctx);
int sss_parse_name(TALLOC_CTX *memctx,
@@ -119,7 +121,9 @@ int sss_cmd_get_version(struct cli_ctx *cctx);
struct cli_protocol_version *register_cli_protocol_version(void);
/* responder_dp.c */
-int sss_dp_init(struct resp_ctx *rctx, struct sbus_interface *intf);
+int sss_dp_init(struct resp_ctx *rctx, struct sbus_interface *intf,
+ uint16_t cli_type, uint16_t cli_version,
+ const char *cli_name, const char *cli_domain);
#define NSS_DP_USER 1
#define NSS_DP_GROUP 2
diff --git a/server/responder/common/responder_common.c b/server/responder/common/responder_common.c
index 75e72103..cf06c3ca 100644
--- a/server/responder/common/responder_common.c
+++ b/server/responder/common/responder_common.c
@@ -455,8 +455,10 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
const char *confdb_service_path,
const char *svc_name,
uint16_t svc_version,
- struct sbus_interface *dp_intf,
struct sbus_interface *monitor_intf,
+ uint16_t cli_type, uint16_t cli_version,
+ const char *cli_name, const char *cli_domain,
+ struct sbus_interface *dp_intf,
struct resp_ctx **responder_ctx)
{
struct resp_ctx *rctx;
@@ -486,7 +488,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
return ret;
}
- ret = sss_dp_init(rctx, dp_intf);
+ ret = sss_dp_init(rctx, dp_intf,
+ cli_type, cli_version,
+ cli_name, cli_domain);
if (ret != EOK) {
DEBUG(0, ("fatal error setting up backend connector\n"));
return ret;
diff --git a/server/responder/common/responder_dp.c b/server/responder/common/responder_dp.c
index dc810fd9..fd13208f 100644
--- a/server/responder/common/responder_dp.c
+++ b/server/responder/common/responder_dp.c
@@ -11,6 +11,12 @@
struct sss_dp_pvt_ctx {
struct resp_ctx *rctx;
struct sbus_interface *intf;
+
+ uint16_t cli_type;
+ uint16_t cli_version;
+ const char *cli_name;
+ const char *cli_domain;
+
time_t last_retry;
int retries;
};
@@ -52,6 +58,17 @@ static void sss_dp_conn_reconnect(struct sss_dp_pvt_ctx *pvt)
ret = sbus_client_init(rctx, rctx->ev, sbus_address,
pvt->intf, &rctx->dp_conn,
sss_dp_conn_destructor, pvt);
+
+ if (ret == EOK) {
+ /* Identify ourselves to the data provider */
+ ret = dp_common_send_id(rctx->dp_conn,
+ pvt->cli_type, pvt->cli_version,
+ pvt->cli_name, pvt->cli_domain);
+ if (ret != EOK) {
+ DEBUG(0, ("Failed to identify to the data provider!\n"));
+ }
+ }
+
if (ret != EOK) {
DEBUG(4, ("Failed to reconnect [%d(%s)]!\n", ret, strerror(ret)));
@@ -97,7 +114,9 @@ int sss_dp_conn_destructor(void *data)
return 0;
}
-int sss_dp_init(struct resp_ctx *rctx, struct sbus_interface *dp_intf)
+int sss_dp_init(struct resp_ctx *rctx, struct sbus_interface *dp_intf,
+ uint16_t cli_type, uint16_t cli_version,
+ const char *cli_name, const char *cli_domain)
{
struct sss_dp_pvt_ctx *pvt;
@@ -106,6 +125,12 @@ int sss_dp_init(struct resp_ctx *rctx, struct sbus_interface *dp_intf)
pvt->rctx = rctx;
pvt->intf = dp_intf;
+ pvt->cli_type = cli_type;
+ pvt->cli_version = cli_version;
+ pvt->cli_name = talloc_strdup(pvt, cli_name);
+ if (!pvt->cli_name) return ENOMEM;
+ pvt->cli_domain = talloc_strdup(pvt, cli_domain);
+ if (!pvt->cli_domain) return ENOMEM;
sss_dp_conn_reconnect(pvt);
diff --git a/server/responder/nss/nsssrv.c b/server/responder/nss/nsssrv.c
index e4b121bf..456c6292 100644
--- a/server/responder/nss/nsssrv.c
+++ b/server/responder/nss/nsssrv.c
@@ -203,12 +203,22 @@ static void nss_dp_reconnect_init(struct sbus_connection *conn, int status, void
nss_shutdown(rctx);
}
+static struct sbus_method nss_dp_methods[] = {
+ { NULL, NULL }
+};
+
+struct sbus_interface nss_dp_interface = {
+ DP_CLI_INTERFACE,
+ DP_CLI_PATH,
+ SBUS_DEFAULT_VTABLE,
+ nss_dp_methods,
+ NULL
+};
int nss_process_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
- struct sbus_interface *nss_dp_interface;
struct sss_cmd_table *nss_cmds;
struct nss_ctx *nctx;
int ret, max_retries;
@@ -225,7 +235,6 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
return ret;
}
- nss_dp_interface = get_nss_dp_interface();
nss_cmds = get_nss_cmds();
ret = sss_process_init(nctx, ev, cdb,
@@ -234,8 +243,11 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
NSS_SRV_CONFIG,
NSS_SBUS_SERVICE_NAME,
NSS_SBUS_SERVICE_VERSION,
- nss_dp_interface,
&monitor_nss_interface,
+ DP_CLI_FRONTEND,
+ DATA_PROVIDER_VERSION,
+ "NSS", "",
+ &nss_dp_interface,
&nctx->rctx);
if (ret != EOK) {
return ret;
diff --git a/server/responder/nss/nsssrv.h b/server/responder/nss/nsssrv.h
index f34456f4..0d3124c7 100644
--- a/server/responder/nss/nsssrv.h
+++ b/server/responder/nss/nsssrv.h
@@ -66,8 +66,6 @@ struct nss_packet;
int nss_cmd_execute(struct cli_ctx *cctx);
-/* from nsssrv_dp.c */
-struct sbus_interface *get_nss_dp_interface(void);
struct sss_cmd_table *get_nss_cmds(void);
#endif /* __NSSSRV_H__ */
diff --git a/server/responder/nss/nsssrv_dp.c b/server/responder/nss/nsssrv_dp.c
deleted file mode 100644
index 92a2d441..00000000
--- a/server/responder/nss/nsssrv_dp.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- SSSD
-
- NSS Responder - Data Provider Interfaces
-
- Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <sys/time.h>
-#include <time.h>
-#include "util/util.h"
-#include "responder/common/responder_packet.h"
-#include "responder/nss/nsssrv.h"
-#include "providers/data_provider.h"
-#include "sbus/sbus_client.h"
-#include "providers/dp_sbus.h"
-
-static int nss_dp_identity(DBusMessage *message, struct sbus_connection *conn)
-{
- dbus_uint16_t version = DATA_PROVIDER_VERSION;
- dbus_uint16_t clitype = DP_CLI_FRONTEND;
- const char *cliname = "NSS";
- const char *nullname = "";
- DBusMessage *reply;
- dbus_bool_t ret;
-
- DEBUG(4,("Sending ID reply: (%d,%d,%s)\n",
- clitype, version, cliname));
-
- reply = dbus_message_new_method_return(message);
- if (!reply) return ENOMEM;
-
- ret = dbus_message_append_args(reply,
- DBUS_TYPE_UINT16, &clitype,
- DBUS_TYPE_UINT16, &version,
- DBUS_TYPE_STRING, &cliname,
- DBUS_TYPE_STRING, &nullname,
- DBUS_TYPE_INVALID);
- if (!ret) {
- dbus_message_unref(reply);
- return EIO;
- }
-
- /* send reply back */
- sbus_conn_send_reply(conn, reply);
- dbus_message_unref(reply);
-
- return EOK;
-}
-
-static struct sbus_method nss_dp_methods[] = {
- { DP_CLI_METHOD_IDENTITY, nss_dp_identity },
- { NULL, NULL }
-};
-
-struct sbus_interface nss_dp_interface = {
- DATA_PROVIDER_INTERFACE,
- DATA_PROVIDER_PATH,
- SBUS_DEFAULT_VTABLE,
- nss_dp_methods,
- NULL
-};
-
-struct sbus_interface *get_nss_dp_interface(void)
-{
- return &nss_dp_interface;
-}
diff --git a/server/responder/pam/pamsrv.c b/server/responder/pam/pamsrv.c
index c0f0ca40..6f92eb96 100644
--- a/server/responder/pam/pamsrv.c
+++ b/server/responder/pam/pamsrv.c
@@ -125,13 +125,24 @@ static int pam_process_init(struct main_context *main_ctx,
return EOK;
}
+static struct sbus_method pam_dp_methods[] = {
+ { NULL, NULL }
+};
+
+struct sbus_interface pam_dp_interface = {
+ DP_CLI_INTERFACE,
+ DP_CLI_PATH,
+ SBUS_DEFAULT_VTABLE,
+ pam_dp_methods,
+ NULL
+};
+
int main(int argc, const char *argv[])
{
int opt;
poptContext pc;
struct main_context *main_ctx;
int ret;
- struct sbus_interface *pam_dp_interface;
struct sss_cmd_table *sss_cmds;
struct resp_ctx *rctx;
@@ -164,7 +175,6 @@ int main(int argc, const char *argv[])
DEBUG(2, ("Could not set up to exit when parent process does\n"));
}
- pam_dp_interface = get_pam_dp_interface();
sss_cmds = register_sss_cmds();
ret = sss_process_init(main_ctx,
main_ctx->event_ctx,
@@ -175,8 +185,11 @@ int main(int argc, const char *argv[])
PAM_SRV_CONFIG,
PAM_SBUS_SERVICE_NAME,
PAM_SBUS_SERVICE_VERSION,
- pam_dp_interface,
&monitor_pam_interface,
+ DP_CLI_FRONTEND,
+ DATA_PROVIDER_VERSION,
+ "PAM", "",
+ &pam_dp_interface,
&rctx);
if (ret != EOK) return 3;
diff --git a/server/responder/pam/pamsrv.h b/server/responder/pam/pamsrv.h
index 1de1cee8..67261157 100644
--- a/server/responder/pam/pamsrv.h
+++ b/server/responder/pam/pamsrv.h
@@ -22,7 +22,6 @@ struct pam_auth_req {
void *data;
};
-struct sbus_interface *get_pam_dp_interface(void);
struct sss_cmd_table *register_sss_cmds(void);
int pam_dp_send_req(struct pam_auth_req *preq, int timeout);
diff --git a/server/responder/pam/pamsrv_dp.c b/server/responder/pam/pamsrv_dp.c
index c0a286b2..3696d3d6 100644
--- a/server/responder/pam/pamsrv_dp.c
+++ b/server/responder/pam/pamsrv_dp.c
@@ -137,52 +137,3 @@ int pam_dp_send_req(struct pam_auth_req *preq, int timeout)
return EOK;
}
-static int pam_dp_identity(DBusMessage *message, struct sbus_connection *conn)
-{
- dbus_uint16_t version = DATA_PROVIDER_VERSION;
- dbus_uint16_t clitype = DP_CLI_FRONTEND;
- const char *cliname = "PAM";
- const char *nullname = "";
- DBusMessage *reply;
- dbus_bool_t ret;
-
- DEBUG(4,("Sending ID reply: (%d,%d,%s)\n", clitype, version, cliname));
-
- reply = dbus_message_new_method_return(message);
- if (!reply) return ENOMEM;
-
- ret = dbus_message_append_args(reply,
- DBUS_TYPE_UINT16, &clitype,
- DBUS_TYPE_UINT16, &version,
- DBUS_TYPE_STRING, &cliname,
- DBUS_TYPE_STRING, &nullname,
- DBUS_TYPE_INVALID);
- if (!ret) {
- dbus_message_unref(reply);
- return EIO;
- }
-
- /* send reply back */
- sbus_conn_send_reply(conn, reply);
- dbus_message_unref(reply);
-
- return EOK;
-}
-
-static struct sbus_method pam_dp_methods[] = {
- { DP_CLI_METHOD_IDENTITY, pam_dp_identity },
- { NULL, NULL }
-};
-
-struct sbus_interface pam_dp_interface = {
- DATA_PROVIDER_INTERFACE,
- DATA_PROVIDER_PATH,
- SBUS_DEFAULT_VTABLE,
- pam_dp_methods,
- NULL
-};
-
-struct sbus_interface *get_pam_dp_interface(void)
-{
- return &pam_dp_interface;
-}