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/ccapi/server | |
| 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/ccapi/server')
25 files changed, 1104 insertions, 1110 deletions
diff --git a/src/ccapi/server/ccs_array.c b/src/ccapi/server/ccs_array.c index d5dd4adb2..c5fb4f3b5 100644 --- a/src/ccapi/server/ccs_array.c +++ b/src/ccapi/server/ccs_array.c @@ -31,7 +31,7 @@ static cc_int32 ccs_client_object_release (cci_array_object_t io_client) { - return cci_check_error (ccs_client_release ((ccs_client_t) io_client)); + return cci_check_error (ccs_client_release ((ccs_client_t) io_client)); } /* ------------------------------------------------------------------------ */ @@ -88,7 +88,7 @@ cc_int32 ccs_client_array_remove (ccs_client_array_t io_array, static cc_int32 ccs_lock_object_release (cci_array_object_t io_lock) { - return cci_check_error (ccs_lock_release ((ccs_lock_t) io_lock)); + return cci_check_error (ccs_lock_release ((ccs_lock_t) io_lock)); } /* ------------------------------------------------------------------------ */ @@ -154,7 +154,7 @@ cc_int32 ccs_lock_array_move (ccs_lock_array_t io_array, static cc_int32 ccs_callback_object_release (cci_array_object_t io_callback) { - return cci_check_error (ccs_callback_release ((ccs_callback_t) io_callback)); + return cci_check_error (ccs_callback_release ((ccs_callback_t) io_callback)); } /* ------------------------------------------------------------------------ */ @@ -286,7 +286,7 @@ cc_uint64 ccs_iteratorref_array_count (ccs_iteratorref_array_t in_array) ccs_generic_list_iterator_t ccs_iteratorref_array_object_at_index (ccs_iteratorref_array_t io_array, cc_uint64 in_position) { - return (ccs_generic_list_iterator_t) cci_array_object_at_index (io_array, + return (ccs_generic_list_iterator_t) cci_array_object_at_index (io_array, in_position); } @@ -296,8 +296,8 @@ cc_int32 ccs_iteratorref_array_insert (ccs_iteratorref_array_t io_array, ccs_generic_list_iterator_t in_iterator, cc_uint64 in_position) { - return cci_array_insert (io_array, - (cci_array_object_t) in_iterator, + return cci_array_insert (io_array, + (cci_array_object_t) in_iterator, in_position); } diff --git a/src/ccapi/server/ccs_cache_collection.c b/src/ccapi/server/ccs_cache_collection.c index 2137e816a..c96a75bee 100644 --- a/src/ccapi/server/ccs_cache_collection.c +++ b/src/ccapi/server/ccs_cache_collection.c @@ -45,48 +45,48 @@ cc_int32 ccs_cache_collection_new (ccs_cache_collection_t *out_cache_collection) { cc_int32 err = ccNoError; ccs_cache_collection_t cache_collection = NULL; - + if (!out_cache_collection) { err = cci_check_error (ccErrBadParam); } - + if (!err) { cache_collection = malloc (sizeof (*cache_collection)); - if (cache_collection) { + if (cache_collection) { *cache_collection = ccs_cache_collection_initializer; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { err = ccs_server_new_identifier (&cache_collection->identifier); } - + if (!err) { err = ccs_lock_state_new (&cache_collection->lock_state, ccErrInvalidContext, ccErrContextLocked, ccErrContextUnlocked); } - + if (!err) { err = ccs_ccache_list_new (&cache_collection->ccaches); } - + if (!err) { err = ccs_callback_array_new (&cache_collection->change_callbacks); } - + if (!err) { err = ccs_cache_collection_changed (cache_collection); } - + if (!err) { *out_cache_collection = cache_collection; cache_collection = NULL; } - + ccs_cache_collection_release (cache_collection); - + return cci_check_error (err); } @@ -95,7 +95,7 @@ cc_int32 ccs_cache_collection_new (ccs_cache_collection_t *out_cache_collection) cc_int32 ccs_cache_collection_release (ccs_cache_collection_t io_cache_collection) { cc_int32 err = ccNoError; - + if (!err && io_cache_collection) { cci_identifier_release (io_cache_collection->identifier); ccs_lock_state_release (io_cache_collection->lock_state); @@ -103,7 +103,7 @@ cc_int32 ccs_cache_collection_release (ccs_cache_collection_t io_cache_collectio ccs_callback_array_release (io_cache_collection->change_callbacks); free (io_cache_collection); } - + return cci_check_error (err); } @@ -114,17 +114,17 @@ cc_int32 ccs_cache_collection_compare_identifier (ccs_cache_collection_t in_cac 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, + err = cci_identifier_compare (in_cache_collection->identifier, + in_identifier, out_equal); } - + return cci_check_error (err); } @@ -138,19 +138,19 @@ cc_int32 ccs_cache_collection_changed (ccs_cache_collection_t io_cache_collectio { cc_int32 err = ccNoError; k5_ipc_stream reply_data = NULL; - + if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!err) { cc_time_t now = time (NULL); - + if (io_cache_collection->last_changed_time < now) { io_cache_collection->last_changed_time = now; } else { io_cache_collection->last_changed_time++; } } - + if (!err) { err = krb5int_ipc_stream_new (&reply_data); } @@ -158,17 +158,17 @@ cc_int32 ccs_cache_collection_changed (ccs_cache_collection_t io_cache_collectio if (!err) { err = krb5int_ipc_stream_write_time (reply_data, io_cache_collection->last_changed_time); } - + if (!err) { /* Loop over callbacks sending messages to them */ cc_uint64 i; cc_uint64 count = ccs_callback_array_count (io_cache_collection->change_callbacks); - + for (i = 0; !err && i < count; i++) { ccs_callback_t callback = ccs_callback_array_object_at_index (io_cache_collection->change_callbacks, i); - + err = ccs_callback_reply_to_client (callback, reply_data); - + if (!err) { cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback); err = ccs_callback_array_remove (io_cache_collection->change_callbacks, i); @@ -176,13 +176,13 @@ cc_int32 ccs_cache_collection_changed (ccs_cache_collection_t io_cache_collectio } } } - + if (!err) { err = ccs_os_notify_cache_collection_changed (io_cache_collection); } - + krb5int_ipc_stream_release (reply_data); - + return cci_check_error (err); } @@ -192,19 +192,19 @@ static cc_int32 ccs_cache_collection_invalidate_change_callback (ccs_callback_ow ccs_callback_t in_callback) { cc_int32 err = ccNoError; - + if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_callback ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { /* Remove callback */ ccs_cache_collection_t cache_collection = (ccs_cache_collection_t) io_cache_collection; cc_uint64 i; cc_uint64 count = ccs_callback_array_count (cache_collection->change_callbacks); - + for (i = 0; !err && i < count; i++) { ccs_callback_t callback = ccs_callback_array_object_at_index (cache_collection->change_callbacks, i); - + if (callback == in_callback) { cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback); err = ccs_callback_array_remove (cache_collection->change_callbacks, i); @@ -212,7 +212,7 @@ static cc_int32 ccs_cache_collection_invalidate_change_callback (ccs_callback_ow } } } - + return cci_check_error (err); } @@ -228,27 +228,27 @@ static cc_int32 ccs_cache_collection_find_ccache_by_name (ccs_cache_collection_t { cc_int32 err = ccNoError; ccs_ccache_list_iterator_t iterator = NULL; - + if (!in_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_name ) { err = cci_check_error (ccErrBadParam); } if (!out_ccache ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - err = ccs_ccache_list_new_iterator (in_cache_collection->ccaches, - CCS_PIPE_NULL, + err = ccs_ccache_list_new_iterator (in_cache_collection->ccaches, + CCS_PIPE_NULL, &iterator); } - + while (!err) { ccs_ccache_t ccache = NULL; - + err = ccs_ccache_list_iterator_next (iterator, &ccache); - + if (!err) { cc_uint32 equal = 0; - + err = ccs_ccache_compare_name (ccache, in_name, &equal); - + if (!err && equal) { *out_ccache = ccache; break; @@ -256,9 +256,9 @@ static cc_int32 ccs_cache_collection_find_ccache_by_name (ccs_cache_collection_t } } if (err == ccIteratorEnd) { err = ccErrCCacheNotFound; } - + if (iterator) { ccs_ccache_list_iterator_release (iterator); } - + return cci_check_error (err); } @@ -273,16 +273,16 @@ cc_int32 ccs_cache_collection_find_ccache (ccs_cache_collection_t in_cache_coll ccs_ccache_t *out_ccache) { cc_int32 err = ccNoError; - + if (!in_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_ccache ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_ccache_list_find (in_cache_collection->ccaches, in_identifier, out_ccache); } - + return cci_check_error (err); } @@ -294,28 +294,28 @@ cc_int32 ccs_ccache_collection_move_ccache (ccs_cache_collection_t io_cache_coll { cc_int32 err = ccNoError; ccs_ccache_t source_ccache = NULL; - + if (!io_cache_collection ) { err = cci_check_error (ccErrBadParam); } if (!in_source_identifier ) { err = cci_check_error (ccErrBadParam); } if (!io_destination_ccache) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_cache_collection_find_ccache (io_cache_collection, - in_source_identifier, + in_source_identifier, &source_ccache); } - + if (!err) { - err = ccs_ccache_swap_contents (source_ccache, - io_destination_ccache, + err = ccs_ccache_swap_contents (source_ccache, + io_destination_ccache, io_cache_collection); } - + if (!err) { err = ccs_cache_collection_destroy_ccache (io_cache_collection, in_source_identifier); } - + return cci_check_error (err); } @@ -326,16 +326,16 @@ cc_int32 ccs_cache_collection_destroy_ccache (ccs_cache_collection_t io_cache_c { cc_int32 err = ccNoError; ccs_ccache_t ccache = NULL; - + if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_cache_collection_find_ccache (io_cache_collection, - in_identifier, + in_identifier, &ccache); } - + if (!err) { /* Notify before deletion because after deletion the ccache * will no longer exist (and won't know about its clients) */ @@ -361,17 +361,17 @@ cc_int32 ccs_cache_collection_find_ccache_iterator (ccs_cache_collection_t in_c ccs_ccache_iterator_t *out_ccache_iterator) { cc_int32 err = ccNoError; - + if (!in_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_ccache_iterator) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_ccache_list_find_iterator (in_cache_collection->ccaches, in_identifier, out_ccache_iterator); } - + return cci_check_error (err); } @@ -388,36 +388,36 @@ cc_int32 ccs_cache_collection_find_credentials_iterator (ccs_cache_collection_t { cc_int32 err = ccNoError; ccs_ccache_list_iterator_t iterator = NULL; - + if (!in_cache_collection ) { 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_ccache_list_new_iterator (in_cache_collection->ccaches, - CCS_PIPE_NULL, + err = ccs_ccache_list_new_iterator (in_cache_collection->ccaches, + CCS_PIPE_NULL, &iterator); } - + while (!err) { ccs_ccache_t ccache = NULL; - + err = ccs_ccache_list_iterator_next (iterator, &ccache); - + if (!err) { - cc_int32 terr = ccs_ccache_find_credentials_iterator (ccache, + cc_int32 terr = ccs_ccache_find_credentials_iterator (ccache, in_identifier, out_credentials_iterator); - if (!terr) { + if (!terr) { *out_ccache = ccache; - break; + break; } } } if (err == ccIteratorEnd) { err = cci_check_error (ccErrInvalidCredentialsIterator); } - + if (iterator) { ccs_ccache_list_iterator_release (iterator); } - + return cci_check_error (err); } @@ -433,27 +433,27 @@ static cc_int32 ccs_cache_collection_get_next_unique_ccache_name (ccs_cache_coll cc_int32 err = ccNoError; cc_uint64 count = 0; char *name = NULL; - + if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!out_name ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_cache_collection_list_count (io_cache_collection->ccaches, &count); } - + if (!err) { if (count > 0) { while (!err) { int ret = asprintf (&name, "%lld", io_cache_collection->next_unique_name++); if (ret < 0 || !name) { err = cci_check_error (ccErrNoMem); } - + if (!err) { ccs_ccache_t ccache = NULL; /* temporary to hold ccache pointer */ - err = ccs_cache_collection_find_ccache_by_name (io_cache_collection, + err = ccs_cache_collection_find_ccache_by_name (io_cache_collection, name, &ccache); } - - if (err == ccErrCCacheNotFound) { + + if (err == ccErrCCacheNotFound) { err = ccNoError; break; /* found a unique one */ } @@ -463,9 +463,9 @@ static cc_int32 ccs_cache_collection_get_next_unique_ccache_name (ccs_cache_coll if (!name) { err = cci_check_error (ccErrNoMem); } } } - + if (!err) { - *out_name = name; + *out_name = name; name = NULL; } @@ -476,86 +476,86 @@ static cc_int32 ccs_cache_collection_get_next_unique_ccache_name (ccs_cache_coll /* ------------------------------------------------------------------------ */ -static cc_int32 ccs_cache_collection_get_default_ccache (ccs_cache_collection_t in_cache_collection, +static cc_int32 ccs_cache_collection_get_default_ccache (ccs_cache_collection_t in_cache_collection, ccs_ccache_t *out_ccache) { cc_int32 err = ccNoError; cc_uint64 count = 0; - + if (!in_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!out_ccache ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_ccache_list_count (in_cache_collection->ccaches, &count); } - + if (!err) { if (count > 0) { /* First ccache is the default */ ccs_ccache_list_iterator_t iterator = NULL; - + err = ccs_ccache_list_new_iterator (in_cache_collection->ccaches, - CCS_PIPE_NULL, + CCS_PIPE_NULL, &iterator); - + if (!err) { err = ccs_ccache_list_iterator_next (iterator, out_ccache); } - + ccs_ccache_list_iterator_release (iterator); - + } else { err = cci_check_error (ccErrCCacheNotFound); } } - + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ -cc_int32 ccs_cache_collection_set_default_ccache (ccs_cache_collection_t io_cache_collection, +cc_int32 ccs_cache_collection_set_default_ccache (ccs_cache_collection_t io_cache_collection, cci_identifier_t in_identifier) { cc_int32 err = ccNoError; ccs_ccache_t old_default = NULL; ccs_ccache_t new_default = NULL; cc_uint32 equal = 0; - + if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - err = ccs_cache_collection_get_default_ccache (io_cache_collection, + err = ccs_cache_collection_get_default_ccache (io_cache_collection, &old_default); } - + if (!err) { err = ccs_ccache_compare_identifier (old_default, in_identifier, &equal); } - - + + if (!err && !equal) { err = ccs_ccache_list_push_front (io_cache_collection->ccaches, in_identifier); - + if (!err) { err = ccs_ccache_notify_default_state_changed (old_default, io_cache_collection, 0 /* no longer default */); } - + if (!err) { - err = ccs_cache_collection_get_default_ccache (io_cache_collection, + err = ccs_cache_collection_get_default_ccache (io_cache_collection, &new_default); } - + if (!err) { err = ccs_ccache_notify_default_state_changed (new_default, io_cache_collection, 1 /* now default */); } - + if (!err) { err = ccs_cache_collection_changed (io_cache_collection); } @@ -576,16 +576,16 @@ static cc_int32 ccs_cache_collection_sync (ccs_cache_collection_t io_cache_colle k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; - + 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 = cci_identifier_write (io_cache_collection->identifier, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -595,16 +595,16 @@ static cc_int32 ccs_cache_collection_get_change_time (ccs_cache_collection_t io_ k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; - + 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 = krb5int_ipc_stream_write_time (io_reply_data, io_cache_collection->last_changed_time); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -619,27 +619,27 @@ static cc_int32 ccs_cache_collection_wait_for_change (ccs_pipe_t in 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_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_cache_collection->last_changed_time) { err = krb5int_ipc_stream_write_time (io_reply_data, io_cache_collection->last_changed_time); - + } else { ccs_callback_t callback = NULL; - err = ccs_callback_new (&callback, - ccErrInvalidContext, - in_client_pipe, + err = ccs_callback_new (&callback, + ccErrInvalidContext, + in_client_pipe, in_reply_pipe, (ccs_callback_owner_t) io_cache_collection, ccs_cache_collection_invalidate_change_callback); @@ -648,19 +648,19 @@ static cc_int32 ccs_cache_collection_wait_for_change (ccs_pipe_t in err = ccs_callback_array_insert (io_cache_collection->change_callbacks, callback, ccs_callback_array_count (io_cache_collection->change_callbacks)); if (!err) { callback = NULL; /* take ownership */ } - + will_block = 1; } ccs_callback_release (callback); } } - + if (!err) { *out_will_block = will_block; } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -671,31 +671,31 @@ static cc_int32 ccs_cache_collection_get_default_ccache_name (ccs_cache_collecti { cc_int32 err = ccNoError; cc_uint64 count = 0; - + 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_list_count (io_cache_collection->ccaches, &count); } - + if (!err) { if (count > 0) { ccs_ccache_t ccache = NULL; err = ccs_cache_collection_get_default_ccache (io_cache_collection, &ccache); - + if (!err) { err = ccs_ccache_write_name (ccache, io_reply_data); } } else { - err = krb5int_ipc_stream_write_string (io_reply_data, + err = krb5int_ipc_stream_write_string (io_reply_data, k_cci_context_initial_ccache_name); } } - return cci_check_error (err); + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -707,27 +707,27 @@ static cc_int32 ccs_cache_collection_open_ccache (ccs_cache_collection_t io_cach cc_int32 err = ccNoError; char *name = NULL; ccs_ccache_t ccache = NULL; - + 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 = krb5int_ipc_stream_read_string (in_request_data, &name); } - + if (!err) { err = ccs_cache_collection_find_ccache_by_name (io_cache_collection, name, &ccache); } - + if (!err) { err = ccs_ccache_write (ccache, io_reply_data); } - + krb5int_ipc_stream_free_string (name); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -738,21 +738,21 @@ static cc_int32 ccs_cache_collection_open_default_ccache (ccs_cache_collection_t { cc_int32 err = ccNoError; ccs_ccache_t ccache = NULL; - + 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_get_default_ccache (io_cache_collection, + err = ccs_cache_collection_get_default_ccache (io_cache_collection, &ccache); } - + if (!err) { err = ccs_ccache_write (ccache, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -766,49 +766,49 @@ static cc_int32 ccs_cache_collection_create_ccache (ccs_cache_collection_t io_ca cc_uint32 cred_vers; char *principal = NULL; ccs_ccache_t ccache = NULL; - + 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 = krb5int_ipc_stream_read_string (in_request_data, &name); } - + if (!err) { err = krb5int_ipc_stream_read_uint32 (in_request_data, &cred_vers); } - + if (!err) { err = krb5int_ipc_stream_read_string (in_request_data, &principal); } - + if (!err) { cc_int32 terr = ccs_cache_collection_find_ccache_by_name (io_cache_collection, name, &ccache); - + if (!terr) { err = ccs_ccache_reset (ccache, io_cache_collection, cred_vers, principal); - + } else { - err = ccs_ccache_new (&ccache, cred_vers, name, principal, + err = ccs_ccache_new (&ccache, cred_vers, name, principal, io_cache_collection->ccaches); } } - + if (!err) { err = ccs_ccache_write (ccache, io_reply_data); } - + if (!err) { err = ccs_cache_collection_changed (io_cache_collection); } - + krb5int_ipc_stream_free_string (name); krb5int_ipc_stream_free_string (principal); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -821,52 +821,52 @@ static cc_int32 ccs_cache_collection_create_default_ccache (ccs_cache_collection cc_uint32 cred_vers; char *principal = NULL; ccs_ccache_t ccache = NULL; - + 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 = krb5int_ipc_stream_read_uint32 (in_request_data, &cred_vers); } - + if (!err) { err = krb5int_ipc_stream_read_string (in_request_data, &principal); } - + if (!err) { err = ccs_cache_collection_get_default_ccache (io_cache_collection, &ccache); - + if (!err) { err = ccs_ccache_reset (ccache, io_cache_collection, cred_vers, principal); } else if (err == ccErrCCacheNotFound) { char *name = NULL; - - err = ccs_cache_collection_get_next_unique_ccache_name (io_cache_collection, + + err = ccs_cache_collection_get_next_unique_ccache_name (io_cache_collection, &name); - + if (!err) { - err = ccs_ccache_new (&ccache, cred_vers, name, principal, + err = ccs_ccache_new (&ccache, cred_vers, name, principal, io_cache_collection->ccaches); } - + free (name); } } - + if (!err) { err = ccs_ccache_write (ccache, io_reply_data); } - + if (!err) { err = ccs_cache_collection_changed (io_cache_collection); } - + krb5int_ipc_stream_free_string (principal); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -880,41 +880,41 @@ static cc_int32 ccs_cache_collection_create_new_ccache (ccs_cache_collection_t i char *principal = NULL; char *name = NULL; ccs_ccache_t ccache = NULL; - + 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 = krb5int_ipc_stream_read_uint32 (in_request_data, &cred_vers); } - + if (!err) { err = krb5int_ipc_stream_read_string (in_request_data, &principal); } - + if (!err) { - err = ccs_cache_collection_get_next_unique_ccache_name (io_cache_collection, + err = ccs_cache_collection_get_next_unique_ccache_name (io_cache_collection, &name); } - + if (!err) { - err = ccs_ccache_new (&ccache, cred_vers, name, principal, + err = ccs_ccache_new (&ccache, cred_vers, name, principal, io_cache_collection->ccaches); } - + if (!err) { err = ccs_ccache_write (ccache, io_reply_data); } - + if (!err) { err = ccs_cache_collection_changed (io_cache_collection); } - + free (name); krb5int_ipc_stream_free_string (principal); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -926,22 +926,22 @@ static cc_int32 ccs_cache_collection_new_ccache_iterator (ccs_cache_collection_ { cc_int32 err = ccNoError; ccs_ccache_iterator_t ccache_iterator = NULL; - + 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_new_iterator (io_cache_collection->ccaches, in_client_pipe, &ccache_iterator); } - + if (!err) { err = ccs_ccache_list_iterator_write (ccache_iterator, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -956,28 +956,28 @@ static cc_int32 ccs_cache_collection_lock (ccs_pipe_t in_client_pip cc_int32 err = ccNoError; cc_uint32 lock_type; cc_uint32 block; - + 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 (!out_will_block ) { err = cci_check_error (ccErrBadParam); } if (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = krb5int_ipc_stream_read_uint32 (in_request_data, &lock_type); } - + if (!err) { err = krb5int_ipc_stream_read_uint32 (in_request_data, &block); } - + if (!err) { - err = ccs_lock_state_add (io_cache_collection->lock_state, - in_client_pipe, in_reply_pipe, + err = ccs_lock_state_add (io_cache_collection->lock_state, + in_client_pipe, in_reply_pipe, lock_type, block, out_will_block); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -988,18 +988,18 @@ static cc_int32 ccs_cache_collection_unlock (ccs_pipe_t in_client_pi 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, + err = ccs_lock_state_remove (io_cache_collection->lock_state, in_client_pipe); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -1019,81 +1019,81 @@ static cc_int32 ccs_cache_collection_unlock (ccs_pipe_t in_client_pi cc_int32 err = ccNoError; cc_uint32 will_block = 0; k5_ipc_stream reply_data = NULL; - + 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_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 (!out_reply_data ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = krb5int_ipc_stream_new (&reply_data); } - + if (!err) { if (in_request_name == cci_context_unused_release_msg_id) { /* Old release message. Do nothing. */ - + } else if (in_request_name == cci_context_sync_msg_id) { err = ccs_cache_collection_sync (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_get_change_time_msg_id) { err = ccs_cache_collection_get_change_time (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_wait_for_change_msg_id) { - err = ccs_cache_collection_wait_for_change (in_client_pipe, in_reply_pipe, + err = ccs_cache_collection_wait_for_change (in_client_pipe, in_reply_pipe, io_cache_collection, in_request_data, reply_data, &will_block); - + } else if (in_request_name == cci_context_get_default_ccache_name_msg_id) { err = ccs_cache_collection_get_default_ccache_name (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_open_ccache_msg_id) { err = ccs_cache_collection_open_ccache (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_open_default_ccache_msg_id) { err = ccs_cache_collection_open_default_ccache (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_create_ccache_msg_id) { err = ccs_cache_collection_create_ccache (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_create_default_ccache_msg_id) { err = ccs_cache_collection_create_default_ccache (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_create_new_ccache_msg_id) { err = ccs_cache_collection_create_new_ccache (io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_context_new_ccache_iterator_msg_id) { err = ccs_cache_collection_new_ccache_iterator (io_cache_collection, in_client_pipe, - in_request_data, + in_request_data, reply_data); - + } else if (in_request_name == cci_context_lock_msg_id) { - err = ccs_cache_collection_lock (in_client_pipe, in_reply_pipe, + err = ccs_cache_collection_lock (in_client_pipe, in_reply_pipe, io_cache_collection, - in_request_data, + in_request_data, &will_block, reply_data); - + } else if (in_request_name == cci_context_unlock_msg_id) { err = ccs_cache_collection_unlock (in_client_pipe, io_cache_collection, in_request_data, reply_data); - + } else { err = ccErrBadInternalMessage; } } - + if (!err) { *out_will_block = will_block; if (!will_block) { @@ -1103,8 +1103,8 @@ static cc_int32 ccs_cache_collection_unlock (ccs_pipe_t in_client_pi *out_reply_data = NULL; } } - + krb5int_ipc_stream_release (reply_data); - + return cci_check_error (err); } diff --git a/src/ccapi/server/ccs_cache_collection.h b/src/ccapi/server/ccs_cache_collection.h index f0507967b..53f97092f 100644 --- a/src/ccapi/server/ccs_cache_collection.h +++ b/src/ccapi/server/ccs_cache_collection.h @@ -39,7 +39,7 @@ cc_int32 ccs_cache_collection_compare_identifier (ccs_cache_collection_t in_cac cc_int32 ccs_cache_collection_changed (ccs_cache_collection_t io_cache_collection); -cc_int32 ccs_cache_collection_set_default_ccache (ccs_cache_collection_t in_cache_collection, +cc_int32 ccs_cache_collection_set_default_ccache (ccs_cache_collection_t in_cache_collection, cci_identifier_t in_identifier); cc_int32 ccs_cache_collection_find_ccache (ccs_cache_collection_t in_cache_collection, diff --git a/src/ccapi/server/ccs_callback.c b/src/ccapi/server/ccs_callback.c index 94e9d9b4b..499ba30de 100644 --- a/src/ccapi/server/ccs_callback.c +++ b/src/ccapi/server/ccs_callback.c @@ -49,52 +49,52 @@ cc_int32 ccs_callback_new (ccs_callback_t *out_callback, 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) { + if (callback) { *callback = ccs_callback_initializer; } else { - err = cci_check_error (ccErrNoMem); + 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); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -102,34 +102,34 @@ cc_int32 ccs_callback_new (ccs_callback_t *out_callback, cc_int32 ccs_callback_release (ccs_callback_t io_callback) { cc_int32 err = ccNoError; - + if (!err && io_callback) { ccs_client_t client = NULL; if (io_callback->pending) { - err = ccs_server_send_reply (io_callback->reply_pipe, + err = ccs_server_send_reply (io_callback->reply_pipe, io_callback->invalid_object_err, NULL); - + io_callback->pending = 0; } - + if (!err) { err = ccs_server_client_for_pipe (io_callback->client_pipe, &client); } - + if (!err && client) { /* if client object still has a reference to us, remove it */ err = ccs_client_remove_callback (client, io_callback); } - + if (!err) { ccs_pipe_release (io_callback->client_pipe); ccs_pipe_release (io_callback->reply_pipe); free (io_callback); } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -137,19 +137,19 @@ cc_int32 ccs_callback_release (ccs_callback_t io_callback) 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!", + cci_debug_printf ("WARNING %s() unable to notify callback owner!", __FUNCTION__); } } - + return cci_check_error (err); } @@ -159,28 +159,28 @@ cc_int32 ccs_callback_reply_to_client (ccs_callback_t io_callback, k5_ipc_stream in_stream) { cc_int32 err = ccNoError; - + if (!io_callback) { err = cci_check_error (ccErrBadParam); } - + if (!err) { if (io_callback->pending) { cci_debug_printf ("%s: callback %p replying to client.", __FUNCTION__, io_callback); err = ccs_server_send_reply (io_callback->reply_pipe, err, in_stream); - + if (err) { - cci_debug_printf ("WARNING %s() called on a lock belonging to a dead client!", + cci_debug_printf ("WARNING %s() called on a lock belonging to a dead client!", __FUNCTION__); } - + io_callback->pending = 0; } else { - cci_debug_printf ("WARNING %s() called on non-pending callback!", + cci_debug_printf ("WARNING %s() called on non-pending callback!", __FUNCTION__); } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -189,15 +189,15 @@ cc_uint32 ccs_callback_is_pending (ccs_callback_t in_callback, cc_uint32 *out_pending) { cc_int32 err = ccNoError; - + if (!in_callback) { err = cci_check_error (ccErrBadParam); } if (!out_pending) { err = cci_check_error (ccErrBadParam); } - + if (!err) { *out_pending = in_callback->pending; } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -207,17 +207,17 @@ cc_int32 ccs_callback_is_for_client_pipe (ccs_callback_t in_callback, cc_uint32 *out_is_for_client_pipe) { cc_int32 err = ccNoError; - + if (!in_callback ) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!out_is_for_client_pipe ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - err = ccs_pipe_compare (in_callback->client_pipe, in_client_pipe, + err = ccs_pipe_compare (in_callback->client_pipe, in_client_pipe, out_is_for_client_pipe); } - - return cci_check_error (err); + + return cci_check_error (err); } @@ -227,13 +227,13 @@ cc_int32 ccs_callback_client_pipe (ccs_callback_t in_callback, ccs_pipe_t *out_client_pipe) { cc_int32 err = ccNoError; - + if (!in_callback ) { err = cci_check_error (ccErrBadParam); } if (!out_client_pipe) { err = cci_check_error (ccErrBadParam); } - + if (!err) { *out_client_pipe = in_callback->client_pipe; } - - return cci_check_error (err); + + return cci_check_error (err); } diff --git a/src/ccapi/server/ccs_ccache.c b/src/ccapi/server/ccs_ccache.c index d7662343a..c1e91bce8 100644 --- a/src/ccapi/server/ccs_ccache.c +++ b/src/ccapi/server/ccs_ccache.c @@ -56,43 +56,43 @@ cc_int32 ccs_ccache_new (ccs_ccache_t *out_ccache, { cc_int32 err = ccNoError; ccs_ccache_t ccache = NULL; - + if (!out_ccache ) { err = cci_check_error (ccErrBadParam); } if (!in_name ) { err = cci_check_error (ccErrBadParam); } if (!in_principal) { err = cci_check_error (ccErrBadParam); } - + if (!err) { ccache = malloc (sizeof (*ccache)); - if (ccache) { + if (ccache) { *ccache = ccs_ccache_initializer; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { err = ccs_server_new_identifier (&ccache->identifier); } - + if (!err) { err = ccs_lock_state_new (&ccache->lock_state, ccErrInvalidCCache, ccErrCCacheLocked, ccErrCCacheUnlocked); } - + if (!err) { ccache->name = strdup (in_name); if (!ccache->name) { err = cci_check_error (ccErrNoMem); } } - + if (!err) { ccache->creds_version = in_creds_version; if (ccache->creds_version == cc_credentials_v4) { ccache->v4_principal = strdup (in_principal); if (!ccache->v4_principal) { err = cci_check_error (ccErrNoMem); } - + } else if (ccache->creds_version == cc_credentials_v5) { ccache->v5_principal = strdup (in_principal); if (!ccache->v5_principal) { err = cci_check_error (ccErrNoMem); } @@ -101,43 +101,43 @@ cc_int32 ccs_ccache_new (ccs_ccache_t *out_ccache, err = cci_check_error (ccErrBadCredentialsVersion); } } - + if (!err) { err = ccs_credentials_list_new (&ccache->credentials); } - + if (!err) { err = ccs_callback_array_new (&ccache->change_callbacks); } - + if (!err) { cc_uint64 now = time (NULL); cc_uint64 count = 0; - + err = ccs_ccache_list_count (io_ccache_list, &count); - + if (!err) { /* first cache is default */ ccache->last_default_time = (count == 0) ? now : 0; - cci_debug_printf ("%s ccache->last_default_time is %d.", + cci_debug_printf ("%s ccache->last_default_time is %d.", __FUNCTION__, ccache->last_default_time); ccache->last_changed_time = now; } } - + if (!err) { /* Add self to the list of ccaches */ err = ccs_ccache_list_add (io_ccache_list, ccache); } - + if (!err) { *out_ccache = ccache; ccache = NULL; } - + ccs_ccache_release (ccache); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -151,41 +151,41 @@ cc_int32 ccs_ccache_reset (ccs_ccache_t io_ccache, char *v4_principal = NULL; char *v5_principal = NULL; ccs_credentials_list_t credentials = NULL; - + if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_principal ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { io_ccache->creds_version = in_creds_version; - + if (io_ccache->creds_version == cc_credentials_v4) { v4_principal = strdup (in_principal); if (!v4_principal) { err = cci_check_error (ccErrNoMem); } - + } else if (io_ccache->creds_version == cc_credentials_v5) { v5_principal = strdup (in_principal); if (!v5_principal) { err = cci_check_error (ccErrNoMem); } - + } else { err = cci_check_error (ccErrBadCredentialsVersion); } } - + if (!err) { err = ccs_credentials_list_new (&credentials); } - + if (!err) { io_ccache->kdc_time_offset_v4 = 0; io_ccache->kdc_time_offset_v4_valid = 0; io_ccache->kdc_time_offset_v5 = 0; io_ccache->kdc_time_offset_v5_valid = 0; - + if (io_ccache->v4_principal) { free (io_ccache->v4_principal); } io_ccache->v4_principal = v4_principal; v4_principal = NULL; /* take ownership */ - + if (io_ccache->v5_principal) { free (io_ccache->v5_principal); } io_ccache->v5_principal = v5_principal; v5_principal = NULL; /* take ownership */ @@ -193,51 +193,51 @@ cc_int32 ccs_ccache_reset (ccs_ccache_t io_ccache, ccs_credentials_list_release (io_ccache->credentials); io_ccache->credentials = credentials; credentials = NULL; /* take ownership */ - + err = ccs_ccache_changed (io_ccache, io_cache_collection); } - + free (v4_principal); free (v5_principal); ccs_credentials_list_release (credentials); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ -cc_int32 ccs_ccache_swap_contents (ccs_ccache_t io_source_ccache, +cc_int32 ccs_ccache_swap_contents (ccs_ccache_t io_source_ccache, ccs_ccache_t io_destination_ccache, ccs_cache_collection_t io_cache_collection) { cc_int32 err = ccNoError; - + if (!io_source_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_destination_ccache) { err = cci_check_error (ccErrBadParam); } - + if (!err) { struct ccs_ccache_d temp_ccache = *io_destination_ccache; - + /* swap everything */ *io_destination_ccache = *io_source_ccache; *io_source_ccache = temp_ccache; - + /* swap back the name and identifier */ io_source_ccache->identifier = io_destination_ccache->identifier; io_destination_ccache->identifier = temp_ccache.identifier; - + io_source_ccache->name = io_destination_ccache->name; io_destination_ccache->name = temp_ccache.name; } - + if (!err) { err = ccs_ccache_changed (io_source_ccache, io_cache_collection); } - + if (!err) { err = ccs_ccache_changed (io_destination_ccache, io_cache_collection); } - + return cci_check_error (err); } @@ -246,7 +246,7 @@ cc_int32 ccs_ccache_swap_contents (ccs_ccache_t io_source_ccache, cc_int32 ccs_ccache_release (ccs_ccache_t io_ccache) { cc_int32 err = ccNoError; - + if (!err && io_ccache) { cci_identifier_release (io_ccache->identifier); ccs_lock_state_release (io_ccache->lock_state); @@ -257,8 +257,8 @@ cc_int32 ccs_ccache_release (ccs_ccache_t io_ccache) ccs_callback_array_release (io_ccache->change_callbacks); free (io_ccache); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -272,17 +272,17 @@ cc_int32 ccs_ccache_compare_identifier (ccs_ccache_t in_ccache, cc_uint32 *out_equal) { cc_int32 err = ccNoError; - + if (!in_ccache ) { 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_ccache->identifier, - in_identifier, + err = cci_identifier_compare (in_ccache->identifier, + in_identifier, out_equal); } - + return cci_check_error (err); } @@ -293,15 +293,15 @@ cc_int32 ccs_ccache_compare_name (ccs_ccache_t in_ccache, cc_uint32 *out_equal) { cc_int32 err = ccNoError; - + if (!in_ccache) { err = cci_check_error (ccErrBadParam); } if (!in_name ) { err = cci_check_error (ccErrBadParam); } if (!out_equal) { err = cci_check_error (ccErrBadParam); } - + if (!err) { *out_equal = (strcmp (in_ccache->name, in_name) == 0); } - + return cci_check_error (err); } @@ -316,28 +316,28 @@ cc_int32 ccs_ccache_changed (ccs_ccache_t io_ccache, { cc_int32 err = ccNoError; k5_ipc_stream reply_data = NULL; - + if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } - + if (!err) { cc_time_t now = time (NULL); - + if (io_ccache->last_changed_time < now) { io_ccache->last_changed_time = now; } else { io_ccache->last_changed_time++; } } - + if (!err) { err = ccs_cache_collection_changed (io_cache_collection); } - + if (!err) { err = krb5int_ipc_stream_new (&reply_data); } - + if (!err) { err = krb5int_ipc_stream_write_time (reply_data, io_ccache->last_changed_time); } @@ -346,12 +346,12 @@ cc_int32 ccs_ccache_changed (ccs_ccache_t io_ccache, /* Loop over callbacks sending messages to them */ cc_uint64 i; cc_uint64 count = ccs_callback_array_count (io_ccache->change_callbacks); - + for (i = 0; !err && i < count; i++) { ccs_callback_t callback = ccs_callback_array_object_at_index (io_ccache->change_callbacks, i); - + err = ccs_callback_reply_to_client (callback, reply_data); - + if (!err) { cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback); err = ccs_callback_array_remove (io_ccache->change_callbacks, i); @@ -359,14 +359,14 @@ cc_int32 ccs_ccache_changed (ccs_ccache_t io_ccache, } } } - + if (!err) { - err = ccs_os_notify_ccache_changed (io_cache_collection, + err = ccs_os_notify_ccache_changed (io_cache_collection, io_ccache->name); } - + krb5int_ipc_stream_release (reply_data); - + return cci_check_error (err); } @@ -376,19 +376,19 @@ static cc_int32 ccs_ccache_invalidate_change_callback (ccs_callback_owner_t io_c ccs_callback_t in_callback) { cc_int32 err = ccNoError; - + if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!in_callback) { err = cci_check_error (ccErrBadParam); } - + if (!err) { /* Remove callback */ ccs_ccache_t ccache = (ccs_ccache_t) io_ccache; cc_uint64 i; cc_uint64 count = ccs_callback_array_count (ccache->change_callbacks); - + for (i = 0; !err && i < count; i++) { ccs_callback_t callback = ccs_callback_array_object_at_index (ccache->change_callbacks, i); - + if (callback == in_callback) { cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback); err = ccs_callback_array_remove (ccache->change_callbacks, i); @@ -396,7 +396,7 @@ static cc_int32 ccs_ccache_invalidate_change_callback (ccs_callback_owner_t io_c } } } - + return cci_check_error (err); } @@ -407,24 +407,24 @@ cc_int32 ccs_ccache_notify_default_state_changed (ccs_ccache_t io_ccac cc_uint32 in_new_default_state) { cc_int32 err = ccNoError; - + if (!io_ccache ) { err = cci_check_error (ccErrBadParam); } if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } - + if (!err && in_new_default_state) { cc_time_t now = time (NULL); - + if (io_ccache->last_default_time < now) { io_ccache->last_default_time = now; } else { io_ccache->last_default_time++; } } - + if (!err) { err = ccs_ccache_changed (io_ccache, io_cache_collection); } - + return cci_check_error (err); } @@ -439,17 +439,17 @@ cc_int32 ccs_ccache_find_credentials_iterator (ccs_ccache_t in_cc 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); } @@ -464,15 +464,15 @@ cc_int32 ccs_ccache_write (ccs_ccache_t in_ccache, k5_ipc_stream io_stream) { cc_int32 err = ccNoError; - + if (!in_ccache) { err = cci_check_error (ccErrBadParam); } if (!io_stream) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = cci_identifier_write (in_ccache->identifier, io_stream); } - - return cci_check_error (err); + + return cci_check_error (err); } @@ -482,15 +482,15 @@ cc_int32 ccs_ccache_write_name (ccs_ccache_t in_ccache, k5_ipc_stream io_stream) { cc_int32 err = ccNoError; - + if (!in_ccache) { err = cci_check_error (ccErrBadParam); } if (!io_stream) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = krb5int_ipc_stream_write_string (io_stream, in_ccache->name); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -506,23 +506,23 @@ static cc_int32 ccs_ccache_destroy (ccs_ccache_t io_ccache, 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_destroy_ccache (io_cache_collection, + err = ccs_cache_collection_destroy_ccache (io_cache_collection, io_ccache->identifier); } - + if (!err) { /* ccache has been destroyed so just mark the cache collection */ err = ccs_cache_collection_changed (io_cache_collection); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -533,18 +533,18 @@ static cc_int32 ccs_ccache_set_default (ccs_ccache_t io_ccache, 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, + err = ccs_cache_collection_set_default_ccache (io_cache_collection, io_ccache->identifier); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -555,17 +555,17 @@ static cc_int32 ccs_ccache_get_credentials_version (ccs_ccache_t io_cc 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 = krb5int_ipc_stream_write_uint32 (io_reply_data, io_ccache->creds_version); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -576,17 +576,17 @@ static cc_int32 ccs_ccache_get_name (ccs_ccache_t io_ccache, 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 = krb5int_ipc_stream_write_string (io_reply_data, io_ccache->name); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -598,33 +598,33 @@ static cc_int32 ccs_ccache_get_principal (ccs_ccache_t io_ccache, { cc_int32 err = ccNoError; cc_uint32 version = 0; - + 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 = krb5int_ipc_stream_read_uint32 (in_request_data, &version); } - + if (!err && version == cc_credentials_v4_v5) { err = cci_check_error (ccErrBadCredentialsVersion); } - + if (!err) { if (version == cc_credentials_v4) { err = krb5int_ipc_stream_write_string (io_reply_data, io_ccache->v4_principal); - + } else if (version == cc_credentials_v5) { err = krb5int_ipc_stream_write_string (io_reply_data, io_ccache->v5_principal); - + } else { err = cci_check_error (ccErrBadCredentialsVersion); } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -637,35 +637,35 @@ static cc_int32 ccs_ccache_set_principal (ccs_ccache_t io_ccache, cc_int32 err = ccNoError; cc_uint32 version = 0; char *principal = NULL; - + 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 = krb5int_ipc_stream_read_uint32 (in_request_data, &version); } - + if (!err) { err = krb5int_ipc_stream_read_string (in_request_data, &principal); } - + if (!err) { /* reset KDC time offsets because they are per-KDC */ if (version == cc_credentials_v4) { io_ccache->kdc_time_offset_v4 = 0; io_ccache->kdc_time_offset_v4_valid = 0; - + if (io_ccache->v4_principal) { free (io_ccache->v4_principal); } io_ccache->v4_principal = principal; principal = NULL; /* take ownership */ - - + + } else if (version == cc_credentials_v5) { io_ccache->kdc_time_offset_v5 = 0; io_ccache->kdc_time_offset_v5_valid = 0; - + if (io_ccache->v5_principal) { free (io_ccache->v5_principal); } io_ccache->v5_principal = principal; principal = NULL; /* take ownership */ @@ -674,16 +674,16 @@ static cc_int32 ccs_ccache_set_principal (ccs_ccache_t io_ccache, err = cci_check_error (ccErrBadCredentialsVersion); } } - + if (!err) { io_ccache->creds_version |= version; - + err = ccs_ccache_changed (io_ccache, io_cache_collection); } - + krb5int_ipc_stream_free_string (principal); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -695,24 +695,24 @@ static cc_int32 ccs_ccache_store_credentials (ccs_ccache_t io_ccache, { cc_int32 err = ccNoError; ccs_credentials_t credentials = NULL; - + 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_credentials_new (&credentials, in_request_data, - io_ccache->creds_version, + err = ccs_credentials_new (&credentials, in_request_data, + io_ccache->creds_version, io_ccache->credentials); } - + if (!err) { err = ccs_ccache_changed (io_ccache, io_cache_collection); } - - - return cci_check_error (err); + + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -724,27 +724,27 @@ static cc_int32 ccs_ccache_remove_credentials (ccs_ccache_t io_ccache, { cc_int32 err = ccNoError; cci_identifier_t credentials_identifier = NULL; - + 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 = cci_identifier_read (&credentials_identifier, in_request_data); } - + if (!err) { err = ccs_credentials_list_remove (io_ccache->credentials, credentials_identifier); } - + if (!err) { err = ccs_ccache_changed (io_ccache, io_cache_collection); } - + cci_identifier_release (credentials_identifier); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -757,23 +757,23 @@ static cc_int32 ccs_ccache_new_credentials_iterator (ccs_ccache_t io_c { cc_int32 err = ccNoError; ccs_credentials_iterator_t credentials_iterator = NULL; - + 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_credentials_list_new_iterator (io_ccache->credentials, in_client_pipe, &credentials_iterator); } - + if (!err) { err = ccs_credentials_list_iterator_write (credentials_iterator, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -785,31 +785,31 @@ static cc_int32 ccs_ccache_move (ccs_ccache_t io_ccache, { cc_int32 err = ccNoError; cci_identifier_t source_identifier = NULL; - + 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) { /* Note: message is sent as the destination ccache to avoid */ /* extra work on the server when deleting it the source ccache. */ err = cci_identifier_read (&source_identifier, in_request_data); } - + if (!err) { err = ccs_ccache_collection_move_ccache (io_cache_collection, - source_identifier, + source_identifier, io_ccache); } - + if (!err) { err = ccs_ccache_changed (io_ccache, io_cache_collection); } - + cci_identifier_release (source_identifier); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -825,29 +825,29 @@ static cc_int32 ccs_ccache_lock (ccs_pipe_t in_client_pipe, cc_int32 err = ccNoError; cc_uint32 lock_type; cc_uint32 block; - + if (!ccs_pipe_valid (in_client_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 (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = krb5int_ipc_stream_read_uint32 (in_request_data, &lock_type); } - + if (!err) { err = krb5int_ipc_stream_read_uint32 (in_request_data, &block); } - + if (!err) { - err = ccs_lock_state_add (io_ccache->lock_state, - in_client_pipe, in_reply_pipe, + err = ccs_lock_state_add (io_ccache->lock_state, + in_client_pipe, in_reply_pipe, lock_type, block, out_will_block); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -859,18 +859,18 @@ static cc_int32 ccs_ccache_unlock (ccs_pipe_t in_client_pipe, k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; - + if (!ccs_pipe_valid (in_client_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 (!io_reply_data ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_lock_state_remove (io_ccache->lock_state, in_client_pipe); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -881,21 +881,21 @@ static cc_int32 ccs_ccache_get_last_default_time (ccs_ccache_t io_ccac 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 && io_ccache->last_default_time == 0) { err = cci_check_error (ccErrNeverDefault); } - + if (!err) { err = krb5int_ipc_stream_write_time (io_reply_data, io_ccache->last_default_time); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -906,17 +906,17 @@ static cc_int32 ccs_ccache_get_change_time (ccs_ccache_t io_ccache, 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 = krb5int_ipc_stream_write_time (io_reply_data, io_ccache->last_changed_time); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -932,51 +932,51 @@ static cc_int32 ccs_ccache_wait_for_change (ccs_pipe_t in_client_pi 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, + 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); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -988,16 +988,16 @@ static cc_int32 ccs_ccache_get_kdc_time_offset (ccs_ccache_t io_ccache { cc_int32 err = ccNoError; cc_uint32 cred_vers = 0; - + 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 = krb5int_ipc_stream_read_uint32 (in_request_data, &cred_vers); } - + if (!err) { if (cred_vers == cc_credentials_v4) { if (io_ccache->kdc_time_offset_v4_valid) { @@ -1005,20 +1005,20 @@ static cc_int32 ccs_ccache_get_kdc_time_offset (ccs_ccache_t io_ccache } else { err = cci_check_error (ccErrTimeOffsetNotSet); } - + } else if (cred_vers == cc_credentials_v5) { if (io_ccache->kdc_time_offset_v5_valid) { err = krb5int_ipc_stream_write_time (io_reply_data, io_ccache->kdc_time_offset_v5); } else { err = cci_check_error (ccErrTimeOffsetNotSet); } - + } else { err = cci_check_error (ccErrBadCredentialsVersion); } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -1030,26 +1030,26 @@ static cc_int32 ccs_ccache_set_kdc_time_offset (ccs_ccache_t io_ccache { cc_int32 err = ccNoError; cc_uint32 cred_vers = 0; - + 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 = krb5int_ipc_stream_read_uint32 (in_request_data, &cred_vers); } - + if (!err) { if (cred_vers == cc_credentials_v4) { err = krb5int_ipc_stream_read_time (in_request_data, &io_ccache->kdc_time_offset_v4); - + if (!err) { io_ccache->kdc_time_offset_v4_valid = 1; } } else if (cred_vers == cc_credentials_v5) { err = krb5int_ipc_stream_read_time (in_request_data, &io_ccache->kdc_time_offset_v5); - + if (!err) { io_ccache->kdc_time_offset_v5_valid = 1; } @@ -1057,12 +1057,12 @@ static cc_int32 ccs_ccache_set_kdc_time_offset (ccs_ccache_t io_ccache err = cci_check_error (ccErrBadCredentialsVersion); } } - + if (!err) { err = ccs_ccache_changed (io_ccache, io_cache_collection); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -1074,35 +1074,35 @@ static cc_int32 ccs_ccache_clear_kdc_time_offset (ccs_ccache_t io_ccac { cc_int32 err = ccNoError; cc_uint32 cred_vers = 0; - + 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 = krb5int_ipc_stream_read_uint32 (in_request_data, &cred_vers); } - + if (!err) { if (cred_vers == cc_credentials_v4) { io_ccache->kdc_time_offset_v4 = 0; io_ccache->kdc_time_offset_v4_valid = 0; - + } else if (cred_vers == cc_credentials_v5) { io_ccache->kdc_time_offset_v5 = 0; io_ccache->kdc_time_offset_v5_valid = 0; - + } else { err = cci_check_error (ccErrBadCredentialsVersion); } } - + if (!err) { err = ccs_ccache_changed (io_ccache, io_cache_collection); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -1123,104 +1123,104 @@ cc_int32 ccs_ccache_handle_message (ccs_pipe_t in_client_pipe, cc_int32 err = ccNoError; cc_uint32 will_block = 0; k5_ipc_stream reply_data = NULL; - + 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_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 (!out_reply_data ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = krb5int_ipc_stream_new (&reply_data); } - + if (!err) { if (in_request_name == cci_ccache_destroy_msg_id) { err = ccs_ccache_destroy (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_set_default_msg_id) { err = ccs_ccache_set_default (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_get_credentials_version_msg_id) { err = ccs_ccache_get_credentials_version (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_get_name_msg_id) { err = ccs_ccache_get_name (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_get_principal_msg_id) { err = ccs_ccache_get_principal (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_set_principal_msg_id) { err = ccs_ccache_set_principal (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_store_credentials_msg_id) { err = ccs_ccache_store_credentials (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_remove_credentials_msg_id) { err = ccs_ccache_remove_credentials (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_new_credentials_iterator_msg_id) { - err = ccs_ccache_new_credentials_iterator (io_ccache, + err = ccs_ccache_new_credentials_iterator (io_ccache, io_cache_collection, in_client_pipe, - in_request_data, + in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_move_msg_id) { err = ccs_ccache_move (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_lock_msg_id) { - err = ccs_ccache_lock (in_client_pipe, in_reply_pipe, + err = ccs_ccache_lock (in_client_pipe, in_reply_pipe, io_ccache, io_cache_collection, - in_request_data, + in_request_data, &will_block, reply_data); - + } else if (in_request_name == cci_ccache_unlock_msg_id) { - err = ccs_ccache_unlock (in_client_pipe, + err = ccs_ccache_unlock (in_client_pipe, io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_get_last_default_time_msg_id) { err = ccs_ccache_get_last_default_time (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_get_change_time_msg_id) { err = ccs_ccache_get_change_time (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_wait_for_change_msg_id) { - err = ccs_ccache_wait_for_change (in_client_pipe, in_reply_pipe, + err = ccs_ccache_wait_for_change (in_client_pipe, in_reply_pipe, io_ccache, io_cache_collection, in_request_data, reply_data, &will_block); - + } else if (in_request_name == cci_ccache_get_kdc_time_offset_msg_id) { err = ccs_ccache_get_kdc_time_offset (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_set_kdc_time_offset_msg_id) { err = ccs_ccache_set_kdc_time_offset (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_clear_kdc_time_offset_msg_id) { err = ccs_ccache_clear_kdc_time_offset (io_ccache, io_cache_collection, in_request_data, reply_data); - + } else { err = ccErrBadInternalMessage; } } - + if (!err) { *out_will_block = will_block; if (!will_block) { @@ -1230,9 +1230,8 @@ cc_int32 ccs_ccache_handle_message (ccs_pipe_t in_client_pipe, *out_reply_data = NULL; } } - + krb5int_ipc_stream_release (reply_data); - + return cci_check_error (err); } - diff --git a/src/ccapi/server/ccs_ccache.h b/src/ccapi/server/ccs_ccache.h index 21c9f410f..9d4e607a8 100644 --- a/src/ccapi/server/ccs_ccache.h +++ b/src/ccapi/server/ccs_ccache.h @@ -40,7 +40,7 @@ cc_int32 ccs_ccache_reset (ccs_ccache_t io_ccache, cc_uint32 in_cred_vers, const char *in_principal); -cc_int32 ccs_ccache_swap_contents (ccs_ccache_t io_source_ccache, +cc_int32 ccs_ccache_swap_contents (ccs_ccache_t io_source_ccache, ccs_ccache_t io_destination_ccache, ccs_cache_collection_t io_cache_collection); diff --git a/src/ccapi/server/ccs_ccache_iterator.c b/src/ccapi/server/ccs_ccache_iterator.c index fb007bf6b..045ad3d09 100644 --- a/src/ccapi/server/ccs_ccache_iterator.c +++ b/src/ccapi/server/ccs_ccache_iterator.c @@ -34,17 +34,17 @@ static cc_int32 ccs_ccache_iterator_release (ccs_ccache_iterator_t io_ccache_i 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); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -56,21 +56,21 @@ static cc_int32 ccs_ccache_iterator_next (ccs_ccache_iterator_t io_ccache_iter { cc_int32 err = ccNoError; ccs_ccache_t ccache = NULL; - + 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_next (io_ccache_iterator, &ccache); } - + if (!err) { err = ccs_ccache_write (ccache, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -82,22 +82,22 @@ static cc_int32 ccs_ccache_iterator_clone (ccs_ccache_iterator_t io_ccache_ite { cc_int32 err = ccNoError; ccs_ccache_iterator_t ccache_iterator = NULL; - + 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_clone (io_ccache_iterator, &ccache_iterator); } - + if (!err) { err = ccs_ccache_list_iterator_write (ccache_iterator, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -114,45 +114,44 @@ static cc_int32 ccs_ccache_iterator_clone (ccs_ccache_iterator_t io_ccache_ite { cc_int32 err = ccNoError; k5_ipc_stream reply_data = NULL; - + if (!in_request_data) { err = cci_check_error (ccErrBadParam); } if (!out_reply_data ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = krb5int_ipc_stream_new (&reply_data); } - + if (!err) { if (in_request_name == cci_ccache_iterator_release_msg_id) { err = ccs_ccache_iterator_release (io_ccache_iterator, io_cache_collection, - in_request_data, + in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_iterator_next_msg_id) { err = ccs_ccache_iterator_next (io_ccache_iterator, io_cache_collection, - in_request_data, + in_request_data, reply_data); - + } else if (in_request_name == cci_ccache_iterator_clone_msg_id) { err = ccs_ccache_iterator_clone (io_ccache_iterator, io_cache_collection, - in_request_data, + in_request_data, reply_data); - + } else { err = ccErrBadInternalMessage; } } - + if (!err) { *out_reply_data = reply_data; reply_data = NULL; /* take ownership */ } - + krb5int_ipc_stream_release (reply_data); - + return cci_check_error (err); } - diff --git a/src/ccapi/server/ccs_client.c b/src/ccapi/server/ccs_client.c index 31ed14ff4..72ae89de1 100644 --- a/src/ccapi/server/ccs_client.c +++ b/src/ccapi/server/ccs_client.c @@ -43,39 +43,39 @@ cc_int32 ccs_client_new (ccs_client_t *out_client, { cc_int32 err = ccNoError; ccs_client_t client = NULL; - + if (!out_client ) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } - + if (!err) { client = malloc (sizeof (*client)); - if (client) { + if (client) { *client = ccs_client_initializer; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { err = ccs_callbackref_array_new (&client->callbacks); } - + if (!err) { err = ccs_iteratorref_array_new (&client->iterators); } - + if (!err) { err = ccs_pipe_copy (&client->client_pipe, in_client_pipe); } - + if (!err) { *out_client = client; client = NULL; } - + ccs_client_release (client); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -83,26 +83,26 @@ cc_int32 ccs_client_new (ccs_client_t *out_client, cc_int32 ccs_client_release (ccs_client_t io_client) { cc_int32 err = ccNoError; - + if (!err && io_client) { cc_uint64 i; cc_uint64 callback_count = ccs_callbackref_array_count (io_client->callbacks); cc_uint64 iterator_count = ccs_iteratorref_array_count (io_client->iterators); - + for (i = 0; !err && i < callback_count; i++) { ccs_callback_t callback = ccs_callbackref_array_object_at_index (io_client->callbacks, i); - - cci_debug_printf ("%s: Invalidating callback reference %p.", + + cci_debug_printf ("%s: Invalidating callback reference %p.", __FUNCTION__, callback); ccs_callback_invalidate (callback); } - + for (i = 0; !err && i < iterator_count; i++) { ccs_generic_list_iterator_t iterator = ccs_iteratorref_array_object_at_index (io_client->iterators, i); - - cci_debug_printf ("%s: Invalidating iterator reference %p.", + + cci_debug_printf ("%s: Invalidating iterator reference %p.", __FUNCTION__, iterator); - ccs_generic_list_iterator_invalidate (iterator); + ccs_generic_list_iterator_invalidate (iterator); } ccs_callbackref_array_release (io_client->callbacks); @@ -110,8 +110,8 @@ cc_int32 ccs_client_release (ccs_client_t io_client) ccs_pipe_release (io_client->client_pipe); free (io_client); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -120,16 +120,16 @@ cc_int32 ccs_client_add_callback (ccs_client_t io_client, ccs_callback_t in_callback) { cc_int32 err = ccNoError; - + if (!io_client ) { err = cci_check_error (ccErrBadParam); } if (!in_callback) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_callbackref_array_insert (io_client->callbacks, in_callback, ccs_callbackref_array_count (io_client->callbacks)); } - - return cci_check_error (err); + + return cci_check_error (err); } @@ -140,16 +140,16 @@ cc_int32 ccs_client_remove_callback (ccs_client_t io_client, { cc_int32 err = ccNoError; cc_uint32 found_callback = 0; - + if (!io_client) { err = cci_check_error (ccErrBadParam); } - + if (!err) { cc_uint64 i; cc_uint64 lock_count = ccs_callbackref_array_count (io_client->callbacks); - + for (i = 0; !err && i < lock_count; i++) { ccs_callback_t callback = ccs_callbackref_array_object_at_index (io_client->callbacks, i); - + if (callback == in_callback) { cci_debug_printf ("%s: Removing callback reference %p.", __FUNCTION__, callback); found_callback = 1; @@ -158,12 +158,12 @@ cc_int32 ccs_client_remove_callback (ccs_client_t io_client, } } } - + if (!err && !found_callback) { cci_debug_printf ("%s: WARNING! callback not found.", __FUNCTION__); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -172,16 +172,16 @@ cc_int32 ccs_client_add_iterator (ccs_client_t io_client, ccs_generic_list_iterator_t in_iterator) { cc_int32 err = ccNoError; - + if (!io_client ) { err = cci_check_error (ccErrBadParam); } if (!in_iterator) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_iteratorref_array_insert (io_client->iterators, in_iterator, ccs_iteratorref_array_count (io_client->iterators)); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -191,16 +191,16 @@ cc_int32 ccs_client_remove_iterator (ccs_client_t io_client, { cc_int32 err = ccNoError; cc_uint32 found_iterator = 0; - + if (!io_client) { err = cci_check_error (ccErrBadParam); } - + if (!err) { cc_uint64 i; cc_uint64 lock_count = ccs_iteratorref_array_count (io_client->iterators); - + for (i = 0; !err && i < lock_count; i++) { ccs_generic_list_iterator_t iterator = ccs_iteratorref_array_object_at_index (io_client->iterators, i); - + if (iterator == in_iterator) { cci_debug_printf ("%s: Removing iterator reference %p.", __FUNCTION__, iterator); found_iterator = 1; @@ -209,12 +209,12 @@ cc_int32 ccs_client_remove_iterator (ccs_client_t io_client, } } } - + if (!err && !found_iterator) { cci_debug_printf ("%s: WARNING! iterator not found.", __FUNCTION__); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -224,14 +224,14 @@ cc_int32 ccs_client_uses_pipe (ccs_client_t in_client, cc_uint32 *out_uses_pipe) { cc_int32 err = ccNoError; - + if (!in_client ) { err = cci_check_error (ccErrBadParam); } if (!in_pipe ) { err = cci_check_error (ccErrBadParam); } if (!out_uses_pipe) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_pipe_compare (in_client->client_pipe, in_pipe, out_uses_pipe); } - - return cci_check_error (err); + + return cci_check_error (err); } diff --git a/src/ccapi/server/ccs_credentials.c b/src/ccapi/server/ccs_credentials.c index 56b5a5799..9795ef86f 100644 --- a/src/ccapi/server/ccs_credentials.c +++ b/src/ccapi/server/ccs_credentials.c @@ -42,44 +42,44 @@ cc_int32 ccs_credentials_new (ccs_credentials_t *out_credentials, { cc_int32 err = ccNoError; ccs_credentials_t credentials = NULL; - + if (!out_credentials) { err = cci_check_error (ccErrBadParam); } if (!in_stream ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { credentials = malloc (sizeof (*credentials)); - if (credentials) { + if (credentials) { *credentials = ccs_credentials_initializer; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { err = cci_credentials_union_read (&credentials->cred_union, in_stream); } - + if (!err && !(credentials->cred_union->version & in_ccache_version)) { /* ccache does not have a principal set for this credentials version */ err = cci_check_error (ccErrBadCredentialsVersion); } - + if (!err) { err = ccs_server_new_identifier (&credentials->identifier); } - + if (!err) { err = ccs_credentials_list_add (io_credentials_list, credentials); } - + if (!err) { *out_credentials = credentials; credentials = NULL; } - + ccs_credentials_release (credentials); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -87,14 +87,14 @@ cc_int32 ccs_credentials_new (ccs_credentials_t *out_credentials, cc_int32 ccs_credentials_release (ccs_credentials_t io_credentials) { cc_int32 err = ccNoError; - + if (!err && io_credentials) { cci_credentials_union_release (io_credentials->cred_union); cci_identifier_release (io_credentials->identifier); free (io_credentials); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -103,19 +103,19 @@ cc_int32 ccs_credentials_write (ccs_credentials_t in_credentials, k5_ipc_stream io_stream) { cc_int32 err = ccNoError; - + if (!in_credentials) { err = cci_check_error (ccErrBadParam); } if (!io_stream ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = cci_identifier_write (in_credentials->identifier, io_stream); } - + if (!err) { err = cci_credentials_union_write (in_credentials->cred_union, io_stream); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -125,16 +125,16 @@ cc_int32 ccs_credentials_compare_identifier (ccs_credentials_t in_credentials, cc_uint32 *out_equal) { cc_int32 err = ccNoError; - + if (!in_credentials) { 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_credentials->identifier, - in_identifier, + err = cci_identifier_compare (in_credentials->identifier, + in_identifier, out_equal); } - + return cci_check_error (err); } diff --git a/src/ccapi/server/ccs_credentials_iterator.c b/src/ccapi/server/ccs_credentials_iterator.c index 3ca7eeeea..27751ed75 100644 --- a/src/ccapi/server/ccs_credentials_iterator.c +++ b/src/ccapi/server/ccs_credentials_iterator.c @@ -34,17 +34,17 @@ static cc_int32 ccs_credentials_iterator_release (ccs_credentials_iterator_t io_ k5_ipc_stream io_reply_data) { cc_int32 err = ccNoError; - + if (!io_credentials_iterator) { err = cci_check_error (ccErrBadParam); } if (!io_ccache ) { 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_credentials_list_iterator_release (io_credentials_iterator); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -56,22 +56,22 @@ static cc_int32 ccs_credentials_iterator_next (ccs_credentials_iterator_t io_cre { cc_int32 err = ccNoError; ccs_credentials_t credentials = NULL; - + if (!io_credentials_iterator) { err = cci_check_error (ccErrBadParam); } if (!io_ccache ) { 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_credentials_list_iterator_next (io_credentials_iterator, &credentials); } - + if (!err) { err = ccs_credentials_write (credentials, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -83,23 +83,23 @@ static cc_int32 ccs_credentials_iterator_clone (ccs_credentials_iterator_t io_c { cc_int32 err = ccNoError; ccs_credentials_iterator_t credentials_iterator = NULL; - + if (!io_credentials_iterator) { err = cci_check_error (ccErrBadParam); } if (!io_ccache ) { 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_credentials_list_iterator_clone (io_credentials_iterator, &credentials_iterator); } - + if (!err) { - err = ccs_credentials_list_iterator_write (credentials_iterator, + err = ccs_credentials_list_iterator_write (credentials_iterator, io_reply_data); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -116,45 +116,44 @@ static cc_int32 ccs_credentials_iterator_clone (ccs_credentials_iterator_t io_c { cc_int32 err = ccNoError; k5_ipc_stream reply_data = NULL; - + if (!in_request_data) { err = cci_check_error (ccErrBadParam); } if (!out_reply_data ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = krb5int_ipc_stream_new (&reply_data); } - + if (!err) { if (in_request_name == cci_credentials_iterator_release_msg_id) { err = ccs_credentials_iterator_release (io_credentials_iterator, io_ccache, in_request_data, reply_data); - + } else if (in_request_name == cci_credentials_iterator_next_msg_id) { err = ccs_credentials_iterator_next (io_credentials_iterator, io_ccache, in_request_data, reply_data); - + } else if (in_request_name == cci_credentials_iterator_clone_msg_id) { err = ccs_credentials_iterator_clone (io_credentials_iterator, io_ccache, in_request_data, reply_data); - + } else { err = ccErrBadInternalMessage; } } - + if (!err) { *out_reply_data = reply_data; reply_data = NULL; /* take ownership */ } - + krb5int_ipc_stream_release (reply_data); - + return cci_check_error (err); } - diff --git a/src/ccapi/server/ccs_list.c b/src/ccapi/server/ccs_list.c index c5b1eb421..8896734b8 100644 --- a/src/ccapi/server/ccs_list.c +++ b/src/ccapi/server/ccs_list.c @@ -49,7 +49,7 @@ static cc_int32 ccs_cache_collection_list_object_compare_identifier (ccs_list_ob cc_int32 ccs_cache_collection_list_new (ccs_cache_collection_list_t *out_list) { - return ccs_list_new (out_list, + return ccs_list_new (out_list, ccErrInvalidContext, ccErrInvalidContext, ccs_cache_collection_list_object_compare_identifier, @@ -122,7 +122,7 @@ static cc_int32 ccs_ccache_list_object_compare_identifier (ccs_list_object_t in cc_int32 ccs_ccache_list_new (ccs_ccache_list_t *out_list) { - return ccs_list_new (out_list, + return ccs_list_new (out_list, ccErrInvalidCCache, ccErrInvalidCCacheIterator, ccs_ccache_list_object_compare_identifier, @@ -161,7 +161,7 @@ cc_int32 ccs_ccache_list_find_iterator (ccs_ccache_list_t in_list, cci_identifier_t in_identifier, ccs_ccache_list_iterator_t *out_list_iterator) { - return ccs_list_find_iterator (in_list, in_identifier, + return ccs_list_find_iterator (in_list, in_identifier, (ccs_list_iterator_t *) out_list_iterator); } @@ -201,7 +201,7 @@ cc_int32 ccs_ccache_list_release (ccs_ccache_list_t io_list) cc_int32 ccs_ccache_list_iterator_write (ccs_ccache_list_iterator_t in_list_iterator, k5_ipc_stream in_stream) { - return ccs_list_iterator_write (in_list_iterator, in_stream); + return ccs_list_iterator_write (in_list_iterator, in_stream); } /* ------------------------------------------------------------------------ */ @@ -253,8 +253,8 @@ static cc_int32 ccs_credentials_list_object_compare_identifier (ccs_list_object_ cc_int32 ccs_credentials_list_new (ccs_credentials_list_t *out_list) { - return ccs_list_new (out_list, - ccErrInvalidCredentials, + return ccs_list_new (out_list, + ccErrInvalidCredentials, ccErrInvalidCredentialsIterator, ccs_credentials_list_object_compare_identifier, ccs_credentials_list_object_release); @@ -292,7 +292,7 @@ cc_int32 ccs_credentials_list_find_iterator (ccs_credentials_list_t in cci_identifier_t in_identifier, ccs_credentials_list_iterator_t *out_list_iterator) { - return ccs_list_find_iterator (in_list, in_identifier, + return ccs_list_find_iterator (in_list, in_identifier, (ccs_list_iterator_t *) out_list_iterator); } @@ -324,7 +324,7 @@ cc_int32 ccs_credentials_list_release (ccs_credentials_list_t io_list) cc_int32 ccs_credentials_list_iterator_write (ccs_credentials_list_iterator_t in_list_iterator, k5_ipc_stream in_stream) { - return ccs_list_iterator_write (in_list_iterator, in_stream); + return ccs_list_iterator_write (in_list_iterator, in_stream); } /* ------------------------------------------------------------------------ */ diff --git a/src/ccapi/server/ccs_list_internal.c b/src/ccapi/server/ccs_list_internal.c index 74bc45a6a..834a7bc47 100644 --- a/src/ccapi/server/ccs_list_internal.c +++ b/src/ccapi/server/ccs_list_internal.c @@ -84,37 +84,37 @@ cc_int32 ccs_list_new (ccs_list_t *out_list, { cc_int32 err = ccNoError; ccs_list_t list = NULL; - + if (!out_list) { err = cci_check_error (ccErrBadParam); } - + if (!err) { list = malloc (sizeof (*list)); - if (list) { + if (list) { *list = ccs_list_initializer; list->object_not_found_err = in_object_not_found_err; list->iterator_not_found_err = in_iterator_not_found_err; list->object_compare_identifier = in_object_compare_identifier; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { err = cci_array_new (&list->objects, in_object_release); } - + if (!err) { err = cci_array_new (&list->iterators, ccs_list_iterator_object_release); } - + if (!err) { *out_list = list; list = NULL; } - + ccs_list_release (list); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -122,14 +122,14 @@ cc_int32 ccs_list_new (ccs_list_t *out_list, cc_int32 ccs_list_release (ccs_list_t io_list) { cc_int32 err = ccNoError; - - if (!err && io_list) { + + if (!err && io_list) { cci_array_release (io_list->iterators); cci_array_release (io_list->objects); free (io_list); } - - return err; + + return err; } /* ------------------------------------------------------------------------ */ @@ -138,8 +138,8 @@ cc_int32 ccs_list_new_iterator (ccs_list_t io_list, ccs_pipe_t in_client_pipe, ccs_list_iterator_t *out_list_iterator) { - return cci_check_error (ccs_list_iterator_new (out_list_iterator, - io_list, + return cci_check_error (ccs_list_iterator_new (out_list_iterator, + io_list, in_client_pipe)); } @@ -150,19 +150,19 @@ cc_int32 ccs_list_release_iterator (ccs_list_t io_list, { 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); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -171,15 +171,15 @@ cc_int32 ccs_list_count (ccs_list_t in_list, cc_uint64 *out_count) { cc_int32 err = ccNoError; - + if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!out_count) { err = cci_check_error (ccErrBadParam); } - + if (!err) { *out_count = cci_array_count (in_list->objects); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -187,7 +187,7 @@ cc_int32 ccs_list_count (ccs_list_t in_list, static ccs_list_iterator_t ccs_list_iterator_at_index (ccs_list_t in_list, cc_uint64 in_index) { - return (ccs_list_iterator_t) cci_array_object_at_index (in_list->iterators, in_index); + return (ccs_list_iterator_t) cci_array_object_at_index (in_list->iterators, in_index); } /* ------------------------------------------------------------------------ */ @@ -198,33 +198,33 @@ static cc_int32 ccs_list_find_index (ccs_list_t in_list, { cc_int32 err = ccNoError; cc_int32 found = 0; - + if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_object_index) { err = cci_check_error (ccErrBadParam); } - + if (!err && !found) { cc_uint64 i; - + for (i = 0; !err && i < cci_array_count (in_list->objects); i++) { cc_uint32 equal = 0; cci_array_object_t object = cci_array_object_at_index (in_list->objects, i); - + err = in_list->object_compare_identifier (object, in_identifier, &equal); - + if (!err && equal) { found = 1; *out_object_index = i; break; } - } + } } - + if (!err && !found) { - err = cci_check_error (in_list->object_not_found_err); + err = cci_check_error (in_list->object_not_found_err); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -234,20 +234,20 @@ cc_int32 ccs_list_find (ccs_list_t in_list, { cc_int32 err = ccNoError; cc_uint64 i; - + if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier) { err = cci_check_error (ccErrBadParam); } if (!out_object ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_list_find_index (in_list, in_identifier, &i); } - + if (!err) { *out_object = cci_array_object_at_index (in_list->objects, i); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -258,33 +258,33 @@ static cc_int32 ccs_list_find_iterator_index (ccs_list_t in_list, { cc_int32 err = ccNoError; cc_int32 found = 0; - + if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_object_index) { err = cci_check_error (ccErrBadParam); } - + if (!err && !found) { cc_uint64 i; - + for (i = 0; !err && i < cci_array_count (in_list->iterators); i++) { cc_uint32 equal = 0; ccs_list_iterator_t iterator = ccs_list_iterator_at_index (in_list, i); - + err = cci_identifier_compare (iterator->identifier, in_identifier, &equal); - + if (!err && equal) { found = 1; *out_object_index = i; break; } - } + } } - + if (!err && !found) { // Don't report this error to the log file. Non-fatal. - return in_list->object_not_found_err; + return in_list->object_not_found_err; } else { - return cci_check_error (err); + return cci_check_error (err); } } @@ -296,20 +296,20 @@ cc_int32 ccs_list_find_iterator (ccs_list_t in_list, { cc_int32 err = ccNoError; cc_uint64 i; - + if (!in_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier ) { err = cci_check_error (ccErrBadParam); } if (!out_list_iterator) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_list_find_iterator_index (in_list, in_identifier, &i); } - + if (!err) { *out_list_iterator = ccs_list_iterator_at_index (in_list, i); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -319,28 +319,28 @@ cc_int32 ccs_list_add (ccs_list_t io_list, { cc_int32 err = ccNoError; cc_uint64 add_index; - + if (!io_list ) { err = cci_check_error (ccErrBadParam); } if (!in_object) { err = cci_check_error (ccErrBadParam); } - + if (!err) { add_index = cci_array_count (io_list->objects); - + err = cci_array_insert (io_list->objects, in_object, add_index); } - + if (!err) { /* Fixup iterator indexes */ cc_uint64 i; - + for (i = 0; !err && i < cci_array_count (io_list->iterators); i++) { ccs_list_iterator_t iterator = ccs_list_iterator_at_index (io_list, i); - + err = ccs_list_iterator_update (iterator, ccs_list_action_insert, add_index); - } - } - - return cci_check_error (err); + } + } + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -350,30 +350,30 @@ cc_int32 ccs_list_remove (ccs_list_t io_list, { cc_int32 err = ccNoError; cc_uint64 remove_index; - + if (!io_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_list_find_index (io_list, in_identifier, &remove_index); } - + if (!err) { err = cci_array_remove (io_list->objects, remove_index); } - + if (!err) { /* Fixup iterator indexes */ cc_uint64 i; - + for (i = 0; !err && i < cci_array_count (io_list->iterators); i++) { ccs_list_iterator_t iterator = ccs_list_iterator_at_index (io_list, i); - + err = ccs_list_iterator_update (iterator, ccs_list_action_remove, remove_index); - } - } - - return cci_check_error (err); + } + } + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -383,32 +383,32 @@ cc_int32 ccs_list_push_front (ccs_list_t io_list, { cc_int32 err = ccNoError; cc_uint64 push_front_index; - + if (!io_list ) { err = cci_check_error (ccErrBadParam); } if (!in_identifier) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_list_find_index (io_list, in_identifier, &push_front_index); } - + if (!err) { - err = cci_array_push_front (io_list->objects, push_front_index); + err = cci_array_push_front (io_list->objects, push_front_index); } - + if (!err) { /* Fixup iterator indexes */ cc_uint64 i; - + for (i = 0; !err && i < cci_array_count (io_list->iterators); i++) { ccs_list_iterator_t iterator = ccs_list_iterator_at_index (io_list, i); - - err = ccs_list_iterator_update (iterator, - ccs_list_action_push_front, + + err = ccs_list_iterator_update (iterator, + ccs_list_action_push_front, push_front_index); - } - } - - return cci_check_error (err); + } + } + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -423,20 +423,20 @@ static cc_int32 ccs_list_iterator_new (ccs_list_iterator_t *out_list_iterator, { cc_int32 err = ccNoError; ccs_list_iterator_t list_iterator = NULL; - + if (!out_list_iterator) { err = cci_check_error (ccErrBadParam); } if (!io_list ) { err = cci_check_error (ccErrBadParam); } /* client_pipe may be NULL if the iterator exists for internal server use */ - + if (!err) { list_iterator = malloc (sizeof (*list_iterator)); - if (list_iterator) { + if (list_iterator) { *list_iterator = ccs_list_iterator_initializer; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { err = ccs_server_new_identifier (&list_iterator->identifier); } @@ -444,21 +444,21 @@ static cc_int32 ccs_list_iterator_new (ccs_list_iterator_t *out_list_iterator, if (!err) { list_iterator->list = io_list; list_iterator->current = 0; - - err = cci_array_insert (io_list->iterators, - (cci_array_object_t) list_iterator, + + err = cci_array_insert (io_list->iterators, + (cci_array_object_t) list_iterator, cci_array_count (io_list->iterators)); } - + if (!err && ccs_pipe_valid (in_client_pipe)) { ccs_client_t client = NULL; - + err = ccs_pipe_copy (&list_iterator->client_pipe, in_client_pipe); - + if (!err) { err = ccs_server_client_for_pipe (in_client_pipe, &client); } - + if (!err) { err = ccs_client_add_iterator (client, list_iterator); } @@ -468,10 +468,10 @@ static cc_int32 ccs_list_iterator_new (ccs_list_iterator_t *out_list_iterator, *out_list_iterator = list_iterator; list_iterator = NULL; } - + ccs_list_iterator_release (list_iterator); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -480,16 +480,16 @@ cc_int32 ccs_list_iterator_write (ccs_list_iterator_t in_list_iterator, k5_ipc_stream in_stream) { cc_int32 err = ccNoError; - + if (!in_list_iterator) { err = cci_check_error (ccErrBadParam); } if (!in_stream ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - err = cci_identifier_write (in_list_iterator->identifier, + err = cci_identifier_write (in_list_iterator->identifier, in_stream); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -499,26 +499,26 @@ cc_int32 ccs_list_iterator_clone (ccs_list_iterator_t in_list_iterator, { cc_int32 err = ccNoError; ccs_list_iterator_t list_iterator = NULL; - + if (!in_list_iterator ) { err = cci_check_error (ccErrBadParam); } if (!out_list_iterator) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - err = ccs_list_iterator_new (&list_iterator, - in_list_iterator->list, + err = ccs_list_iterator_new (&list_iterator, + in_list_iterator->list, in_list_iterator->client_pipe); } - + if (!err) { list_iterator->current = in_list_iterator->current; *out_list_iterator = list_iterator; list_iterator = NULL; } - + ccs_list_iterator_release (list_iterator); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -527,27 +527,27 @@ static cc_int32 ccs_list_iterator_object_release (cci_array_object_t io_list_ite { cc_int32 err = ccNoError; ccs_list_iterator_t list_iterator = (ccs_list_iterator_t) io_list_iterator; - + if (!io_list_iterator) { err = ccErrBadParam; } - + if (!err && ccs_pipe_valid (list_iterator->client_pipe)) { ccs_client_t client = NULL; err = ccs_server_client_for_pipe (list_iterator->client_pipe, &client); - + if (!err && client) { /* if client object still has a reference to us, remove it */ err = ccs_client_remove_iterator (client, list_iterator); } } - + if (!err) { ccs_pipe_release (list_iterator->client_pipe); cci_identifier_release (list_iterator->identifier); free (io_list_iterator); } - - return err; + + return err; } /* ------------------------------------------------------------------------ */ @@ -555,12 +555,12 @@ static cc_int32 ccs_list_iterator_object_release (cci_array_object_t io_list_ite cc_int32 ccs_list_iterator_release (ccs_list_iterator_t io_list_iterator) { cc_int32 err = ccNoError; - + if (!err && io_list_iterator) { cc_uint64 i = 0; - - if (ccs_list_find_iterator_index (io_list_iterator->list, - io_list_iterator->identifier, + + if (ccs_list_find_iterator_index (io_list_iterator->list, + io_list_iterator->identifier, &i) == ccNoError) { /* cci_array_remove will call ccs_list_iterator_object_release */ err = cci_array_remove (io_list_iterator->list->iterators, i); @@ -568,8 +568,8 @@ cc_int32 ccs_list_iterator_release (ccs_list_iterator_t io_list_iterator) cci_debug_printf ("Warning: iterator not in iterator list!"); } } - - return err; + + return err; } /* ------------------------------------------------------------------------ */ @@ -578,20 +578,20 @@ cc_int32 ccs_list_iterator_invalidate (ccs_list_iterator_t io_list_iterator) { cc_int32 err = ccNoError; ccs_list_iterator_t list_iterator = (ccs_list_iterator_t) io_list_iterator; - + if (!io_list_iterator) { err = ccErrBadParam; } - + if (!err) { /* Client owner died. Remove client reference and then the iterator. */ - if (ccs_pipe_valid (list_iterator->client_pipe)) { + if (ccs_pipe_valid (list_iterator->client_pipe)) { ccs_pipe_release (list_iterator->client_pipe); list_iterator->client_pipe = CCS_PIPE_NULL; } - + err = ccs_list_iterator_release (io_list_iterator); } - - return err; + + return err; } /* ------------------------------------------------------------------------ */ @@ -600,20 +600,20 @@ cc_int32 ccs_list_iterator_current (ccs_list_iterator_t io_list_iterator, ccs_list_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, + *out_object = cci_array_object_at_index (io_list_iterator->list->objects, io_list_iterator->current); } else { err = ccIteratorEnd; } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -622,21 +622,21 @@ cc_int32 ccs_list_iterator_next (ccs_list_iterator_t io_list_iterator, ccs_list_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, + *out_object = cci_array_object_at_index (io_list_iterator->list->objects, io_list_iterator->current); io_list_iterator->current++; } else { err = ccIteratorEnd; } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -646,9 +646,9 @@ static cc_int32 ccs_list_iterator_update (ccs_list_iterator_t io_list_iterator, cc_uint64 in_object_index) { cc_int32 err = ccNoError; - + if (!io_list_iterator) { err = cci_check_error (ccErrBadParam); } - + if (!err) { /* When the list changes adjust the current index so that */ /* we don't unnecessarily skip or double count items */ @@ -656,22 +656,21 @@ static cc_int32 ccs_list_iterator_update (ccs_list_iterator_t io_list_iterator, if (io_list_iterator->current > in_object_index) { io_list_iterator->current++; } - + } else if (in_action == ccs_list_action_remove) { if (io_list_iterator->current >= in_object_index) { io_list_iterator->current--; } - + } else if (in_action == ccs_list_action_push_front) { if (io_list_iterator->current < in_object_index) { io_list_iterator->current++; } - + } else { err = cci_check_error (ccErrBadParam); } } - - return cci_check_error (err); -} + return cci_check_error (err); +} diff --git a/src/ccapi/server/ccs_lock.c b/src/ccapi/server/ccs_lock.c index 639bd1732..23756b49c 100644 --- a/src/ccapi/server/ccs_lock.c +++ b/src/ccapi/server/ccs_lock.c @@ -48,48 +48,48 @@ cc_int32 ccs_lock_new (ccs_lock_t *out_lock, { cc_int32 err = ccNoError; ccs_lock_t lock = NULL; - + if (!out_lock ) { 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_lock_state_owner ) { err = cci_check_error (ccErrBadParam); } - - if (in_type != cc_lock_read && + + if (in_type != cc_lock_read && in_type != cc_lock_write && in_type != cc_lock_upgrade && - in_type != cc_lock_downgrade) { - err = cci_check_error (ccErrBadLockType); + in_type != cc_lock_downgrade) { + err = cci_check_error (ccErrBadLockType); } - + if (!err) { lock = malloc (sizeof (*lock)); - if (lock) { + if (lock) { *lock = ccs_lock_initializer; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { lock->type = in_type; lock->lock_state_owner = in_lock_state_owner; - err = ccs_callback_new (&lock->callback, - in_invalid_object_err, - in_client_pipe, + err = ccs_callback_new (&lock->callback, + in_invalid_object_err, + in_client_pipe, in_reply_pipe, (ccs_callback_owner_t) lock, ccs_lock_invalidate_callback); } - + if (!err) { *out_lock = lock; lock = NULL; } - + ccs_lock_release (lock); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -97,13 +97,13 @@ cc_int32 ccs_lock_new (ccs_lock_t *out_lock, cc_int32 ccs_lock_release (ccs_lock_t io_lock) { cc_int32 err = ccNoError; - + if (!err && io_lock) { ccs_callback_release (io_lock->callback); free (io_lock); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -112,17 +112,17 @@ static cc_int32 ccs_lock_invalidate_callback (ccs_callback_owner_t io_lock, ccs_callback_t in_callback) { cc_int32 err = ccNoError; - + if (!io_lock ) { err = cci_check_error (ccErrBadParam); } if (!in_callback) { err = cci_check_error (ccErrBadParam); } - + if (!err) { ccs_lock_t lock = (ccs_lock_t) io_lock; - + err = ccs_lock_state_invalidate_lock (lock->lock_state_owner, lock); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -130,14 +130,14 @@ static cc_int32 ccs_lock_invalidate_callback (ccs_callback_owner_t io_lock, cc_int32 ccs_lock_grant_lock (ccs_lock_t io_lock) { cc_int32 err = ccNoError; - + if (!io_lock) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_callback_reply_to_client (io_lock->callback, NULL); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -146,15 +146,15 @@ cc_uint32 ccs_lock_is_pending (ccs_lock_t in_lock, cc_uint32 *out_pending) { cc_int32 err = ccNoError; - + if (!in_lock ) { err = cci_check_error (ccErrBadParam); } if (!out_pending) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_callback_is_pending (in_lock->callback, out_pending); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -163,15 +163,15 @@ cc_int32 ccs_lock_type (ccs_lock_t in_lock, cc_uint32 *out_lock_type) { cc_int32 err = ccNoError; - + if (!in_lock ) { err = cci_check_error (ccErrBadParam); } if (!out_lock_type) { err = cci_check_error (ccErrBadParam); } - + if (!err) { *out_lock_type = in_lock->type; } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -180,16 +180,16 @@ cc_int32 ccs_lock_is_read_lock (ccs_lock_t in_lock, cc_uint32 *out_is_read_lock) { cc_int32 err = ccNoError; - + if (!in_lock ) { err = cci_check_error (ccErrBadParam); } if (!out_is_read_lock) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - *out_is_read_lock = (in_lock->type == cc_lock_read || + *out_is_read_lock = (in_lock->type == cc_lock_read || in_lock->type == cc_lock_downgrade); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -198,16 +198,16 @@ cc_int32 ccs_lock_is_write_lock (ccs_lock_t in_lock, cc_uint32 *out_is_write_lock) { cc_int32 err = ccNoError; - + if (!in_lock ) { err = cci_check_error (ccErrBadParam); } if (!out_is_write_lock) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - *out_is_write_lock = (in_lock->type == cc_lock_write || + *out_is_write_lock = (in_lock->type == cc_lock_write || in_lock->type == cc_lock_upgrade); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -217,17 +217,17 @@ cc_int32 ccs_lock_is_for_client_pipe (ccs_lock_t in_lock, cc_uint32 *out_is_for_client_pipe) { cc_int32 err = ccNoError; - + if (!in_lock ) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!out_is_for_client_pipe ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - err = ccs_callback_is_for_client_pipe (in_lock->callback, in_client_pipe, + err = ccs_callback_is_for_client_pipe (in_lock->callback, in_client_pipe, out_is_for_client_pipe); } - - return cci_check_error (err); + + return cci_check_error (err); } @@ -237,13 +237,13 @@ cc_int32 ccs_lock_client_pipe (ccs_lock_t in_lock, ccs_pipe_t *out_client_pipe) { cc_int32 err = ccNoError; - + if (!in_lock ) { err = cci_check_error (ccErrBadParam); } if (!out_client_pipe) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_callback_client_pipe (in_lock->callback, out_client_pipe); } - - return cci_check_error (err); + + return cci_check_error (err); } diff --git a/src/ccapi/server/ccs_lock_state.c b/src/ccapi/server/ccs_lock_state.c index 516a1e26a..94edcec0f 100644 --- a/src/ccapi/server/ccs_lock_state.c +++ b/src/ccapi/server/ccs_lock_state.c @@ -38,41 +38,41 @@ struct ccs_lock_state_d ccs_lock_state_initializer = { 1, 1, 1, NULL, 0 }; /* ------------------------------------------------------------------------ */ -cc_int32 ccs_lock_state_new (ccs_lock_state_t *out_lock_state, - cc_int32 in_invalid_object_err, - cc_int32 in_pending_lock_err, +cc_int32 ccs_lock_state_new (ccs_lock_state_t *out_lock_state, + cc_int32 in_invalid_object_err, + cc_int32 in_pending_lock_err, cc_int32 in_no_lock_err) { cc_int32 err = ccNoError; ccs_lock_state_t lock_state = NULL; - + if (!out_lock_state) { err = cci_check_error (ccErrBadParam); } - + if (!err) { lock_state = malloc (sizeof (*lock_state)); - if (lock_state) { + if (lock_state) { *lock_state = ccs_lock_state_initializer; } else { - err = cci_check_error (ccErrNoMem); + err = cci_check_error (ccErrNoMem); } } - + if (!err) { err = ccs_lock_array_new (&lock_state->locks); } - + if (!err) { lock_state->invalid_object_err = in_invalid_object_err; lock_state->pending_lock_err = in_pending_lock_err; lock_state->no_lock_err = in_no_lock_err; - + *out_lock_state = lock_state; lock_state = NULL; } - + ccs_lock_state_release (lock_state); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -80,13 +80,13 @@ cc_int32 ccs_lock_state_new (ccs_lock_state_t *out_lock_state, 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); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -103,31 +103,31 @@ static cc_int32 ccs_lock_status_add_pending_lock (ccs_lock_state_t io_lock_stat { 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, + err = ccs_lock_new (&lock, in_lock_type, io_lock_state->invalid_object_err, - in_client_pipe, in_reply_pipe, + 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); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -136,18 +136,18 @@ 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--; + + if (!err && in_lock_index < io_lock_state->first_pending_lock_index) { + io_lock_state->first_pending_lock_index--; } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -160,36 +160,36 @@ static cc_int32 ccs_lock_status_grant_lock (ccs_lock_state_t io_lock_state, cc_uint32 type = 0; if (!io_lock_state) { err = cci_check_error (ccErrBadParam); } - + if (!err) { - pending_lock = ccs_lock_array_object_at_index (io_lock_state->locks, + pending_lock = ccs_lock_array_object_at_index (io_lock_state->locks, in_pending_lock_index); if (!pending_lock || in_pending_lock_index < io_lock_state->first_pending_lock_index) { err = cci_check_error (ccErrBadParam); } } - + if (!err) { err = ccs_lock_type (pending_lock, &type); } - + if (!err && (type == cc_lock_upgrade || type == cc_lock_downgrade)) { /* lock upgrades or downgrades. Find the old lock and remove it. */ ccs_pipe_t pending_client_pipe = CCS_PIPE_NULL; - + err = ccs_lock_client_pipe (pending_lock, &pending_client_pipe); if (!err) { cc_uint64 i; - + for (i = 0; !err && i < io_lock_state->first_pending_lock_index; i++) { ccs_lock_t lock = ccs_lock_array_object_at_index (io_lock_state->locks, i); cc_uint32 is_lock_for_client = 0; - + err = ccs_lock_is_for_client_pipe (lock, pending_client_pipe, &is_lock_for_client); - + if (!err && is_lock_for_client) { - cci_debug_printf ("%s: Removing old lock %p at index %d to replace with pending lock %p.", + cci_debug_printf ("%s: Removing old lock %p at index %d to replace with pending lock %p.", __FUNCTION__, lock, (int) i, pending_lock); err = ccs_lock_status_remove_lock (io_lock_state, i); if (!err) { i--; in_pending_lock_index--; /* We removed one so back up an index */ } @@ -198,22 +198,22 @@ static cc_int32 ccs_lock_status_grant_lock (ccs_lock_state_t io_lock_state, } } } - - if (!err) { + + if (!err) { cc_uint64 new_lock_index = 0; - err = ccs_lock_array_move (io_lock_state->locks, - in_pending_lock_index, + err = ccs_lock_array_move (io_lock_state->locks, + in_pending_lock_index, io_lock_state->first_pending_lock_index, &new_lock_index); if (!err) { io_lock_state->first_pending_lock_index++; } } - + if (!err) { err = ccs_lock_grant_lock (pending_lock); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -234,35 +234,35 @@ static cc_int32 ccs_lock_state_check_pending_lock (ccs_lock_state_t io_lock_sta cc_uint32 client_lock_type = 0; cc_uint64 client_lock_index = 0; cc_uint32 grant_lock = 0; - + if (!io_lock_state ) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_pending_lock_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!out_grant_lock ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { cc_uint64 i; cc_uint64 lock_count = io_lock_state->first_pending_lock_index; - + for (i = 0; !err && i < lock_count; i++) { ccs_lock_t lock = ccs_lock_array_object_at_index (io_lock_state->locks, i); cc_uint32 lock_type = 0; cc_uint32 lock_is_for_client = 0; - + err = ccs_lock_type (lock, &lock_type); - + if (!err) { - err = ccs_lock_is_for_client_pipe (lock, in_pending_lock_client_pipe, + err = ccs_lock_is_for_client_pipe (lock, in_pending_lock_client_pipe, &lock_is_for_client); } - + if (!err) { if (lock_type == cc_lock_write || lock_type == cc_lock_upgrade) { is_write_locked = 1; } - + if (!lock_is_for_client) { other_clients_have_locks = 1; - + } else if (!client_has_lock) { /* only record type of 1st lock */ client_has_lock = 1; client_lock_type = lock_type; @@ -271,35 +271,35 @@ static cc_int32 ccs_lock_state_check_pending_lock (ccs_lock_state_t io_lock_sta } } } - + if (!err) { cc_uint64 lock_count = io_lock_state->first_pending_lock_index; - + if (in_pending_lock_type == cc_lock_write) { if (client_has_lock) { err = cci_check_error (ccErrBadLockType); } else { grant_lock = (lock_count == 0); } - + } else if (in_pending_lock_type == cc_lock_read) { if (client_has_lock) { err = cci_check_error (ccErrBadLockType); } else { grant_lock = !is_write_locked; } - + } else if (in_pending_lock_type == cc_lock_upgrade) { - if (!client_has_lock || (client_lock_type != cc_lock_read && + if (!client_has_lock || (client_lock_type != cc_lock_read && client_lock_type != cc_lock_downgrade)) { err = cci_check_error (ccErrBadLockType); } else { /* don't grant if other clients have read locks */ - grant_lock = !other_clients_have_locks; + grant_lock = !other_clients_have_locks; } - + } else if (in_pending_lock_type == cc_lock_downgrade) { - if (!client_has_lock || (client_lock_type != cc_lock_write && + if (!client_has_lock || (client_lock_type != cc_lock_write && client_lock_type != cc_lock_upgrade)) { err = cci_check_error (ccErrBadLockType); } else { @@ -310,62 +310,62 @@ static cc_int32 ccs_lock_state_check_pending_lock (ccs_lock_state_t io_lock_sta err = cci_check_error (ccErrBadLockType); } } - + if (!err) { *out_grant_lock = grant_lock; } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ -static cc_int32 ccs_lock_status_try_to_grant_pending_locks (ccs_lock_state_t io_lock_state) +static cc_int32 ccs_lock_status_try_to_grant_pending_locks (ccs_lock_state_t io_lock_state) { cc_int32 err = ccNoError; cc_uint32 done = 0; - + if (!io_lock_state) { err = cci_check_error (ccErrBadParam); } - - /* Look at the pending locks and see if we can grant them. + + /* Look at the pending locks and see if we can grant them. * Note that downgrade locks mean we must check all pending locks each pass * since a downgrade lock might be last in the list. */ - + while (!err && !done) { cc_uint64 i; cc_uint64 count = ccs_lock_array_count (io_lock_state->locks); cc_uint32 granted_lock = 0; - + for (i = io_lock_state->first_pending_lock_index; !err && i < count; i++) { ccs_lock_t lock = ccs_lock_array_object_at_index (io_lock_state->locks, i); cc_uint32 lock_type = 0; ccs_pipe_t client_pipe = CCS_PIPE_NULL; cc_uint32 can_grant_lock_now = 0; - + err = ccs_lock_client_pipe (lock, &client_pipe); - + if (!err) { err = ccs_lock_type (lock, &lock_type); } - + if (!err) { err = ccs_lock_state_check_pending_lock (io_lock_state, client_pipe, lock_type, &can_grant_lock_now); } - + if (!err && can_grant_lock_now) { err = ccs_lock_status_grant_lock (io_lock_state, i); if (!err) { granted_lock = 1; } } } - + if (!err && !granted_lock) { /* we walked over all the locks and couldn't grant any of them */ done = 1; } - } - - return cci_check_error (err); + } + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -383,54 +383,54 @@ cc_int32 ccs_lock_state_add (ccs_lock_state_t io_lock_state, { cc_int32 err = ccNoError; cc_uint32 can_grant_lock_now = 0; - + 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 (!out_will_send_reply ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { /* Sanity check: if there are any pending locks for this client * the client must have timed out waiting for our reply. Remove any * existing pending locks for the client. */ cc_uint64 i; - + for (i = io_lock_state->first_pending_lock_index; !err && i < ccs_lock_array_count (io_lock_state->locks); i++) { ccs_lock_t lock = ccs_lock_array_object_at_index (io_lock_state->locks, i); cc_uint32 has_pending_lock_for_client = 0; - + err = ccs_lock_is_for_client_pipe (lock, in_client_pipe, &has_pending_lock_for_client); - + if (!err && has_pending_lock_for_client) { - cci_debug_printf ("WARNING %s: Removing unexpected pending lock %p at index %d.", + cci_debug_printf ("WARNING %s: Removing unexpected pending lock %p at index %d.", __FUNCTION__, lock, (int) i); err = ccs_lock_status_remove_lock (io_lock_state, i); if (!err) { i--; /* We removed one so back up an index */ } } } } - + if (!err) { err = ccs_lock_state_check_pending_lock (io_lock_state, in_client_pipe, in_lock_type, &can_grant_lock_now); } - + if (!err) { if (!can_grant_lock_now && (in_block == cc_lock_noblock)) { err = cci_check_error (io_lock_state->pending_lock_err); - + } else { cc_uint64 new_lock_index = 0; - + err = ccs_lock_status_add_pending_lock (io_lock_state, in_client_pipe, in_reply_pipe, in_lock_type, &new_lock_index); - + if (!err && can_grant_lock_now) { err = ccs_lock_status_grant_lock (io_lock_state, new_lock_index); - + if (!err && (in_lock_type == cc_lock_downgrade)) { /* downgrades can allow us to grant other locks */ err = ccs_lock_status_try_to_grant_pending_locks (io_lock_state); @@ -438,13 +438,13 @@ cc_int32 ccs_lock_state_add (ccs_lock_state_t io_lock_state, } } } - + if (!err) { /* ccs_lock_state_add sends its replies via callback so caller shouldn't */ *out_will_send_reply = 1; } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -454,45 +454,45 @@ cc_int32 ccs_lock_state_remove (ccs_lock_state_t io_lock_state, { cc_int32 err = ccNoError; cc_uint32 found_lock = 0; - + if (!io_lock_state ) { err = cci_check_error (ccErrBadParam); } if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } - + if (!err) { cc_uint64 i; - - /* Remove all locks for this client. + + /* Remove all locks for this client. * There should only be one so warn if there are multiple */ for (i = 0; !err && i < io_lock_state->first_pending_lock_index; i++) { ccs_lock_t lock = ccs_lock_array_object_at_index (io_lock_state->locks, i); cc_uint32 is_for_client = 0; - + err = ccs_lock_is_for_client_pipe (lock, in_client_pipe, &is_for_client); - + if (!err && is_for_client) { if (found_lock) { - cci_debug_printf ("WARNING %s: Found multiple locks for client.", + cci_debug_printf ("WARNING %s: Found multiple locks for client.", __FUNCTION__); } - + found_lock = 1; - + cci_debug_printf ("%s: Removing lock %p at index %d.", __FUNCTION__, lock, (int) i); err = ccs_lock_status_remove_lock (io_lock_state, i); if (!err) { i--; /* We removed one so back up an index */ } } } } - + if (!err && !found_lock) { err = cci_check_error (io_lock_state->no_lock_err); } - + if (!err) { err = ccs_lock_status_try_to_grant_pending_locks (io_lock_state); - } - - return cci_check_error (err); + } + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -501,26 +501,26 @@ cc_int32 ccs_lock_state_invalidate_lock (ccs_lock_state_t io_lock_state, ccs_lock_t in_lock) { cc_int32 err = ccNoError; - + if (!io_lock_state) { err = ccErrBadParam; } - + if (!err) { cc_uint64 i; cc_uint64 count = ccs_lock_array_count (io_lock_state->locks); - + for (i = 0; !err && i < count; i++) { ccs_lock_t lock = ccs_lock_array_object_at_index (io_lock_state->locks, i); - + if (lock == in_lock) { err = ccs_lock_status_remove_lock (io_lock_state, i); - + if (!err) { err = ccs_lock_status_try_to_grant_pending_locks (io_lock_state); break; - } + } } } } - - return cci_check_error (err); + + return cci_check_error (err); } diff --git a/src/ccapi/server/ccs_lock_state.h b/src/ccapi/server/ccs_lock_state.h index c6b9bdb0d..aa0c23a3c 100644 --- a/src/ccapi/server/ccs_lock_state.h +++ b/src/ccapi/server/ccs_lock_state.h @@ -29,9 +29,9 @@ #include "ccs_types.h" -cc_int32 ccs_lock_state_new (ccs_lock_state_t *out_lock_state, - cc_int32 in_invalid_object_err, - cc_int32 in_pending_lock_err, +cc_int32 ccs_lock_state_new (ccs_lock_state_t *out_lock_state, + cc_int32 in_invalid_object_err, + cc_int32 in_pending_lock_err, cc_int32 in_no_lock_err); cc_int32 ccs_lock_state_release (ccs_lock_state_t io_lock_state); diff --git a/src/ccapi/server/ccs_pipe.c b/src/ccapi/server/ccs_pipe.c index 0a65a0aeb..41ec60c79 100644 --- a/src/ccapi/server/ccs_pipe.c +++ b/src/ccapi/server/ccs_pipe.c @@ -40,7 +40,7 @@ cc_int32 ccs_pipe_compare (ccs_pipe_t in_pipe, ccs_pipe_t in_compare_to_pipe, cc_uint32 *out_equal) { - return ccs_os_pipe_compare (in_pipe, in_compare_to_pipe, out_equal); + return ccs_os_pipe_compare (in_pipe, in_compare_to_pipe, out_equal); } /* ------------------------------------------------------------------------ */ diff --git a/src/ccapi/server/ccs_server.c b/src/ccapi/server/ccs_server.c index 30476e407..469834196 100644 --- a/src/ccapi/server/ccs_server.c +++ b/src/ccapi/server/ccs_server.c @@ -38,35 +38,35 @@ ccs_client_array_t g_client_array = NULL; int main (int argc, const char *argv[]) { cc_int32 err = 0; - + if (!err) { err = ccs_os_server_initialize (argc, argv); } - + if (!err) { err = cci_identifier_new_uuid (&g_server_id); } - + if (!err) { err = ccs_cache_collection_new (&g_cache_collection); } - + if (!err) { err = ccs_client_array_new (&g_client_array); } - + if (!err) { err = ccs_os_server_listen_loop (argc, argv); } - + if (!err) { free (g_server_id); cci_check_error (ccs_cache_collection_release (g_cache_collection)); cci_check_error (ccs_client_array_release (g_client_array)); - + err = ccs_os_server_cleanup (argc, argv); } - + return cci_check_error (err) ? 1 : 0; } @@ -92,19 +92,19 @@ cc_int32 ccs_server_add_client (ccs_pipe_t in_connection_pipe) { cc_int32 err = ccNoError; ccs_client_t client = NULL; - + if (!err) { err = ccs_client_new (&client, in_connection_pipe); } - + if (!err) { cci_debug_printf ("%s: Adding client %p.", __FUNCTION__, client); - err = ccs_client_array_insert (g_client_array, + err = ccs_client_array_insert (g_client_array, client, ccs_client_array_count (g_client_array)); } - return cci_check_error (err); + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -117,26 +117,26 @@ cc_int32 ccs_server_remove_client (ccs_pipe_t in_connection_pipe) cc_uint64 i; cc_uint64 count = ccs_client_array_count (g_client_array); cc_uint32 found = 0; - + for (i = 0; !err && i < count; i++) { ccs_client_t client = ccs_client_array_object_at_index (g_client_array, i); - + err = ccs_client_uses_pipe (client, in_connection_pipe, &found); - + if (!err && found) { cci_debug_printf ("%s: Removing client %p.", __FUNCTION__, client); err = ccs_client_array_remove (g_client_array, i); break; } } - + if (!err && !found) { - cci_debug_printf ("WARNING %s() didn't find client in client list.", + cci_debug_printf ("WARNING %s() didn't find client in client list.", __FUNCTION__); - } + } } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -146,32 +146,32 @@ cc_int32 ccs_server_client_for_pipe (ccs_pipe_t in_client_pipe, { cc_int32 err = ccNoError; ccs_client_t client_for_pipe = NULL; - + if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!out_client ) { err = cci_check_error (ccErrBadParam); } if (!err) { cc_uint64 i; cc_uint64 count = ccs_client_array_count (g_client_array); - + for (i = 0; !err && i < count; i++) { ccs_client_t client = ccs_client_array_object_at_index (g_client_array, i); cc_uint32 uses_pipe = 0; - + err = ccs_client_uses_pipe (client, in_client_pipe, &uses_pipe); - + if (!err && uses_pipe) { client_for_pipe = client; break; } } } - + if (!err) { *out_client = client_for_pipe; /* may be NULL if not found */ } - return cci_check_error (err); + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -181,19 +181,19 @@ cc_int32 ccs_server_client_is_valid (ccs_pipe_t in_client_pipe, { cc_int32 err = ccNoError; ccs_client_t client = NULL; - + if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); } if (!out_client_is_valid ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = ccs_server_client_for_pipe (in_client_pipe, &client); } - + if (!err) { *out_client_is_valid = (client != NULL); } - - return cci_check_error (err); + + return cci_check_error (err); } #ifdef TARGET_OS_MAC @@ -221,9 +221,9 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t in_client_pipe if (!err) { if (in_request_name > cci_context_first_msg_id && in_request_name < cci_context_last_msg_id) { - /* Note: context identifier doesn't need to match. + /* Note: context identifier doesn't need to match. * Client just uses the identifier to detect server relaunch. */ - + if (!err) { err = ccs_cache_collection_handle_message (in_client_pipe, in_reply_pipe, @@ -233,15 +233,15 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t in_client_pipe out_will_block, out_reply_data); } - + } else if (in_request_name > cci_ccache_first_msg_id && in_request_name < cci_ccache_last_msg_id) { ccs_ccache_t ccache = NULL; - + err = ccs_cache_collection_find_ccache (in_cache_collection, in_request_identifier, - &ccache); - + &ccache); + if (!err) { err = ccs_ccache_handle_message (in_client_pipe, in_reply_pipe, @@ -251,16 +251,16 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t in_client_pipe in_request_data, out_will_block, out_reply_data); - } - + } + } else if (in_request_name > cci_ccache_iterator_first_msg_id && in_request_name < cci_ccache_iterator_last_msg_id) { ccs_ccache_iterator_t ccache_iterator = NULL; - + err = ccs_cache_collection_find_ccache_iterator (in_cache_collection, in_request_identifier, - &ccache_iterator); - + &ccache_iterator); + if (!err) { err = ccs_ccache_iterator_handle_message (ccache_iterator, in_cache_collection, @@ -268,21 +268,21 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t in_client_pipe in_request_data, out_reply_data); } - + if (!err) { *out_will_block = 0; /* can't block */ } - + } else if (in_request_name > cci_credentials_iterator_first_msg_id && in_request_name < cci_credentials_iterator_last_msg_id) { ccs_credentials_iterator_t credentials_iterator = NULL; ccs_ccache_t ccache = NULL; - + err = ccs_cache_collection_find_credentials_iterator (in_cache_collection, in_request_identifier, &ccache, - &credentials_iterator); - + &credentials_iterator); + if (!err) { err = ccs_credentials_iterator_handle_message (credentials_iterator, ccache, @@ -290,16 +290,16 @@ static cc_int32 ccs_server_request_demux (ccs_pipe_t in_client_pipe in_request_data, out_reply_data); } - + if (!err) { *out_will_block = 0; /* can't block */ } - + } else { err = ccErrBadInternalMessage; } } - + return cci_check_error (err); } @@ -318,46 +318,46 @@ cc_int32 ccs_server_handle_request (ccs_pipe_t in_client_pipe, cci_identifier_t request_identifier = NULL; cc_uint32 will_block = 0; k5_ipc_stream reply_data = NULL; - + 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_request ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = cci_message_read_request_header (in_request, &request_name, &request_identifier); } - + if (!err) { cc_uint32 server_err = 0; cc_uint32 valid = 0; ccs_cache_collection_t cache_collection = g_cache_collection; - - server_err = cci_identifier_is_for_server (request_identifier, - g_server_id, + + server_err = cci_identifier_is_for_server (request_identifier, + g_server_id, &valid); - + if (!server_err && !valid) { server_err = cci_message_invalid_object_err (request_name); } - + if (!server_err) { - - /* Monolithic server implementation would need to select + + /* Monolithic server implementation would need to select * cache collection here. Currently we only support per-user * servers so we always use the same cache collection. */ - + server_err = ccs_server_request_demux (in_client_pipe, in_reply_pipe, cache_collection, request_name, request_identifier, - in_request, + in_request, &will_block, &reply_data); } - + if (server_err || !will_block) { /* send a reply now if the server isn't blocked on something */ @@ -367,8 +367,8 @@ cc_int32 ccs_server_handle_request (ccs_pipe_t in_client_pipe, cci_identifier_release (request_identifier); krb5int_ipc_stream_release (reply_data); - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -379,24 +379,24 @@ cc_int32 ccs_server_send_reply (ccs_pipe_t in_reply_pipe, { cc_int32 err = ccNoError; k5_ipc_stream reply = NULL; - + if (!ccs_pipe_valid (in_reply_pipe) ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { err = cci_message_new_reply_header (&reply, in_reply_err); } - + if (!err && in_reply_data && krb5int_ipc_stream_size (in_reply_data) > 0) { - err = krb5int_ipc_stream_write (reply, - krb5int_ipc_stream_data (in_reply_data), + err = krb5int_ipc_stream_write (reply, + krb5int_ipc_stream_data (in_reply_data), krb5int_ipc_stream_size (in_reply_data)); } - + if (!err) { err = ccs_os_server_send_reply (in_reply_pipe, reply); } - + krb5int_ipc_stream_release (reply); - - return cci_check_error (err); + + return cci_check_error (err); } diff --git a/src/ccapi/server/mac/ccs_os_notify.c b/src/ccapi/server/mac/ccs_os_notify.c index 920282316..84501fbd6 100644 --- a/src/ccapi/server/mac/ccs_os_notify.c +++ b/src/ccapi/server/mac/ccs_os_notify.c @@ -33,22 +33,22 @@ 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) { + if (center) { CFNotificationCenterPostNotification (center, kCCAPICacheCollectionChangedNotification, NULL, NULL, TRUE); } } - - - - return cci_check_error (err); + + + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -57,24 +57,24 @@ cc_int32 ccs_os_notify_ccache_changed (ccs_cache_collection_t io_cache_collecti const char *in_ccache_name) { cc_int32 err = ccNoError; - + if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); } if (!in_ccache_name ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter (); CFStringRef name = CFStringCreateWithCString (kCFAllocatorDefault, in_ccache_name, kCFStringEncodingUTF8); - - if (center && name) { + + if (center && name) { CFNotificationCenterPostNotification (center, kCCAPICCacheChangedNotification, name, NULL, TRUE); } - + if (name) { CFRelease (name); } } - - return cci_check_error (err); + + return cci_check_error (err); } diff --git a/src/ccapi/server/mac/ccs_os_pipe.c b/src/ccapi/server/mac/ccs_os_pipe.c index 91227676c..0462a64e6 100644 --- a/src/ccapi/server/mac/ccs_os_pipe.c +++ b/src/ccapi/server/mac/ccs_os_pipe.c @@ -44,16 +44,16 @@ cc_int32 ccs_os_pipe_compare (ccs_pipe_t in_pipe, cc_uint32 *out_equal) { cc_int32 err = ccNoError; - + if (!in_pipe ) { err = cci_check_error (ccErrBadParam); } if (!in_compare_to_pipe) { err = cci_check_error (ccErrBadParam); } if (!out_equal ) { err = cci_check_error (ccErrBadParam); } - + if (!err) { *out_equal = (in_pipe == in_compare_to_pipe); } - - return cci_check_error (err); + + return cci_check_error (err); } /* ------------------------------------------------------------------------ */ @@ -62,9 +62,9 @@ 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); } @@ -73,9 +73,8 @@ cc_int32 ccs_os_pipe_copy (ccs_pipe_t *out_pipe, cc_int32 ccs_os_pipe_release (ccs_pipe_t io_pipe) { cc_int32 err = 0; - + /* Nothing to do here on Mac OS X */ - + return cci_check_error (err); } - diff --git a/src/ccapi/server/mac/ccs_os_server.c b/src/ccapi/server/mac/ccs_os_server.c index 98bc6b30a..276c1ad14 100644 --- a/src/ccapi/server/mac/ccs_os_server.c +++ b/src/ccapi/server/mac/ccs_os_server.c @@ -51,8 +51,8 @@ kern_return_t k5_ipc_server_handle_request (mach_port_t in_connection_port, mach_port_t in_reply_port, k5_ipc_stream in_request_stream) { - return cci_check_error (ccs_server_handle_request (in_connection_port, - in_reply_port, + return cci_check_error (ccs_server_handle_request (in_connection_port, + in_reply_port, in_request_stream)); } @@ -63,10 +63,10 @@ kern_return_t k5_ipc_server_handle_request (mach_port_t in_connection_port, cc_int32 ccs_os_server_initialize (int argc, const char *argv[]) { cc_int32 err = 0; - + openlog (argv[0], LOG_CONS | LOG_PID, LOG_AUTH); - syslog (LOG_INFO, "Starting up."); - + syslog (LOG_INFO, "Starting up."); + return cci_check_error (err); } @@ -75,9 +75,9 @@ cc_int32 ccs_os_server_initialize (int argc, const char *argv[]) cc_int32 ccs_os_server_cleanup (int argc, const char *argv[]) { cc_int32 err = 0; - + syslog (LOG_NOTICE, "Exiting."); - + return cci_check_error (err); } @@ -93,6 +93,6 @@ cc_int32 ccs_os_server_listen_loop (int argc, const char *argv[]) cc_int32 ccs_os_server_send_reply (ccs_pipe_t in_reply_pipe, k5_ipc_stream in_reply_stream) { - return cci_check_error (k5_ipc_server_send_reply (in_reply_pipe, + return cci_check_error (k5_ipc_server_send_reply (in_reply_pipe, in_reply_stream)); } diff --git a/src/ccapi/server/win/ccs_os_pipe.c b/src/ccapi/server/win/ccs_os_pipe.c index 95af378e7..4573fa5e9 100644 --- a/src/ccapi/server/win/ccs_os_pipe.c +++ b/src/ccapi/server/win/ccs_os_pipe.c @@ -31,7 +31,7 @@ /* ------------------------------------------------------------------------ */ /* On Windows, a pipe is a struct. See ccs_win_pipe.h for details. */ - + /* ------------------------------------------------------------------------ */ @@ -43,7 +43,7 @@ cc_int32 ccs_os_pipe_valid (ccs_pipe_t in_pipe) { cc_int32 ccs_os_pipe_copy (ccs_pipe_t* out_pipe, ccs_pipe_t in_pipe) { return ccs_win_pipe_copy( - out_pipe, + out_pipe, in_pipe); } @@ -61,4 +61,3 @@ cc_int32 ccs_os_pipe_compare (ccs_pipe_t pipe_1, return ccs_win_pipe_compare(pipe_1, pipe_2, out_equal); } - diff --git a/src/ccapi/server/win/ccs_request_proc.c b/src/ccapi/server/win/ccs_request_proc.c index 8421b7224..00a8f032d 100644 --- a/src/ccapi/server/win/ccs_request_proc.c +++ b/src/ccapi/server/win/ccs_request_proc.c @@ -50,8 +50,8 @@ void ccs_rpc_request( cci_debug_printf("%s rpcmsg:%d; UUID:<%s> SST:<%s>", __FUNCTION__, rpcmsg, pszUUID, serverStartTime); #endif status = (rpcmsg != CCMSG_REQUEST) && (rpcmsg != CCMSG_PING); - - if (!status) { + + if (!status) { status = krb5int_ipc_stream_new (&stream); /* Create a stream for the request data */ } @@ -59,7 +59,7 @@ void ccs_rpc_request( status = krb5int_ipc_stream_write (stream, pbRequest, lenRequest); } - pipe = ccs_win_pipe_new(pszUUID, *p); + pipe = ccs_win_pipe_new(pszUUID, *p); worklist_add(rpcmsg, pipe, stream, serverStartTime); *return_status = status; } @@ -76,7 +76,7 @@ void ccs_rpc_connect( #if 0 cci_debug_printf("%s; rpcmsg:%d; UUID: <%s>", __FUNCTION__, rpcmsg, pszUUID); #endif - worklist_add( rpcmsg, + worklist_add( rpcmsg, pipe, NULL, /* No payload with connect request */ (const time_t)0 ); /* No server session number with connect request */ diff --git a/src/ccapi/server/win/ccs_win_pipe.c b/src/ccapi/server/win/ccs_win_pipe.c index 4ef807dd5..243f8f222 100644 --- a/src/ccapi/server/win/ccs_win_pipe.c +++ b/src/ccapi/server/win/ccs_win_pipe.c @@ -55,7 +55,7 @@ struct ccs_win_pipe_t* ccs_win_pipe_new (const char* uuid, const HANDLE h) { if (!uuidCopy) {err = cci_check_error(ccErrBadParam);} strcpy(uuidCopy, uuid); } - + if (!err) { out_pipe = (struct ccs_win_pipe_t*)malloc(sizeof(struct ccs_win_pipe_t)); if (!out_pipe) {err = cci_check_error(ccErrBadParam);} @@ -70,10 +70,10 @@ struct ccs_win_pipe_t* ccs_win_pipe_new (const char* uuid, const HANDLE h) { /* ------------------------------------------------------------------------ */ -cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, +cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, const WIN_PIPE* in_pipe) { - *out_pipe = + *out_pipe = ccs_win_pipe_new( ccs_win_pipe_getUuid (in_pipe), ccs_win_pipe_getHandle(in_pipe) ); diff --git a/src/ccapi/server/win/ccs_win_pipe.h b/src/ccapi/server/win/ccs_win_pipe.h index 3600d12af..c489aafd2 100644 --- a/src/ccapi/server/win/ccs_win_pipe.h +++ b/src/ccapi/server/win/ccs_win_pipe.h @@ -33,16 +33,16 @@ /* ------------------------------------------------------------------------ */ -/* On Windows, a pipe is a struct containing a UUID and a handle. Both the - UUID and handle are supplied by the client. - - The UUID is used to build the client's reply endpoint. - +/* On Windows, a pipe is a struct containing a UUID and a handle. Both the + UUID and handle are supplied by the client. + + The UUID is used to build the client's reply endpoint. + The handle is to the requesting client thread's thread local storage struct, so that the client's one and only reply handler can put reply data where the requesting thread will be able to see it. */ - + struct ccs_win_pipe_t { char* uuid; HANDLE clientHandle; @@ -58,7 +58,7 @@ cc_int32 ccs_win_pipe_compare (const WIN_PIPE* win_pipe_1, const WIN_PIPE* win_pipe_2, cc_uint32 *out_equal); -cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, +cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, const WIN_PIPE* in_pipe); cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe); @@ -66,4 +66,4 @@ cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe); char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe); HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe); -#endif // _ccs_win_pipe_h_
\ No newline at end of file +#endif // _ccs_win_pipe_h_ diff --git a/src/ccapi/server/win/workitem.h b/src/ccapi/server/win/workitem.h index 9829f8500..1d3df155c 100644 --- a/src/ccapi/server/win/workitem.h +++ b/src/ccapi/server/win/workitem.h @@ -15,9 +15,9 @@ private: const long _rpcmsg; const long _sst; public: - WorkItem( k5_ipc_stream buf, - WIN_PIPE* pipe, - const long type, + WorkItem( k5_ipc_stream buf, + WIN_PIPE* pipe, + const long type, const long serverStartTime); WorkItem( const WorkItem&); WorkItem(); |
