[SSSD] [PATCH] Subdomains: Send the DP reply in the correct format
Jakub Hrozek
jhrozek at redhat.com
Tue Jul 31 11:28:29 UTC 2012
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.
-------------- next part --------------
From 752551219ef4424388df8fb628549b351871b138 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 | 54 ++++++++++++++++++++++++++++----------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index 0717bff347b2900768c1cbe3233d952ee8f5aa24..8d23f187f3bc589e7232a8a43913cccbea55e2af 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -316,29 +316,55 @@ 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);
+ 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);
- 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);
-
talloc_free(req);
}
--
1.7.10.4
More information about the sssd-devel
mailing list