summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandra Ellwood <lxs@mit.edu>2008-09-28 20:53:12 +0000
committerAlexandra Ellwood <lxs@mit.edu>2008-09-28 20:53:12 +0000
commit876e89da92c0a98e25e16b4080546b7de0d5137c (patch)
treefb08ff04d2e6b4bf2d1e83e627be64e78ee615a7
parentb5dce4285a9330d25542528030ce93da78e36375 (diff)
downloadkrb5-876e89da92c0a98e25e16b4080546b7de0d5137c.tar.gz
krb5-876e89da92c0a98e25e16b4080546b7de0d5137c.tar.xz
krb5-876e89da92c0a98e25e16b4080546b7de0d5137c.zip
Added kim_selection_hints_create_from_stream and
kim_selection_hints_write_to_stream for client/server communication. ticket: 6055 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20770 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/kim/agent/mac/ServerDemux.m4
-rw-r--r--src/kim/lib/kim.exports3
-rw-r--r--src/kim/lib/kim_options.c123
-rw-r--r--src/kim/lib/kim_options_private.h8
-rw-r--r--src/kim/lib/kim_selection_hints.c188
-rw-r--r--src/kim/lib/kim_selection_hints_private.h6
-rw-r--r--src/kim/lib/mac/kim_os_ui_gui.c2
7 files changed, 329 insertions, 5 deletions
diff --git a/src/kim/agent/mac/ServerDemux.m b/src/kim/agent/mac/ServerDemux.m
index 7c2e4f084..d7cfec949 100644
--- a/src/kim/agent/mac/ServerDemux.m
+++ b/src/kim/agent/mac/ServerDemux.m
@@ -23,6 +23,7 @@
*/
#import "ServerDemux.h"
+#import "kim_selection_hints_private.h"
// ---------------------------------------------------------------------------
@@ -189,7 +190,8 @@ static int32_t kim_handle_request_select_identity (mach_port_t in_client_port,
kim_selection_hints hints = NULL;
if (!err) {
- //err = kim_os_selection_hints_read (out_hints, in_request_stream);
+ err = kim_selection_hints_create_from_stream (&hints,
+ in_request_stream);
}
if (!err) {
diff --git a/src/kim/lib/kim.exports b/src/kim/lib/kim.exports
index fea6bf813..8a2c6c32a 100644
--- a/src/kim/lib/kim.exports
+++ b/src/kim/lib/kim.exports
@@ -55,6 +55,9 @@ kim_selection_hints_remember_identity
kim_selection_hints_forget_identity
kim_selection_hints_free
+# Used by KerberosAgent
+kim_selection_hints_create_from_stream
+
kim_preferences_create
kim_preferences_copy
kim_preferences_set_options
diff --git a/src/kim/lib/kim_options.c b/src/kim/lib/kim_options.c
index a5470f413..89272b635 100644
--- a/src/kim/lib/kim_options.c
+++ b/src/kim/lib/kim_options.c
@@ -136,7 +136,7 @@ kim_error kim_options_copy (kim_options *out_options,
}
}
}
-
+
if (!err) {
*out_options = options;
options = NULL;
@@ -484,7 +484,7 @@ krb5_get_init_creds_opt *kim_options_init_cred_options (kim_options in_options)
addresses);
addresses = NULL;
}
-
+
if (addresses) { krb5_free_addresses (in_options->init_cred_context,
addresses); }
@@ -508,8 +508,125 @@ void kim_options_free (kim_options *io_options)
}
krb5_free_context ((*io_options)->init_cred_context);
}
-
+
free (*io_options);
*io_options = NULL;
}
}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_options_write_to_stream (kim_options in_options,
+ k5_ipc_stream io_stream)
+{
+ kim_error err = KIM_NO_ERROR;
+
+ if (!err && !in_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !io_stream ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+
+ if (!err) {
+ err = k5_ipc_stream_write_int64 (io_stream, in_options->start_time);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_write_int64 (io_stream, in_options->lifetime);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_write_int32 (io_stream, in_options->renewable);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_write_int64 (io_stream,
+ in_options->renewal_lifetime);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_write_int32 (io_stream, in_options->forwardable);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_write_int32 (io_stream, in_options->proxiable);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_write_int32 (io_stream, in_options->addressless);
+ }
+
+ if (!err) {
+ kim_string service_name = (in_options->service_name ?
+ in_options->service_name : "");
+ err = k5_ipc_stream_write_string (io_stream, service_name);
+ }
+
+
+
+ return check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_options_create_from_stream (kim_options *out_options,
+ k5_ipc_stream io_stream)
+{
+ kim_error err = KIM_NO_ERROR;
+ kim_options options = NULL;
+
+ if (!err && !out_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !io_stream ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+
+ if (!err) {
+ err = kim_options_allocate (&options);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_read_int64 (io_stream, &options->start_time);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_read_int64 (io_stream, &options->lifetime);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_read_int32 (io_stream, &options->renewable);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_read_int64 (io_stream,
+ &options->renewal_lifetime);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_read_int32 (io_stream, &options->forwardable);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_read_int32 (io_stream, &options->proxiable);
+ }
+
+ if (!err) {
+ err = k5_ipc_stream_read_int32 (io_stream, &options->addressless);
+ }
+
+ if (!err) {
+ char *service_name = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &service_name);
+
+ if (!err) {
+ err = kim_string_copy (&options->service_name, service_name);
+ }
+
+ k5_ipc_stream_free_string (service_name);
+ }
+
+ if (!err) {
+ *out_options = options;
+ options = NULL;
+ }
+
+ kim_options_free (&options);
+
+ return check_error (err);
+}
diff --git a/src/kim/lib/kim_options_private.h b/src/kim/lib/kim_options_private.h
index 5c49e41f2..6feddc507 100644
--- a/src/kim/lib/kim_options_private.h
+++ b/src/kim/lib/kim_options_private.h
@@ -28,6 +28,7 @@
#define KIM_OPTIONS_PRIVATE_H
#include <kim/kim.h>
+#include "k5-ipc_stream.h"
kim_error kim_options_create_empty (kim_options *out_options);
@@ -37,4 +38,11 @@ char *kim_options_service_name (kim_options in_options);
kim_time kim_options_start_time (kim_options in_options);
+
+kim_error kim_options_write_to_stream (kim_options in_options,
+ k5_ipc_stream io_stream);
+
+kim_error kim_options_create_from_stream (kim_options *out_options,
+ k5_ipc_stream io_stream);
+
#endif /* KIM_OPTIONS_PRIVATE_H */
diff --git a/src/kim/lib/kim_selection_hints.c b/src/kim/lib/kim_selection_hints.c
index 6903afb86..8cb98f683 100644
--- a/src/kim/lib/kim_selection_hints.c
+++ b/src/kim/lib/kim_selection_hints.c
@@ -556,3 +556,191 @@ void kim_selection_hints_free (kim_selection_hints *io_selection_hints)
}
}
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_selection_hints_write_to_stream (kim_selection_hints in_selection_hints,
+ k5_ipc_stream io_stream)
+{
+ kim_error err = KIM_NO_ERROR;
+
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !io_stream ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+
+ if (!err) {
+ err = k5_ipc_stream_write_string (io_stream,
+ in_selection_hints->application_identifier);
+ }
+
+ if (!err) {
+ kim_string explanation = (in_selection_hints->explanation ?
+ in_selection_hints->explanation : "");
+ err = k5_ipc_stream_write_string (io_stream, explanation);
+ }
+
+ if (!err) {
+ err = kim_options_write_to_stream (in_selection_hints->options, io_stream);
+ }
+
+ if (!err) {
+ kim_string service_identity = (in_selection_hints->service_identity ?
+ in_selection_hints->service_identity : "");
+ err = k5_ipc_stream_write_string (io_stream, service_identity);
+ }
+
+ if (!err) {
+ kim_string client_realm = (in_selection_hints->client_realm ?
+ in_selection_hints->client_realm : "");
+ err = k5_ipc_stream_write_string (io_stream, client_realm);
+ }
+
+ if (!err) {
+ kim_string user = (in_selection_hints->user ?
+ in_selection_hints->user : "");
+ err = k5_ipc_stream_write_string (io_stream, user);
+ }
+
+ if (!err) {
+ kim_string service_realm = (in_selection_hints->service_realm ?
+ in_selection_hints->service_realm : "");
+ err = k5_ipc_stream_write_string (io_stream, service_realm);
+ }
+
+ if (!err) {
+ kim_string service = (in_selection_hints->service ?
+ in_selection_hints->service : "");
+ err = k5_ipc_stream_write_string (io_stream, service);
+ }
+
+ if (!err) {
+ kim_string server = (in_selection_hints->server ?
+ in_selection_hints->server : "");
+ err = k5_ipc_stream_write_string (io_stream, server);
+ }
+
+ return check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_selection_hints_create_from_stream (kim_selection_hints *out_selection_hints,
+ k5_ipc_stream io_stream)
+{
+ kim_error err = KIM_NO_ERROR;
+ kim_selection_hints selection_hints = NULL;
+
+ if (!err && !out_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !io_stream ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+
+ if (!err) {
+ err = kim_selection_hints_allocate (&selection_hints);
+ }
+
+ if (!err) {
+ char *application_identifier = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &application_identifier);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->application_identifier,
+ application_identifier);
+ }
+
+ k5_ipc_stream_free_string (application_identifier);
+ }
+
+ if (!err) {
+ char *explanation = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &explanation);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->explanation, explanation);
+ }
+
+ k5_ipc_stream_free_string (explanation);
+ }
+
+ if (!err) {
+ err = kim_options_create_from_stream (&selection_hints->options,
+ io_stream);
+ }
+
+ if (!err) {
+ char *service_identity = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &service_identity);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->service_identity,
+ service_identity);
+ }
+
+ k5_ipc_stream_free_string (service_identity);
+ }
+
+ if (!err) {
+ char *client_realm = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &client_realm);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->client_realm,
+ client_realm);
+ }
+
+ k5_ipc_stream_free_string (client_realm);
+ }
+
+ if (!err) {
+ char *user = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &user);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->user, user);
+ }
+
+ k5_ipc_stream_free_string (user);
+ }
+
+ if (!err) {
+ char *service_realm = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &service_realm);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->service_realm,
+ service_realm);
+ }
+
+ k5_ipc_stream_free_string (service_realm);
+ }
+
+ if (!err) {
+ char *service = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &service);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->service, service);
+ }
+
+ k5_ipc_stream_free_string (service);
+ }
+
+ if (!err) {
+ char *server = NULL;
+ err = k5_ipc_stream_read_string (io_stream, &server);
+
+ if (!err) {
+ err = kim_string_copy (&selection_hints->server, server);
+ }
+
+ k5_ipc_stream_free_string (server);
+ }
+
+ if (!err) {
+ *out_selection_hints = selection_hints;
+ selection_hints = NULL;
+ }
+
+ kim_selection_hints_free (&selection_hints);
+
+ return check_error (err);
+}
+
diff --git a/src/kim/lib/kim_selection_hints_private.h b/src/kim/lib/kim_selection_hints_private.h
index 34694893e..50e942e5e 100644
--- a/src/kim/lib/kim_selection_hints_private.h
+++ b/src/kim/lib/kim_selection_hints_private.h
@@ -28,6 +28,7 @@
#define KIM_SELECTION_HINTS_PRIVATE_H
#include <kim/kim.h>
+#include "k5-ipc_stream.h"
typedef struct kim_selection_hints_preference_strings {
kim_string application_identifier;
@@ -53,5 +54,10 @@ kim_error kim_os_selection_hints_remember_identity (kim_selection_hints in_selec
kim_error kim_os_selection_hints_forget_identity (kim_selection_hints in_selection_hints);
+kim_error kim_selection_hints_write_to_stream (kim_selection_hints in_selection_hints,
+ k5_ipc_stream io_stream);
+
+kim_error kim_selection_hints_create_from_stream (kim_selection_hints *out_selection_hints,
+ k5_ipc_stream in_stream);
#endif /* KIM_SELECTION_HINTS_PRIVATE_H */
diff --git a/src/kim/lib/mac/kim_os_ui_gui.c b/src/kim/lib/mac/kim_os_ui_gui.c
index 7559dbed9..a011ec251 100644
--- a/src/kim/lib/mac/kim_os_ui_gui.c
+++ b/src/kim/lib/mac/kim_os_ui_gui.c
@@ -172,7 +172,7 @@ kim_error kim_os_ui_gui_select_identity (kim_ui_context *in_context,
}
if (!err) {
- //err = kim_os_selection_hints_write (in_hints, request);
+ err = kim_selection_hints_write_to_stream (in_hints, request);
}
if (!err) {