summaryrefslogtreecommitdiff
path: root/server/responder
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2009-03-19 14:50:17 +0100
committerSimo Sorce <ssorce@redhat.com>2009-03-20 11:14:56 -0400
commit7cf16d5930031d07a59a9d4741a49dac4409f695 (patch)
tree7bfc8eec97cd2259fd58b2eab1019101a42b5a67 /server/responder
parent6a3ca34ec2ff7ecaa3b2ddac041ab49dd6a1b17c (diff)
downloadsssd-7cf16d5930031d07a59a9d4741a49dac4409f695.tar.gz
sssd-7cf16d5930031d07a59a9d4741a49dac4409f695.tar.bz2
sssd-7cf16d5930031d07a59a9d4741a49dac4409f695.zip
added response type PAM_ENV_ITEM and integrated response data into dbus messages
Diffstat (limited to 'server/responder')
-rw-r--r--server/responder/pam/pamsrv.h10
-rw-r--r--server/responder/pam/pamsrv_util.c107
2 files changed, 98 insertions, 19 deletions
diff --git a/server/responder/pam/pamsrv.h b/server/responder/pam/pamsrv.h
index c5250f8d..ac29cb16 100644
--- a/server/responder/pam/pamsrv.h
+++ b/server/responder/pam/pamsrv.h
@@ -41,7 +41,7 @@ struct pam_data {
};
int pam_add_response(struct pam_data *pd, enum response_type type,
- int len, uint8_t *data);
+ int len, const uint8_t *data);
void pam_print_data(int l, struct pam_data *pd);
typedef void (*pam_dp_callback_t)(struct pam_data *pd);
@@ -52,8 +52,8 @@ int pam_dp_send_req(struct cli_ctx *cctx, pam_dp_callback_t callback,
int timeout, struct pam_data *pd);
-int dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd);
-int dp_unpack_pam_request(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error);
-int dp_pack_pam_response(DBusMessage *msg, struct pam_data *pd);
-int dp_unpack_pam_response(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error);
+bool dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd);
+bool dp_unpack_pam_request(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error);
+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);
#endif /* __PAMSRV_H__ */
diff --git a/server/responder/pam/pamsrv_util.c b/server/responder/pam/pamsrv_util.c
index fb82cdcb..1d0ab103 100644
--- a/server/responder/pam/pamsrv_util.c
+++ b/server/responder/pam/pamsrv_util.c
@@ -17,7 +17,7 @@ void pam_print_data(int l, struct pam_data *pd)
}
int pam_add_response(struct pam_data *pd, enum response_type type,
- int len, uint8_t *data)
+ int len, const uint8_t *data)
{
struct response_data *new;
@@ -34,7 +34,7 @@ int pam_add_response(struct pam_data *pd, enum response_type type,
return EOK;
}
-int dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd)
+bool dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd)
{
int ret;
@@ -59,7 +59,7 @@ int dp_pack_pam_request(DBusMessage *msg, struct pam_data *pd)
return ret;
}
-int dp_unpack_pam_request(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error)
+bool dp_unpack_pam_request(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error)
{
int ret;
@@ -84,27 +84,106 @@ int dp_unpack_pam_request(DBusMessage *msg, struct pam_data *pd, DBusError *dbus
return ret;
}
-int dp_pack_pam_response(DBusMessage *msg, struct pam_data *pd)
+bool dp_pack_pam_response(DBusMessage *msg, struct pam_data *pd)
{
int ret;
+ struct response_data *resp;
ret = dbus_message_append_args(msg,
DBUS_TYPE_UINT32, &(pd->pam_status),
DBUS_TYPE_STRING, &(pd->domain),
DBUS_TYPE_INVALID);
-
- return ret;
+ if (!ret) return ret;
+
+ resp = pd->resp_list;
+ while (resp != NULL) {
+ ret=dbus_message_append_args(msg,
+ DBUS_TYPE_UINT32, &(resp->type),
+ DBUS_TYPE_UINT32, &(resp->len),
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+ &(resp->data),
+ resp->len,
+ DBUS_TYPE_INVALID);
+ if (!ret) return ret;
+
+ resp = resp->next;
+ }
+
+ return true;
}
-int dp_unpack_pam_response(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error)
+bool dp_unpack_pam_response(DBusMessage *msg, struct pam_data *pd, DBusError *dbus_error)
{
int ret;
-
- ret = dbus_message_get_args(msg, dbus_error,
- DBUS_TYPE_UINT32, &(pd->pam_status),
- DBUS_TYPE_STRING, &(pd->domain),
- DBUS_TYPE_INVALID);
-
- return ret;
+ DBusMessageIter iter;
+ DBusMessageIter sub_iter;
+ int type;
+ int len;
+ int len_msg;
+ const uint8_t *data;
+
+ if (!dbus_message_iter_init(msg, &iter)) {
+ DEBUG(1, ("pam response has no arguments.\n"));
+ return false;
+ }
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+ dbus_message_iter_get_basic(&iter, &(pd->pam_status));
+
+ if (!dbus_message_iter_next(&iter)) {
+ DEBUG(1, ("pam response has too few arguments.\n"));
+ return false;
+ }
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+ dbus_message_iter_get_basic(&iter, &(pd->domain));
+
+ while(dbus_message_iter_next(&iter)) {
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+ dbus_message_iter_get_basic(&iter, &type);
+
+ if (!dbus_message_iter_next(&iter)) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+ dbus_message_iter_get_basic(&iter, &len);
+
+ if (!dbus_message_iter_next(&iter)) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
+ dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+
+ dbus_message_iter_recurse(&iter, &sub_iter);
+ dbus_message_iter_get_fixed_array(&sub_iter, &data, &len_msg);
+ if (len != len_msg) {
+ DEBUG(1, ("pam response format error.\n"));
+ return false;
+ }
+
+ pam_add_response(pd, type, len, data);
+
+ }
+
+ return true;
}