示例#1
0
static cc_int32 ccs_lock_status_add_pending_lock (ccs_lock_state_t  io_lock_state,
                                                  ccs_pipe_t        in_client_pipe,
                                                  ccs_pipe_t        in_reply_pipe,
                                                  cc_uint32         in_lock_type,
                                                  cc_uint64        *out_lock_index)
{
    cc_int32 err = ccNoError;
    ccs_lock_t lock = NULL;

    if (!io_lock_state                  ) { err = cci_check_error (ccErrBadParam); }
    if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
    if (!ccs_pipe_valid (in_reply_pipe) ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = ccs_lock_new (&lock, in_lock_type,
                            io_lock_state->invalid_object_err,
                            in_client_pipe, in_reply_pipe,
                            io_lock_state);
    }

    if (!err) {
        err = ccs_lock_array_insert (io_lock_state->locks, lock,
                                     ccs_lock_array_count (io_lock_state->locks));
        if (!err) { lock = NULL; /* take ownership */ }
    }

    if (!err) {
        *out_lock_index = ccs_lock_array_count (io_lock_state->locks) - 1;
    }

    ccs_lock_release (lock);

    return cci_check_error (err);
}
示例#2
0
文件: ccs_ccache.c 项目: krb5/krb5
static cc_int32 ccs_ccache_wait_for_change (ccs_pipe_t              in_client_pipe,
					    ccs_pipe_t              in_reply_pipe,
					    ccs_ccache_t            io_ccache,
					    ccs_cache_collection_t  io_cache_collection,
					    k5_ipc_stream            in_request_data,
					    k5_ipc_stream            io_reply_data,
					    cc_uint32              *out_will_block)
{
    cc_int32 err = ccNoError;
    cc_time_t last_wait_for_change_time = 0;
    cc_uint32 will_block = 0;

    if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
    if (!ccs_pipe_valid (in_reply_pipe )) { err = cci_check_error (ccErrBadParam); }
    if (!io_ccache                      ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection            ) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data                ) { err = cci_check_error (ccErrBadParam); }
    if (!out_will_block                 ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = krb5int_ipc_stream_read_time (in_request_data, &last_wait_for_change_time);
    }

    if (!err) {
	if (last_wait_for_change_time < io_ccache->last_changed_time) {
	    cci_debug_printf ("%s returning immediately", __FUNCTION__);
	    err = krb5int_ipc_stream_write_time (io_reply_data, io_ccache->last_changed_time);

	} else {
	    ccs_callback_t callback = NULL;

	    err = ccs_callback_new (&callback,
				    ccErrInvalidCCache,
				    in_client_pipe,
				    in_reply_pipe,
				    (ccs_callback_owner_t) io_ccache,
				    ccs_ccache_invalidate_change_callback);

	    if (!err) {
		err = ccs_callback_array_insert (io_ccache->change_callbacks, callback,
						 ccs_callback_array_count (io_ccache->change_callbacks));
		if (!err) { callback = NULL; /* take ownership */ }

		cci_debug_printf ("%s blocking", __FUNCTION__);
		will_block = 1;
	    }

	    ccs_callback_release (callback);
	}
    }

    if (!err) {
	*out_will_block = will_block;
    }

    return cci_check_error (err);
}
示例#3
0
cc_int32 ccs_callback_new (ccs_callback_t                  *out_callback,
			   cc_int32                         in_invalid_object_err,
			   ccs_pipe_t                       in_client_pipe,
			   ccs_pipe_t                       in_reply_pipe,
			   ccs_callback_owner_t             in_owner,
			   ccs_callback_owner_invalidate_t  in_owner_invalidate_function)
{
    cc_int32 err = ccNoError;
    ccs_callback_t callback = NULL;
    ccs_client_t client = NULL;
    
    if (!out_callback                   ) { err = cci_check_error (ccErrBadParam); }
    if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
    if (!ccs_pipe_valid (in_reply_pipe) ) { err = cci_check_error (ccErrBadParam); }
    if (!in_owner                       ) { err = cci_check_error (ccErrBadParam); }
    if (!in_owner_invalidate_function   ) { err = cci_check_error (ccErrBadParam); }
    
    if (!err) {
        callback = malloc (sizeof (*callback));
        if (callback) { 
            *callback = ccs_callback_initializer;
        } else {
            err = cci_check_error (ccErrNoMem); 
        }
    }
    
    if (!err) {
        err = ccs_server_client_for_pipe (in_client_pipe, &client);
    }
    
    if (!err) {
	err = ccs_pipe_copy (&callback->client_pipe, in_client_pipe);
    }
    
    if (!err) {
	err = ccs_pipe_copy (&callback->reply_pipe, in_reply_pipe);
    }
    
    if (!err) {
        callback->client_pipe = in_client_pipe;
        callback->reply_pipe = in_reply_pipe;
        callback->invalid_object_err = in_invalid_object_err;
        callback->owner = in_owner;
        callback->owner_invalidate = in_owner_invalidate_function;
    
        err = ccs_client_add_callback (client, callback);
    }
     
    if (!err) {
        *out_callback = callback;
        callback = NULL;
    }
    
    ccs_callback_release (callback);
    
    return cci_check_error (err);    
}
示例#4
0
文件: ccs_lock.c 项目: Akasurde/krb5
cc_int32 ccs_lock_new (ccs_lock_t       *out_lock,
                       cc_uint32         in_type,
                       cc_int32          in_invalid_object_err,
                       ccs_pipe_t        in_client_pipe,
                       ccs_pipe_t        in_reply_pipe,
                       ccs_lock_state_t  in_lock_state_owner)
{
    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 &&
        in_type != cc_lock_write &&
        in_type != cc_lock_upgrade &&
        in_type != cc_lock_downgrade) {
        err = cci_check_error (ccErrBadLockType);
    }

    if (!err) {
        lock = malloc (sizeof (*lock));
        if (lock) {
            *lock = ccs_lock_initializer;
        } else {
            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,
				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);
}
示例#5
0
文件: ccs_ccache.c 项目: krb5/krb5
static cc_int32 ccs_ccache_lock (ccs_pipe_t             in_client_pipe,
                                 ccs_pipe_t             in_reply_pipe,
                                 ccs_ccache_t           io_ccache,
                                 ccs_cache_collection_t io_cache_collection,
                                 k5_ipc_stream           in_request_data,
                                 cc_uint32              *out_will_block,
                                 k5_ipc_stream           io_reply_data)
{
    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,
                                  lock_type, block, out_will_block);
    }

    return cci_check_error (err);
}
static cc_int32 ccs_list_iterator_object_release (cci_array_object_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 && 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;    
}
static cc_int32 ccs_list_iterator_new (ccs_list_iterator_t *out_list_iterator,
                                       ccs_list_t           io_list,
                                       ccs_pipe_t           in_client_pipe)
{
    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) { 
            *list_iterator = ccs_list_iterator_initializer;
        } else {
            err = cci_check_error (ccErrNoMem); 
        }
    }
    
    if (!err) {
        err = ccs_server_new_identifier (&list_iterator->identifier);
    }

    if (!err) {
        list_iterator->list = io_list;
        list_iterator->current = 0;
        
        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);
        }
    }

    if (!err) {
        *out_list_iterator = list_iterator;
        list_iterator = NULL;
    }
    
    ccs_list_iterator_release (list_iterator);
    
    return cci_check_error (err);    
}
示例#8
0
cc_int32 ccs_lock_state_remove (ccs_lock_state_t io_lock_state,
                                ccs_pipe_t       in_client_pipe)
{
    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.
         * 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.",
                                      __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);
}
示例#9
0
文件: ccs_lock.c 项目: Akasurde/krb5
cc_int32 ccs_lock_is_for_client_pipe (ccs_lock_t     in_lock,
                                      ccs_pipe_t     in_client_pipe,
                                      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,
					       out_is_for_client_pipe);
    }

    return cci_check_error (err);
}
示例#10
0
static cc_int32 ccs_cache_collection_unlock (ccs_pipe_t             in_client_pipe,
                                             ccs_cache_collection_t io_cache_collection,
                                             k5_ipc_stream           in_request_data,
                                             k5_ipc_stream           io_reply_data)
{
    cc_int32 err = ccNoError;

    if (!ccs_pipe_valid (in_client_pipe)) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection            ) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data                ) { err = cci_check_error (ccErrBadParam); }
    if (!io_reply_data                  ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = ccs_lock_state_remove (io_cache_collection->lock_state,
                                     in_client_pipe);
    }

    return cci_check_error (err);
}
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)) { 
            ccs_pipe_release (list_iterator->client_pipe);
            list_iterator->client_pipe = CCS_PIPE_NULL;
        }
        
        err = ccs_list_iterator_release (io_list_iterator);
    }
    
    return err;        
}
示例#12
0
cc_int32 ccs_lock_state_add (ccs_lock_state_t  io_lock_state,
                             ccs_pipe_t        in_client_pipe,
                             ccs_pipe_t        in_reply_pipe,
                             cc_uint32         in_lock_type,
                             cc_uint32         in_block,
                             cc_uint32        *out_will_send_reply)
{
    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.",
                                  __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);
                }
            }
        }
    }

    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);
}
示例#13
0
static cc_int32 ccs_lock_state_check_pending_lock (ccs_lock_state_t  io_lock_state,
        ccs_pipe_t        in_pending_lock_client_pipe,
        cc_uint32         in_pending_lock_type,
        cc_uint32        *out_grant_lock)
{
    cc_int32 err = ccNoError;
    cc_uint32 is_write_locked = 0;
    cc_uint32 client_has_lock = 0;
    cc_uint32 other_clients_have_locks = 0;
    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,
                                                   &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;
                    client_lock_index = i;
                }
            }
        }
    }

    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 &&
                                     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;
            }

        } else if (in_pending_lock_type == cc_lock_downgrade) {
            if (!client_has_lock || (client_lock_type != cc_lock_write &&
                                     client_lock_type != cc_lock_upgrade)) {
                err = cci_check_error (ccErrBadLockType);
            } else {
                /* downgrades can never block */
                grant_lock = 1;
            }
        } else {
            err = cci_check_error (ccErrBadLockType);
        }
    }

    if (!err) {
        *out_grant_lock = grant_lock;
    }

    return cci_check_error (err);
}
示例#14
0
文件: ccs_ccache.c 项目: krb5/krb5
cc_int32 ccs_ccache_handle_message (ccs_pipe_t              in_client_pipe,
                                    ccs_pipe_t              in_reply_pipe,
                                    ccs_ccache_t            io_ccache,
                                    ccs_cache_collection_t  io_cache_collection,
                                    enum cci_msg_id_t       in_request_name,
                                    k5_ipc_stream            in_request_data,
                                    cc_uint32              *out_will_block,
                                    k5_ipc_stream           *out_reply_data)
{
    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,
                                                       io_cache_collection,
                                                       in_client_pipe,
                                                       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,
                                   io_ccache, io_cache_collection,
                                   in_request_data,
                                   &will_block, reply_data);

        } else if (in_request_name == cci_ccache_unlock_msg_id) {
            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,
					      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) {
            *out_reply_data = reply_data;
            reply_data = NULL; /* take ownership */
        } else {
            *out_reply_data = NULL;
        }
    }

    krb5int_ipc_stream_release (reply_data);

    return cci_check_error (err);
}
示例#15
0
 cc_int32 ccs_cache_collection_handle_message (ccs_pipe_t              in_client_pipe,
                                               ccs_pipe_t              in_reply_pipe,
                                               ccs_cache_collection_t  io_cache_collection,
                                               enum cci_msg_id_t       in_request_name,
                                               k5_ipc_stream            in_request_data,
                                               cc_uint32              *out_will_block,
                                               k5_ipc_stream           *out_reply_data)
{
    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,
							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,
                                                            reply_data);

        } else if (in_request_name == cci_context_lock_msg_id) {
            err = ccs_cache_collection_lock (in_client_pipe, in_reply_pipe,
                                             io_cache_collection,
                                             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) {
            *out_reply_data = reply_data;
            reply_data = NULL; /* take ownership */
        } else {
            *out_reply_data = NULL;
        }
    }

    krb5int_ipc_stream_release (reply_data);

    return cci_check_error (err);
}