summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-03-10 15:27:59 -0500
committerStephen Gallagher <sgallagh@redhat.com>2010-03-15 11:12:56 -0400
commit9fbf00c7802719becd633ecbc45879d5d0ddb985 (patch)
treec38722bd78d605b26d76c24d6c13bd45bc0936bf /src/responder
parent065b4307c33407e28f28fdba1aee2747b88b0984 (diff)
downloadsssd-9fbf00c7802719becd633ecbc45879d5d0ddb985.tar.gz
sssd-9fbf00c7802719becd633ecbc45879d5d0ddb985.tar.xz
sssd-9fbf00c7802719becd633ecbc45879d5d0ddb985.zip
Properly handle dbus send attempts on a closed connection
dbus_connection_send_with_reply() will report success and return a NULL pending_reply when the connection is not open for communication. This patch creates a new wrapper around dbus_connection_send_with_reply() to properly detect this condition and report it as an error.
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/common/responder_dp.c32
-rw-r--r--src/responder/pam/pamsrv_dp.c27
2 files changed, 15 insertions, 44 deletions
diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c
index d5a4ca760..001661ca6 100644
--- a/src/responder/common/responder_dp.c
+++ b/src/responder/common/responder_dp.c
@@ -412,7 +412,6 @@ static int sss_dp_send_acct_req_create(struct resp_ctx *rctx,
void *callback_ctx,
struct sss_dp_req **ndp)
{
- DBusConnection *dbus_conn;
DBusMessage *msg;
DBusPendingCall *pending_reply;
dbus_bool_t dbret;
@@ -432,7 +431,6 @@ static int sss_dp_send_acct_req_create(struct resp_ctx *rctx,
" This maybe a bug, it shouldn't happen!\n", domain));
return EIO;
}
- dbus_conn = sbus_get_connection(be_conn->conn);
/* create the message */
msg = dbus_message_new_method_call(NULL,
@@ -457,9 +455,16 @@ static int sss_dp_send_acct_req_create(struct resp_ctx *rctx,
return EIO;
}
- dbret = dbus_connection_send_with_reply(dbus_conn, msg,
- &pending_reply, timeout);
- if (!dbret || pending_reply == NULL) {
+ sdp_req = talloc_zero(rctx, struct sss_dp_req);
+ if (!sdp_req) {
+ dbus_message_unref(msg);
+ return ENOMEM;
+ }
+
+ ret = sbus_conn_send(be_conn->conn, msg, timeout,
+ sss_dp_send_acct_callback,
+ sdp_req, &pending_reply);
+ if (ret != EOK) {
/*
* Critical Failure
* We can't communicate on this connection
@@ -470,11 +475,6 @@ static int sss_dp_send_acct_req_create(struct resp_ctx *rctx,
return EIO;
}
- sdp_req = talloc_zero(rctx, struct sss_dp_req);
- if (!sdp_req) {
- dbus_message_unref(msg);
- return ENOMEM;
- }
sdp_req->ev = rctx->ev;
sdp_req->pending_reply = pending_reply;
@@ -493,18 +493,6 @@ static int sss_dp_send_acct_req_create(struct resp_ctx *rctx,
talloc_set_destructor((TALLOC_CTX *)cb, sss_dp_callback_destructor);
}
- /* Set up the reply handler */
- dbret = dbus_pending_call_set_notify(pending_reply,
- sss_dp_send_acct_callback,
- sdp_req, NULL);
- if (!dbret) {
- DEBUG(0, ("Could not queue up pending request!\n"));
- talloc_zfree(sdp_req);
- dbus_pending_call_cancel(pending_reply);
- dbus_message_unref(msg);
- return EIO;
- }
-
dbus_message_unref(msg);
*ndp = sdp_req;
diff --git a/src/responder/pam/pamsrv_dp.c b/src/responder/pam/pamsrv_dp.c
index 071d09b8e..d9431f225 100644
--- a/src/responder/pam/pamsrv_dp.c
+++ b/src/responder/pam/pamsrv_dp.c
@@ -43,10 +43,10 @@ static void pam_dp_process_reply(DBusPendingCall *pending, void *ptr)
dbus_error_init(&dbus_error);
- dbus_pending_call_block(pending);
msg = dbus_pending_call_steal_reply(pending);
if (msg == NULL) {
- DEBUG(0, ("Severe error. A reply callback was called but no reply was received and no timeout occurred\n"));
+ DEBUG(0, ("Severe error. A reply callback was called but no reply was"
+ "received and no timeout occurred\n"));
preq->pd->pam_status = PAM_SYSTEM_ERR;
goto done;
}
@@ -84,8 +84,6 @@ int pam_dp_send_req(struct pam_auth_req *preq, int timeout)
struct pam_data *pd = preq->pd;
struct be_conn *be_conn;
DBusMessage *msg;
- DBusPendingCall *pending_reply;
- DBusConnection *dbus_conn;
dbus_bool_t ret;
int res;
@@ -100,7 +98,6 @@ int pam_dp_send_req(struct pam_auth_req *preq, int timeout)
" This maybe a bug, it shouldn't happen!\n", preq->domain));
return EIO;
}
- dbus_conn = sbus_get_connection(be_conn->conn);
msg = dbus_message_new_method_call(NULL,
DP_PATH,
@@ -121,22 +118,8 @@ int pam_dp_send_req(struct pam_auth_req *preq, int timeout)
return EIO;
}
- ret = dbus_connection_send_with_reply(dbus_conn, msg, &pending_reply, timeout);
- if (!ret || 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"));
- dbus_message_unref(msg);
- return EIO;
- }
-
- dbus_pending_call_set_notify(pending_reply,
- pam_dp_process_reply, preq, NULL);
- dbus_message_unref(msg);
-
- return EOK;
+ return sbus_conn_send(be_conn->conn, msg,
+ timeout, pam_dp_process_reply,
+ preq, NULL);
}