#include <mach/mach_error.h>
#include <unistd.h>
+/* ------------------------------------------------------------------------ */
+
+static inline int32_t kim_os_ui_gui_send_request (int32_t in_launch_server,
+ k5_ipc_stream in_request_stream,
+ k5_ipc_stream *out_reply_stream)
+{
+ return k5_ipc_send_request (kim_os_agent_bundle_id,
+ in_launch_server,
+ in_request_stream,
+ out_reply_stream);
+}
+
/* ------------------------------------------------------------------------ */
}
if (!err) {
- err = k5_ipc_send_request (1 /* launch server */,
- request,
- &reply);
+ err = kim_os_ui_gui_send_request (1 /* launch server */,
+ request,
+ &reply);
}
if (!err) {
if (!err) {
- err = k5_ipc_send_request (0 /* don't launch server */,
- request,
- &reply);
+ err = kim_os_ui_gui_send_request (0 /* don't launch server */,
+ request,
+ &reply);
if (!reply) { err = check_error (KIM_NO_SERVER_ERR); }
}
}
if (!err) {
- err = k5_ipc_send_request (0 /* don't launch server */,
- request,
- &reply);
+ err = kim_os_ui_gui_send_request (0 /* don't launch server */,
+ request,
+ &reply);
if (!reply) { err = check_error (KIM_NO_SERVER_ERR); }
}
}
if (!err) {
- err = k5_ipc_send_request (0 /* don't launch server */,
- request,
- &reply);
+ err = kim_os_ui_gui_send_request (0 /* don't launch server */,
+ request,
+ &reply);
if (!reply) { err = check_error (KIM_NO_SERVER_ERR); }
}
}
if (!err) {
- err = k5_ipc_send_request (0 /* don't launch server */,
- request,
- &reply);
+ err = kim_os_ui_gui_send_request (0 /* don't launch server */,
+ request,
+ &reply);
if (!reply) { err = check_error (KIM_NO_SERVER_ERR); }
}
}
if (!err) {
- err = k5_ipc_send_request (0 /* don't launch server */,
- request,
- &reply);
+ err = kim_os_ui_gui_send_request (0 /* don't launch server */,
+ request,
+ &reply);
if (!reply) { err = check_error (KIM_NO_SERVER_ERR); }
}
}
if (!err) {
- err = k5_ipc_send_request (0 /* don't launch server */,
- request,
- &reply);
+ err = kim_os_ui_gui_send_request (0 /* don't launch server */,
+ request,
+ &reply);
if (!reply) { err = check_error (KIM_NO_SERVER_ERR); }
}
#include "k5_mig_replyServer.h"
#include "k5-thread.h"
+#define KIPC_SERVICE_COUNT 3
+
+typedef struct k5_ipc_request_port {
+ char *service_id;
+ mach_port_t port;
+} k5_ipc_request_port;
+
+static k5_ipc_request_port k5_ipc_known_ports[KIPC_SERVICE_COUNT] = {
+{ "edu.mit.Kerberos.CCacheServer", MACH_PORT_NULL },
+{ "edu.mit.Kerberos.KerberosAgent", MACH_PORT_NULL },
+{ "edu.mit.Kerberos.OldKerberosAgent", MACH_PORT_NULL } };
+
MAKE_INIT_FUNCTION(k5_cli_ipc_thread_init);
MAKE_FINI_FUNCTION(k5_cli_ipc_thread_fini);
/* ------------------------------------------------------------------------ */
-int32_t k5_ipc_send_request (int32_t in_launch_server,
+int32_t k5_ipc_send_request (const char *in_service_id,
+ int32_t in_launch_server,
k5_ipc_stream in_request_stream,
k5_ipc_stream *out_reply_stream)
{
}
if (!err) {
- request_port = k5_getspecific (K5_KEY_IPC_REQUEST_PORT);
+ k5_ipc_request_port *request_ports = NULL;
- if (!request_port) {
- request_port = malloc (sizeof (mach_port_t));
+ request_ports = k5_getspecific (K5_KEY_IPC_REQUEST_PORT);
+
+ if (!request_ports) {
+ int size = sizeof (*request_ports) * KIPC_SERVICE_COUNT;
+
+ request_ports = malloc (size);
if (!request_port) { err = ENOMEM; }
if (!err) {
- *request_port = MACH_PORT_NULL;
- err = k5_setspecific (K5_KEY_IPC_REQUEST_PORT, request_port);
+ int i;
+
+ for (i = 0; i < KIPC_SERVICE_COUNT; i++) {
+ request_ports[i].service_id = k5_ipc_known_ports [i].service_id;
+ request_ports[i].port = k5_ipc_known_ports [i].port;
+ }
+
+ err = k5_setspecific (K5_KEY_IPC_REQUEST_PORT, request_ports);
}
}
+
+ if (!err) {
+ int i, found = 0;
+
+ for (i = 0; i < KIPC_SERVICE_COUNT; i++) {
+ if (!strcmp (in_service_id, request_ports[i].service_id)) {
+ found = 1;
+ request_port = &request_ports[i].port;
+ }
+ }
+
+ if (!found) { err = EINVAL; }
+ }
}
if (!err) {
}
if (!err) {
- err = kipc_client_lookup_server (K5_IPC_SERVER_ID,
- in_launch_server, TRUE, &server_port);
+ err = kipc_client_lookup_server (in_service_id, in_launch_server,
+ TRUE, &server_port);
}
while (!err && !done) {
}
/* Look up server name again without using the cached copy */
- err = kipc_client_lookup_server (K5_IPC_SERVER_ID,
- in_launch_server, FALSE, &server_port);
+ err = kipc_client_lookup_server (in_service_id,
+ in_launch_server,
+ FALSE, &server_port);
} else {
/* Talked to server, though we may have gotten an error */