summaryrefslogtreecommitdiff
path: root/server/providers
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2009-10-14 15:22:10 +0200
committerStephen Gallagher <sgallagh@redhat.com>2009-10-14 15:43:29 -0400
commitcf741fe83dcba32d6ac09b8fc41ecc31f6a67e54 (patch)
tree47ad61e1053957107b1299cea22ff1aee5368b54 /server/providers
parentc4f19342a55bbbaa09e126013b8976cb2dd31b94 (diff)
downloadsssd-cf741fe83dcba32d6ac09b8fc41ecc31f6a67e54.tar.gz
sssd-cf741fe83dcba32d6ac09b8fc41ecc31f6a67e54.tar.bz2
sssd-cf741fe83dcba32d6ac09b8fc41ecc31f6a67e54.zip
send a message if a backend target is not configured
If a backend target is not configured the return code is changed from PAM_SYSTEM_ERR to PAM_MODULE_UNKNOWN and an error message is sent back to the client.
Diffstat (limited to 'server/providers')
-rw-r--r--server/providers/data_provider_be.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c
index c891a0f1..f6dcf518 100644
--- a/server/providers/data_provider_be.c
+++ b/server/providers/data_provider_be.c
@@ -43,6 +43,8 @@
#include "providers/dp_backend.h"
#include "monitor/monitor_interfaces.h"
+#define MSG_TARGET_NO_CONFIGURED "sssd_be: The requested target is not configured"
+
struct sbus_method monitor_be_methods[] = {
{ MON_CLI_METHOD_PING, monitor_common_pong },
{ MON_CLI_METHOD_RES_INIT, monitor_common_res_init },
@@ -418,7 +420,6 @@ static int be_pam_handler(DBusMessage *message, struct sbus_connection *conn)
void *user_data;
struct pam_data *pd = NULL;
struct be_req *be_req = NULL;
- uint32_t pam_status = PAM_SYSTEM_ERR;
enum bet_type target = BET_NULL;
user_data = sbus_conn_get_private_data(conn);
@@ -429,7 +430,6 @@ static int be_pam_handler(DBusMessage *message, struct sbus_connection *conn)
reply = dbus_message_new_method_return(message);
if (!reply) {
DEBUG(1, ("dbus_message_new_method_return failed, cannot send reply.\n"));
- talloc_free(pd);
return ENOMEM;
}
@@ -445,14 +445,24 @@ static int be_pam_handler(DBusMessage *message, struct sbus_connection *conn)
be_req->pvt = reply;
pd = talloc_zero(be_req, struct pam_data);
- if (!pd) return ENOMEM;
+ if (!pd) {
+ talloc_free(be_req);
+ return ENOMEM;
+ }
+
+ pd->pam_status = PAM_SYSTEM_ERR;
+ pd->domain = talloc_strdup(pd, becli->bectx->domain->name);
+ if (pd->domain == NULL) {
+ talloc_free(be_req);
+ return ENOMEM;
+ }
dbus_error_init(&dbus_error);
ret = dp_unpack_pam_request(message, pd, &dbus_error);
if (!ret) {
DEBUG(1,("Failed, to parse message!\n"));
- talloc_free(pd);
+ talloc_free(be_req);
return EIO;
}
@@ -471,14 +481,21 @@ static int be_pam_handler(DBusMessage *message, struct sbus_connection *conn)
break;
default:
DEBUG(7, ("Unsupported PAM command [%d].\n", pd->cmd));
- pam_status = PAM_SUCCESS;
+ pd->pam_status = PAM_SUCCESS;
ret = EOK;
goto done;
}
- /* return an error if corresponding backend target is configured */
+ /* return an error if corresponding backend target is not configured */
if (!becli->bectx->bet_info[target].bet_ops) {
DEBUG(7, ("Undefined backend target.\n"));
+ pd->pam_status = PAM_MODULE_UNKNOWN;
+ ret = pam_add_response(pd, PAM_USER_INFO,
+ sizeof(MSG_TARGET_NO_CONFIGURED),
+ (const uint8_t *) MSG_TARGET_NO_CONFIGURED);
+ if (ret != EOK) {
+ DEBUG(1, ("pam_add_response failed.\n"));
+ }
goto done;
}
@@ -495,15 +512,14 @@ static int be_pam_handler(DBusMessage *message, struct sbus_connection *conn)
return EOK;
done:
- talloc_free(be_req);
DEBUG(4, ("Sending result [%d][%s]\n",
- pam_status, becli->bectx->domain->name));
- ret = dbus_message_append_args(reply,
- DBUS_TYPE_UINT32, &pam_status,
- DBUS_TYPE_STRING, &becli->bectx->domain->name,
- DBUS_TYPE_INVALID);
+ pd->pam_status, pd->domain));
+
+ ret = dp_pack_pam_response(reply, pd);
if (!ret) {
+ DEBUG(1, ("Failed to generate dbus reply\n"));
+ talloc_free(be_req);
return EIO;
}
@@ -511,6 +527,8 @@ done:
sbus_conn_send_reply(conn, reply);
dbus_message_unref(reply);
+ talloc_free(be_req);
+
return EOK;
}