[SSSD] [PATCH] Subdomains: Send the DP reply in the correct format
Jakub Hrozek
jhrozek at redhat.com
Tue Aug 7 07:13:37 UTC 2012
On Thu, Aug 02, 2012 at 11:00:58AM +0200, Pavel Březina wrote:
> On 07/31/2012 01:28 PM, Jakub Hrozek wrote:
> >I found this issue when testing Simo's patches.
> >
> >The DP was sending the reply in a format the responder did not expect,
> >so the responder always failed to parse the message.
>
> Nack.
>
> You should talloc_free(req) even when you are unable to send dbus
> message, because it is the end of the request anyway.
Thanks, new patch is attached.
-------------- next part --------------
>From 7d95501a679916f3c9a5e2d25540989ddc69769d Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Mon, 30 Jul 2012 19:38:11 +0200
Subject: [PATCH] Subdomains: Send the DP reply in the correct format
The DP was sending the reply in a format the responder did not expect,
so the responder always failed to parse the message.
---
src/providers/data_provider_be.c | 55 ++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 14 deletions(-)
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index 0717bff347b2900768c1cbe3233d952ee8f5aa24..2e4ee0754e62a48248cc7537243705b3a1004502 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -316,29 +316,56 @@ static void get_subdomains_callback(struct be_req *req,
DBusMessage *reply;
DBusConnection *dbus_conn;
dbus_bool_t dbret;
+ dbus_uint16_t err_maj = 0;
+ dbus_uint32_t err_min = 0;
+ const char *err_msg = NULL;
DEBUG(SSSDBG_TRACE_FUNC, ("Backend returned: (%d, %d, %s) [%s]\n",
dp_err_type, errnum, errstr?errstr:"<NULL>",
dp_pam_err_to_string(req, dp_err_type, errnum)));
reply = (DBusMessage *)req->pvt;
- dbret = dbus_message_append_args(reply,
- DBUS_TYPE_UINT32, &errnum,
- DBUS_TYPE_INVALID);
- if (!dbret) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to generate dbus reply\n"));
+
+ if (reply) {
+ /* Return a reply if one was requested
+ * There may not be one if this request began
+ * while we were offline
+ */
+ err_maj = dp_err_type;
+ err_min = errnum;
+ if (errstr) {
+ err_msg = errstr;
+ } else {
+ err_msg = dp_pam_err_to_string(req, dp_err_type, errnum);
+ }
+ if (!err_msg) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Failed to set err_msg, Out of memory?\n"));
+ err_msg = "OOM";
+ }
+
+ dbret = dbus_message_append_args(reply,
+ DBUS_TYPE_UINT16, &err_maj,
+ DBUS_TYPE_UINT32, &err_min,
+ DBUS_TYPE_STRING, &err_msg,
+ DBUS_TYPE_INVALID);
+
+ if (!dbret) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to generate dbus reply\n"));
+ dbus_message_unref(reply);
+ goto done;
+ }
+
+ dbus_conn = sbus_get_connection(req->becli->conn);
+ if (dbus_conn == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("D-BUS not connected\n"));
+ goto done;
+ }
+ dbus_connection_send(dbus_conn, reply, NULL);
dbus_message_unref(reply);
- return;
}
- dbus_conn = sbus_get_connection(req->becli->conn);
- if (dbus_conn == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("D-BUS not connected\n"));
- return;
- }
- dbus_connection_send(dbus_conn, reply, NULL);
- dbus_message_unref(reply);
-
+done:
talloc_free(req);
}
--
1.7.11.2
More information about the sssd-devel
mailing list