cc_int32 ccs_cache_collection_compare_identifier (ccs_cache_collection_t in_cache_collection, cci_identifier_t in_identifier, cc_uint32 *out_equal) { cc_int32 err = ccNoError; if (!in_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_equal ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = cci_identifier_compare (in_cache_collection->identifier, in_identifier, out_equal); } return cci_check_error (err); }
char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe) { char* result = NULL; if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);} else {result = in_pipe->uuid;} return result; }
HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe) { HANDLE result = NULL; if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);} else {result = in_pipe->clientHandle;} return result; }
cc_int32 ccs_os_pipe_copy (ccs_pipe_t *out_pipe, ccs_pipe_t in_pipe) { cc_int32 err = 0; *out_pipe = in_pipe; return cci_check_error (err); }
static cc_int32 ccs_ccache_iterator_release (ccs_ccache_iterator_t io_ccache_iterator, ccs_cache_collection_t io_cache_collection, k5_ipc_stream in_request_data, k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; if (!io_ccache_iterator ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_request_data ) { err = cci_check_error (ccErrBadParam); } if (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_ccache_list_iterator_release (io_ccache_iterator); } return cci_check_error (err); }
cc_int32 ccs_callback_invalidate (ccs_callback_t io_callback) { cc_int32 err = ccNoError; if (!io_callback) { err = cci_check_error (ccErrBadParam); } if (!err) { io_callback->pending = 0; /* client is dead, don't try to talk to it */ if (io_callback->owner_invalidate) { err = io_callback->owner_invalidate (io_callback->owner, io_callback); } else { cci_debug_printf ("WARNING %s() unable to notify callback owner!", __FUNCTION__); } } return cci_check_error (err); }
cc_uint32 cci_identifier_write (cci_identifier_t in_identifier, k5_ipc_stream io_stream) { cc_int32 err = ccNoError; if (!in_identifier) { err = cci_check_error (ccErrBadParam); } if (!io_stream ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = k5_ipc_stream_write_string (io_stream, in_identifier->server_id); } if (!err) { err = k5_ipc_stream_write_string (io_stream, in_identifier->object_id); } return cci_check_error (err); }
static cc_int32 ccs_ccache_get_change_time (ccs_ccache_t io_ccache, ccs_cache_collection_t io_cache_collection, k5_ipc_stream in_request_data, k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_request_data ) { err = cci_check_error (ccErrBadParam); } if (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = k5_ipc_stream_write_time (io_reply_data, io_ccache->last_changed_time); } return cci_check_error (err); }
static cc_int32 ccs_ccache_get_credentials_version (ccs_ccache_t io_ccache, ccs_cache_collection_t io_cache_collection, k5_ipc_stream in_request_data, k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_request_data ) { err = cci_check_error (ccErrBadParam); } if (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = k5_ipc_stream_write_uint32 (io_reply_data, io_ccache->creds_version); } return cci_check_error (err); }
static cc_uint32 cci_cc_data_array_read (cc_data ***io_ccdata_array, k5_ipc_stream io_stream) { cc_int32 err = ccNoError; cc_uint32 count = 0; cc_data **array = NULL; cc_uint32 i; if (!io_stream ) { err = cci_check_error (ccErrBadParam); } if (!io_ccdata_array) { err = cci_check_error (ccErrBadParam); } if (!err) { err = krb5int_ipc_stream_read_uint32 (io_stream, &count); } if (!err && count > 0) { array = malloc ((count + 1) * sizeof (*array)); if (array) { for (i = 0; i <= count; i++) { array[i] = NULL; } } else { err = cci_check_error (ccErrNoMem); } } if (!err) { for (i = 0; !err && i < count; i++) { array[i] = malloc (sizeof (cc_data)); if (!array[i]) { err = cci_check_error (ccErrNoMem); } if (!err) { err = cci_cc_data_read (array[i], io_stream); } } } if (!err) { *io_ccdata_array = array; array = NULL; } cci_cc_data_array_release (array); return cci_check_error (err); }
HANDLE openThreadEvent(char* uuid, char* suffix) { LPSTR event_name = NULL; HANDLE hEvent = NULL; DWORD status = 0; event_name = allocEventName(uuid, suffix); if (!event_name) status = cci_check_error(ccErrNoMem); #if 0 cci_debug_printf("%s event_name:%s", __FUNCTION__, event_name); #endif if (!status) { hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, event_name); if (!hEvent) status = cci_check_error(GetLastError()); } if (event_name) free(event_name); return hEvent; }
cc_int32 cci_identifier_compare (cci_identifier_t in_identifier, cci_identifier_t in_compare_to_identifier, cc_uint32 *out_equal) { cc_int32 err = ccNoError; if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!in_compare_to_identifier) { err = cci_check_error (ccErrBadParam); } if (!out_equal ) { err = cci_check_error (ccErrBadParam); } if (!err) { *out_equal = (!strcmp (in_identifier->object_id, in_compare_to_identifier->object_id) && !strcmp (in_identifier->server_id, in_compare_to_identifier->server_id)); } return cci_check_error (err); }
cc_int32 ccapi_ccache_iterator_clone (cc_ccache_iterator_t in_ccache_iterator, cc_ccache_iterator_t *out_ccache_iterator) { cc_int32 err = ccNoError; cci_ccache_iterator_t ccache_iterator = (cci_ccache_iterator_t) in_ccache_iterator; k5_ipc_stream reply = NULL; cc_uint32 initialized = 0; cci_identifier_t identifier = NULL; if (!in_ccache_iterator ) { err = cci_check_error (ccErrBadParam); } if (!out_ccache_iterator) { err = cci_check_error (ccErrBadParam); } if (!err) { err = cci_identifier_is_initialized (ccache_iterator->identifier, &initialized); } if (!err) { if (initialized) { err = cci_ipc_send (cci_ccache_iterator_next_msg_id, ccache_iterator->identifier, NULL, &reply); if (!err) { err = cci_identifier_read (&identifier, reply); } } else { /* server doesn't actually exist. Make another dummy one. */ identifier = cci_identifier_uninitialized; } } if (!err) { err = cci_ccache_iterator_new (out_ccache_iterator, identifier); } cci_identifier_release (identifier); krb5int_ipc_stream_release (reply); return cci_check_error (err); }
cc_int32 ccapi_ccache_iterator_next (cc_ccache_iterator_t in_ccache_iterator, cc_ccache_t *out_ccache) { cc_int32 err = ccNoError; cci_ccache_iterator_t ccache_iterator = (cci_ccache_iterator_t) in_ccache_iterator; k5_ipc_stream reply = NULL; cci_identifier_t identifier = NULL; if (!in_ccache_iterator) { err = cci_check_error (ccErrBadParam); } if (!out_ccache ) { err = cci_check_error (ccErrBadParam); } if (!err) { cc_uint32 initialized = 0; err = cci_identifier_is_initialized (ccache_iterator->identifier, &initialized); if (!err && !initialized) { /* server doesn't actually exist. Pretend we're empty. */ err = cci_check_error (ccIteratorEnd); } } if (!err) { err = cci_ipc_send (cci_ccache_iterator_next_msg_id, ccache_iterator->identifier, NULL, &reply); } if (!err) { err = cci_identifier_read (&identifier, reply); } if (!err) { err = cci_ccache_new (out_ccache, identifier); } krb5int_ipc_stream_release (reply); cci_identifier_release (identifier); return cci_check_error (err); }
static cc_int32 ccs_cache_collection_unlock (ccs_pipe_t in_client_pipe, ccs_cache_collection_t io_cache_collection, k5_ipc_stream in_request_data, k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection ) { err = cci_check_error (ccErrBadParam); } if (!in_request_data ) { err = cci_check_error (ccErrBadParam); } if (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_lock_state_remove (io_cache_collection->lock_state, in_client_pipe); } return cci_check_error (err); }
static cc_int32 test_obj_compare_identifier (ccs_object_t in_object, cci_identifier_t in_identifier, cc_uint32 *out_equal) { cc_int32 err = ccNoError; test_object_t object = (test_object_t) in_object; if (!in_object ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier) { err = cci_check_error (ccErrBadParam); } if (!out_equal ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = cci_identifier_compare (object->identifier, in_identifier, out_equal); } return cci_check_error (err); }
cc_int32 cci_ipc_send (enum cci_msg_id_t in_request_name, cci_identifier_t in_identifier, k5_ipc_stream in_request_data, k5_ipc_stream *out_reply_data) { return cci_check_error (_cci_ipc_send (in_request_name, 1, in_identifier, in_request_data, out_reply_data)); }
cc_int32 ccs_list_iterator_current (ccs_list_iterator_t io_list_iterator, ccs_object_t *out_object) { cc_int32 err = ccNoError; if (!io_list_iterator) { err = cci_check_error (ccErrBadParam); } if (!out_object ) { err = cci_check_error (ccErrBadParam); } if (!err) { if (io_list_iterator->current < cci_array_count (io_list_iterator->list->objects)) { *out_object = cci_array_object_at_index (io_list_iterator->list->objects, io_list_iterator->current); } else { err = ccIteratorEnd; } } return cci_check_error (err); }
static cc_int32 ccs_lock_status_remove_lock (ccs_lock_state_t io_lock_state, cc_uint64 in_lock_index) { cc_int32 err = ccNoError; if (!io_lock_state) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_lock_array_remove (io_lock_state->locks, in_lock_index); if (!err && in_lock_index < io_lock_state->first_pending_lock_index) { io_lock_state->first_pending_lock_index--; } } return cci_check_error (err); }
cc_int32 ccs_list_release_iterator (ccs_list_t io_list, cci_identifier_t in_identifier) { cc_int32 err = ccNoError; ccs_list_iterator_t iterator = NULL; if (!io_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_list_find_iterator (io_list, in_identifier, &iterator); } if (!err) { err = ccs_list_iterator_release (iterator); } return cci_check_error (err); }
static cc_int32 ccs_ccache_set_default (ccs_ccache_t io_ccache, ccs_cache_collection_t io_cache_collection, k5_ipc_stream in_request_data, k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_request_data ) { err = cci_check_error (ccErrBadParam); } if (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_cache_collection_set_default_ccache (io_cache_collection, io_ccache->identifier); } return cci_check_error (err); }
cc_int32 ccs_ccache_find_credentials_iterator (ccs_ccache_t in_ccache, cci_identifier_t in_identifier, ccs_credentials_iterator_t *out_credentials_iterator) { cc_int32 err = ccNoError; if (!in_ccache ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_credentials_iterator) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_credentials_list_find_iterator (in_ccache->credentials, in_identifier, out_credentials_iterator); } // Don't report ccErrInvalidCredentials to the log file. Non-fatal. return (err == ccErrInvalidCredentials) ? err : cci_check_error (err); }
static cc_uint32 cci_cc_data_array_copy (cc_data ***io_ccdata_array, cc_data **in_ccdata_array) { cc_int32 err = ccNoError; cc_uint32 count = 0; cc_data **array = NULL; cc_uint32 i; if (!io_ccdata_array) { err = cci_check_error (ccErrBadParam); } if (!err) { for (count = 0; in_ccdata_array && in_ccdata_array[count]; count++); } if (!err && count > 0) { array = malloc ((count + 1) * sizeof (*array)); if (array) { for (i = 0; i <= count; i++) { array[i] = NULL; } } else { err = cci_check_error (ccErrNoMem); } } if (!err) { for (i = 0; !err && i < count; i++) { array[i] = malloc (sizeof (cc_data)); if (!array[i]) { err = cci_check_error (ccErrNoMem); } if (!err) { err = cci_cc_data_copy_contents (array[i], in_ccdata_array[i]); } } } if (!err) { *io_ccdata_array = array; array = NULL; } cci_cc_data_array_release (array); return cci_check_error (err); }
cc_int32 ccapi_ccache_get_principal (cc_ccache_t in_ccache, cc_uint32 in_credentials_version, cc_string_t *out_principal) { cc_int32 err = ccNoError; cci_ccache_t ccache = (cci_ccache_t) in_ccache; k5_ipc_stream request = NULL; k5_ipc_stream reply = NULL; char *principal = NULL; if (!in_ccache ) { err = cci_check_error (ccErrBadParam); } if (!out_principal) { err = cci_check_error (ccErrBadParam); } if (!err) { err = k5_ipc_stream_new (&request); } if (!err) { err = k5_ipc_stream_write_uint32 (request, in_credentials_version); } if (!err) { err = cci_ipc_send (cci_ccache_get_principal_msg_id, ccache->identifier, request, &reply); } if (!err) { err = k5_ipc_stream_read_string (reply, &principal); } if (!err) { err = cci_string_new (out_principal, principal); } k5_ipc_stream_release (request); k5_ipc_stream_release (reply); k5_ipc_stream_free_string (principal); return cci_check_error (err); }
static cc_int32 ccs_lock_status_add_pending_lock (ccs_lock_state_t io_lock_state, ccs_pipe_t in_client_pipe, ccs_pipe_t in_reply_pipe, cc_uint32 in_lock_type, cc_uint64 *out_lock_index) { cc_int32 err = ccNoError; ccs_lock_t lock = NULL; if (!io_lock_state ) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_reply_pipe) ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccs_lock_new (&lock, in_lock_type, io_lock_state->invalid_object_err, in_client_pipe, in_reply_pipe, io_lock_state); } if (!err) { err = ccs_lock_array_insert (io_lock_state->locks, lock, ccs_lock_array_count (io_lock_state->locks)); if (!err) { lock = NULL; /* take ownership */ } } if (!err) { *out_lock_index = ccs_lock_array_count (io_lock_state->locks) - 1; } ccs_lock_release (lock); return cci_check_error (err); }
static cc_int32 ccs_ccache_wait_for_change (ccs_pipe_t in_client_pipe, ccs_pipe_t in_reply_pipe, ccs_ccache_t io_ccache, ccs_cache_collection_t io_cache_collection, k5_ipc_stream in_request_data, k5_ipc_stream io_reply_data, cc_uint32 *out_will_block) { cc_int32 err = ccNoError; cc_time_t last_wait_for_change_time = 0; cc_uint32 will_block = 0; if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_reply_pipe )) { err = cci_check_error (ccErrBadParam); } if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection ) { err = cci_check_error (ccErrBadParam); } if (!in_request_data ) { err = cci_check_error (ccErrBadParam); } if (!out_will_block ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = krb5int_ipc_stream_read_time (in_request_data, &last_wait_for_change_time); } if (!err) { if (last_wait_for_change_time < io_ccache->last_changed_time) { cci_debug_printf ("%s returning immediately", __FUNCTION__); err = krb5int_ipc_stream_write_time (io_reply_data, io_ccache->last_changed_time); } else { ccs_callback_t callback = NULL; err = ccs_callback_new (&callback, ccErrInvalidCCache, in_client_pipe, in_reply_pipe, (ccs_callback_owner_t) io_ccache, ccs_ccache_invalidate_change_callback); if (!err) { err = ccs_callback_array_insert (io_ccache->change_callbacks, callback, ccs_callback_array_count (io_ccache->change_callbacks)); if (!err) { callback = NULL; /* take ownership */ } cci_debug_printf ("%s blocking", __FUNCTION__); will_block = 1; } ccs_callback_release (callback); } } if (!err) { *out_will_block = will_block; } return cci_check_error (err); }
cc_uint32 cci_credentials_union_read (cc_credentials_union **out_credentials_union, k5_ipc_stream io_stream) { cc_int32 err = ccNoError; cc_credentials_union *credentials_union = NULL; if (!io_stream ) { err = cci_check_error (ccErrBadParam); } if (!out_credentials_union) { err = cci_check_error (ccErrBadParam); } if (!err) { credentials_union = calloc (1, sizeof (*credentials_union)); if (!credentials_union) { err = cci_check_error (ccErrNoMem); } } if (!err) { err = krb5int_ipc_stream_read_uint32 (io_stream, &credentials_union->version); } if (!err) { if (credentials_union->version == cc_credentials_v4) { err = cci_credentials_v4_read (&credentials_union->credentials.credentials_v4, io_stream); } else if (credentials_union->version == cc_credentials_v5) { err = cci_credentials_v5_read (&credentials_union->credentials.credentials_v5, io_stream); } else { err = ccErrBadCredentialsVersion; } } if (!err) { *out_credentials_union = credentials_union; credentials_union = NULL; } if (credentials_union) { cci_credentials_union_release (credentials_union); } return cci_check_error (err); }
cc_int32 ccs_callback_new (ccs_callback_t *out_callback, cc_int32 in_invalid_object_err, ccs_pipe_t in_client_pipe, ccs_pipe_t in_reply_pipe, ccs_callback_owner_t in_owner, ccs_callback_owner_invalidate_t in_owner_invalidate_function) { cc_int32 err = ccNoError; ccs_callback_t callback = NULL; ccs_client_t client = NULL; if (!out_callback ) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_reply_pipe) ) { err = cci_check_error (ccErrBadParam); } if (!in_owner ) { err = cci_check_error (ccErrBadParam); } if (!in_owner_invalidate_function ) { err = cci_check_error (ccErrBadParam); } if (!err) { callback = malloc (sizeof (*callback)); if (callback) { *callback = ccs_callback_initializer; } else { err = cci_check_error (ccErrNoMem); } } if (!err) { err = ccs_server_client_for_pipe (in_client_pipe, &client); } if (!err) { err = ccs_pipe_copy (&callback->client_pipe, in_client_pipe); } if (!err) { err = ccs_pipe_copy (&callback->reply_pipe, in_reply_pipe); } if (!err) { callback->client_pipe = in_client_pipe; callback->reply_pipe = in_reply_pipe; callback->invalid_object_err = in_invalid_object_err; callback->owner = in_owner; callback->owner_invalidate = in_owner_invalidate_function; err = ccs_client_add_callback (client, callback); } if (!err) { *out_callback = callback; callback = NULL; } ccs_callback_release (callback); return cci_check_error (err); }
cc_int32 ccs_lock_state_release (ccs_lock_state_t io_lock_state) { cc_int32 err = ccNoError; if (!err && io_lock_state) { ccs_lock_array_release (io_lock_state->locks); free (io_lock_state); } return cci_check_error (err); }
cc_int32 ccs_os_notify_cache_collection_changed (ccs_cache_collection_t io_cache_collection) { cc_int32 err = ccNoError; if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!err) { CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter (); if (center) { CFNotificationCenterPostNotification (center, kCCAPICacheCollectionChangedNotification, NULL, NULL, TRUE); } } return cci_check_error (err); }