diff options
| author | Tom Yu <tlyu@mit.edu> | 2009-10-31 00:48:38 +0000 |
|---|---|---|
| committer | Tom Yu <tlyu@mit.edu> | 2009-10-31 00:48:38 +0000 |
| commit | 02d6bcbc98a214e7aeaaa9f45f0db8784a7b743b (patch) | |
| tree | 61b9147863cd8be3eff63903dc36cae168254bd5 /src/util/mac | |
| parent | 162ab371748cba0cc6f172419bd6e71fa04bb878 (diff) | |
| download | krb5-02d6bcbc98a214e7aeaaa9f45f0db8784a7b743b.tar.gz krb5-02d6bcbc98a214e7aeaaa9f45f0db8784a7b743b.tar.xz krb5-02d6bcbc98a214e7aeaaa9f45f0db8784a7b743b.zip | |
make mark-cstyle
make reindent
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23100 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/mac')
| -rw-r--r-- | src/util/mac/k5_mig_client.c | 256 | ||||
| -rw-r--r-- | src/util/mac/k5_mig_server.c | 210 | ||||
| -rw-r--r-- | src/util/mac/k5_mig_server.h | 4 | ||||
| -rw-r--r-- | src/util/mac/k5_mig_types.h | 14 |
4 files changed, 242 insertions, 242 deletions
diff --git a/src/util/mac/k5_mig_client.c b/src/util/mac/k5_mig_client.c index 603ffdc70f..6964abccaa 100644 --- a/src/util/mac/k5_mig_client.c +++ b/src/util/mac/k5_mig_client.c @@ -53,15 +53,15 @@ typedef struct k5_ipc_service_port { /* global service ports and mutex to protect it */ static k5_mutex_t g_service_ports_mutex = K5_MUTEX_PARTIAL_INITIALIZER; -static k5_ipc_service_port g_service_ports[KIPC_SERVICE_COUNT] = { +static k5_ipc_service_port g_service_ports[KIPC_SERVICE_COUNT] = { { "edu.mit.Kerberos.CCacheServer", MACH_PORT_NULL }, { "edu.mit.Kerberos.KerberosAgent", MACH_PORT_NULL } }; /* ------------------------------------------------------------------------ */ /* This struct exists to hold the per-thread connection port used for ipc - * messages to the server. Each thread is issued a separate connection - * port so that the server can distinguish between threads in the same + * messages to the server. Each thread is issued a separate connection + * port so that the server can distinguish between threads in the same * application. */ typedef struct k5_ipc_connection { @@ -76,7 +76,7 @@ typedef struct k5_ipc_connection_info { } *k5_ipc_connection_info; /* initializer for k5_ipc_request_port to fill in server names in TLS */ -static const char *k5_ipc_known_services[KIPC_SERVICE_COUNT] = { +static const char *k5_ipc_known_services[KIPC_SERVICE_COUNT] = { "edu.mit.Kerberos.CCacheServer", "edu.mit.Kerberos.KerberosAgent" }; @@ -87,11 +87,11 @@ static void k5_ipc_client_cinfo_free (void *io_cinfo) if (io_cinfo) { k5_ipc_connection_info cinfo = io_cinfo; int i; - + for (i = 0; i < KIPC_SERVICE_COUNT; i++) { if (MACH_PORT_VALID (cinfo->connections[i].port)) { - mach_port_mod_refs (mach_task_self(), - cinfo->connections[i].port, + mach_port_mod_refs (mach_task_self(), + cinfo->connections[i].port, MACH_PORT_RIGHT_SEND, -1 ); cinfo->connections[i].port = MACH_PORT_NULL; } @@ -107,29 +107,29 @@ static int k5_ipc_client_cinfo_allocate (k5_ipc_connection_info *out_cinfo) { int err = 0; k5_ipc_connection_info cinfo = NULL; - + cinfo = malloc (sizeof (*cinfo)); if (!cinfo) { err = ENOMEM; } - + if (!err) { int i; - + cinfo->server_died = 0; cinfo->reply_stream = NULL; - + for (i = 0; i < KIPC_SERVICE_COUNT; i++) { cinfo->connections[i].service_id = k5_ipc_known_services[i]; cinfo->connections[i].port = MACH_PORT_NULL; } } - + if (!err) { *out_cinfo = cinfo; cinfo = NULL; } - + k5_ipc_client_cinfo_free (cinfo); - + return err; } @@ -144,38 +144,38 @@ MAKE_FINI_FUNCTION(k5_cli_ipc_thread_fini); static int k5_cli_ipc_thread_init (void) { int err = 0; - - err = k5_key_register (K5_KEY_IPC_CONNECTION_INFO, + + err = k5_key_register (K5_KEY_IPC_CONNECTION_INFO, k5_ipc_client_cinfo_free); - + if (!err) { err = k5_mutex_finish_init (&g_service_ports_mutex); } - + return err; } /* ------------------------------------------------------------------------ */ static void k5_cli_ipc_thread_fini (void) -{ +{ int err = 0; - + err = k5_mutex_lock (&g_service_ports_mutex); if (!err) { int i; - + for (i = 0; i < KIPC_SERVICE_COUNT; i++) { if (MACH_PORT_VALID (g_service_ports[i].service_port)) { - mach_port_destroy (mach_task_self (), - g_service_ports[i].service_port); + mach_port_destroy (mach_task_self (), + g_service_ports[i].service_port); g_service_ports[i].service_port = MACH_PORT_NULL; } } k5_mutex_unlock (&g_service_ports_mutex); } - + k5_key_delete (K5_KEY_IPC_CONNECTION_INFO); k5_mutex_destroy (&g_service_ports_mutex); } @@ -187,22 +187,22 @@ static void k5_cli_ipc_thread_fini (void) static kern_return_t k5_ipc_client_lookup_server (const char *in_service_id, boolean_t in_launch_if_necessary, boolean_t in_use_cached_port, - mach_port_t *out_service_port) + mach_port_t *out_service_port) { kern_return_t err = 0; kern_return_t lock_err = 0; mach_port_t k5_service_port = MACH_PORT_NULL; boolean_t found_entry = 0; int i; - + if (!in_service_id ) { err = EINVAL; } if (!out_service_port) { err = EINVAL; } - + if (!err) { lock_err = k5_mutex_lock (&g_service_ports_mutex); if (lock_err) { err = lock_err; } } - + for (i = 0; !err && i < KIPC_SERVICE_COUNT; i++) { if (!strcmp (in_service_id, g_service_ports[i].service_id)) { found_entry = 1; @@ -212,65 +212,65 @@ static kern_return_t k5_ipc_client_lookup_server (const char *in_service_id, break; } } - + if (!err && (!MACH_PORT_VALID (k5_service_port) || !in_use_cached_port)) { mach_port_t boot_port = MACH_PORT_NULL; char *service = NULL; - + /* Get our bootstrap port */ err = task_get_bootstrap_port (mach_task_self (), &boot_port); - + if (!err && !in_launch_if_necessary) { char *lookup = NULL; mach_port_t lookup_port = MACH_PORT_NULL; - - int w = asprintf (&lookup, "%s%s", + + int w = asprintf (&lookup, "%s%s", in_service_id, K5_MIG_LOOKUP_SUFFIX); if (w < 0) { err = ENOMEM; } - + if (!err) { - /* Use the lookup name because the service name will return + /* Use the lookup name because the service name will return * a valid port even if the server isn't running */ err = bootstrap_look_up (boot_port, lookup, &lookup_port); } - + free (lookup); - if (MACH_PORT_VALID (lookup_port)) { - mach_port_deallocate (mach_task_self (), lookup_port); + if (MACH_PORT_VALID (lookup_port)) { + mach_port_deallocate (mach_task_self (), lookup_port); } } - + if (!err) { - int w = asprintf (&service, "%s%s", + int w = asprintf (&service, "%s%s", in_service_id, K5_MIG_SERVICE_SUFFIX); if (w < 0) { err = ENOMEM; } } - + if (!err) { err = bootstrap_look_up (boot_port, service, &k5_service_port); - + if (!err && found_entry) { /* Free old port if it is valid */ if (!err && MACH_PORT_VALID (g_service_ports[i].service_port)) { - mach_port_deallocate (mach_task_self (), + mach_port_deallocate (mach_task_self (), g_service_ports[i].service_port); } - + g_service_ports[i].service_port = k5_service_port; } } - + free (service); - if (MACH_PORT_VALID (boot_port)) { mach_port_deallocate (mach_task_self (), + if (MACH_PORT_VALID (boot_port)) { mach_port_deallocate (mach_task_self (), boot_port); } } - + if (!err) { *out_service_port = k5_service_port; } - + if (!lock_err) { k5_mutex_unlock (&g_service_ports_mutex); } - + return err; } @@ -278,29 +278,29 @@ static kern_return_t k5_ipc_client_lookup_server (const char *in_service_id, /* ------------------------------------------------------------------------ */ -static boolean_t k5_ipc_reply_demux (mach_msg_header_t *request, - mach_msg_header_t *reply) +static boolean_t k5_ipc_reply_demux (mach_msg_header_t *request, + mach_msg_header_t *reply) { boolean_t handled = 0; - + if (CALL_INIT_FUNCTION (k5_cli_ipc_thread_init) != 0) { return 0; - } - + } + if (!handled && request->msgh_id == MACH_NOTIFY_NO_SENDERS) { k5_ipc_connection_info cinfo = k5_getspecific (K5_KEY_IPC_CONNECTION_INFO); - if (cinfo) { + if (cinfo) { cinfo->server_died = 1; } - + handled = 1; /* server died */ } - + if (!handled) { handled = k5_ipc_reply_server (request, reply); } - - return handled; + + return handled; } /* ------------------------------------------------------------------------ */ @@ -313,34 +313,34 @@ kern_return_t k5_ipc_client_reply (mach_port_t in_reply_port, { kern_return_t err = KERN_SUCCESS; k5_ipc_connection_info cinfo = NULL; - + if (!err) { err = CALL_INIT_FUNCTION (k5_cli_ipc_thread_init); } - + if (!err) { cinfo = k5_getspecific (K5_KEY_IPC_CONNECTION_INFO); if (!cinfo || !cinfo->reply_stream) { err = EINVAL; } } - + if (!err) { if (in_inl_replyCnt) { - err = krb5int_ipc_stream_write (cinfo->reply_stream, + err = krb5int_ipc_stream_write (cinfo->reply_stream, in_inl_reply, in_inl_replyCnt); - + } else if (in_ool_replyCnt) { - err = krb5int_ipc_stream_write (cinfo->reply_stream, + err = krb5int_ipc_stream_write (cinfo->reply_stream, in_ool_reply, in_ool_replyCnt); - + } else { err = EINVAL; } } - - if (in_ool_replyCnt) { vm_deallocate (mach_task_self (), - (vm_address_t) in_ool_reply, + + if (in_ool_replyCnt) { vm_deallocate (mach_task_self (), + (vm_address_t) in_ool_reply, in_ool_replyCnt); } - + return err; } @@ -367,29 +367,29 @@ int32_t k5_ipc_send_request (const char *in_service_id, if (!in_request_stream) { err = EINVAL; } if (!out_reply_stream ) { err = EINVAL; } - + if (!err) { err = CALL_INIT_FUNCTION (k5_cli_ipc_thread_init); - } - + } + if (!err) { - /* depending on how big the message is, use the fast inline buffer or + /* depending on how big the message is, use the fast inline buffer or * the slow dynamically allocated buffer */ mach_msg_type_number_t request_length = krb5int_ipc_stream_size (in_request_stream); - + if (request_length > K5_IPC_MAX_INL_MSG_SIZE) { - /*dprintf ("%s choosing out of line buffer (size is %d)", + /*dprintf ("%s choosing out of line buffer (size is %d)", * __FUNCTION__, request_length); */ - - err = vm_read (mach_task_self (), - (vm_address_t) krb5int_ipc_stream_data (in_request_stream), - request_length, - (vm_address_t *) &ool_request, - &ool_request_length); + + err = vm_read (mach_task_self (), + (vm_address_t) krb5int_ipc_stream_data (in_request_stream), + request_length, + (vm_address_t *) &ool_request, + &ool_request_length); } else { /*dprintf ("%s choosing in line buffer (size is %d)", * __FUNCTION__, request_length); */ - + inl_request_length = request_length; inl_request = krb5int_ipc_stream_data (in_request_stream); } @@ -405,7 +405,7 @@ int32_t k5_ipc_send_request (const char *in_service_id, err = k5_setspecific (K5_KEY_IPC_CONNECTION_INFO, cinfo); } } - + if (!err) { int i, found = 0; @@ -416,114 +416,114 @@ int32_t k5_ipc_send_request (const char *in_service_id, break; } } - + if (!found) { err = EINVAL; } } } - + if (!err) { - err = k5_ipc_client_lookup_server (in_service_id, in_launch_server, + err = k5_ipc_client_lookup_server (in_service_id, in_launch_server, TRUE, &server_port); } if (!err) { - err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &reply_port); } - + while (!err && !done) { if (!err && !MACH_PORT_VALID (connection->port)) { - err = k5_ipc_client_create_client_connection (server_port, + err = k5_ipc_client_create_client_connection (server_port, &connection->port); } - + if (!err) { err = k5_ipc_client_request (connection->port, reply_port, inl_request, inl_request_length, ool_request, ool_request_length); - + } - + if (err == MACH_SEND_INVALID_DEST) { - if (try_count < 2) { + if (try_count < 2) { try_count++; err = 0; } if (MACH_PORT_VALID (connection->port)) { - mach_port_mod_refs (mach_task_self(), connection->port, + mach_port_mod_refs (mach_task_self(), connection->port, MACH_PORT_RIGHT_SEND, -1 ); connection->port = MACH_PORT_NULL; - } - + } + /* Look up server name again without using the cached copy */ - err = k5_ipc_client_lookup_server (in_service_id, - in_launch_server, + err = k5_ipc_client_lookup_server (in_service_id, + in_launch_server, FALSE, &server_port); - + } else { /* Talked to server, though we may have gotten an error */ done = 1; - - /* Because we use ",dealloc" ool_request will be freed by mach. + + /* Because we use ",dealloc" ool_request will be freed by mach. * Don't double free it. */ - ool_request = NULL; - ool_request_length = 0; - } + ool_request = NULL; + ool_request_length = 0; + } } - + if (!err) { err = krb5int_ipc_stream_new (&cinfo->reply_stream); } - + if (!err) { mach_port_t old_notification_target = MACH_PORT_NULL; /* request no-senders notification so we know when server dies */ - err = mach_port_request_notification (mach_task_self (), reply_port, - MACH_NOTIFY_NO_SENDERS, 1, - reply_port, - MACH_MSG_TYPE_MAKE_SEND_ONCE, + err = mach_port_request_notification (mach_task_self (), reply_port, + MACH_NOTIFY_NO_SENDERS, 1, + reply_port, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &old_notification_target); - + if (!err && old_notification_target != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), old_notification_target); } } - + if (!err) { cinfo->server_died = 0; - - err = mach_msg_server_once (k5_ipc_reply_demux, K5_IPC_MAX_MSG_SIZE, + + err = mach_msg_server_once (k5_ipc_reply_demux, K5_IPC_MAX_MSG_SIZE, reply_port, MACH_MSG_TIMEOUT_NONE); - + if (!err && cinfo->server_died) { err = ENOTCONN; } } - + if (err == BOOTSTRAP_UNKNOWN_SERVICE && !in_launch_server) { err = 0; /* If server is not running just return an empty stream. */ } - + if (!err) { *out_reply_stream = cinfo->reply_stream; cinfo->reply_stream = NULL; } - - if (reply_port != MACH_PORT_NULL) { - mach_port_destroy (mach_task_self (), reply_port); + + if (reply_port != MACH_PORT_NULL) { + mach_port_destroy (mach_task_self (), reply_port); } - if (ool_request_length) { - vm_deallocate (mach_task_self (), - (vm_address_t) ool_request, ool_request_length); + if (ool_request_length) { + vm_deallocate (mach_task_self (), + (vm_address_t) ool_request, ool_request_length); } - if (cinfo && cinfo->reply_stream) { - krb5int_ipc_stream_release (cinfo->reply_stream); + if (cinfo && cinfo->reply_stream) { + krb5int_ipc_stream_release (cinfo->reply_stream); cinfo->reply_stream = NULL; } - - return err; + + return err; } #endif /* LEAN CLIENT */ diff --git a/src/util/mac/k5_mig_server.c b/src/util/mac/k5_mig_server.c index 03a7a81306..815fbed71a 100644 --- a/src/util/mac/k5_mig_server.c +++ b/src/util/mac/k5_mig_server.c @@ -44,15 +44,15 @@ static boolean_t g_ready_to_quit = 0; /* ------------------------------------------------------------------------ */ -static boolean_t k5_ipc_request_demux (mach_msg_header_t *request, - mach_msg_header_t *reply) +static boolean_t k5_ipc_request_demux (mach_msg_header_t *request, + mach_msg_header_t *reply) { boolean_t handled = 0; - + if (!handled) { handled = k5_ipc_request_server (request, reply); } - + /* Our session has a send right. If that goes away it's time to quit. */ if (!handled && (request->msgh_id == MACH_NOTIFY_NO_SENDERS && request->msgh_local_port == g_notify_port)) { @@ -63,21 +63,21 @@ static boolean_t k5_ipc_request_demux (mach_msg_header_t *request, /* Check here for a client death. If so remove it */ if (!handled && request->msgh_id == MACH_NOTIFY_NO_SENDERS) { kern_return_t err = KERN_SUCCESS; - + err = k5_ipc_server_remove_client (request->msgh_local_port); - + if (!err) { - err = mach_port_mod_refs (mach_task_self (), - request->msgh_local_port, + err = mach_port_mod_refs (mach_task_self (), + request->msgh_local_port, MACH_PORT_RIGHT_RECEIVE, -1); } - + if (!err) { handled = 1; /* was a port we are tracking */ } } - - return handled; + + return handled; } /* ------------------------------------------------------------------------ */ @@ -88,39 +88,39 @@ kern_return_t k5_ipc_server_create_client_connection (mach_port_t in_server_p kern_return_t err = KERN_SUCCESS; mach_port_t connection_port = MACH_PORT_NULL; mach_port_t old_notification_target = MACH_PORT_NULL; - + if (!err) { - err = mach_port_allocate (mach_task_self (), + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &connection_port); } - + if (!err) { - err = mach_port_move_member (mach_task_self (), + err = mach_port_move_member (mach_task_self (), connection_port, g_listen_port_set); } - + if (!err) { /* request no-senders notification so we can tell when client quits/crashes */ - err = mach_port_request_notification (mach_task_self (), - connection_port, - MACH_NOTIFY_NO_SENDERS, 1, - connection_port, - MACH_MSG_TYPE_MAKE_SEND_ONCE, + err = mach_port_request_notification (mach_task_self (), + connection_port, + MACH_NOTIFY_NO_SENDERS, 1, + connection_port, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &old_notification_target ); } - + if (!err) { err = k5_ipc_server_add_client (connection_port); } - + if (!err) { *out_connection_port = connection_port; connection_port = MACH_PORT_NULL; } - + if (MACH_PORT_VALID (connection_port)) { mach_port_deallocate (mach_task_self (), connection_port); } - - return err; + + return err; } /* ------------------------------------------------------------------------ */ @@ -134,36 +134,36 @@ kern_return_t k5_ipc_server_request (mach_port_t in_connection_port, { kern_return_t err = KERN_SUCCESS; k5_ipc_stream request_stream = NULL; - + if (!err) { err = krb5int_ipc_stream_new (&request_stream); } - + if (!err) { if (in_inl_requestCnt) { err = krb5int_ipc_stream_write (request_stream, in_inl_request, in_inl_requestCnt); - + } else if (in_ool_requestCnt) { err = krb5int_ipc_stream_write (request_stream, in_ool_request, in_ool_requestCnt); - + } else { err = EINVAL; } } - + if (!err) { err = k5_ipc_server_handle_request (in_connection_port, in_reply_port, request_stream); } - + krb5int_ipc_stream_release (request_stream); if (in_ool_requestCnt) { vm_deallocate (mach_task_self (), (vm_address_t) in_ool_request, in_ool_requestCnt); } - + return err; } /* ------------------------------------------------------------------------ */ -static kern_return_t k5_ipc_server_get_lookup_and_service_names (char **out_lookup, +static kern_return_t k5_ipc_server_get_lookup_and_service_names (char **out_lookup, char **out_service) { kern_return_t err = KERN_SUCCESS; @@ -173,32 +173,32 @@ static kern_return_t k5_ipc_server_get_lookup_and_service_names (char **out_look char *service_id = NULL; char *lookup = NULL; char *service = NULL; - + if (!out_lookup ) { err = EINVAL; } if (!out_service) { err = EINVAL; } - + if (!err) { bundle = CFBundleGetMainBundle (); if (!bundle) { err = ENOENT; } } - + if (!err) { id_string = CFBundleGetIdentifier (bundle); if (!id_string) { err = ENOMEM; } } - + if (!err) { - len = CFStringGetMaximumSizeForEncoding (CFStringGetLength (id_string), + len = CFStringGetMaximumSizeForEncoding (CFStringGetLength (id_string), kCFStringEncodingUTF8) + 1; } - + if (!err) { service_id = calloc (len, sizeof (char)); if (!service_id) { err = errno; } } - - if (!err && !CFStringGetCString (id_string, service_id, len, - kCFStringEncodingUTF8)) { + + if (!err && !CFStringGetCString (id_string, service_id, len, + kCFStringEncodingUTF8)) { err = ENOMEM; } @@ -206,23 +206,23 @@ static kern_return_t k5_ipc_server_get_lookup_and_service_names (char **out_look int w = asprintf (&lookup, "%s%s", service_id, K5_MIG_LOOKUP_SUFFIX); if (w < 0) { err = ENOMEM; } } - + if (!err) { int w = asprintf (&service, "%s%s", service_id, K5_MIG_SERVICE_SUFFIX); if (w < 0) { err = ENOMEM; } } - + if (!err) { *out_lookup = lookup; lookup = NULL; *out_service = service; service = NULL; } - + free (service); free (lookup); free (service_id); - + return err; } @@ -232,101 +232,101 @@ static kern_return_t k5_ipc_server_get_lookup_and_service_names (char **out_look int32_t k5_ipc_server_listen_loop (void) { - /* Run the Mach IPC listen loop. + /* Run the Mach IPC listen loop. * This will call k5_ipc_server_create_client_connection for new clients * and k5_ipc_server_request for existing clients */ - + kern_return_t err = KERN_SUCCESS; char *service = NULL; char *lookup = NULL; mach_port_t lookup_port = MACH_PORT_NULL; mach_port_t boot_port = MACH_PORT_NULL; mach_port_t previous_notify_port = MACH_PORT_NULL; - + if (!err) { err = k5_ipc_server_get_lookup_and_service_names (&lookup, &service); } - + if (!err) { /* Get the bootstrap port */ err = task_get_bootstrap_port (mach_task_self (), &boot_port); } - + if (!err) { /* We are an on-demand server so our lookup port already exists. */ err = bootstrap_check_in (boot_port, lookup, &lookup_port); - } - + } + if (!err) { /* We are an on-demand server so our service port already exists. */ err = bootstrap_check_in (boot_port, service, &g_service_port); - } + } if (!err) { /* Create the port set that the server will listen on */ - err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &g_notify_port); - } - + } + if (!err) { /* Ask for notification when the server port has no more senders - * A send-once right != a send right so our send-once right will + * A send-once right != a send right so our send-once right will * not interfere with the notification */ - err = mach_port_request_notification (mach_task_self (), g_service_port, - MACH_NOTIFY_NO_SENDERS, true, - g_notify_port, - MACH_MSG_TYPE_MAKE_SEND_ONCE, + err = mach_port_request_notification (mach_task_self (), g_service_port, + MACH_NOTIFY_NO_SENDERS, true, + g_notify_port, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous_notify_port); } - + if (!err) { /* Create the port set that the server will listen on */ - err = mach_port_allocate (mach_task_self (), + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, &g_listen_port_set); - } - + } + if (!err) { /* Add the lookup port to the port set */ - err = mach_port_move_member (mach_task_self (), + err = mach_port_move_member (mach_task_self (), lookup_port, g_listen_port_set); - } - + } + if (!err) { /* Add the service port to the port set */ - err = mach_port_move_member (mach_task_self (), + err = mach_port_move_member (mach_task_self (), g_service_port, g_listen_port_set); - } - + } + if (!err) { /* Add the notify port to the port set */ - err = mach_port_move_member (mach_task_self (), + err = mach_port_move_member (mach_task_self (), g_notify_port, g_listen_port_set); - } - + } + while (!err && !g_ready_to_quit) { - /* Handle one message at a time so we can check to see if + /* Handle one message at a time so we can check to see if * the server wants to quit */ - err = mach_msg_server_once (k5_ipc_request_demux, K5_IPC_MAX_MSG_SIZE, + err = mach_msg_server_once (k5_ipc_request_demux, K5_IPC_MAX_MSG_SIZE, g_listen_port_set, MACH_MSG_OPTION_NONE); } - + /* Clean up the ports and strings */ - if (MACH_PORT_VALID (g_notify_port)) { - mach_port_destroy (mach_task_self (), g_notify_port); + if (MACH_PORT_VALID (g_notify_port)) { + mach_port_destroy (mach_task_self (), g_notify_port); g_notify_port = MACH_PORT_NULL; } - if (MACH_PORT_VALID (g_listen_port_set)) { - mach_port_destroy (mach_task_self (), g_listen_port_set); - g_listen_port_set = MACH_PORT_NULL; + if (MACH_PORT_VALID (g_listen_port_set)) { + mach_port_destroy (mach_task_self (), g_listen_port_set); + g_listen_port_set = MACH_PORT_NULL; } - if (MACH_PORT_VALID (boot_port)) { - mach_port_deallocate (mach_task_self (), boot_port); + if (MACH_PORT_VALID (boot_port)) { + mach_port_deallocate (mach_task_self (), boot_port); } - + free (service); free (lookup); - - return err; + + return err; } /* ------------------------------------------------------------------------ */ @@ -339,46 +339,46 @@ int32_t k5_ipc_server_send_reply (mach_port_t in_reply_port, mach_msg_type_number_t inl_reply_length = 0; k5_ipc_ool_reply_t ool_reply = NULL; mach_msg_type_number_t ool_reply_length = 0; - + if (!MACH_PORT_VALID (in_reply_port)) { err = EINVAL; } if (!in_reply_stream ) { err = EINVAL; } - + if (!err) { - /* depending on how big the message is, use the fast inline buffer or + /* depending on how big the message is, use the fast inline buffer or * the slow dynamically allocated buffer */ mach_msg_type_number_t reply_length = krb5int_ipc_stream_size (in_reply_stream); - - if (reply_length > K5_IPC_MAX_INL_MSG_SIZE) { - //dprintf ("%s choosing out of line buffer (size is %d)", + + if (reply_length > K5_IPC_MAX_INL_MSG_SIZE) { + //dprintf ("%s choosing out of line buffer (size is %d)", // __FUNCTION__, reply_length); - - err = vm_read (mach_task_self (), - (vm_address_t) krb5int_ipc_stream_data (in_reply_stream), reply_length, + + err = vm_read (mach_task_self (), + (vm_address_t) krb5int_ipc_stream_data (in_reply_stream), reply_length, (vm_address_t *) &ool_reply, &ool_reply_length); - + } else { //cci_debug_printf ("%s choosing in line buffer (size is %d)", // __FUNCTION__, reply_length); - + inl_reply_length = reply_length; memcpy (inl_reply, krb5int_ipc_stream_data (in_reply_stream), reply_length); } } - + if (!err) { - err = k5_ipc_server_reply (in_reply_port, + err = k5_ipc_server_reply (in_reply_port, inl_reply, inl_reply_length, ool_reply, ool_reply_length); } - + if (!err) { /* Because we use ",dealloc" ool_reply will be freed by mach. Don't double free it. */ ool_reply = NULL; ool_reply_length = 0; } - + if (ool_reply_length) { vm_deallocate (mach_task_self (), (vm_address_t) ool_reply, ool_reply_length); } - + return err; } diff --git a/src/util/mac/k5_mig_server.h b/src/util/mac/k5_mig_server.h index 0c66ae5bfe..4bd4c2c022 100644 --- a/src/util/mac/k5_mig_server.h +++ b/src/util/mac/k5_mig_server.h @@ -35,8 +35,8 @@ int32_t k5_ipc_server_add_client (mach_port_t in_client_port); int32_t k5_ipc_server_remove_client (mach_port_t in_client_port); -int32_t k5_ipc_server_handle_request (mach_port_t in_connection_port, - mach_port_t in_reply_port, +int32_t k5_ipc_server_handle_request (mach_port_t in_connection_port, + mach_port_t in_reply_port, k5_ipc_stream in_request_stream); /* Server control functions */ diff --git a/src/util/mac/k5_mig_types.h b/src/util/mac/k5_mig_types.h index 0f877a3144..87c786b1f0 100644 --- a/src/util/mac/k5_mig_types.h +++ b/src/util/mac/k5_mig_types.h @@ -1,14 +1,14 @@ /* $Copyright: * * Copyright 2004-2006 by the Massachusetts Institute of Technology. -* +* * All rights reserved. -* +* * Export of this software from the United States of America may require a * specific license from the United States Government. It is the * responsibility of any person or organization contemplating export to * obtain such a license before exporting. -* +* * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute * this software and its documentation for any purpose and without fee is * hereby granted, provided that the above copyright notice appear in all @@ -21,19 +21,19 @@ * the original MIT software. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. -* +* * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -* +* * Individual source code files are copyright MIT, Cygnus Support, * OpenVision, Oracle, Sun Soft, FundsXpress, and others. -* +* * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, * and Zephyr are trademarks of the Massachusetts Institute of Technology * (MIT). No commercial use of these trademarks may be made without prior * written permission of MIT. -* +* * "Commercial use" means use of a name in a product or other for-profit * manner. It does NOT prevent a commercial firm from referring to the MIT * trademarks in order to convey information (although in doing so, |
