diff options
| author | Sam Hartman <hartmans@mit.edu> | 2006-10-21 20:20:30 +0000 |
|---|---|---|
| committer | Sam Hartman <hartmans@mit.edu> | 2006-10-21 20:20:30 +0000 |
| commit | faa68ad5ae7d1504b8be9e8a7bedb0b6e533d3cd (patch) | |
| tree | 314105a642beca7c1117bd24b069719e37ac3b35 /src/lib/ccapi/client | |
| parent | c1c08a16cde35a876a8c7fd36470cc7a1f2536c3 (diff) | |
| download | krb5-faa68ad5ae7d1504b8be9e8a7bedb0b6e533d3cd.tar.gz krb5-faa68ad5ae7d1504b8be9e8a7bedb0b6e533d3cd.tar.xz krb5-faa68ad5ae7d1504b8be9e8a7bedb0b6e533d3cd.zip | |
Delete src/lib/ccapi.
The ccapi shipped in 1.6 will not be based off this code
and will live in src/ccapi.
It will be copied onto the trunk and branch when ready, but this code is being removed before the branch cut.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18731 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/ccapi/client')
| -rw-r--r-- | src/lib/ccapi/client/NTMakefile | 18 | ||||
| -rw-r--r-- | src/lib/ccapi/client/cacheapi.c | 149 | ||||
| -rw-r--r-- | src/lib/ccapi/client/ccache.c | 1316 | ||||
| -rw-r--r-- | src/lib/ccapi/client/ccache.h | 146 | ||||
| -rw-r--r-- | src/lib/ccapi/client/ccache_iterator.c | 264 | ||||
| -rw-r--r-- | src/lib/ccapi/client/ccache_iterator.h | 89 | ||||
| -rw-r--r-- | src/lib/ccapi/client/ccapiv2.c | 295 | ||||
| -rw-r--r-- | src/lib/ccapi/client/ccstring.c | 94 | ||||
| -rw-r--r-- | src/lib/ccapi/client/ccstring.h | 65 | ||||
| -rw-r--r-- | src/lib/ccapi/client/context.c | 996 | ||||
| -rw-r--r-- | src/lib/ccapi/client/context.h | 131 | ||||
| -rw-r--r-- | src/lib/ccapi/client/credentials.c | 181 | ||||
| -rw-r--r-- | src/lib/ccapi/client/credentials.h | 94 | ||||
| -rw-r--r-- | src/lib/ccapi/client/credentials_iterator.c | 273 | ||||
| -rw-r--r-- | src/lib/ccapi/client/credentials_iterator.h | 76 |
15 files changed, 0 insertions, 4187 deletions
diff --git a/src/lib/ccapi/client/NTMakefile b/src/lib/ccapi/client/NTMakefile deleted file mode 100644 index 2ce87c350..000000000 --- a/src/lib/ccapi/client/NTMakefile +++ /dev/null @@ -1,18 +0,0 @@ -!INCLUDE <WIN32.MAK> - -CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) - -CC_CLIENT_OBJS = cacheapi.obj context.obj ccache.obj credentials.obj ccache_iterator.obj \ - credentials_iterator.obj ccstring.obj ccapiv2.obj - -CC_CLIENT_LIB = cc_client.lib - -CC_COMMON_LIB = ..\common\cc_common.lib - -$(CC_CLIENT_LIB): $(CC_CLIENT_OBJS) - $(implib) /NOLOGO /OUT:$@ $** - -all: $(CC_CLIENT_LIB) - -clean: - del *.obj *.lib diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c deleted file mode 100644 index 89c5e63d1..000000000 --- a/src/lib/ccapi/client/cacheapi.c +++ /dev/null @@ -1,149 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <CredentialsCache.h> -#include "ccache.h" -#include "ccache_iterator.h" -#include "context.h" -#include "cc_rpc.h" -#include "msg.h" -#include "msg_headers.h" - -/*! \fn cc_initialize - * \brief A function that initializes a ccapi context for the caller. - * \param[out] outContext a cc_context_t pointer to which is assigned the newly created context upon success. - * \param[in] inVersion a cc_int32 that specifies the - */ - -CCACHE_API cc_int32 -cc_initialize ( cc_context_t* outContext, - cc_int32 inVersion, - cc_int32* outSupportedVersion, - char const** outVendor) -{ - static char vendor[128] = ""; - cc_msg_t *request = NULL; - ccmsg_init_t *request_header; - cc_msg_t *response = NULL; - cc_uint32 type; - ccmsg_init_resp_t *response_header; - cc_int32 code; - - if ((inVersion != ccapi_version_2) && - (inVersion != ccapi_version_3) && - (inVersion != ccapi_version_4) && - (inVersion != ccapi_version_5) && - (inVersion != ccapi_version_6)) { - - if (outSupportedVersion != NULL) { - *outSupportedVersion = ccapi_version_6; - } - return ccErrBadAPIVersion; - } - - request_header = (ccmsg_init_t*)malloc(sizeof(ccmsg_init_t)); - if (request_header == NULL) - return ccErrNoMem; - - /* If the version number is 2, the caller will be passing - * the structure into the v2 compatibility functions which - * in turn will call the v6 functions. Set the version to - * ccapi_version_max since that is what the compatibility - * functions will be expecting. - */ - if (inVersion == ccapi_version_2) - inVersion = ccapi_version_max; - - /* Construct the request */ - request_header->in_version = htonl(inVersion); - - code = cci_msg_new(ccmsg_INIT, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_init_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_init_resp_t *)response->header; - *outSupportedVersion = ntohl(response_header->out_version); - code = cc_int_context_new(outContext, ntohll(response_header->out_ctx), ntohl(response_header->out_version)); - - if (!vendor[0]) { - char * string; - code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string); - strncpy(vendor, string, sizeof(vendor)-1); - vendor[sizeof(vendor)-1] = '\0'; - free(string); - } - *outVendor = vendor; - - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - diff --git a/src/lib/ccapi/client/ccache.c b/src/lib/ccapi/client/ccache.c deleted file mode 100644 index c442a8827..000000000 --- a/src/lib/ccapi/client/ccache.c +++ /dev/null @@ -1,1316 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - - -/* ccache.c */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <CredentialsCache.h> -#include "credentials.h" -#include "credentials_iterator.h" -#include "ccache.h" -#include "cc_rpc.h" -#include "msg.h" -#include "msg_headers.h" -#include "ccstring.h" - -/* - * cc_int_ccache_new - * - * Input parameters in host order. - */ - -cc_int32 -cc_int_ccache_new( cc_ccache_t * pccache, cc_handle hctx, cc_handle hccache ) -{ - cc_int_ccache_t ccache = (cc_int_ccache_t)malloc(sizeof(cc_int_ccache_d)); - if ( ccache == NULL ) - return ccErrNoMem; - - ccache->functions = (cc_ccache_f*)malloc(sizeof(cc_ccache_f)); - if ( ccache->functions == NULL ) { - free(ccache); - return ccErrNoMem; - } - - ccache->functions->release = cc_int_ccache_release; - ccache->functions->destroy = cc_int_ccache_destroy; - ccache->functions->set_default = cc_int_ccache_set_default; - ccache->functions->get_credentials_version = cc_int_ccache_get_credentials_version; - ccache->functions->get_name = cc_int_ccache_get_name; - ccache->functions->get_principal = cc_int_ccache_get_principal; - ccache->functions->set_principal = cc_int_ccache_set_principal; - ccache->functions->store_credentials = cc_int_ccache_store_credentials; - ccache->functions->remove_credentials = cc_int_ccache_remove_credentials; - ccache->functions->new_credentials_iterator = cc_int_ccache_new_credentials_iterator; - ccache->functions->move = cc_int_ccache_move; - ccache->functions->lock = cc_int_ccache_lock; - ccache->functions->unlock = cc_int_ccache_unlock; - ccache->functions->get_last_default_time = cc_int_ccache_get_last_default_time; - ccache->functions->get_change_time = cc_int_ccache_get_change_time; - ccache->functions->compare = cc_int_ccache_compare; - ccache->functions->get_kdc_time_offset = cc_int_ccache_get_kdc_time_offset; - ccache->functions->set_kdc_time_offset = cc_int_ccache_set_kdc_time_offset; - ccache->functions->clear_kdc_time_offset = cc_int_ccache_clear_kdc_time_offset; - - ccache->magic = CC_CCACHE_MAGIC; - ccache->ctx = hctx; - ccache->handle = hccache; - - *pccache = (cc_ccache_t)ccache; - - return ccNoError; -} - -cc_int32 -cc_int_ccache_release( cc_ccache_t ccache ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_release_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_release_t*)malloc(sizeof(ccmsg_ccache_release_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_RELEASE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_release_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - if (int_ccache->functions) - free(int_ccache->functions); - free(int_ccache); - return code; -} - - -cc_int32 -cc_int_ccache_destroy( cc_ccache_t ccache ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_destroy_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_destroy_t*)malloc(sizeof(ccmsg_ccache_destroy_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_DESTROY, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_destroy_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - free(ccache); - return code; -} - - -cc_int32 -cc_int_ccache_set_default( cc_ccache_t ccache ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_set_default_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_set_default_t*)malloc(sizeof(ccmsg_ccache_set_default_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_SET_DEFAULT, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_set_default_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_get_credentials_version( cc_ccache_t ccache, - cc_uint32* credentials_version) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_get_creds_version_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_get_creds_version_t*)malloc(sizeof(ccmsg_ccache_get_creds_version_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_GET_CREDS_VERSION, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_creds_version_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - ccmsg_ccache_get_creds_version_resp_t * response_header = (ccmsg_ccache_get_creds_version_resp_t*)response->header; - *credentials_version = ntohl(response_header->version); - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_get_name( cc_ccache_t ccache, cc_string_t* name ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_get_name_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_get_name_t*)malloc(sizeof(ccmsg_ccache_get_name_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_GET_NAME, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_name_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - char * string; - ccmsg_ccache_get_name_resp_t * response_header = (ccmsg_ccache_get_name_resp_t*)response->header; - code = cci_msg_retrieve_blob(response, response_header->name_offset, - response_header->name_len, &string); - if (code == ccNoError) { - code = cci_string_new(name, string); - free(string); - } - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_get_principal( cc_ccache_t ccache, - cc_uint32 credentials_version, - cc_string_t* principal ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_get_principal_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_get_principal_t*)malloc(sizeof(ccmsg_ccache_get_principal_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - request_header->version = htonl(credentials_version); - - code = cci_msg_new(ccmsg_CCACHE_GET_PRINCIPAL, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_principal_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - char * string; - ccmsg_ccache_get_principal_resp_t * response_header = (ccmsg_ccache_get_principal_resp_t*)response->header; - code = cci_msg_retrieve_blob(response, response_header->principal_offset, - response_header->principal_len, &string); - if (code == ccNoError) { - code = cci_string_new(principal, string); - free(string); - } - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_set_principal( cc_ccache_t ccache, - cc_uint32 credentials_version, - const char* principal ) -{ - cc_uint32 blob_pos; - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_set_principal_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_set_principal_t*)malloc(sizeof(ccmsg_ccache_set_principal_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - request_header->version = htonl(credentials_version); - - code = cci_msg_new(ccmsg_CCACHE_GET_PRINCIPAL, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_data_blob(request, (void*)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) - goto cleanup; - - request_header->principal_offset = htonl(blob_pos); - request_header->principal_len = htonl(strlen(principal) + 1); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_set_principal_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, - cc_credentials_iterator_t* iterator ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_creds_iterator_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_creds_iterator_t*)malloc(sizeof(ccmsg_ccache_creds_iterator_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_NEW_CREDS_ITERATOR, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_creds_iterator_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - ccmsg_ccache_creds_iterator_resp_t * response_header = (ccmsg_ccache_creds_iterator_resp_t*)response->header; - code = cc_int_credentials_iterator_new(iterator, int_ccache->ctx, int_ccache->handle, - ntohll(response_header->iterator)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_store_credentials( cc_ccache_t ccache, - const cc_credentials_union* credentials ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_store_creds_t *request_header = NULL; - cc_msg_t *response = NULL; - char *flat_cred = 0; - cc_uint32 flat_cred_len = 0; - cc_uint32 blob_pos; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL || credentials == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_store_creds_t*)malloc(sizeof(ccmsg_ccache_store_creds_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_STORE_CREDS, &request); - if (code != ccNoError) - goto cleanup; - - switch ( credentials->version ) { - case cc_credentials_v4: - code = cci_creds_v4_marshall(credentials->credentials.credentials_v4, &flat_cred, &flat_cred_len); - break; - case cc_credentials_v5: - code = cci_creds_v5_marshall(credentials->credentials.credentials_v5, &flat_cred, &flat_cred_len); - break; - default: - code = ccErrBadCredentialsVersion; - } - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_data_blob(request, (void*)flat_cred, flat_cred_len, &blob_pos); - if (code != ccNoError) - goto cleanup; - - request_header->creds_version = htonl(credentials->version); - request_header->creds_offset = htonl(blob_pos); - request_header->creds_len = htonl(flat_cred_len); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_store_creds_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (flat_cred) - free(flat_cred); - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_remove_credentials( cc_ccache_t ccache, - cc_credentials_t credentials ) -{ - cc_int_ccache_t int_ccache; - cc_int_credentials_t int_creds; - cc_msg_t *request = NULL; - ccmsg_ccache_rem_creds_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL || credentials == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - int_creds = (cc_int_credentials_t)credentials; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - if ( int_creds->magic != CC_CREDS_MAGIC ) - return ccErrInvalidCredentials; - - request_header = (ccmsg_ccache_rem_creds_t*)malloc(sizeof(ccmsg_ccache_rem_creds_t)); - if (request_header == NULL) - return ccErrNoMem; - - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - request_header->creds = htonll(int_creds->handle); - - code = cci_msg_new(ccmsg_CCACHE_REM_CREDS, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_rem_creds_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - - -cc_int32 -cc_int_ccache_move( cc_ccache_t source, - cc_ccache_t destination ) -{ - cc_int_ccache_t int_ccache_source; - cc_int_ccache_t int_ccache_dest; - cc_msg_t *request = NULL; - ccmsg_ccache_move_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( source == NULL || destination == NULL ) - return ccErrBadParam; - - int_ccache_source = (cc_int_ccache_t)source; - int_ccache_dest = (cc_int_ccache_t)destination; - - if ( int_ccache_source->magic != CC_CCACHE_MAGIC || - int_ccache_dest->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - if ( int_ccache_source->ctx != int_ccache_dest->ctx ) - return ccErrInvalidContext; - - request_header = (ccmsg_ccache_move_t*)malloc(sizeof(ccmsg_ccache_move_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CCACHE_MOVE, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_ccache_source->ctx); - request_header->ccache_source = htonll(int_ccache_source->handle); - request_header->ccache_dest = htonll(int_ccache_dest->handle); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_move_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_lock( cc_ccache_t ccache, - cc_uint32 lock_type, - cc_uint32 block ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_lock_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL || - (lock_type != cc_lock_read && lock_type != cc_lock_write && - lock_type != cc_lock_upgrade && lock_type != cc_lock_downgrade) || - (block != cc_lock_block && block != cc_lock_noblock) ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_lock_t*)malloc(sizeof(ccmsg_ccache_lock_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CCACHE_LOCK, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - request_header->lock_type = htonl(lock_type); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_lock_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - - // TODO: if (block == cc_lock_block) ..... - } else if (response->type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_unlock( cc_ccache_t ccache ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_unlock_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_unlock_t*)malloc(sizeof(ccmsg_ccache_unlock_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CCACHE_UNLOCK, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_unlock_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = htonl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = htonl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - - -cc_int32 -cc_int_ccache_get_last_default_time( cc_ccache_t ccache, - cc_time* time_offset ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_get_last_default_time_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_time64 t64; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_get_last_default_time_t*)malloc(sizeof(ccmsg_ccache_get_last_default_time_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_GET_LAST_DEFAULT_TIME, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_last_default_time_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - ccmsg_ccache_get_last_default_time_resp_t * response_header = (ccmsg_ccache_get_last_default_time_resp_t*)response->header; - t64 = ntohll(response_header->last_default_time); - /* TODO: validate that we do not overflow the max value of time_offset */ - *time_offset = t64; - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_get_change_time( cc_ccache_t ccache, cc_time* change_time ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_get_change_time_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_time64 t64; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_get_change_time_t*)malloc(sizeof(ccmsg_ccache_get_change_time_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - - code = cci_msg_new(ccmsg_CCACHE_GET_CHANGE_TIME, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_change_time_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - ccmsg_ccache_get_change_time_resp_t * response_header = (ccmsg_ccache_get_change_time_resp_t*)response->header; - t64 = htonll(response_header->time); - /* TODO: validate that we do not overflow 'time' */ - *change_time = t64; - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_compare( cc_ccache_t ccache, - cc_ccache_t compare_to, - cc_uint32* equal ) -{ - cc_int_ccache_t int_ccache; - cc_int_ccache_t int_compare_to; - cc_msg_t *request = NULL; - ccmsg_ccache_compare_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - int_compare_to = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC || - int_compare_to->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_compare_t*)malloc(sizeof(ccmsg_ccache_compare_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache1 = htonll(int_ccache->handle); - request_header->ccache2 = htonll(int_compare_to->handle); - - code = cci_msg_new(ccmsg_CCACHE_COMPARE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_compare_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - ccmsg_ccache_compare_resp_t * response_header = (ccmsg_ccache_compare_resp_t*)response->header; - *equal = ntohl(response_header->is_equal); - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, - cc_int32 credentials_version, - cc_time* time_offset ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_get_kdc_time_offset_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_get_kdc_time_offset_t*)malloc(sizeof(ccmsg_ccache_get_kdc_time_offset_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - request_header->creds_version = htonl(credentials_version); - - code = cci_msg_new(ccmsg_CCACHE_GET_KDC_TIME_OFFSET, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_kdc_time_offset_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (response->type == ccmsg_ACK) { - ccmsg_ccache_get_kdc_time_offset_resp_t * response_header = (ccmsg_ccache_get_kdc_time_offset_resp_t*)response->header; - *time_offset = (cc_time64)ntohll(response_header->offset); - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, - cc_int32 credentials_version, - cc_time time_offset ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_set_kdc_time_offset_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_int64 t64; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_set_kdc_time_offset_t*)malloc(sizeof(ccmsg_ccache_set_kdc_time_offset_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - request_header->creds_version = htonl(credentials_version); - t64 = time_offset; - request_header->offset = htonll(t64); - - code = cci_msg_new(ccmsg_CCACHE_SET_KDC_TIME_OFFSET, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_set_kdc_time_offset_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, - cc_int32 credentials_version ) -{ - cc_int_ccache_t int_ccache; - cc_msg_t *request = NULL; - ccmsg_ccache_clear_kdc_time_offset_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_ccache = (cc_int_ccache_t)ccache; - - if ( int_ccache->magic != CC_CCACHE_MAGIC ) - return ccErrInvalidCCache; - - request_header = (ccmsg_ccache_clear_kdc_time_offset_t*)malloc(sizeof(ccmsg_ccache_clear_kdc_time_offset_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_ccache->ctx); - request_header->ccache = htonll(int_ccache->handle); - request_header->creds_version = htonl(credentials_version); - - code = cci_msg_new(ccmsg_CCACHE_CLEAR_KDC_TIME_OFFSET, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_clear_kdc_time_offset_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} diff --git a/src/lib/ccapi/client/ccache.h b/src/lib/ccapi/client/ccache.h deleted file mode 100644 index 255cf2a42..000000000 --- a/src/lib/ccapi/client/ccache.h +++ /dev/null @@ -1,146 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* ccache.h */ - -#define CC_CCACHE_MAGIC ('C'<<24 | 'C'<<16 | 'A'<<8 | 'C') - -struct cc_int_ccache_d { - cc_ccache_f* functions; -#if TARGET_OS_MAC - const cc_ccache_f* otherFunctions; -#endif - cc_uint32 magic; - cc_handle handle; - cc_handle ctx; -}; -typedef struct cc_int_ccache_d cc_int_ccache_d; -typedef cc_int_ccache_d* cc_int_ccache_t; - - -cc_int32 -cc_int_ccache_new( cc_ccache_t * pccache, cc_handle hctx, cc_handle hccache ); - -cc_int32 -cc_int_ccache_release( cc_ccache_t ccache ); - -cc_int32 -cc_int_ccache_destroy( cc_ccache_t ccache ); - -cc_int32 -cc_int_ccache_set_default( cc_ccache_t ccache ); - -cc_int32 -cc_int_ccache_get_credentials_version( cc_ccache_t ccache, - cc_uint32* credentials_version); - -cc_int32 -cc_int_ccache_get_name( cc_ccache_t ccache, - cc_string_t* name ); - -cc_int32 -cc_int_ccache_get_principal( cc_ccache_t ccache, - cc_uint32 credentials_version, - cc_string_t* principal ); - -cc_int32 -cc_int_ccache_set_principal( cc_ccache_t ccache, - cc_uint32 credentials_version, - const char* principal ); - -cc_int32 -cc_int_ccache_store_credentials( cc_ccache_t ccache, - const cc_credentials_union* credentials ); - -cc_int32 -cc_int_ccache_remove_credentials( cc_ccache_t ccache, - cc_credentials_t credentials ); - -cc_int32 -cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, - cc_credentials_iterator_t* iterator ); - -cc_int32 -cc_int_ccache_move( cc_ccache_t source, - cc_ccache_t destination ); - -cc_int32 -cc_int_ccache_lock( cc_ccache_t ccache, - cc_uint32 block, - cc_uint32 lock_type ); - -cc_int32 -cc_int_ccache_unlock( cc_ccache_t ccache ); - -cc_int32 -cc_int_ccache_get_last_default_time( cc_ccache_t ccache, - cc_time* last_default_tim ); - -cc_int32 -cc_int_ccache_get_change_time( cc_ccache_t ccache, - cc_time* change_time ); - -cc_int32 -cc_int_ccache_compare( cc_ccache_t ccache, - cc_ccache_t compare_to, - cc_uint32* equal ); - -cc_int32 -cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, - cc_int32 credentials_version, - cc_time* kdc_time_offset ); - -cc_int32 -cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, - cc_int32 credentials_version, - cc_time kdc_time_offset ); - -cc_int32 -cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, - cc_int32 credentials_version ); - - -cc_int32 -cc_int_ccache_compat_clone( cc_int_ccache_t ccache, - cc_int_ccache_t *clone ); - diff --git a/src/lib/ccapi/client/ccache_iterator.c b/src/lib/ccapi/client/ccache_iterator.c deleted file mode 100644 index 3da9b3547..000000000 --- a/src/lib/ccapi/client/ccache_iterator.c +++ /dev/null @@ -1,264 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* ccache_iterator.c */ - -#include <stdlib.h> -#include <stdio.h> -#include <CredentialsCache.h> -#include "ccache.h" -#include "ccache_iterator.h" -#include "cc_rpc.h" -#include "msg.h" -#include "msg_headers.h" - - -cc_int32 -cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, - cc_handle ctx, - cc_handle handle ) -{ - cc_int_ccache_iterator_t iter = NULL; - - if ( piter == NULL ) - return ccErrBadParam; - - iter = (cc_int_ccache_iterator_t) malloc( sizeof(cc_int_ccache_iterator_d) ); - if ( iter == NULL ) - return ccErrNoMem; - - iter->functions = (cc_ccache_iterator_f*)malloc( sizeof(cc_ccache_iterator_f)); - if ( iter->functions == NULL ) { - free(iter); - return ccErrNoMem; - } - - iter->functions->release = cc_int_ccache_iterator_release; - iter->functions->next = cc_int_ccache_iterator_next; - iter->magic = CC_CCACHE_ITER_MAGIC; - iter->ctx = ctx; - iter->handle = handle; - - *piter = (cc_ccache_iterator_t)iter; - return ccNoError; -} - -cc_int32 -cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) -{ - cc_int_ccache_iterator_t int_iter; - cc_msg_t *request = NULL; - ccmsg_ccache_iterator_release_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - - if ( iter == NULL ) - return ccErrBadParam; - - int_iter = (cc_int_ccache_iterator_t) iter; - - if ( int_iter->magic != CC_CCACHE_ITER_MAGIC ) - return ccErrInvalidCCacheIterator; - - request_header = (ccmsg_ccache_iterator_release_t*)malloc(sizeof(ccmsg_ccache_iterator_release_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_iter->ctx); - request_header->iterator = htonll(int_iter->handle); - code = cci_msg_new(ccmsg_CCACHE_ITERATOR_RELEASE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_iterator_release_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - - if (int_iter->functions) - free(int_iter->functions); - if (iter) - free(int_iter); - return ccNoError; -} - -cc_int32 -cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, - cc_ccache_t * ccache ) -{ - cc_int_ccache_iterator_t int_iter; - cc_msg_t *request = NULL; - ccmsg_ccache_iterator_next_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( ccache == NULL ) - return ccErrBadParam; - - int_iter = (cc_int_ccache_iterator_t)iter; - - if ( int_iter->magic != CC_CCACHE_ITER_MAGIC ) - return ccErrInvalidCCacheIterator; - - request_header = (ccmsg_ccache_iterator_next_t*)malloc(sizeof(ccmsg_ccache_iterator_next_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_iter->ctx); - request_header->iterator = htonll(int_iter->handle); - - code = cci_msg_new(ccmsg_CCACHE_ITERATOR_NEXT, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_iterator_next_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (type == ccmsg_ACK) { - ccmsg_ccache_iterator_next_resp_t * response_header = (ccmsg_ccache_iterator_next_resp_t*)response->header; - code = cc_int_ccache_new(ccache, int_iter->ctx, ntohll(response_header->ccache)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_ccache_iterator_clone( cc_ccache_iterator_t iter, - cc_ccache_iterator_t * new_iter ) -{ - cc_int_ccache_iterator_t int_iter; - cc_msg_t *request = NULL; - ccmsg_ccache_iterator_clone_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( iter == NULL || new_iter == NULL ) - return ccErrBadParam; - - int_iter = (cc_int_ccache_iterator_t)iter; - - if ( int_iter->magic != CC_CCACHE_ITER_MAGIC ) - return ccErrInvalidCCacheIterator; - - request_header = (ccmsg_ccache_iterator_clone_t*)malloc(sizeof(ccmsg_ccache_iterator_clone_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_iter->ctx); - request_header->iterator = htonll(int_iter->handle); - - code = cci_msg_new(ccmsg_CCACHE_ITERATOR_CLONE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_iterator_clone_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - ccmsg_ccache_iterator_clone_resp_t * response_header = (ccmsg_ccache_iterator_clone_resp_t*)response->header; - code = cc_int_ccache_iterator_new(new_iter, int_iter->ctx, ntohll(response_header->iterator)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} diff --git a/src/lib/ccapi/client/ccache_iterator.h b/src/lib/ccapi/client/ccache_iterator.h deleted file mode 100644 index 5a390b82e..000000000 --- a/src/lib/ccapi/client/ccache_iterator.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* ccache_iterator.h */ - -#define CC_CCACHE_ITER_MAGIC ('C'<<24 | 'C'<<16 | 'I'<<8 | 'T') - -struct cc_int_ccache_iterator_d { - cc_ccache_iterator_f* functions; -#if TARGET_OS_MAC - cc_ccache_iterator_f* otherFunctions; -#endif - cc_uint32 magic; - cc_handle handle; - cc_handle ctx; - - cc_uint32 repeat_count; - cc_ccache_t compat_copy; -}; -typedef struct cc_int_ccache_iterator_d cc_int_ccache_iterator_d; -typedef cc_int_ccache_iterator_d* cc_int_ccache_iterator_t; - - -cc_int32 -cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, - cc_handle ctx, - cc_handle handle ); - -cc_int32 -cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ); - -cc_int32 -cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, - cc_ccache_t * ccache ); - -cc_int32 -cc_int_ccache_iterator_clone( cc_ccache_iterator_t iter, - cc_ccache_iterator_t * iter_new ); - -cc_int32 -cc_int_ccache_iterator_set_repeat_count( cc_int_ccache_iterator_t iter, - cc_uint32 count ); - -cc_int32 -cc_int_ccache_iterator_get_repeat_count( cc_int_ccache_iterator_t iter, - cc_uint32 * count ); - - - diff --git a/src/lib/ccapi/client/ccapiv2.c b/src/lib/ccapi/client/ccapiv2.c deleted file mode 100644 index 82b04c2c8..000000000 --- a/src/lib/ccapi/client/ccapiv2.c +++ /dev/null @@ -1,295 +0,0 @@ -/* $Copyright:
- *
- * Copyright 1998-2006 by the Massachusetts Institute of Technology.
- *
- * All rights reserved.
- *
- * Export of this software from the United States of America may require a
- * specific license from the United States Government. It is the
- * responsibility of any person or organization contemplating export to
- * obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute
- * this software and its documentation for any purpose and without fee is
- * hereby granted, provided that the above copyright notice appear in all
- * copies and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of M.I.T. not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. Furthermore if you
- * modify this software you must label your software as modified software
- * and not distribute it in such a fashion that it might be confused with
- * the original MIT software. M.I.T. makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Individual source code files are copyright MIT, Cygnus Support,
- * OpenVision, Oracle, Sun Soft, FundsXpress, and others.
- *
- * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
- * and Zephyr are trademarks of the Massachusetts Institute of Technology
- * (MIT). No commercial use of these trademarks may be made without prior
- * written permission of MIT.
- *
- * "Commercial use" means use of a name in a product or other for-profit
- * manner. It does NOT prevent a commercial firm from referring to the MIT
- * trademarks in order to convey information (although in doing so,
- * recognition of their trademark status should be given).
- * $
- */
-/*
- * This is backwards compatibility for CCache API v2 clients to be able to run
- * against the CCache API v3 library
- */
-
-#include "CredentialsCache2.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-CCACHE_API cc_int32 cc_shutdown (
- apiCB** ioContext)
-{
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_get_NC_info (
- apiCB* inContext,
- infoNC*** outInfo)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_get_change_time (
- apiCB* inContext,
- cc_time* outTime)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_open (
- apiCB* inContext,
- const char* inName,
- cc_int32 inVersion,
- cc_uint32 inFlags,
- ccache_p** outCCache)
-{
- if (inVersion != CC_CRED_V4 && inVersion != CC_CRED_V5)
- return CC_ERR_CRED_VERSION;
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_create (
- apiCB* inContext,
- const char* inName,
- const char* inPrincipal,
- cc_int32 inVersion,
- cc_uint32 inFlags,
- ccache_p** outCCache)
-{
- if (inVersion != CC_CRED_V4 && inVersion != CC_CRED_V5)
- return CC_ERR_CRED_VERSION;
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_close (
- apiCB* inContext,
- ccache_p** ioCCache)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_destroy (
- apiCB* inContext,
- ccache_p** ioCCache)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_seq_fetch_NCs_begin (
- apiCB* inContext,
- ccache_cit** outIterator)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_seq_fetch_NCs_next (
- apiCB* inContext,
- ccache_p** outCCache,
- ccache_cit* inIterator)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_seq_fetch_NCs_end (
- apiCB* inContext,
- ccache_cit** ioIterator)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_get_name (
- apiCB* inContext,
- ccache_p* inCCache,
- char** outName)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_get_cred_version (
- apiCB* inContext,
- ccache_p* inCCache,
- cc_int32* outVersion)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_set_principal (
- apiCB* inContext,
- ccache_p* inCCache,
- cc_int32 inVersion,
- char* inPrincipal)
-{
- if (inVersion != CC_CRED_V4 && inVersion != CC_CRED_V5)
- return CC_ERR_CRED_VERSION;
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_get_principal (
- apiCB* inContext,
- ccache_p* inCCache,
- char** outPrincipal)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_store (
- apiCB* inContext,
- ccache_p* inCCache,
- cred_union inCredentials)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_remove_cred (
- apiCB* inContext,
- ccache_p* inCCache,
- cred_union inCredentials)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_seq_fetch_creds_begin (
- apiCB* inContext,
- const ccache_p* inCCache,
- ccache_cit** outIterator)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_seq_fetch_creds_next (
- apiCB* inContext,
- cred_union** outCreds,
- ccache_cit* inIterator)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_seq_fetch_creds_end (
- apiCB* inContext,
- ccache_cit** ioIterator)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_free_principal (
- apiCB* inContext,
- char** ioPrincipal)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_free_name (
- apiCB* inContext,
- char** ioName)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_free_creds (
- apiCB* inContext,
- cred_union** creds)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_free_NC_info (
- apiCB* inContext,
- infoNC*** ioInfo)
-{
-
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-CCACHE_API cc_int32 cc_lock_request(
- apiCB* inContext,
- const ccache_p* inCCache,
- const cc_int32 lock_type)
-{
- /* replace this return value when the function is implemented */
- return CC_NOT_SUPP;
-}
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
diff --git a/src/lib/ccapi/client/ccstring.c b/src/lib/ccapi/client/ccstring.c deleted file mode 100644 index 6f3fa2bcb..000000000 --- a/src/lib/ccapi/client/ccstring.c +++ /dev/null @@ -1,94 +0,0 @@ -/* $Copyright: - * - * Copyright 2004 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* ccstring.c */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <CredentialsCache.h> -#include "ccstring.h" - -cc_int32 -cci_string_new( cc_string_t * pstring, char * data ) -{ - cci_string_t string = (cci_string_t)malloc(sizeof(cci_string_d)); - if ( string == NULL ) - return ccErrNoMem; - - string->functions = (cc_string_f *)malloc(sizeof(cc_string_f)); - if ( string->functions == NULL ) { - free(string); - return ccErrNoMem; - } - - string->magic = CC_STRING_MAGIC; - string->functions->release = cci_string_release; - - string->data = strdup(data); - if ( string->data == NULL ) { - free(string->functions); - free(string); - return ccErrNoMem; - } - - *pstring = (cc_string_t)string; - return ccNoError; -} - -cc_int32 -cci_string_release( cc_string_t str ) -{ - cci_string_t int_string; - if ( str == NULL ) - return ccErrBadParam; - - int_string = (cci_string_t)str; - if ( int_string->magic != CC_STRING_MAGIC ) - return ccErrInvalidString; - - free(int_string->functions); - free(int_string->data); - free(int_string); - return ccNoError; -} diff --git a/src/lib/ccapi/client/ccstring.h b/src/lib/ccapi/client/ccstring.h deleted file mode 100644 index 2c973afbb..000000000 --- a/src/lib/ccapi/client/ccstring.h +++ /dev/null @@ -1,65 +0,0 @@ -/* $Copyright: - * - * Copyright 2004 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* ccstring.h */ - -#define CC_STRING_MAGIC ('S'<<24 | 'T'<<16 | 'R'<<8 | 'I') - -struct cci_string_d { - char* data; - cc_string_f* functions; -#if TARGET_OS_MAC - cc_string_f* otherFunctions; -#endif - cc_uint32 magic; -}; -typedef struct cci_string_d cci_string_d; -typedef cci_string_d* cci_string_t; - -cc_int32 -cci_string_new( cc_string_t * pstring, char * data ); - -cc_int32 -cci_string_release( cc_string_t string ); - - diff --git a/src/lib/ccapi/client/context.c b/src/lib/ccapi/client/context.c deleted file mode 100644 index 4bcfc040c..000000000 --- a/src/lib/ccapi/client/context.c +++ /dev/null @@ -1,996 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* context.c */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <CredentialsCache.h> -#include "context.h" -#include "ccache.h" -#include "ccache_iterator.h" -#include "cc_rpc.h" -#include "msg.h" -#include "msg_headers.h" -#include "ccstring.h" - -/* cc_int_context_new - * - * input parameters (handle, version) are in host order - */ - -cc_int32 -cc_int_context_new( cc_context_t * pcontext, cc_handle handle, cc_uint32 version ) -{ - cc_int_context_t context = (cc_int_context_t)malloc(sizeof(cc_int_context_d)); - if (context == NULL) - return ccErrNoMem; - - context->functions = (cc_context_f*)malloc(sizeof(cc_context_f)); - if (context->functions == NULL) { - free(context); - return ccErrNoMem; - } - - context->functions->release = cc_int_context_release; - context->functions->get_change_time = cc_int_context_get_change_time; - context->functions->get_default_ccache_name = cc_int_context_get_default_ccache_name; - context->functions->open_ccache = cc_int_context_open_ccache; - context->functions->open_default_ccache = cc_int_context_open_default_ccache; - context->functions->create_ccache = cc_int_context_create_ccache; - context->functions->create_default_ccache = cc_int_context_create_default_ccache; - context->functions->create_new_ccache = cc_int_context_create_new_ccache; - context->functions->new_ccache_iterator = cc_int_context_new_ccache_iterator; - context->functions->lock = cc_int_context_lock; - context->functions->unlock = cc_int_context_unlock; - context->functions->compare = cc_int_context_compare; - - context->magic = CC_CONTEXT_MAGIC; - context->handle = handle; - context->api_version = version; - - *pcontext = (cc_context_t)context; - return ccNoError; -} - -cc_int32 -cc_int_context_release( cc_context_t context ) -{ - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ctx_release_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ctx_release_t*)malloc(sizeof(ccmsg_ctx_release_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_context->handle); - - code = cci_msg_new(ccmsg_CTX_RELEASE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_release_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - request_header = NULL; - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - free(int_context->functions); - free(int_context); - return code; -} - -cc_int32 -cc_int_context_get_change_time( cc_context_t context, - cc_time* change_time) -{ - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ctx_get_change_time_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ctx_get_change_time_resp_t *response_header; - cc_time64 t64; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || time == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ctx_get_change_time_t*)malloc(sizeof(ccmsg_ctx_get_change_time_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_context->handle); - - code = cci_msg_new(ccmsg_CTX_GET_CHANGE_TIME, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_get_change_time_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (response->type == ccmsg_ACK) { - response_header = (ccmsg_ctx_get_change_time_resp_t*)response->header; - t64 = ntohll(response_header->time); - /* TODO: validate that value is not greater than can fit in cc_time */ - *change_time = (cc_time)t64; - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_get_default_ccache_name( cc_context_t context, - cc_string_t* name ) -{ - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ctx_get_default_ccache_name_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ctx_get_default_ccache_name_resp_t *response_header; - char *string = NULL; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || name == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ctx_get_default_ccache_name_t*)malloc(sizeof(ccmsg_ctx_get_default_ccache_name_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_context->handle); - - code = cci_msg_new(ccmsg_CTX_GET_DEFAULT_CCACHE_NAME, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_get_default_ccache_name_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ctx_get_default_ccache_name_resp_t*)response->header; - code = cci_msg_retrieve_blob(response, response_header->name_offset, - response_header->name_len, &string); - if (code == ccNoError) - code = cci_string_new(name, string); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (string) - free(string); - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_compare( cc_context_t context, - cc_context_t compare_to, - cc_uint32* equal ) -{ - cc_int_context_t int_context, int_compare_to; - cc_msg_t *request = NULL; - ccmsg_ctx_compare_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ctx_compare_resp_t *response_header; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || compare_to == NULL || - equal == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - int_compare_to = (cc_int_context_t)compare_to; - - if ( int_context->magic != CC_CONTEXT_MAGIC || - int_compare_to->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ctx_compare_t*)malloc(sizeof(ccmsg_ctx_compare_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx1 = htonll(int_context->handle); - request_header->ctx2 = htonll(int_compare_to->handle); - - code = cci_msg_new(ccmsg_CTX_COMPARE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_compare_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ctx_compare_resp_t*)response->header; - *equal = ntohl(response_header->is_equal); - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - - -cc_int32 -cc_int_context_new_ccache_iterator( cc_context_t context, - cc_ccache_iterator_t* iterator ) -{ - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ctx_new_ccache_iterator_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ctx_new_ccache_iterator_resp_t *response_header; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || iterator == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ctx_new_ccache_iterator_t*)malloc(sizeof(ccmsg_ctx_new_ccache_iterator_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_context->handle); - - code = cci_msg_new(ccmsg_CTX_NEW_CCACHE_ITERATOR, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_new_ccache_iterator_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ctx_new_ccache_iterator_resp_t*)response->header; - code = cc_int_ccache_iterator_new(iterator, int_context->handle, - ntohll(response_header->iterator)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_open_ccache( cc_context_t context, - const char* name, - cc_ccache_t* ccache ) -{ - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ccache_open_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ccache_open_resp_t *response_header; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || name == NULL || ccache == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ccache_open_t*)malloc(sizeof(ccmsg_ccache_open_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_context->handle); - request_header->name_offset = htonl(blob_pos); - request_header->name_len = htonl(strlen(name) + 1); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_open_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_open_default_ccache( cc_context_t context, - cc_ccache_t* ccache) -{ - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ccache_open_default_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ccache_open_resp_t *response_header; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || ccache == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ccache_open_default_t*)malloc(sizeof(ccmsg_ccache_open_default_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN_DEFAULT, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_context->handle); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_open_default_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_create_ccache( cc_context_t context, - const char* name, - cc_uint32 cred_vers, - const char* principal, - cc_ccache_t* ccache ) -{ - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ccache_create_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ccache_create_resp_t *response_header; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || name == NULL || - cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || - principal == NULL || ccache == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ccache_create_t*)malloc(sizeof(ccmsg_ccache_create_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_context->handle); - request_header->version = htonl(cred_vers); - request_header->name_offset = htonl(blob_pos); - request_header->name_len = htonl(strlen(name) + 1); - - code = cci_msg_add_data_blob(request, (void *)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) - goto cleanup; - - request_header->principal_offset = htonl(blob_pos); - request_header->principal_len = htonl(strlen(principal) + 1); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_create_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_create_default_ccache( cc_context_t context, - cc_uint32 cred_vers, - const char* principal, - cc_ccache_t* ccache ) -{ - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ccache_create_default_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ccache_create_resp_t *response_header; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || - cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || - principal == NULL || ccache == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ccache_create_default_t*)malloc(sizeof(ccmsg_ccache_create_default_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_DEFAULT, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_context->handle); - request_header->version = htonl(cred_vers); - - code = cci_msg_add_data_blob(request, (void *)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) - goto cleanup; - - request_header->principal_offset = htonl(blob_pos); - request_header->principal_len = htonl(strlen(principal) + 1); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_create_default_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_create_new_ccache( cc_context_t context, - cc_uint32 cred_vers, - const char* principal, - cc_ccache_t* ccache ) -{ - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ccache_create_unique_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ccache_create_resp_t *response_header; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || - cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || - principal == NULL || ccache == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ccache_create_unique_t*)malloc(sizeof(ccmsg_ccache_create_unique_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_UNIQUE, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_context->handle); - request_header->version = htonl(cred_vers); - - code = cci_msg_add_data_blob(request, (void *)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) - goto cleanup; - - request_header->principal_offset = htonl(blob_pos); - request_header->principal_len = htonl(strlen(principal) + 1); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_create_unique_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = htonl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ccache_create_resp_t*)response-> header; - code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_lock( cc_context_t context, - cc_uint32 lock_type, - cc_uint32 block ) -{ - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ctx_lock_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL || - (lock_type != cc_lock_read && lock_type != cc_lock_write && - lock_type != cc_lock_upgrade && lock_type != cc_lock_downgrade) || - (block != cc_lock_block && block != cc_lock_noblock) ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ctx_lock_t*)malloc(sizeof(ccmsg_ctx_lock_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CTX_LOCK, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_context->handle); - request_header->lock_type = htonl(lock_type); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_lock_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - - // TODO: if (block == cc_lock_block) ..... - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_unlock( cc_context_t context ) -{ - cc_int_context_t int_context; - cc_msg_t *request = NULL; - ccmsg_ctx_unlock_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( context == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - request_header = (ccmsg_ctx_unlock_t*)malloc(sizeof(ccmsg_ctx_unlock_t)); - if (request_header == NULL) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CTX_UNLOCK, &request); - if (code != ccNoError) - goto cleanup; - - request_header->ctx = htonll(int_context->handle); - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_unlock_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_clone( cc_context_t inContext, - cc_context_t* outContext, - cc_int32 requestedVersion, - cc_int32* supportedVersion, - char const** vendor ) -{ - cc_int_context_t int_context; - static char vendor_st[128] = ""; - cc_msg_t *request = NULL; - ccmsg_ctx_clone_t *request_header = NULL; - cc_msg_t *response = NULL; - ccmsg_ctx_clone_resp_t *response_header; - char *string = NULL; - cc_uint32 type; - cc_int32 code; - - if ( inContext == NULL || - outContext == NULL || - supportedVersion == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)inContext; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - if ((requestedVersion != ccapi_version_2) && - (requestedVersion != ccapi_version_3) && - (requestedVersion != ccapi_version_4) && - (requestedVersion != ccapi_version_5) && - (requestedVersion != ccapi_version_6)) { - - if (supportedVersion != NULL) { - *supportedVersion = ccapi_version_max; - } - return ccErrBadAPIVersion; - } - - request_header = (ccmsg_ctx_clone_t*)malloc(sizeof(ccmsg_ctx_clone_t)); - if (request_header == NULL) - return ccErrNoMem; - - request_header->ctx = htonll(int_context->handle); - request_header->in_version = htonl(requestedVersion); - - code = cci_msg_new(ccmsg_INIT, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_clone_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - response_header = (ccmsg_ctx_clone_resp_t *)response->header; - *supportedVersion = ntohl(response_header->out_version); - code = cc_int_context_new(outContext, ntohll(response_header->out_ctx), ntohl(response_header->out_version)); - - if (!vendor_st[0]) { - code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string); - strncpy(vendor_st, string, sizeof(vendor_st)-1); - vendor_st[sizeof(vendor_st)-1] = '\0'; - } - *vendor = vendor_st; - - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (string) - free(string); - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_context_get_version( cc_context_t context, - cc_int32* version ) -{ - cc_int_context_t int_context; - - if ( context == NULL || - version == NULL ) - return ccErrBadParam; - - int_context = (cc_int_context_t)context; - - if ( int_context->magic != CC_CONTEXT_MAGIC ) - return ccErrInvalidContext; - - *version = int_context->api_version; - return ccNoError; -} - - diff --git a/src/lib/ccapi/client/context.h b/src/lib/ccapi/client/context.h deleted file mode 100644 index eb0ea520e..000000000 --- a/src/lib/ccapi/client/context.h +++ /dev/null @@ -1,131 +0,0 @@ -/* $Copyright: - * - * Copyright 2004 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* context.h */ - -#define CC_CONTEXT_MAGIC ('C'<<24 | 'C'<<16 | 'T'<<8 | 'X') - -struct cc_int_context { - cc_context_f* functions; - - cc_uint32 magic; -#ifdef CCAPI_V2_COMPAT - cc_uint32 version; -#endif - cc_uint32 api_version; - cc_handle handle; -}; -typedef struct cc_int_context cc_int_context_d; -typedef cc_int_context_d* cc_int_context_t; - -cc_int32 -cc_int_context_new( cc_context_t *pcontext, cc_handle handle, cc_uint32 version ); - -cc_int32 -cc_int_context_release( cc_context_t context ); - -cc_int32 -cc_int_context_get_change_time( cc_context_t context, - cc_time* change_time); - -cc_int32 -cc_int_context_get_default_ccache_name( cc_context_t context, - cc_string_t* name ); - -cc_int32 -cc_int_context_open_ccache( cc_context_t context, - const char* name, - cc_ccache_t* ccache ); - -cc_int32 -cc_int_context_open_default_ccache( cc_context_t context, - cc_ccache_t* ccache ); - -cc_int32 -cc_int_context_create_ccache( cc_context_t context, - const char* name, - cc_uint32 cred_vers, - const char* principal, - cc_ccache_t* ccache ); - -cc_int32 -cc_int_context_create_default_ccache( cc_context_t context, - cc_uint32 cred_vers, - const char* principal, - cc_ccache_t* ccache ); - -cc_int32 -cc_int_context_create_new_ccache( cc_context_t context, - cc_uint32 cred_vers, - const char* principal, - cc_ccache_t* ccache ); - -cc_int32 -cc_int_context_new_ccache_iterator( cc_context_t context, - cc_ccache_iterator_t* iterator ); - -cc_int32 -cc_int_context_lock( cc_context_t context, - cc_uint32 lock_type, - cc_uint32 block ); - -cc_int32 -cc_int_context_unlock( cc_context_t context ); - -cc_int32 -cc_int_context_compare( cc_context_t context, - cc_context_t compare_to, - cc_uint32* equal ); - -cc_int32 -cc_int_context_clone( cc_context_t inContext, - cc_context_t* outContext, - cc_int32 requestedVersion, - cc_int32* supportedVersion, - char const** vendor ); - -cc_int32 -cc_int_context_get_version( cc_context_t context, - cc_int32* version ); - - diff --git a/src/lib/ccapi/client/credentials.c b/src/lib/ccapi/client/credentials.c deleted file mode 100644 index dbdf6345e..000000000 --- a/src/lib/ccapi/client/credentials.c +++ /dev/null @@ -1,181 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* credentials.c */ - -#include <stdlib.h> -#include <stdio.h> -#include <CredentialsCache.h> -#include "credentials.h" -#include "msg.h" -#include "msg_headers.h" - - -cc_int32 -cc_int_credentials_new( cc_credentials_t *pcredentials, cc_uint32 version, - cc_handle ctx, cc_handle ccache, cc_handle handle, - char * data, cc_uint32 len ) -{ - cc_int_credentials_t credentials; - cc_int32 code; - - if ( pcredentials == NULL ) - return ccErrBadParam; - - credentials = (cc_int_credentials_t)malloc(sizeof(cc_int_credentials_d)); - if ( credentials == NULL ) - return ccErrNoMem; - - credentials->data = (cc_credentials_union *)malloc(sizeof(cc_credentials_union)); - if ( credentials->data == NULL ) { - free(credentials); - return ccErrNoMem; - } - - credentials->functions = (cc_credentials_f *)malloc(sizeof(cc_credentials_f)); - if ( credentials->functions == NULL ) { - free(credentials->data); - free(credentials); - return ccErrNoMem; - } - - credentials->functions->release = cc_int_credentials_release; - credentials->functions->compare = cc_int_credentials_compare; - credentials->magic = CC_CREDS_MAGIC; - credentials->ctx = ctx; - credentials->ccache = ccache; - credentials->handle = handle; - - switch ( version ) { - case cc_credentials_v4: - code = cci_creds_v4_unmarshall(data, len, credentials->data); - break; - case cc_credentials_v5: - code = cci_creds_v5_unmarshall(data, len, credentials->data); - break; - default: - free(credentials); - return ccErrBadCredentialsVersion; - } - - *pcredentials = (cc_credentials_t)credentials; - return ccNoError; -} - - -cc_int32 -cc_int_credentials_release( cc_credentials_t creds ) -{ - cc_int_credentials_t int_creds; - unsigned short i; - - if ( creds == NULL ) - return ccErrBadParam; - - int_creds = (cc_int_credentials_t)creds; - - if ( int_creds->magic != CC_CREDS_MAGIC ) - return ccErrInvalidCredentials; - - switch (int_creds->data->version) { - case cc_credentials_v4: - free(int_creds->data->credentials.credentials_v4); - break; - case cc_credentials_v5: - if ( int_creds->data->credentials.credentials_v5->client ) - free(int_creds->data->credentials.credentials_v5->client); - if ( int_creds->data->credentials.credentials_v5->server ) - free(int_creds->data->credentials.credentials_v5->server ); - if ( int_creds->data->credentials.credentials_v5->keyblock.data ) - free(int_creds->data->credentials.credentials_v5->keyblock.data); - if ( int_creds->data->credentials.credentials_v5->ticket.data ) - free(int_creds->data->credentials.credentials_v5->ticket.data); - if ( int_creds->data->credentials.credentials_v5->second_ticket.data ) - free(int_creds->data->credentials.credentials_v5->second_ticket.data); - if ( int_creds->data->credentials.credentials_v5->addresses ) { - for ( i=0; int_creds->data->credentials.credentials_v5->addresses[i]; i++) { - if (int_creds->data->credentials.credentials_v5->addresses[i]->data) - free(int_creds->data->credentials.credentials_v5->addresses[i]->data); - } - free(int_creds->data->credentials.credentials_v5->addresses); - } - if ( int_creds->data->credentials.credentials_v5->authdata ) { - for ( i=0; int_creds->data->credentials.credentials_v5->authdata[i]; i++) { - if ( int_creds->data->credentials.credentials_v5->authdata[i]->data ) - free(int_creds->data->credentials.credentials_v5->authdata[i]->data); - } - free(int_creds->data->credentials.credentials_v5->authdata); - } - break; - default: - return ccErrBadCredentialsVersion; - } - - free(int_creds->functions); - free(int_creds->data); - free(int_creds); - return ccNoError; -} - -cc_int32 -cc_int_credentials_compare( cc_credentials_t credentials, - cc_credentials_t compare_to, - cc_uint32* equal ) -{ - cc_int_credentials_t int_credentials; - cc_int_credentials_t int_compare_to; - - if ( credentials == NULL || compare_to == NULL || equal == NULL ) - return ccErrBadParam; - - int_credentials = (cc_int_credentials_t)credentials; - int_compare_to = (cc_int_credentials_t)compare_to; - - if ( int_credentials->magic != CC_CREDS_MAGIC || - int_compare_to->magic != CC_CREDS_MAGIC ) - return ccErrInvalidCredentials; - - *equal = (int_credentials->handle == int_compare_to->handle); - - return ccNoError; -} diff --git a/src/lib/ccapi/client/credentials.h b/src/lib/ccapi/client/credentials.h deleted file mode 100644 index dfd589f32..000000000 --- a/src/lib/ccapi/client/credentials.h +++ /dev/null @@ -1,94 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* credentials.h */ - -#define CC_CREDS_MAGIC ('C'<<24 | 'R'<<16 | 'E'<<8 | 'D') - -struct cc_int_credentials_d { - cc_credentials_union* data; - cc_credentials_f* functions; -#if TARGET_OS_MAC - cc_credentials_f* otherFunctions; -#endif - cc_uint32 magic; - cc_handle ctx; - cc_handle ccache; - cc_handle handle; -}; -typedef struct cc_int_credentials_d cc_int_credentials_d; -typedef cc_int_credentials_d* cc_int_credentials_t; - -cc_int32 -cc_int_credentials_new( cc_credentials_t * pcredentials, cc_uint32 version, - cc_handle ctx, cc_handle ccache, cc_handle handle, - char * data, cc_uint32 len); - -cc_int32 -cc_int_credentials_release( cc_credentials_t credentials ); - -cc_int32 -cc_int_credentials_compare( cc_credentials_t credentials, - cc_credentials_t compare_to, - cc_uint32* equal ); - -cc_int32 -cci_creds_v4_marshall( cc_credentials_v4_t * creds, - char ** flat, - cc_uint32 * len); - -cc_int32 -cci_creds_v5_marshall( cc_credentials_v5_t * creds, - char ** flat, - cc_uint32 * len); - -cc_int32 -cci_creds_v4_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds); - -cc_int32 -cci_creds_v5_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds); - diff --git a/src/lib/ccapi/client/credentials_iterator.c b/src/lib/ccapi/client/credentials_iterator.c deleted file mode 100644 index 3cdab875a..000000000 --- a/src/lib/ccapi/client/credentials_iterator.c +++ /dev/null @@ -1,273 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* credentials_iterator.c */ - -#include <stdlib.h> -#include <stdio.h> -#include <CredentialsCache.h> -#include "credentials.h" -#include "credentials_iterator.h" -#include "cc_rpc.h" -#include "msg.h" -#include "msg_headers.h" - - -cc_int32 -cc_int_credentials_iterator_new( cc_credentials_iterator_t * piter, - cc_handle ctx, - cc_handle ccache, - cc_handle handle ) -{ - cc_int_credentials_iterator_t iter; - - if ( piter == NULL ) - return ccErrBadParam; - - iter = (cc_int_credentials_iterator_t) malloc( sizeof(cc_int_credentials_iterator_d) ); - if ( iter == NULL ) - return ccErrNoMem; - - iter->functions = (cc_credentials_iterator_f*)malloc(sizeof(cc_credentials_iterator_f)); - if ( iter->functions == NULL ) { - free(iter); - return ccErrNoMem; - } - - iter->functions->release = cc_int_credentials_iterator_release; - iter->functions->next = cc_int_credentials_iterator_next; - iter->functions->clone = cc_int_credentials_iterator_clone; - iter->magic = CC_CREDS_ITER_MAGIC; - iter->ctx = ctx; - iter->ccache = ccache; - iter->handle = handle; - - *piter = (cc_credentials_iterator_t) iter; - return ccNoError; -} - -cc_int32 -cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) -{ - cc_int_credentials_iterator_t int_iter; - cc_msg_t *request = NULL; - ccmsg_creds_iterator_release_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( iter == NULL ) - return ccErrBadParam; - - int_iter = (cc_int_credentials_iterator_t) iter; - - if ( int_iter->magic != CC_CREDS_ITER_MAGIC ) - return ccErrInvalidCredentialsIterator; - - request_header = (ccmsg_creds_iterator_release_t*)malloc(sizeof(ccmsg_creds_iterator_release_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_iter->ctx); - request_header->ccache = htonll(int_iter->ccache); - request_header->iterator = htonll(int_iter->handle); - - code = cci_msg_new(ccmsg_CREDS_ITERATOR_RELEASE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_creds_iterator_release_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = htonl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = htonl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - code = ccNoError; - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - - free(int_iter->functions); - free(int_iter); - return ccNoError; -} - -cc_int32 -cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, - cc_credentials_t * credentials ) -{ - cc_int_credentials_iterator_t int_iter; - cc_msg_t *request = NULL; - ccmsg_creds_iterator_next_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( credentials == NULL ) - return ccErrBadParam; - - int_iter = (cc_int_credentials_iterator_t)iter; - - if ( int_iter->magic != CC_CREDS_ITER_MAGIC ) - return ccErrInvalidCredentialsIterator; - - request_header = (ccmsg_creds_iterator_next_t*)malloc(sizeof(ccmsg_creds_iterator_next_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_iter->ctx); - request_header->ccache = htonll(int_iter->ccache); - request_header->iterator = htonll(int_iter->handle); - - code = cci_msg_new(ccmsg_CREDS_ITERATOR_NEXT, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_creds_iterator_next_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - char * blob; - ccmsg_creds_iterator_next_resp_t * response_header = (ccmsg_creds_iterator_next_resp_t*)response->header; - code = cci_msg_retrieve_blob(response, ntohl(response_header->creds_offset), ntohl(response_header->creds_len), &blob); - code = cc_int_credentials_new(credentials, ntohl(response_header->version), - int_iter->ctx, int_iter->ccache, ntohll(response_header->creds_handle), - blob, ntohl(response_header->creds_len)); - free(blob); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - -cc_int32 -cc_int_credentials_iterator_clone( cc_credentials_iterator_t iter, - cc_credentials_iterator_t* new_iter) -{ - cc_int_credentials_iterator_t int_iter; - cc_msg_t *request = NULL; - ccmsg_creds_iterator_clone_t *request_header = NULL; - cc_msg_t *response = NULL; - cc_uint32 type; - cc_int32 code; - - if ( iter == NULL || new_iter == NULL ) - return ccErrBadParam; - - int_iter = (cc_int_credentials_iterator_t)iter; - - if ( int_iter->magic != CC_CREDS_ITER_MAGIC ) - return ccErrInvalidCCacheIterator; - - request_header = (ccmsg_creds_iterator_clone_t*)malloc(sizeof(ccmsg_creds_iterator_clone_t)); - if (request_header == NULL) - return ccErrNoMem; - request_header->ctx = htonll(int_iter->ctx); - request_header->iterator = htonll(int_iter->handle); - - code = cci_msg_new(ccmsg_CREDS_ITERATOR_CLONE, &request); - if (code != ccNoError) - goto cleanup; - - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_creds_iterator_clone_t)); - if (code != ccNoError) - goto cleanup; - request_header = NULL; - - code = cci_perform_rpc(request, &response); - if (code != ccNoError) - goto cleanup; - - type = ntohl(response->type); - if (type == ccmsg_NACK) { - ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = ntohl(nack_header->err_code); - } else if (type == ccmsg_ACK) { - ccmsg_creds_iterator_clone_resp_t * response_header = (ccmsg_creds_iterator_clone_resp_t*)response->header; - code = cc_int_credentials_iterator_new(new_iter, int_iter->ctx, int_iter->ccache, ntohll(response_header->iterator)); - } else { - code = ccErrBadInternalMessage; - } - - cleanup: - if (request_header) - free(request_header); - if (request) - cci_msg_destroy(request); - if (response) - cci_msg_destroy(response); - return code; -} - diff --git a/src/lib/ccapi/client/credentials_iterator.h b/src/lib/ccapi/client/credentials_iterator.h deleted file mode 100644 index 954d2f1af..000000000 --- a/src/lib/ccapi/client/credentials_iterator.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $Copyright: - * - * Copyright 2004-2006 by the Massachusetts Institute of Technology. - * - * All rights reserved. - * - * Export of this software from the United States of America may require a - * specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute - * this software and its documentation for any purpose and without fee is - * hereby granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of M.I.T. not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Furthermore if you - * modify this software you must label your software as modified software - * and not distribute it in such a fashion that it might be confused with - * the original MIT software. M.I.T. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* credentials_iterator.h */ - -#define CC_CREDS_ITER_MAGIC ('C'<<24 | 'R'<<16 | 'I'<<8 | 'T') - -struct cc_int_credentials_iterator_d { - cc_credentials_iterator_f* functions; -#if TARGET_OS_MAC - cc_credentials_iterator_f* otherFunctions; -#endif - cc_uint32 magic; - cc_handle handle; - cc_handle ccache; - cc_handle ctx; -}; -typedef struct cc_int_credentials_iterator_d cc_int_credentials_iterator_d; -typedef cc_int_credentials_iterator_d* cc_int_credentials_iterator_t; - - -cc_int32 -cc_int_credentials_iterator_new( cc_credentials_iterator_t * piter, cc_handle ctx, cc_handle ccache, cc_handle iter ); - -cc_int32 -cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ); - -cc_int32 -cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, - cc_credentials_t * credentials ); - -cc_int32 -cc_int_credentials_iterator_clone( cc_credentials_iterator_t iter, - cc_credentials_iterator_t * new_iter ); - - |
