From 4e824737afa8bb05db07d92a04855149c2fba5d8 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 19 May 2006 09:18:37 +0000 Subject: Updates of portable CCAPI sources. All code compiles git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18022 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/NTMakefile | 4 +- src/lib/ccapi/client/cacheapi.c | 42 +- src/lib/ccapi/client/cacheapi.def | 29 + src/lib/ccapi/client/ccache.c | 482 ++++++++------ src/lib/ccapi/client/ccache.h | 10 +- src/lib/ccapi/client/ccache_iterator.c | 93 ++- src/lib/ccapi/client/ccache_iterator.h | 6 +- src/lib/ccapi/client/ccapiv2.c | 286 ++++++++ src/lib/ccapi/client/context.c | 337 +++++----- src/lib/ccapi/client/context.h | 2 +- src/lib/ccapi/client/credentials.c | 14 +- src/lib/ccapi/client/credentials.h | 6 +- src/lib/ccapi/client/credentials_iterator.c | 104 ++- src/lib/ccapi/client/credentials_iterator.h | 6 +- src/lib/ccapi/client/marshall.c | 445 +++++++++++++ src/lib/ccapi/client/msg.c | 628 ++++++++++++++++++ src/lib/ccapi/include/CredentialsCache.h | 122 ++-- src/lib/ccapi/include/CredentialsCache2.h | 64 +- src/lib/ccapi/include/cc_rpc.h | 52 ++ src/lib/ccapi/include/generic_lists.h | 95 +++ src/lib/ccapi/include/marshall.h | 31 +- src/lib/ccapi/include/msg.h | 51 +- src/lib/ccapi/include/msg_headers.h | 73 +- src/lib/ccapi/marshall.c | 378 ----------- src/lib/ccapi/msg.c | 582 ---------------- src/lib/ccapi/server/NTMakefile | 18 +- src/lib/ccapi/server/ccache.c | 703 -------------------- src/lib/ccapi/server/ccs_ccache.c | 703 ++++++++++++++++++++ src/lib/ccapi/server/ccs_context.c | 325 +++++++++ src/lib/ccapi/server/ccs_lists.c | 996 ++++++++++++++++++++++++++++ src/lib/ccapi/server/context.c | 325 --------- src/lib/ccapi/server/datastore.h | 186 ++---- src/lib/ccapi/server/lists.c | 996 ---------------------------- src/lib/ccapi/server/main.c | 12 + src/lib/ccapi/server/serv_ops.c | 417 ++++++------ src/lib/ccapi/server/serv_ops.h | 184 +++-- src/lib/ccapi/unit-test/NTMakefile | 30 + src/lib/ccapi/windows/rpcsstest/NTMakefile | 24 + src/lib/ccapi/windows/rpcsstest/client.c | 87 +++ src/lib/ccapi/windows/rpcsstest/cstest.acf | 8 + src/lib/ccapi/windows/rpcsstest/cstest.idl | 14 + src/lib/ccapi/windows/rpcsstest/server.c | 537 +++++++++++++++ 42 files changed, 5556 insertions(+), 3951 deletions(-) create mode 100644 src/lib/ccapi/client/cacheapi.def create mode 100644 src/lib/ccapi/client/ccapiv2.c create mode 100644 src/lib/ccapi/client/marshall.c create mode 100644 src/lib/ccapi/client/msg.c create mode 100644 src/lib/ccapi/include/cc_rpc.h create mode 100644 src/lib/ccapi/include/generic_lists.h delete mode 100644 src/lib/ccapi/marshall.c delete mode 100644 src/lib/ccapi/msg.c delete mode 100644 src/lib/ccapi/server/ccache.c create mode 100644 src/lib/ccapi/server/ccs_ccache.c create mode 100644 src/lib/ccapi/server/ccs_context.c create mode 100644 src/lib/ccapi/server/ccs_lists.c delete mode 100644 src/lib/ccapi/server/context.c delete mode 100644 src/lib/ccapi/server/lists.c create mode 100644 src/lib/ccapi/server/main.c create mode 100644 src/lib/ccapi/unit-test/NTMakefile create mode 100644 src/lib/ccapi/windows/rpcsstest/NTMakefile create mode 100644 src/lib/ccapi/windows/rpcsstest/client.c create mode 100644 src/lib/ccapi/windows/rpcsstest/cstest.acf create mode 100644 src/lib/ccapi/windows/rpcsstest/cstest.idl create mode 100644 src/lib/ccapi/windows/rpcsstest/server.c (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/client/NTMakefile b/src/lib/ccapi/client/NTMakefile index 09ef9df38..57ff87416 100644 --- a/src/lib/ccapi/client/NTMakefile +++ b/src/lib/ccapi/client/NTMakefile @@ -12,11 +12,11 @@ $(CCAPI_LIB): $(CCAPI_OBJS) CCAPI_DLLFILE = krbcc32.dll - - $(CCAPI_DLLFILE): $(CCAPI_LIB) $(DLLGUILINK) -def:windows\krbcc32.def $(DLLPREP) +all: $(CCAPI_DLLFILE) + clean: del *.obj *.lib diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index 2c874bec0..704925dfd 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -47,10 +47,17 @@ #include "ccache.h" #include "ccache_iterator.h" #include "context.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" -cc_int32 +/*! \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, @@ -60,16 +67,18 @@ cc_initialize ( cc_context_t* outContext, cc_msg_t *request; ccmsg_init_t *request_header; cc_msg_t *response; + 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_5) && + (inVersion != ccapi_version_6)) { if (outSupportedVersion != NULL) { - *outSupportedVersion = ccapi_version_5; + *outSupportedVersion = ccapi_version_6; } return ccErrBadAPIVersion; } @@ -78,7 +87,17 @@ cc_initialize ( cc_context_t* outContext, if (request_header == NULL) return ccErrNoMem; - request_header->in_version = inVersion; + /* 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) { @@ -90,17 +109,18 @@ cc_initialize ( cc_context_t* outContext, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_init_resp_t *)response->header; - *outSupportedVersion = response_header->out_version; - code = cc_context_int_new(outContext, response_header->out_ctx, response_header->out_version); + *outSupportedVersion = ntohl(response_header->out_version); + code = cc_int_context_new(outContext, ntohl(response_header->out_ctx), ntohl(response_header->out_version)); if (!vendor[0]) { char * string; - code = cci_msg_retrieve_blob(response, response_header->vendor_offset, response_header->vendor_length, &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); diff --git a/src/lib/ccapi/client/cacheapi.def b/src/lib/ccapi/client/cacheapi.def new file mode 100644 index 000000000..c54cc1106 --- /dev/null +++ b/src/lib/ccapi/client/cacheapi.def @@ -0,0 +1,29 @@ +EXPORTS + ; ccapi v3 only exports one function + cc_initialize @14 + + ; ccapi v2 compatibility functions + cc_close @2 + cc_create @3 + cc_destroy @4 + cc_free_NC_info @5 + cc_free_creds @6 + cc_free_name @7 + cc_free_principal @8 + cc_get_NC_info @9 + cc_get_change_time @10 + cc_get_cred_version @11 + cc_get_name @12 + cc_get_principal @13 + cc_lock_request @15 + cc_open @16 + cc_remove_cred @17 + cc_seq_fetch_NCs_begin @18 + cc_seq_fetch_NCs_end @19 + cc_seq_fetch_NCs_next @20 + cc_seq_fetch_creds_begin @21 + cc_seq_fetch_creds_end @22 + cc_seq_fetch_creds_next @23 + cc_set_principal @24 + cc_shutdown @25 + cc_store @26 diff --git a/src/lib/ccapi/client/ccache.c b/src/lib/ccapi/client/ccache.c index 5de3880e4..42064d54d 100644 --- a/src/lib/ccapi/client/ccache.c +++ b/src/lib/ccapi/client/ccache.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -49,9 +49,16 @@ #include #include "credentials.h" #include "ccache.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.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 ) { @@ -97,11 +104,12 @@ 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_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request; + ccmsg_ccache_release_t *request_header; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -114,8 +122,8 @@ cc_int_ccache_release( cc_ccache_t ccache ) request_header = (ccmsg_ccache_release_t*)malloc(sizeof(ccmsg_ccache_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -127,10 +135,11 @@ cc_int_ccache_release( cc_ccache_t ccache ) code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -146,11 +155,12 @@ cc_int_ccache_release( cc_ccache_t ccache ) cc_int32 cc_int_ccache_destroy( cc_ccache_t ccache ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_destroy_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request; + ccmsg_ccache_destroy_t *request_header; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -163,8 +173,8 @@ cc_int_ccache_destroy( cc_ccache_t ccache ) request_header = (ccmsg_ccache_destroy_t*)malloc(sizeof(ccmsg_ccache_destroy_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -176,10 +186,11 @@ cc_int_ccache_destroy( cc_ccache_t ccache ) code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -194,11 +205,12 @@ cc_int_ccache_destroy( cc_ccache_t ccache ) cc_int32 cc_int_ccache_set_default( cc_ccache_t ccache ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_set_default_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request; + ccmsg_ccache_set_default_t *request_header; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -211,8 +223,8 @@ cc_int_ccache_set_default( cc_ccache_t ccache ) request_header = (ccmsg_ccache_set_default_t*)malloc(sizeof(ccmsg_ccache_set_default_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -224,10 +236,11 @@ cc_int_ccache_set_default( cc_ccache_t ccache ) code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -241,11 +254,12 @@ 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; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_get_creds_version_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -258,8 +272,8 @@ cc_int_ccache_get_credentials_version( cc_ccache_t ccache, 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 = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -271,12 +285,13 @@ cc_int_ccache_get_credentials_version( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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 = response_header->version; + *credentials_version = ntohl(response_header->version); code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -287,14 +302,14 @@ cc_int_ccache_get_credentials_version( cc_ccache_t ccache, } cc_int32 -cc_int_ccache_get_name( cc_ccache_t ccache, - cc_string_t* name ) +cc_int_ccache_get_name( cc_ccache_t ccache, cc_string_t* name ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_get_name_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -307,8 +322,8 @@ cc_int_ccache_get_name( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_name_t*)malloc(sizeof(ccmsg_ccache_get_name_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -320,10 +335,11 @@ cc_int_ccache_get_name( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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, @@ -345,11 +361,12 @@ 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; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_get_principal_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -362,9 +379,9 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_principal_t*)malloc(sizeof(ccmsg_ccache_get_principal_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->version = credentials_version; + 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) { @@ -376,10 +393,11 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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, @@ -401,12 +419,13 @@ 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; + cc_uint32 blob_pos; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_set_principal_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -419,9 +438,9 @@ cc_int_ccache_set_principal( cc_ccache_t ccache, request_header = (ccmsg_ccache_set_principal_t*)malloc(sizeof(ccmsg_ccache_set_principal_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->version = credentials_version; + 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) { @@ -436,17 +455,18 @@ cc_int_ccache_set_principal( cc_ccache_t ccache, return code; } - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -460,11 +480,12 @@ 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; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_creds_iterator_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -477,10 +498,10 @@ cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, request_header = (ccmsg_ccache_creds_iterator_t*)malloc(sizeof(ccmsg_ccache_creds_iterator_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); - code = cci_msg_new(ccmsg_CCACHE_CREDS_ITERATOR, &request); + code = cci_msg_new(ccmsg_CCACHE_NEW_CREDS_ITERATOR, &request); if (code != ccNoError) { free(request_header); return code; @@ -490,12 +511,14 @@ cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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, response_header->iterator); + code = cc_int_credentials_iterator_new(iterator, int_ccache->ctx, int_ccache->handle, + ntohll(response_header->iterator)); } else { code = ccErrBadInternalMessage; } @@ -508,14 +531,15 @@ 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; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_store_creds_t *request_header; - cc_msg_t *response; - char *flat_cred = 0; - cc_uint32 flat_cred_len = 0; - cc_uint32 blob_pos; - cc_int32 code; + cc_msg_t *response; + 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; @@ -528,8 +552,8 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, request_header = (ccmsg_ccache_store_creds_t*)malloc(sizeof(ccmsg_ccache_store_creds_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -562,18 +586,19 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, return code; } - request_header->creds_version = credentials->version; - request_header->creds_offset = blob_pos; - request_header->creds_len = flat_cred_len; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -588,12 +613,13 @@ 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; - ccmsg_ccache_rem_creds_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_int_credentials_t int_creds; + cc_msg_t *request; + ccmsg_ccache_rem_creds_t *request_header; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL || credentials == NULL ) return ccErrBadParam; @@ -611,9 +637,9 @@ cc_int_ccache_remove_credentials( cc_ccache_t ccache, if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds = int_creds->handle; + 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) { @@ -625,10 +651,11 @@ cc_int_ccache_remove_credentials( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -643,12 +670,13 @@ 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; + cc_int_ccache_t int_ccache_source; + cc_int_ccache_t int_ccache_dest; + cc_msg_t *request; ccmsg_ccache_move_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( source == NULL || destination == NULL ) return ccErrBadParam; @@ -673,18 +701,19 @@ cc_int_ccache_move( cc_ccache_t source, return code; } - request_header->ctx = int_ccache_source->ctx; - request_header->ccache_source = int_ccache_source->handle; - request_header->ccache_dest = int_ccache_dest->handle; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -698,14 +727,16 @@ 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; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_lock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL || - (lock_type != cc_lock_read && lock_type != cc_lock_write) || + (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; @@ -724,17 +755,18 @@ cc_int_ccache_lock( cc_ccache_t ccache, return code; } - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->lock_type; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + code = ntohl(nack_header->err_code); // TODO: if (block == cc_lock_block) ..... } else if (response->type == ccmsg_ACK) { @@ -750,11 +782,12 @@ cc_int_ccache_lock( cc_ccache_t ccache, cc_int32 cc_int_ccache_unlock( cc_ccache_t ccache ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_unlock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request; + ccmsg_ccache_unlock_t *request_header; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -774,17 +807,18 @@ cc_int_ccache_unlock( cc_ccache_t ccache ) return code; } - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = htonl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = htonl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -797,13 +831,15 @@ cc_int_ccache_unlock( cc_ccache_t ccache ) cc_int32 cc_int_ccache_get_last_default_time( cc_ccache_t ccache, - cc_time_t* time_offset ) + cc_time* time_offset ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_get_last_default_time_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_time64 t64; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -816,8 +852,8 @@ cc_int_ccache_get_last_default_time( cc_ccache_t ccache, 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 = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -829,13 +865,16 @@ cc_int_ccache_get_last_default_time( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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; - *time_offset = response_header->last_default_time; - code = ccNoError; + 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; } @@ -845,14 +884,15 @@ cc_int_ccache_get_last_default_time( cc_ccache_t ccache, } cc_int32 -cc_int_ccache_get_change_time( cc_ccache_t ccache, - cc_time_t* time ) +cc_int_ccache_get_change_time( cc_ccache_t ccache, cc_time* time ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_get_change_time_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_time64 t64; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -865,8 +905,8 @@ cc_int_ccache_get_change_time( cc_ccache_t ccache, 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 = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + 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) { @@ -878,12 +918,15 @@ cc_int_ccache_get_change_time( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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; - *time = response_header->time; + t64 = htonll(response_header->time); + /* TODO: validate that we do not overflow 'time' */ + *time = t64; code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -898,12 +941,13 @@ 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; - ccmsg_ccache_compare_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_int_ccache_t int_compare_to; + cc_msg_t *request; + ccmsg_ccache_compare_t *request_header; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -918,9 +962,9 @@ cc_int_ccache_compare( cc_ccache_t ccache, request_header = (ccmsg_ccache_compare_t*)malloc(sizeof(ccmsg_ccache_compare_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache1 = int_ccache->handle; - request_header->ccache2 = int_compare_to->handle; + 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) { @@ -932,12 +976,13 @@ cc_int_ccache_compare( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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 = response_header->is_equal; + *equal = ntohl(response_header->is_equal); code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -950,13 +995,14 @@ cc_int_ccache_compare( cc_ccache_t ccache, cc_int32 cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t* time_offset ) + cc_time* time_offset ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_get_kdc_time_offset_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -969,9 +1015,9 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, 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 = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds_version = credentials_version; + 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) { @@ -983,12 +1029,13 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + 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 = response_header->offset; + *time_offset = ntohll(response_header->offset); code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -1001,13 +1048,15 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, cc_int32 cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t time_offset ) + cc_time time_offset ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_set_kdc_time_offset_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_int64 t64; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -1020,9 +1069,11 @@ cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, 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 = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds_version = credentials_version; + 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) { @@ -1034,10 +1085,11 @@ cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -1051,11 +1103,12 @@ 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; + cc_int_ccache_t int_ccache; + cc_msg_t *request; ccmsg_ccache_clear_kdc_time_offset_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -1068,9 +1121,9 @@ cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, 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 = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds_version = credentials_version; + 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) { @@ -1082,10 +1135,11 @@ cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -1094,5 +1148,3 @@ cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, cci_msg_destroy(response); return code; } - - diff --git a/src/lib/ccapi/client/ccache.h b/src/lib/ccapi/client/ccache.h index e3b3993ee..0a92ebf63 100644 --- a/src/lib/ccapi/client/ccache.h +++ b/src/lib/ccapi/client/ccache.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -114,11 +114,11 @@ cc_int_ccache_unlock( cc_ccache_t ccache ); cc_int32 cc_int_ccache_get_last_default_time( cc_ccache_t ccache, - cc_time_t* time ); + cc_time* time ); cc_int32 cc_int_ccache_get_change_time( cc_ccache_t ccache, - cc_time_t* time ); + cc_time* time ); cc_int32 cc_int_ccache_compare( cc_ccache_t ccache, @@ -128,12 +128,12 @@ cc_int_ccache_compare( cc_ccache_t ccache, cc_int32 cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t* time_offset ); + cc_time* time_offset ); cc_int32 cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t time_offset ); + cc_time time_offset ); cc_int32 cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, diff --git a/src/lib/ccapi/client/ccache_iterator.c b/src/lib/ccapi/client/ccache_iterator.c index 03266b1bb..3f3e1675e 100644 --- a/src/lib/ccapi/client/ccache_iterator.c +++ b/src/lib/ccapi/client/ccache_iterator.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -47,6 +47,7 @@ #include #include #include "ccache_iterator.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" @@ -84,11 +85,12 @@ cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, cc_int32 cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) { - cc_int_ccache_iterator_t int_iter; - cc_msg_t *request; + cc_int_ccache_iterator_t int_iter; + cc_msg_t *request; ccmsg_ccache_iterator_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( iter == NULL ) @@ -102,8 +104,8 @@ cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) request_header = (ccmsg_ccache_iterator_release_t*)malloc(sizeof(ccmsg_ccache_iterator_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->iterator = int_iter->handle; + 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) { free(request_header); @@ -114,10 +116,11 @@ cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -134,11 +137,12 @@ 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; + cc_int_ccache_iterator_t int_iter; + cc_msg_t *request; ccmsg_ccache_iterator_next_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -151,8 +155,8 @@ cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, request_header = (ccmsg_ccache_iterator_next_t*)malloc(sizeof(ccmsg_ccache_iterator_next_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->iterator = int_iter->handle; + 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) { @@ -164,12 +168,63 @@ cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + } else if (type == ccmsg_ACK) { ccmsg_ccache_iterator_next_resp_t * response_header = (ccmsg_ccache_iterator_next_resp_t*)response->header; - code = cc_ccache_new(ccache, int_iter->ctx, response_header->ccache); + code = cc_int_ccache_new(ccache, int_iter->ctx, ntohll(response_header->ccache)); + } else { + code = ccErrBadInternalMessage; + } + cci_msg_destroy(request); + 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; + ccmsg_ccache_iterator_clone_t *request_header; + cc_msg_t *response; + 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) { + free(request_header); + return code; + } + + code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_iterator_clone_t)); + + code = cci_perform_rpc(request, &response); + + 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; } diff --git a/src/lib/ccapi/client/ccache_iterator.h b/src/lib/ccapi/client/ccache_iterator.h index c55d72ee6..5a390b82e 100644 --- a/src/lib/ccapi/client/ccache_iterator.h +++ b/src/lib/ccapi/client/ccache_iterator.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -73,6 +73,10 @@ 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 ); diff --git a/src/lib/ccapi/client/ccapiv2.c b/src/lib/ccapi/client/ccapiv2.c new file mode 100644 index 000000000..ffbb589a2 --- /dev/null +++ b/src/lib/ccapi/client/ccapiv2.c @@ -0,0 +1,286 @@ +/* $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_t* 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; +} + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + diff --git a/src/lib/ccapi/client/context.c b/src/lib/ccapi/client/context.c index 86c41b8e7..efac3020c 100644 --- a/src/lib/ccapi/client/context.c +++ b/src/lib/ccapi/client/context.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -47,9 +47,15 @@ #include #include #include "context.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.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 ) { @@ -87,11 +93,13 @@ 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_int_context_t int_context; - cc_msg_t *request; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ctx_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_time64 t64; + cc_int32 code; if ( context == NULL ) return ccErrBadParam; @@ -104,7 +112,7 @@ cc_int_context_release( cc_context_t context ) request_header = (ccmsg_ctx_release_t*)malloc(sizeof(ccmsg_ctx_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_context->handle; + request_header->ctx = htonl(int_context->handle); code = cci_msg_new(ccmsg_CTX_RELEASE, &request); if (code != ccNoError) { @@ -116,10 +124,11 @@ cc_int_context_release( cc_context_t context ) code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -133,14 +142,16 @@ cc_int_context_release( cc_context_t context ) cc_int32 cc_int_context_get_change_time( cc_context_t context, - cc_time_t* time) + cc_time* time) { - cc_int_context_t int_context; - cc_msg_t *request; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ctx_get_change_time_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ctx_get_change_time_resp_t *response_header; - cc_int32 code; + cc_time64 t64; + cc_uint32 type; + cc_int32 code; if ( context == NULL || time == NULL ) return ccErrBadParam; @@ -153,7 +164,7 @@ cc_int_context_get_change_time( cc_context_t context, 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 = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_GET_CHANGE_TIME, &request); if (code != ccNoError) { @@ -165,12 +176,15 @@ cc_int_context_get_change_time( cc_context_t context, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + code = ntohl(nack_header->err_code); } else if (response->type == ccmsg_ACK) { response_header = (ccmsg_ctx_get_change_time_resp_t*)response->header; - *time = response_header->time; + t64 = ntohll(response_header->time); + /* TODO: validate that value is not greater than can fit in cc_time */ + *time = (cc_time)t64; code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -184,12 +198,13 @@ 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; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ctx_get_default_ccache_name_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ctx_get_default_ccache_name_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || name == NULL ) return ccErrBadParam; @@ -202,7 +217,7 @@ cc_int_context_get_default_ccache_name( cc_context_t context, 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 = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_GET_DEFAULT_CCACHE_NAME, &request); if (code != ccNoError) { @@ -214,10 +229,11 @@ cc_int_context_get_default_ccache_name( cc_context_t context, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { char * string; response_header = (ccmsg_ctx_get_default_ccache_name_resp_t*)response->header; code = cci_msg_retrieve_blob(response, response_header->name_offset, @@ -244,7 +260,8 @@ cc_int_context_compare( cc_context_t context, ccmsg_ctx_compare_t *request_header; cc_msg_t *response; ccmsg_ctx_compare_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || compare_to == NULL || equal == NULL ) @@ -260,8 +277,8 @@ cc_int_context_compare( cc_context_t context, request_header = (ccmsg_ctx_compare_t*)malloc(sizeof(ccmsg_ctx_compare_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx1 = int_context->handle; - request_header->ctx2 = int_compare_to->handle; + request_header->ctx1 = htonl(int_context->handle); + request_header->ctx2 = htonl(int_compare_to->handle); code = cci_msg_new(ccmsg_CTX_COMPARE, &request); if (code != ccNoError) { @@ -273,12 +290,13 @@ cc_int_context_compare( cc_context_t context, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ctx_compare_resp_t*)response->header; - *equal = response_header->is_equal; + *equal = ntohl(response_header->is_equal); code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -293,12 +311,13 @@ 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; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ctx_new_ccache_iterator_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ctx_new_ccache_iterator_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || iterator == NULL ) return ccErrBadParam; @@ -311,7 +330,7 @@ cc_int_context_new_ccache_iterator( cc_context_t context, 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 = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_NEW_CCACHE_ITERATOR, &request); if (code != ccNoError) { @@ -323,12 +342,14 @@ cc_int_context_new_ccache_iterator( cc_context_t context, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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, response_header->iterator); + code = cc_int_ccache_iterator_new(iterator, int_context->handle, + ntohll(response_header->iterator)); } else { code = ccErrBadInternalMessage; } @@ -342,13 +363,14 @@ 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; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ccache_open_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ccache_open_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || name == NULL || ccache == NULL ) return ccErrBadParam; @@ -362,7 +384,7 @@ cc_int_context_open_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_OPEN, &request); + code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN, &request); if (code != ccNoError) { free(request_header); return code; @@ -375,20 +397,21 @@ cc_int_context_open_ccache( cc_context_t context, return code; } - request_header->ctx = int_context->handle; - request_header->name_offset = blob_pos; - request_header->name_len = strlen(name) + 1; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -401,12 +424,13 @@ 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; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ccache_open_default_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ccache_open_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || ccache == NULL ) return ccErrBadParam; @@ -420,24 +444,25 @@ cc_int_context_open_default_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_OPEN_DEFAULT, &request); + code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN_DEFAULT, &request); if (code != ccNoError) { free(request_header); return code; } - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_open_default_t)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -453,13 +478,14 @@ cc_int_context_create_ccache( cc_context_t context, const char* principal, cc_ccache_t* ccache ) { - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ccache_create_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ccache_create_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || name == NULL || cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || @@ -475,7 +501,7 @@ cc_int_context_create_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_CREATE, &request); + code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE, &request); if (code != ccNoError) { free(request_header); return code; @@ -488,10 +514,10 @@ cc_int_context_create_ccache( cc_context_t context, return code; } - request_header->ctx = int_context->handle; - request_header->version = cred_vers; - request_header->name_offset = blob_pos; - request_header->name_len = strlen(name) + 1; + 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) { @@ -499,19 +525,20 @@ cc_int_context_create_ccache( cc_context_t context, free(request_header); return code; } - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -526,13 +553,14 @@ cc_int_context_create_default_ccache( cc_context_t context, const char* principal, cc_ccache_t* ccache ) { - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ccache_create_default_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ccache_create_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || @@ -548,14 +576,14 @@ cc_int_context_create_default_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_CREATE_DEFAULT, &request); + code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_DEFAULT, &request); if (code != ccNoError) { free(request_header); return code; } - request_header->ctx = int_context->handle; - request_header->version = cred_vers; + 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) { @@ -563,19 +591,20 @@ cc_int_context_create_default_ccache( cc_context_t context, free(request_header); return code; } - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -590,13 +619,14 @@ cc_int_context_create_new_ccache( cc_context_t context, const char* principal, cc_ccache_t* ccache ) { - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ccache_create_unique_t *request_header; - cc_msg_t *response; + cc_msg_t *response; ccmsg_ccache_create_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || @@ -612,14 +642,14 @@ cc_int_context_create_new_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_CREATE_UNIQUE, &request); + code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_UNIQUE, &request); if (code != ccNoError) { free(request_header); return code; } - request_header->ctx = int_context->handle; - request_header->version = cred_vers; + 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) { @@ -627,19 +657,20 @@ cc_int_context_create_new_ccache( cc_context_t context, free(request_header); return code; } - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = htonl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response-> header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -653,14 +684,16 @@ 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; - ccmsg_ctx_lock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_context_t int_context; + cc_msg_t *request; + ccmsg_ctx_lock_t *request_header; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( context == NULL || - (lock_type != cc_lock_read && lock_type != cc_lock_write) || + (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; @@ -679,19 +712,20 @@ cc_int_context_lock( cc_context_t context, return code; } - request_header->ctx = int_context->handle; - request_header->lock_type; + 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)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + code = ntohl(nack_header->err_code); // TODO: if (block == cc_lock_block) ..... - } else if (response->type == ccmsg_ACK) { + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -704,11 +738,12 @@ cc_int_context_lock( cc_context_t context, cc_int32 cc_int_context_unlock( cc_context_t context ) { - cc_int_context_t int_context; - cc_msg_t *request; + cc_int_context_t int_context; + cc_msg_t *request; ccmsg_ctx_unlock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( context == NULL ) return ccErrBadParam; @@ -728,16 +763,17 @@ cc_int_context_unlock( cc_context_t context ) return code; } - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_unlock_t)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -754,20 +790,21 @@ cc_int_context_clone( cc_context_t inContext, cc_int32* supportedVersion, char const** vendor ) { - cc_int_context_t int_context, new_context; - static char vendor_st[128] = ""; - cc_msg_t *request; - ccmsg_clone_t *request_header; - cc_msg_t *response; - ccmsg_clone_resp_t *response_header; - cc_int32 code; + cc_int_context_t int_context, new_context; + static char vendor_st[128] = ""; + cc_msg_t *request; + ccmsg_ctx_clone_t *request_header; + cc_msg_t *response; + ccmsg_ctx_clone_resp_t *response_header; + cc_uint32 type; + cc_int32 code; if ( inContext == NULL || outContext == NULL || supportedVersion == NULL ) return ccErrBadParam; - int_context = (cc_int_context_t)context; + int_context = (cc_int_context_t)inContext; if ( int_context->magic != CC_CONTEXT_MAGIC ) return ccErrInvalidContext; @@ -775,20 +812,21 @@ cc_int_context_clone( cc_context_t inContext, if ((requestedVersion != ccapi_version_2) && (requestedVersion != ccapi_version_3) && (requestedVersion != ccapi_version_4) && - (requestedVersion != ccapi_version_5)) { + (requestedVersion != ccapi_version_5) && + (requestedVersion != ccapi_version_6)) { if (supportedVersion != NULL) { - *supportedVersion = ccapi_version_5; + *supportedVersion = ccapi_version_max; } return ccErrBadAPIVersion; } - request_header = (ccmsg_clone_t*)malloc(sizeof(ccmsg_clone_t)); + request_header = (ccmsg_ctx_clone_t*)malloc(sizeof(ccmsg_ctx_clone_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_context->handle; - request_header->in_version = requestedVersion; + request_header->ctx = htonll(int_context->handle); + request_header->in_version = htonl(requestedVersion); code = cci_msg_new(ccmsg_INIT, &request); if (code != ccNoError) { @@ -796,21 +834,22 @@ cc_int_context_clone( cc_context_t inContext, return code; } - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_init_t)); + code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_clone_t)); code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { - response_header = (ccmsg_clone_resp_t *)response->header; - *supportedVersion = response_header->out_version; - code = cc_int_context_new(outContext, response_header->out_ctx, response_header->out_version); + 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), nthol(response_header->out_version)); if (!vendor_st[0]) { char * string; - code = cci_msg_retrieve_blob(response, response_header->vendor_offset, response_header->vendor_length, &string); + 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'; free(string); diff --git a/src/lib/ccapi/client/context.h b/src/lib/ccapi/client/context.h index cd5ca678d..6ff113a26 100644 --- a/src/lib/ccapi/client/context.h +++ b/src/lib/ccapi/client/context.h @@ -66,7 +66,7 @@ cc_int_context_release( cc_context_t context ); cc_int32 cc_int_context_get_change_time( cc_context_t context, - cc_time_t* time); + cc_time* time); cc_int32 cc_int_context_get_default_ccache_name( cc_context_t context, diff --git a/src/lib/ccapi/client/credentials.c b/src/lib/ccapi/client/credentials.c index b0a3df2b7..8b8867689 100644 --- a/src/lib/ccapi/client/credentials.c +++ b/src/lib/ccapi/client/credentials.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -159,23 +159,23 @@ cc_int_credentials_release( cc_credentials_t creds ) cc_int32 cc_int_credentials_compare( cc_credentials_t credentials, - cc_credentials_t compare_to, - cc_uint32* equal ) + 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; - int_credentials = (cc_int_credentials_t)credentials; - int_compare_to = (cc_int_credentials_t)compare_to; - *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 index 320c61825..dfd589f32 100644 --- a/src/lib/ccapi/client/credentials.h +++ b/src/lib/ccapi/client/credentials.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -84,8 +84,8 @@ cci_creds_v5_marshall( cc_credentials_v5_t * creds, cc_int32 cci_creds_v4_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds); + cc_uint32 len, + cc_credentials_union * creds); cc_int32 cci_creds_v5_unmarshall( char * flat, diff --git a/src/lib/ccapi/client/credentials_iterator.c b/src/lib/ccapi/client/credentials_iterator.c index b7333daf3..bae60ffdf 100644 --- a/src/lib/ccapi/client/credentials_iterator.c +++ b/src/lib/ccapi/client/credentials_iterator.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -47,6 +47,7 @@ #include #include #include "credentials_iterator.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" @@ -74,6 +75,7 @@ cc_int_credentials_iterator_new( cc_credentials_iterator_t * piter, 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; @@ -87,10 +89,11 @@ cc_int32 cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) { cc_int_credentials_iterator_t int_iter; - cc_msg_t *request; + cc_msg_t *request; ccmsg_creds_iterator_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( iter == NULL ) return ccErrBadParam; @@ -103,9 +106,10 @@ cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) request_header = (ccmsg_creds_iterator_release_t*)malloc(sizeof(ccmsg_creds_iterator_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->ccache = int_iter->ccache; - request_header->iterator = int_iter->handle; + 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) { free(request_header); @@ -116,10 +120,11 @@ cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = htonl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = htonl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; @@ -137,10 +142,11 @@ 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; + cc_msg_t *request; ccmsg_creds_iterator_next_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *response; + cc_uint32 type; + cc_int32 code; if ( credentials == NULL ) return ccErrBadParam; @@ -153,9 +159,9 @@ cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, request_header = (ccmsg_creds_iterator_next_t*)malloc(sizeof(ccmsg_creds_iterator_next_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->ccache = int_iter->ccache; - request_header->iterator = int_iter->handle; + 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) { @@ -167,16 +173,17 @@ cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + 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 (response->type == ccmsg_ACK) { + 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, response_header->creds_offset, response_header->creds_len, &blob); - code = cc_credentials_new(credentials, response_header->version, - int_iter->ctx, int_iter->ccache, response_header->creds_handle, - blob, response_header->creds_len); + 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; @@ -185,3 +192,54 @@ cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, 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; + ccmsg_creds_iterator_clone_t *request_header; + cc_msg_t *response; + 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) { + free(request_header); + return code; + } + + code = cci_msg_add_header(request, request_header, sizeof(ccmsg_creds_iterator_clone_t)); + + code = cci_perform_rpc(request, &response); + + 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; + } + cci_msg_destroy(request); + cci_msg_destroy(response); + return code; +} + diff --git a/src/lib/ccapi/client/credentials_iterator.h b/src/lib/ccapi/client/credentials_iterator.h index 2a6f8edf2..954d2f1af 100644 --- a/src/lib/ccapi/client/credentials_iterator.h +++ b/src/lib/ccapi/client/credentials_iterator.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -69,4 +69,8 @@ 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 ); + diff --git a/src/lib/ccapi/client/marshall.c b/src/lib/ccapi/client/marshall.c new file mode 100644 index 000000000..31ebacd7b --- /dev/null +++ b/src/lib/ccapi/client/marshall.c @@ -0,0 +1,445 @@ +/* $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). + * $ + */ + +/* marshall.c */ + +#include +#include +#include +#include "msg.h" +#include "msg_headers.h" +#include "marshall.h" + +cc_int32 +cci_creds_v4_marshall( cc_credentials_v4_t * creds, + char ** pflat, + cc_uint32 * plen) +{ + cc_uint32 len; + char * flat; + cci_flat_creds_v4_t * header; + cc_uint32 length; + cc_time64 t64; + + if ( creds == NULL || pflat == NULL || plen == NULL ) + return ccErrBadParam; + + len = sizeof(cci_flat_creds_v4_t); + flat = (char *)malloc(len); + if ( flat == NULL ) + return ccErrNoMem; + memset(flat, 0, len); + + header = (cci_flat_creds_v4_t *)flat; + header->version = htonl(creds->version); + memcpy(header->principal, creds->principal, cc_v4_name_size); + memcpy(header->principal_instance, creds->principal_instance, cc_v4_instance_size); + memcpy(header->service, creds->service, cc_v4_name_size); + memcpy(header->service_instance, creds->service_instance, cc_v4_instance_size); + memcpy(header->realm, creds->realm, cc_v4_realm_size); + memcpy(header->session_key, creds->session_key, cc_v4_key_size); + header->kvno = htonl(creds->kvno); + header->string_to_key_type = htonl(creds->string_to_key_type); + t64 = creds->issue_date; + header->issue_date = htonll(t64); + header->lifetime = htonl(creds->lifetime); + /* TODO: verify that address is stored in host order */ + header->address = htonl(creds->address); + header->ticket_size = htonl(creds->ticket_size); + memcpy(header->ticket, creds->ticket, cc_v4_ticket_size); + + *pflat = flat; + *plen = len; + + return ccNoError; +} + +cc_int32 +cci_creds_v4_unmarshall( char * flat, + cc_uint32 len, + cc_credentials_union * creds_union) +{ + struct cci_flat_creds_v4 * header; + cc_credentials_v4_t * creds; + cc_flat_data * flat_data; + cc_time64 t64; + cc_uint32 length; + cc_int32 code; + + if ( flat == NULL || len == 0 || creds_union == NULL ) + return ccErrBadParam; + + creds_union->version = cc_credentials_v4; + + header = (cci_flat_creds_v4_t *)flat; + + creds = (cc_credentials_v4_t *)malloc(sizeof(cc_credentials_v4_t)); + if ( creds == NULL ) + return ccErrNoMem; + + creds->version = ntohl(header->version); + memcpy(creds->principal, header->principal, cc_v4_name_size); + memcpy(creds->principal_instance, header->principal_instance, cc_v4_instance_size); + memcpy(creds->service, header->service, cc_v4_name_size); + memcpy(creds->service_instance, header->service_instance, cc_v4_instance_size); + memcpy(creds->realm, header->realm, cc_v4_realm_size); + memcpy(creds->session_key, header->session_key, cc_v4_key_size); + creds->kvno = htonl(header->kvno); + creds->string_to_key_type = htonl(header->string_to_key_type); + t64 = header->issue_date; + creds->issue_date = ntohll(t64); + creds->lifetime = ntohl(header->lifetime); + /* TODO: verify that address is stored in host order */ + creds->address = ntohl(header->address); + creds->ticket_size = ntohl(header->ticket_size); + memcpy(creds->ticket, header->ticket, cc_v4_ticket_size); + + creds_union->credentials.credentials_v4 = creds; + + return ccNoError; +} + + +cc_int32 +cci_creds_cc_data_array_count_entries( cc_data ** array, cc_uint32 * pcount) +{ + cc_uint32 count; + + if (array == NULL) { + *pcount = 0; + return ccNoError; + } + + for ( count=0; array[count] != NULL ; count++) ; + + *pcount = count; + return ccNoError; +} + +cc_int32 +cci_creds_v5_compute_flat_size( cc_credentials_v5_t * creds, cc_uint32 * plen) +{ + cc_uint32 len; + cc_uint32 i, count; + + len = sizeof(struct cci_flat_creds_v5); + + if (creds->client) + len += strlen(creds->client) + 1; + + if (creds->server) + len += strlen(creds->server) + 1; + + len += creds->keyblock.length; + + cci_creds_cc_data_array_count_entries( creds->addresses, &count ); + len += count * sizeof(cc_flat_data); + for ( i=0; iaddresses[i]->length; + } + + len += creds->ticket.length; + len += creds->second_ticket.length; + + cci_creds_cc_data_array_count_entries( creds->authdata, &count ); + len += count * sizeof(cc_flat_data); + for ( i=0; iauthdata[i]->length; + } + + *plen = len; + return ccNoError; +} + +cc_int32 +cci_creds_v5_marshall( cc_credentials_v5_t * creds, + char ** pflat, + cc_uint32 * plen) +{ + cc_uint32 len; + char * flat; + struct cci_flat_creds_v5 * header; + cc_uint32 length; + cc_uint32 offset; + cc_time64 t64; + cc_uint32 count; + cc_uint32 i; + + if ( creds == NULL || pflat == NULL || plen == NULL ) + return ccErrBadParam; + + cci_creds_v5_compute_flat_size(creds, &len); + + flat = (char *)malloc(len); + if ( flat == NULL ) + return ccErrNoMem; + memset(flat, 0, len); + + offset = sizeof(struct cci_flat_creds_v5); + header = (struct cci_flat_creds_v5 *)flat; + header->version = htonl(FLAT_CREDS_V5_VERSION); + if (creds->client) { + length = strlen(creds->client) + 1; + header->client.length = htonl(length); + header->client.data = htonl(offset); + memcpy(flat + offset, creds->client, length); + offset += length; + } + + if (creds->server) { + length = strlen(creds->server) + 1; + header->server.length = htonl(length); + header->server.data = htonl(offset); + memcpy(flat + offset, creds->server, length); + offset += length; + } + + header->keyblock.type = htonl(creds->keyblock.type); + if (creds->keyblock.length) { + length = creds->keyblock.length; + header->keyblock.length = htonl(length); + header->keyblock.data = htonl(offset); + memcpy(flat + offset, creds->keyblock.data, length); + offset += length; + } + + t64 = creds->authtime; + header->authtime = htonll(t64); + t64 = creds->starttime; + header->starttime = htonll(t64); + t64 = creds->endtime; + header->endtime = htonll(t64); + t64 = creds->renew_till; + header->renew_till = htonll(t64); + + header->is_skey = htonl(creds->is_skey); + header->ticket_flags = htonl(creds->ticket_flags); + + cci_creds_cc_data_array_count_entries( creds->addresses, &count ); + if ( count ) { + cc_flat_data * addresses = (cc_flat_data *)flat + offset; + header->address_count = htonl(count); + header->addresses = htonl(offset); + offset += count * sizeof(cc_flat_data); + + for ( i=0; i < count; i++ ) { + addresses[i].type = htonl(creds->addresses[i]->type); + if (creds->addresses[i]->length) { + length = creds->addresses[i]->length; + addresses[i].length = htonl(length); + addresses[i].data = htonl(offset); + /* TODO: verify that addresses are stored in network order */ + memcpy(flat + offset, creds->addresses[i]->data, length); + offset += length; + } + } + } + + header->ticket.type = htonl(creds->ticket.type); + if (creds->ticket.length) { + length = creds->ticket.length; + header->ticket.length = htonl(length); + header->ticket.data = htonl(offset); + memcpy(flat + offset, creds->ticket.data, length); + offset += length; + } + + header->second_ticket.type = htonl(creds->second_ticket.type); + if (creds->second_ticket.length) { + length = creds->second_ticket.length; + header->second_ticket.length = htonl(length); + header->second_ticket.data = htonl(offset); + memcpy(flat + offset, creds->second_ticket.data, length); + offset += length; + } + + cci_creds_cc_data_array_count_entries( creds->authdata, &count ); + if ( count ) { + cc_flat_data * authdata = (cc_flat_data *)flat + offset; + + header->authdata_count = htonl(count); + header->authdata = (offset); + offset += count * sizeof(cc_flat_data); + + for ( i=0; i < count; i++ ) { + authdata[i].type = htonl(creds->authdata[i]->type); + if (creds->authdata[i]->length) { + length = creds->authdata[i]->length; + authdata[i].length = htonl(length); + authdata[i].data = htonl(offset); + memcpy(flat + offset, creds->authdata[i]->data, length); + offset += length; + } + } + } + + *pflat = flat; + *plen = len; + return ccNoError; +} + + +// TODO: a much better job of checking for out of memory errors +// and validating that we do not read beyond the flat input +// data buffer + +cc_int32 +cci_creds_v5_unmarshall( char * flat, + cc_uint32 len, + cc_credentials_union * creds_union) +{ + struct cci_flat_creds_v5 * header; + cc_credentials_v5_t * creds; + cc_flat_data * flat_data; + cc_time64 t64; + cc_uint32 length; + cc_uint32 count; + cc_uint32 i; + cc_int32 code; + + if ( flat == NULL || len == 0 || creds_union == NULL ) + return ccErrBadParam; + + creds_union->version = cc_credentials_v5; + + header = (struct cci_flat_creds_v5 *)flat; + + if ( ntohl(header->version) != FLAT_CREDS_V5_VERSION ) + return ccErrBadParam; + + creds = (cc_credentials_v5_t *)malloc(sizeof(cc_credentials_v5_t)); + if ( creds == NULL ) + return ccErrNoMem; + memset(creds, 0, sizeof(cc_credentials_v5_t)); + + if ( header->client.length ) { + length = ntohl(header->client.length); + creds->client = (char *)malloc(length); + memcpy(creds->client, flat + header->client.data, length); + } + + if ( header->server.length ) { + length = ntohl(header->server.length); + creds->server = (char *)malloc(length); + memcpy(creds->server, flat + header->server.data, length); + } + + creds->keyblock.type = ntohl(header->keyblock.type); + if ( header->keyblock.length ) { + length = ntohl(header->keyblock.length); + creds->keyblock.length = length; + creds->keyblock.data = malloc(length); + memcpy(creds->keyblock.data, flat + header->keyblock.data, length); + } + + /* TODO: need to perform overflow validation checks to ensure + * that we do not attempt to store too large a value into cc_time_t + * when it is a 32-bit field. + */ + t64 = ntohll(header->authtime); + creds->authtime = (cc_time)t64; + t64 = ntohll(header->starttime); + creds->starttime = (cc_time)t64; + t64 = ntohll(header->endtime); + creds->endtime = (cc_time)t64; + t64 = ntohll(header->renew_till); + creds->renew_till = (cc_time)t64; + + creds->is_skey = ntohl(header->is_skey); + creds->ticket_flags = ntohl(header->ticket_flags); + + count = ntohl(header->address_count); + creds->addresses = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); + flat_data = (cc_flat_data *)flat + header->addresses; + for ( i=0 ; i < count ; i++ ) { + creds->addresses[i] = (cc_data *)malloc(sizeof(cc_data)); + creds->addresses[i]->type = ntohl(flat_data[i].type); + length = ntohl(flat_data[i].length); + creds->addresses[i]->length = length; + if ( length ) { + creds->addresses[i]->data = malloc(length); + /* TODO: verify that addresses are stored in network order */ + memcpy(creds->addresses[i]->data, flat + flat_data[i].data, length); + } else { + creds->addresses[i]->data = NULL; + } + } + creds->addresses[i] = NULL; + + creds->ticket.type = ntohl(header->ticket.type); + length = ntohl(header->ticket.length); + if ( length ) { + creds->ticket.length = length; + creds->ticket.data = malloc(length); + memcpy(creds->ticket.data, flat + header->ticket.data, length); + } + + creds->second_ticket.type = header->second_ticket.type; + if ( header->second_ticket.length ) { + creds->second_ticket.length = header->second_ticket.length; + creds->second_ticket.data = malloc(creds->second_ticket.length); + memcpy(creds->second_ticket.data, flat + header->second_ticket.data, creds->second_ticket.length); + } + + count = ntohl(header->authdata_count); + creds->authdata = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); + flat_data = (cc_flat_data *)flat + header->authdata; + for ( i=0 ; i < count ; i++ ) { + creds->authdata[i] = (cc_data *)malloc(sizeof(cc_data)); + creds->authdata[i]->type = ntohl(flat_data[i].type); + length = ntohl(flat_data[i].length); + creds->authdata[i]->length = length; + if ( length ) { + creds->authdata[i]->data = malloc(length); + memcpy(creds->authdata[i]->data, flat + flat_data[i].data, length); + } else { + creds->authdata[i]->data = NULL; + } + } + creds->authdata[i] = NULL; + + creds_union->credentials.credentials_v5 = creds; + + return ccNoError; +} + diff --git a/src/lib/ccapi/client/msg.c b/src/lib/ccapi/client/msg.c new file mode 100644 index 000000000..facaffffc --- /dev/null +++ b/src/lib/ccapi/client/msg.c @@ -0,0 +1,628 @@ +/* $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). + * $ + */ + +/* + * Verifiable, extensible message format. + * + * Format: + * + * + * + * + * + * + * + * + * + * ... + * + * + * If the header has variable length data it is included in the data blobs. + * The header field has the offset from the beginning of the message of the 1st + * byte of the data and the length of the data. + */ + +#include "CredentialsCache.h" +#include "msg.h" +#include "generic_lists.h" + +#include +#include +#include +#include + +/** + * cci_msg_new() + * + * Purpose: Allocate and initialize a new cc_msg_t structure + * + * Input parameter (type) in host order + * + * Return: non-NULL, the msg + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_msg_new(cc_uint32 type, cc_msg_t** msgpp) +{ + // type should be validated. If invalid set error to ccErrBadParam + cc_msg_t* msg; + + if ( type > CC_MSG_MAX_TYPE || msgpp == NULL ) + return ccErrBadParam; + + msg = (cc_msg_t*)malloc(sizeof(cc_msg_t)); + if (msg == NULL) + return ccErrNoMem; + + msg->type = htonl(type); + msg->flat = NULL; + msg->header = NULL; + msg->flat_len = 0; + msg->header_len = 0; + msg->magic = 0; + cci_generic_list_new(&msg->data_blobs); + if (msg->data_blobs == NULL) { + // pass on error from previous call + free(msg); + return ccErrNoMem; + } + + *msgpp = msg; + return ccNoError; +} + +/** + * cci_msg_calc_header_size() + * + * Purpose: Calculates the size of the header + * + * Return: the size in bytes + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_msg_calc_header_size(cc_msg_t* msg, cc_uint32 * lenp) +{ + int header_len = 12; /* header size, entire size, type */ + + if ( msg == NULL || lenp == NULL ) + return ccErrBadParam; + + header_len += msg->header_len; + *lenp = header_len; + return ccNoError; +} + +/** + * cci_msg_calc_size() + * + * Purpose: Calculates the size of the message + * (does not include the magic bytes) + * + * Return: the size in bytes + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_msg_calc_size(cc_msg_t* msg, cc_uint32 * lenp) +{ + cc_uint32 flat_len; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + if ( msg == NULL || lenp == NULL ) + return ccErrBadParam; + + code = cci_msg_calc_header_size(msg, &flat_len); + if (code != ccNoError) + goto bad; + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + if ( code != ccNoError ) + goto bad; + + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (code != ccNoError) + break; + flat_len += gen_node->len + BLOB_LEN; + } + cci_generic_free_iterator(gen_iterator); + if (code != ccNoError) + goto bad; + + flat_len += MAGIC_HEAD_LEN + MAGIC_DATA_LEN; + *lenp = flat_len; + + bad: + return code; +} + +/** + * cci_msg_add_data_blob() + * + * Purpose: Adds 'len' bytes of data to the msg + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_add_data_blob(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 *lenp) +{ + cc_int32 code; + + if (msg == NULL || data == NULL || len <= 0 || lenp == NULL) + return ccErrBadParam; + + code = cci_generic_list_append(msg->data_blobs, data, len, NULL); + if ( code != ccNoError ) + return code; + return cci_msg_calc_blob_pos(msg, data, len, lenp); +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_calc_blob_pos(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 * posp) +{ + cc_uint32 pos; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + code = cci_msg_calc_header_size(msg, &pos); + pos += sizeof(cc_uint32); /*+ sizeof(cc_uint32) for magic*/ + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (gen_node->len != len && gen_node->data != data) { + pos += gen_node->len + sizeof(cc_uint32); + } else { + cci_generic_free_iterator(gen_iterator); + *posp = pos + sizeof(cc_uint32); + return ccNoError; + } + } + + cci_generic_free_iterator(gen_iterator); + return ccIteratorEnd; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_add_header(cc_msg_t* msg, void *header, cc_uint32 header_len) +{ + if ( msg == NULL || header == NULL ) + return ccErrBadParam; + + msg->header = header; + msg->header_len = header_len; + return ccNoError; +} + + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_flatten(cc_msg_t* msg, void **flatpp) +{ + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + char *cur_pos; + cc_uint32 zero = 0; + cc_uint32 magic = 0; + cc_uint32 msg_len; + cc_uint32 u32; + cc_int32 code; + + if (msg == NULL || flatpp == NULL) + return ccErrBadParam; + + code = cci_msg_calc_size(msg,&msg->flat_len); + if ( code != ccNoError ) + return code; + + if (msg->flat_len > CC_MSG_MAX_SIZE) + return ccErrBadParam; + + msg->flat = (void *)malloc(msg->flat_len); + if (msg->flat == NULL) + return ccErrNoMem; + + cur_pos = msg->flat; + + u32 = msg->header_len; + htonl(u32); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + u32 = msg->flat_len; + htonl(u32); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + u32 = msg->type; + htonl(u32); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + /* header data is already in network order */ + memcpy(cur_pos, msg->header, msg->header_len); + cur_pos += msg->header_len; + + u32 = zero; + htonl(zero); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*will be magic number later*/ + cur_pos += sizeof(cc_uint32); + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + if ( code != ccNoError ) { + free(msg->flat); + return code; + } + + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (code != ccNoError) { + free(gen_iterator); + free(msg->flat); + return code; + } + u32 = gen_node->len; + htonl(u32); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + /* data already in network order */ + memcpy(cur_pos, gen_node->data, gen_node->len); + cur_pos += gen_node->len; + } + free(gen_iterator); + + u32 = zero; + htonl(zero); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*magic number will go here later*/ + cur_pos += sizeof(cc_uint32); + + if (cur_pos - (char *)msg->flat != msg->flat_len) { + fprintf(stderr, "ERROR cur_pos - msg->flat = %d\n",msg->flat_len); + } + + cci_msg_calc_magic(msg->flat, msg->flat_len, &magic); + printf("magic = %d\n",magic); + + cci_msg_calc_header_size(msg, &msg_len); + memcpy((char *)msg->flat + msg_len, &magic, sizeof(cc_uint32)); + memcpy((char *)msg->flat + msg->flat_len - sizeof(cc_uint32), &magic, sizeof(cc_uint32)); + + if ( flatpp != NULL ) + *flatpp = msg->flat; + + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * magicp) +{ + cc_uint32 magic = 0; + int i; + + for (i = 0; i < flat_len; i += sizeof(cc_uint32)) { + magic = magic ^ *(int *)((char *)flat + i); + } + *magicp = htonl(magic); + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_verify(void *flat, int flat_len, cc_uint32 * validp) +{ + cc_uint32 *magic1, *magic2; + cc_uint32 *pheader_len; + cc_uint32 header_len; + cc_uint32 *ptotal_len; + cc_uint32 total_len; + cc_uint32 *pblob_len; + cc_uint32 blob_len; + cc_uint32 *ptype; + cc_uint32 type; + cc_uint32 num_blobs = 0; + cc_uint32 zero = 0; + cc_uint32 msg_magic, msg_magic2; + + if (flat == NULL || flat_len <= 0 || validp == NULL) + return ccErrBadParam; + + pheader_len = flat; + ptotal_len = (cc_uint32 *)((char *)pheader_len + sizeof(cc_uint32)); + ptype = (cc_uint32 *)((char *)ptotal_len + sizeof(cc_uint32)); + + header_len = ntohl(*pheader_len); + total_len = ntohl(*ptotal_len); + type = ntohl(*ptype); + + if (total_len != flat_len) { + *validp = 0; + return ccNoError; + } + + if (header_len > flat_len) { + /*too weak. We could verify header_len against type spec header.*/ + *validp = 0; + return ccNoError; + } + if (type > CC_MSG_MAX_TYPE) { + *validp = 0; + return ccNoError; + } + + magic1 = (cc_uint32 *)((char *)ptype + sizeof(cc_uint32) + header_len); + if ((char *)magic1 - (char *)flat == (flat_len - 8)) { + /*There are no data blobs*/ + magic2 = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); + num_blobs = 0; + } else { + pblob_len = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); + num_blobs = 1; + blob_len = nothl(*pblob_len); + + while (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) < (flat_len - sizeof(cc_uint32))) { + pblob_len = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); + num_blobs++; + blob_len = ntohl(*pblob_len); + } + + if (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) != (flat_len - sizeof(cc_uint32))) { + /*blobs didn't line up*/ + *validp = 0; + return ccNoError; + } + magic2 = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); /*2nd magic should be directly after the last blob*/ + } + + if (*magic1 != *magic2) { + *validp = 0; + return ccNoError; + } + msg_magic = *magic1; + + printf("%d %d\n", (char *)magic1 - (char *)flat, (char *)magic2 - (char *)flat); + + memcpy(magic1, &zero, sizeof(cc_uint32)); + memcpy(magic2, &zero, sizeof(cc_uint32)); + cci_msg_calc_magic(flat, flat_len, &msg_magic2); + /* both msg_magic and msg_magic2 are in network order */ + if (msg_magic != msg_magic2) { + *validp = 0; + return ccNoError; + } + memcpy(magic1, &msg_magic, sizeof(cc_uint32)); + memcpy(magic2, &msg_magic, sizeof(cc_uint32)); + + *validp = 1; + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp) +{ + cc_msg_t* msg; + char *cur_pos; + cc_uint32 blob_len; + char *blob; + cc_uint32 valid; + cc_int32 code; + + if ( flat == NULL || flat_len <= 0 || msgpp == NULL ) + return ccErrBadParam; + + code = cci_msg_new(0, &msg); + if (code) + return code; + + cci_msg_verify(flat, flat_len, &valid); + if (valid != 1) { + cci_msg_destroy(msg); + return ccErrBadParam; + } + + cur_pos = flat; + msg->flat = flat; + + msg->header_len = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->flat_len = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->type = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->header = (void *)malloc(msg->header_len); + if (msg->header == NULL) { + cci_msg_destroy(msg); + return ccErrNoMem; + } + memcpy(msg->header, cur_pos, msg->header_len); + cur_pos += msg->header_len; + + msg->magic = nothl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + if (cur_pos - (char *)flat != flat_len - 8) { /*at least 1 blob*/ + blob_len = ntohl(*(cc_uint32 *)cur_pos); + while (blob_len + (cur_pos - (char *)flat) + sizeof(cc_uint32) <= flat_len - sizeof(cc_uint32)) { + blob = (void *)malloc(blob_len); + if (blob == NULL) { + cci_msg_destroy(msg); + return ccErrNoMem; + } + memcpy(blob, cur_pos + sizeof(cc_uint32), blob_len); + cci_generic_list_append(msg->data_blobs, blob, blob_len, NULL); + + cur_pos += sizeof(cc_uint32) + blob_len; + blob_len = ntohl(*(int *)cur_pos); + } + } + *msgpp = msg; + return ccNoError; +} + +cc_int32 +cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **blobp) +{ + cc_generic_iterate_t* gen_iterator; + cc_generic_list_node_t* gen_node; + void *ret; + cc_uint32 blob_pos; + cc_int32 code; + + /*Ensure that the message has been unflattened*/ + if ( msg == NULL || msg->flat == NULL || blob_offset > msg->flat_len || + blob_len > msg->flat_len - blob_offset || blobp == NULL) + return ccErrBadParam; + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + code = cci_msg_calc_blob_pos(msg, gen_node->data, gen_node->len, &blob_pos); + if (blob_pos == blob_offset && gen_node->len == blob_len) { + free(gen_iterator); + ret = (void *)malloc(blob_len); + if (ret == NULL) + return ccErrNoMem; + memcpy(ret,(char *)msg->flat + blob_offset, blob_len); + *blobp = ret; + return ccNoError; + } + } + free(gen_iterator); + return ccIteratorEnd; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_destroy(cc_msg_t* msg) +{ + if (msg->flat != NULL) + free(msg->flat); + if (msg->header != NULL) + free(msg->flat); + cci_generic_list_destroy(msg->data_blobs); + free(msg); + return ccNoError; +} + diff --git a/src/lib/ccapi/include/CredentialsCache.h b/src/lib/ccapi/include/CredentialsCache.h index dd60fa46d..7143da4e2 100644 --- a/src/lib/ccapi/include/CredentialsCache.h +++ b/src/lib/ccapi/include/CredentialsCache.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 1998-2004 by the Massachusetts Institute of Technology. + * Copyright 1998-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -46,12 +46,12 @@ /* * Declarations for Credentials Cache API Library * - * API specification: + * API specification: * * Revision 1: Frank Dabek, 6/4/1998 * Revision 2: meeroh, 2/24/1999 * Revision 3: meeroh, 11/12/1999 - * Revision 4: jaltman, 10/27/2004 + * Revision 6: jaltman, 10/27/2004 * */ @@ -81,6 +81,17 @@ extern "C" { #pragma options align=mac68k #endif +#if defined(_WIN32) +#define CCACHE_API __declspec(dllexport) + +#if _INTEGRAL_MAX_BITS >= 64 && _MSC_VER >= 1400 && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T) +#if defined(_TIME_T_DEFINED) || defined(_INC_IO) || defined(_INC_TIME) || defined(_INC_WCHAR) +#error time_t has been defined as a 64-bit integer which is incompatible with Kerberos on this platform. +#endif /* _TIME_T_DEFINED */ +#define _USE_32BIT_TIME_T +#endif +#endif + #include /* @@ -92,14 +103,16 @@ enum { ccapi_version_2 = 2, ccapi_version_3 = 3, ccapi_version_4 = 4, - ccapi_version_5 = 5 + ccapi_version_5 = 5, + ccapi_version_6 = 6, + ccapi_version_max = ccapi_version_6 }; /* Errors */ enum { - ccNoError = 0, + ccNoError = 0, - ccIteratorEnd = 201, + ccIteratorEnd = 201, ccErrBadParam, ccErrNoMem, ccErrInvalidContext, @@ -111,7 +124,7 @@ enum { ccErrInvalidCredentialsIterator, ccErrInvalidLock, - ccErrBadName, /* 211 */ + ccErrBadName, /* 211 */ ccErrBadCredentialsVersion, ccErrBadAPIVersion, ccErrContextLocked, @@ -123,7 +136,7 @@ enum { ccErrNeverDefault, ccErrCredentialsNotFound, - ccErrCCacheNotFound, /* 221 */ + ccErrCCacheNotFound, /* 221 */ ccErrContextNotFound, ccErrServerUnavailable, ccErrServerInsecure, @@ -135,20 +148,22 @@ enum { }; /* Credentials versions */ -enum { +enum cc_credential_versions { cc_credentials_v4 = 1, cc_credentials_v5 = 2, cc_credentials_v4_v5 = 3 }; /* Lock types */ -enum { - cc_lock_read = 1, - cc_lock_write = 2 +enum cc_lock_types { + cc_lock_read = 0, + cc_lock_write = 1, + cc_lock_upgrade = 2, + cc_lock_downgrade = 3 }; /* Locking Modes */ -enum { +enum cc_lock_modes { cc_lock_noblock = 0, cc_lock_block = 1 }; @@ -157,12 +172,20 @@ enum { * Basic types */ -typedef char cc_int8; -typedef unsigned char cc_uint8; -typedef int cc_int32; -typedef unsigned int cc_uint32; -typedef time_t cc_time_t; -typedef void * cc_handle; +typedef char cc_int8; +typedef unsigned char cc_uint8; +typedef int cc_int32; +typedef unsigned int cc_uint32; +#if defined (WIN32) +typedef __int64 cc_int64; +typedef unsigned __int64 cc_uint64; +#else +typedef long long cc_int64; +typedef unsigned long long cc_uint64; +#endif +typedef time_t cc_time; +typedef cc_int64 cc_time64; +typedef cc_uint64 cc_handle; /* * API types @@ -190,10 +213,11 @@ typedef struct cc_credentials_f cc_credentials_f; /* Credentials types */ enum { /* Make sure all of these are multiples of four (for alignment sanity) */ - cc_v4_name_size = 40, + cc_v4_name_size = 40, cc_v4_instance_size = 40, cc_v4_realm_size = 40, - cc_v4_ticket_size = 1254 + cc_v4_ticket_size = 1254, + cc_v4_key_size = 8 }; enum cc_string_to_key_type { @@ -211,10 +235,10 @@ struct cc_credentials_v4_t { char service [cc_v4_name_size]; char service_instance [cc_v4_instance_size]; char realm [cc_v4_realm_size]; - unsigned char session_key [8]; + unsigned char session_key [cc_v4_key_size]; cc_int32 kvno; cc_int32 string_to_key_type; - cc_time_t issue_date; + cc_time issue_date; cc_int32 lifetime; cc_uint32 address; cc_int32 ticket_size; @@ -233,10 +257,10 @@ struct cc_credentials_v5_t { char* client; char* server; cc_data keyblock; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renew_till; + cc_time authtime; + cc_time starttime; + cc_time endtime; + cc_time renew_till; cc_uint32 is_skey; cc_uint32 ticket_flags; cc_data** addresses; @@ -320,7 +344,7 @@ struct cc_context_f { cc_context_t context); cc_int32 (*get_change_time) ( cc_context_t context, - cc_time_t* time); + cc_time* time); cc_int32 (*get_default_ccache_name) ( cc_context_t context, cc_string_t* name); @@ -397,16 +421,16 @@ struct cc_ccache_f { cc_ccache_t destination); cc_int32 (*lock) ( cc_ccache_t ccache, - cc_uint32 block, - cc_uint32 lock_type); + cc_uint32 lock_type, + cc_uint32 block); cc_int32 (*unlock) ( cc_ccache_t ccache); cc_int32 (*get_last_default_time) ( cc_ccache_t ccache, - cc_time_t* time); + cc_time* time); cc_int32 (*get_change_time) ( cc_ccache_t ccache, - cc_time_t* time); + cc_time* time); cc_int32 (*compare) ( cc_ccache_t ccache, cc_ccache_t compare_to, @@ -414,11 +438,11 @@ struct cc_ccache_f { cc_int32 (*get_kdc_time_offset) ( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t* time_offset); + cc_time* time_offset); cc_int32 (*set_kdc_time_offset) ( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t time_offset); + cc_time time_offset); cc_int32 (*clear_kdc_time_offset) ( cc_ccache_t ccache, @@ -446,6 +470,9 @@ struct cc_ccache_iterator_f { cc_int32 (*next) ( cc_ccache_iterator_t iter, cc_ccache_t* ccache); + + cc_int32 (*clone) ( cc_ccache_iterator_t iter, + cc_ccache_iterator_t* new_iter); }; struct cc_credentials_iterator_f { @@ -454,16 +481,19 @@ struct cc_credentials_iterator_f { cc_int32 (*next) ( cc_credentials_iterator_t iter, cc_credentials_t* ccache); + + cc_int32 (*clone) ( cc_credentials_iterator_t iter, + cc_credentials_iterator_t* new_iter); }; /* * API functions */ -cc_int32 cc_initialize ( +CCACHE_API cc_int32 cc_initialize ( cc_context_t* outContext, - cc_int32 inVersion, - cc_int32* outSupportedVersion, + cc_int32 inVersion, + cc_int32* outSupportedVersion, char const** outVendor); /* @@ -488,8 +518,8 @@ cc_int32 cc_initialize ( ((context) -> functions -> create_new_ccache (context, version, principal, ccache)) #define cc_context_new_ccache_iterator(context, iterator) \ ((context) -> functions -> new_ccache_iterator (context, iterator)) -#define cc_context_lock(context, type, lock) \ - ((context) -> functions -> lock (context, type, lock)) +#define cc_context_lock(context, type, block) \ + ((context) -> functions -> lock (context, type, block)) #define cc_context_unlock(context) \ ((context) -> functions -> unlock (context)) #define cc_context_compare(context, compare_to, equal) \ @@ -515,8 +545,8 @@ cc_int32 cc_initialize ( ((ccache) -> functions -> remove_credentials (ccache, credentials)) #define cc_ccache_new_credentials_iterator(ccache, iterator) \ ((ccache) -> functions -> new_credentials_iterator (ccache, iterator)) -#define cc_ccache_lock(ccache, lock) \ - ((ccache) -> functions -> lock (ccache, lock)) +#define cc_ccache_lock(ccache, type, block) \ + ((ccache) -> functions -> lock (ccache, type, block)) #define cc_ccache_unlock(ccache, unlock) \ ((ccache) -> functions -> unlock (ccache, unlock)) #define cc_ccache_get_last_default_time(ccache, time) \ @@ -528,11 +558,11 @@ cc_int32 cc_initialize ( #define cc_ccache_compare(ccache, compare_to, equal) \ ((ccache) -> functions -> compare (ccache, compare_to, equal)) #define cc_ccache_get_kdc_time_offset(ccache, version, time) \ - ((ccache) -> functions -> get_kdc_time_offset (version, time)) + ((ccache) -> functions -> get_kdc_time_offset (version, time)) #define cc_ccache_set_kdc_time_offset(ccache, version, time) \ - ((ccache) -> functions -> set_kdc_time_offset (version, time)) + ((ccache) -> functions -> set_kdc_time_offset (version, time)) #define cc_ccache_clear_kdc_time_offset(ccache, version) \ - ((ccache) -> functions -> clear_kdc_time_offset (version)) + ((ccache) -> functions -> clear_kdc_time_offset (version)) #define cc_string_release(string) \ ((string) -> functions -> release (string)) @@ -546,11 +576,15 @@ cc_int32 cc_initialize ( ((iterator) -> functions -> release (iterator)) #define cc_ccache_iterator_next(iterator, ccache) \ ((iterator) -> functions -> next (iterator, ccache)) +#define cc_ccache_iterator_clone(iterator, new_iter) \ + ((iterator) -> functions -> clone (iterator, new_iter)) #define cc_credentials_iterator_release(iterator) \ ((iterator) -> functions -> release (iterator)) #define cc_credentials_iterator_next(iterator, credentials) \ ((iterator) -> functions -> next (iterator, credentials)) +#define cc_credentials_iterator_clone(iterator, new_iter) \ + ((iterator) -> functions -> clone (iterator, new_iter)) #if TARGET_OS_MAC #if defined(__MWERKS__) diff --git a/src/lib/ccapi/include/CredentialsCache2.h b/src/lib/ccapi/include/CredentialsCache2.h index 401e093f4..214d93a02 100644 --- a/src/lib/ccapi/include/CredentialsCache2.h +++ b/src/lib/ccapi/include/CredentialsCache2.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 1998-2004 by the Massachusetts Institute of Technology. + * Copyright 1998-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -48,7 +48,7 @@ #ifndef __CREDENTIALSCACHE2__ #define __CREDENTIALSCACHE2__ -#include +#include "CredentialsCache.h" #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) #include #if TARGET_RT_MAC_CFM @@ -185,25 +185,25 @@ enum { CC_CRED_MAX }; -cc_int32 cc_shutdown ( +CCACHE_API cc_int32 cc_shutdown ( apiCB** ioContext); -cc_int32 cc_get_NC_info ( +CCACHE_API cc_int32 cc_get_NC_info ( apiCB* inContext, infoNC*** outInfo); -cc_int32 cc_get_change_time ( +CCACHE_API cc_int32 cc_get_change_time ( apiCB* inContext, cc_time_t* outTime); -cc_int32 cc_open ( +CCACHE_API cc_int32 cc_open ( apiCB* inContext, const char* inName, cc_int32 inVersion, cc_uint32 inFlags, ccache_p** outCCache); -cc_int32 cc_create ( +CCACHE_API cc_int32 cc_create ( apiCB* inContext, const char* inName, const char* inPrincipal, @@ -211,85 +211,85 @@ cc_int32 cc_create ( cc_uint32 inFlags, ccache_p** outCCache); -cc_int32 cc_close ( +CCACHE_API cc_int32 cc_close ( apiCB* inContext, ccache_p** ioCCache); -cc_int32 cc_destroy ( +CCACHE_API cc_int32 cc_destroy ( apiCB* inContext, ccache_p** ioCCache); -cc_int32 cc_seq_fetch_NCs_begin ( +CCACHE_API cc_int32 cc_seq_fetch_NCs_begin ( apiCB* inContext, - ccache_cit** outIterator); + ccache_cit** outIterator); -cc_int32 cc_seq_fetch_NCs_next ( +CCACHE_API cc_int32 cc_seq_fetch_NCs_next ( apiCB* inContext, ccache_p** outCCache, ccache_cit* inIterator); -cc_int32 cc_seq_fetch_NCs_end ( +CCACHE_API cc_int32 cc_seq_fetch_NCs_end ( apiCB* inContext, - ccache_cit** ioIterator); + ccache_cit** ioIterator); -cc_int32 cc_get_name ( +CCACHE_API cc_int32 cc_get_name ( apiCB* inContext, ccache_p* inCCache, char** outName); -cc_int32 cc_get_cred_version ( +CCACHE_API cc_int32 cc_get_cred_version ( apiCB* inContext, ccache_p* inCCache, cc_int32* outVersion); -cc_int32 cc_set_principal ( +CCACHE_API cc_int32 cc_set_principal ( apiCB* inContext, ccache_p* inCCache, cc_int32 inVersion, char* inPrincipal); -cc_int32 cc_get_principal ( +CCACHE_API cc_int32 cc_get_principal ( apiCB* inContext, ccache_p* inCCache, char** outPrincipal); -cc_int32 cc_store ( +CCACHE_API cc_int32 cc_store ( apiCB* inContext, ccache_p* inCCache, cred_union inCredentials); -cc_int32 cc_remove_cred ( +CCACHE_API cc_int32 cc_remove_cred ( apiCB* inContext, ccache_p* inCCache, cred_union inCredentials); -cc_int32 cc_seq_fetch_creds_begin ( +CCACHE_API cc_int32 cc_seq_fetch_creds_begin ( apiCB* inContext, - const ccache_p* inCCache, - ccache_cit** outIterator); + const ccache_p* inCCache, + ccache_cit** outIterator); -cc_int32 cc_seq_fetch_creds_next ( +CCACHE_API cc_int32 cc_seq_fetch_creds_next ( apiCB* inContext, - cred_union** outCreds, + cred_union** outCreds, ccache_cit* inIterator); -cc_int32 cc_seq_fetch_creds_end ( +CCACHE_API cc_int32 cc_seq_fetch_creds_end ( apiCB* inContext, - ccache_cit** ioIterator); + ccache_cit** ioIterator); -cc_int32 cc_free_principal ( +CCACHE_API cc_int32 cc_free_principal ( apiCB* inContext, char** ioPrincipal); -cc_int32 cc_free_name ( +CCACHE_API cc_int32 cc_free_name ( apiCB* inContext, char** ioName); -cc_int32 cc_free_creds ( +CCACHE_API cc_int32 cc_free_creds ( apiCB* inContext, - cred_union** creds); + cred_union** creds); -cc_int32 cc_free_NC_info ( +CCACHE_API cc_int32 cc_free_NC_info ( apiCB* inContext, infoNC*** ioInfo); diff --git a/src/lib/ccapi/include/cc_rpc.h b/src/lib/ccapi/include/cc_rpc.h new file mode 100644 index 000000000..0f14724b9 --- /dev/null +++ b/src/lib/ccapi/include/cc_rpc.h @@ -0,0 +1,52 @@ +/* $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). + * $ + */ + + +#ifndef __CC_RPC_H__ +#define __CC_RPC_H__ + +#include "msg.h" + +cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response); + +#endif /* __CC_RPC_H__ */ diff --git a/src/lib/ccapi/include/generic_lists.h b/src/lib/ccapi/include/generic_lists.h new file mode 100644 index 000000000..4d49e276b --- /dev/null +++ b/src/lib/ccapi/include/generic_lists.h @@ -0,0 +1,95 @@ +/* $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). + * $ + */ +/* + * Prototypes and data structures for datastore. + * + */ + + +#ifndef __CC_GENERIC_LISTS_H_ +#define __CC_GENERIC_LISTS_H_ + +struct cc_generic_list_node_t { + cc_uint8* data; + cc_uint32 len; + struct cc_generic_list_node_t* next; + struct cc_generic_list_node_t* prev; +}; +typedef struct cc_generic_list_node_t cc_generic_list_node_t; + +struct cc_generic_list_head_t { + enum cc_list_type type; + cc_generic_list_node_t* head; + cc_generic_list_node_t* tail; +}; +typedef struct cc_generic_list_head_t cc_generic_list_head_t; + + +struct cc_generic_iterate_t { + cc_generic_list_node_t* next; +}; +typedef struct cc_generic_iterate_t cc_generic_iterate_t; + +typedef cc_generic_list_head_t cc_context_list_head_t; +typedef cc_generic_list_node_t cc_context_list_node_t; + +typedef cc_generic_list_head_t cc_ccache_list_head_t; +typedef cc_generic_list_node_t cc_ccache_list_node_t; + +typedef cc_generic_list_head_t cc_credentials_list_head_t; +typedef cc_generic_list_node_t cc_credentials_list_node_t; + +cc_int32 cci_generic_iterate_has_next(cc_generic_iterate_t *iterate); +cc_int32 cci_generic_iterate_next(cc_generic_iterate_t *iterate, cc_generic_list_node_t**); + +cc_int32 cci_generic_list_new(cc_generic_list_head_t **); +cc_int32 cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); +cc_int32 cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); +cc_int32 cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem); +cc_int32 cci_generic_free_element(cc_generic_list_node_t* node); +cc_int32 cci_generic_list_destroy(cc_generic_list_head_t* head); +cc_int32 cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t**); +cc_int32 cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t**); +cc_int32 cci_generic_free_iterator(cc_generic_iterate_t* iterator); + +#endif /* __CC_GENERIC_LISTS_H_ */ diff --git a/src/lib/ccapi/include/marshall.h b/src/lib/ccapi/include/marshall.h index 19b9463b0..ca6b12e96 100644 --- a/src/lib/ccapi/include/marshall.h +++ b/src/lib/ccapi/include/marshall.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -41,7 +41,6 @@ * $ */ -#define FLAT_CREDS_V5_VERSION 1 struct cc_flat_data { cc_uint32 type; cc_uint32 length; @@ -49,15 +48,16 @@ struct cc_flat_data { }; typedef struct cc_flat_data cc_flat_data; +#define FLAT_CREDS_V5_VERSION 1 struct cci_flat_creds_v5 { cc_uint32 version; /* version of this structure */ cc_flat_data client; cc_flat_data server; cc_flat_data keyblock; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renew_till; + cc_time64 authtime; + cc_time64 starttime; + cc_time64 endtime; + cc_time64 renew_till; cc_uint32 is_skey; cc_uint32 ticket_flags; cc_uint32 address_count; @@ -67,6 +67,25 @@ struct cci_flat_creds_v5 { cc_uint32 authdata_count; cc_uint32 authdata; /* offset to array */ }; +typedef struct cci_flat_creds_v5 cci_flat_creds_v5_t; + +struct cci_flat_creds_v4 { + cc_uint32 version; + char principal [cc_v4_name_size]; + char principal_instance [cc_v4_instance_size]; + char service [cc_v4_name_size]; + char service_instance [cc_v4_instance_size]; + char realm [cc_v4_realm_size]; + unsigned char session_key [cc_v4_key_size]; + cc_int32 kvno; + cc_int32 string_to_key_type; + cc_time64 issue_date; + cc_int32 lifetime; + cc_uint32 address; + cc_int32 ticket_size; + unsigned char ticket [cc_v4_ticket_size]; +}; +typedef struct cci_flat_creds_v4 cci_flat_creds_v4_t; cc_int32 cci_creds_v4_marshall( cc_credentials_v4_t * creds, diff --git a/src/lib/ccapi/include/msg.h b/src/lib/ccapi/include/msg.h index 0d712d666..182ebc161 100644 --- a/src/lib/ccapi/include/msg.h +++ b/src/lib/ccapi/include/msg.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -43,7 +43,7 @@ /* * Verifiable, extensible message format. - * + * * Format: * * @@ -60,13 +60,13 @@ * If the header has variable length data it is included in the data blobs. * The header field has the offset from the beginning of the message of the 1st * byte of the data and the length of the data. - * */ #ifndef __CC_MSG_H__ #define __CC_MSG_H__ #include "CredentialsCache.h" +#include "generic_lists.h" struct cc_msg_t { cc_uint32 type; /*type of message*/ @@ -87,16 +87,15 @@ enum { ccmsg_CTX_RELEASE, ccmsg_CTX_GET_CHANGE_TIME, ccmsg_CTX_GET_DEFAULT_CCACHE_NAME, - ccmsg_CTX_COMPARE, + ccmsg_CTX_CCACHE_OPEN, + ccmsg_CTX_CCACHE_OPEN_DEFAULT, + ccmsg_CTX_CCACHE_CREATE, + ccmsg_CTX_CCACHE_CREATE_DEFAULT, + ccmsg_CTX_CCACHE_CREATE_UNIQUE, ccmsg_CTX_NEW_CCACHE_ITERATOR, ccmsg_CTX_LOCK, ccmsg_CTX_UNLOCK, - ccmsg_CTX_CLONE, - ccmsg_CCACHE_OPEN, - ccmsg_CCACHE_OPEN_DEFAULT, - ccmsg_CCACHE_CREATE, - ccmsg_CCACHE_CREATE_DEFAULT, - ccmsg_CCACHE_CREATE_UNIQUE, + ccmsg_CTX_COMPARE, ccmsg_CCACHE_RELEASE, ccmsg_CCACHE_DESTROY, ccmsg_CCACHE_SET_DEFAULT, @@ -104,29 +103,28 @@ enum { ccmsg_CCACHE_GET_NAME, ccmsg_CCACHE_GET_PRINCIPAL, ccmsg_CCACHE_SET_PRINCIPAL, - ccmsg_CCACHE_CREDS_ITERATOR, + ccmsg_CCACHE_NEW_CREDS_ITERATOR, ccmsg_CCACHE_STORE_CREDS, ccmsg_CCACHE_REM_CREDS, + ccmsg_CCACHE_MOVE, + ccmsg_CCACHE_LOCK, + ccmsg_CCACHE_UNLOCK, ccmsg_CCACHE_GET_LAST_DEFAULT_TIME, ccmsg_CCACHE_GET_CHANGE_TIME, - ccmsg_CCACHE_MOVE, ccmsg_CCACHE_COMPARE, ccmsg_CCACHE_GET_KDC_TIME_OFFSET, ccmsg_CCACHE_SET_KDC_TIME_OFFSET, ccmsg_CCACHE_CLEAR_KDC_TIME_OFFSET, ccmsg_CCACHE_ITERATOR_RELEASE, ccmsg_CCACHE_ITERATOR_NEXT, - ccmsg_CCACHE_LOCK, - ccmsg_CCACHE_UNLOCK, + ccmsg_CCACHE_ITERATOR_CLONE, ccmsg_CREDS_ITERATOR_RELEASE, ccmsg_CREDS_ITERATOR_NEXT, - ccmsg_CREDS_RELEASE, - ccmsg_CREDS_V4, - ccmsg_CREDS_V5 + ccmsg_CREDS_ITERATOR_CLONE }; #define CC_MSG_MAX_SIZE 1073741824 /*2^30*/ -#define CC_MSG_MAX_TYPE ccmsg_CREDS_V5 +#define CC_MSG_MAX_TYPE ccmsg_CREDS_ITERATOR_CLONE #define BLOB_LEN (sizeof(cc_uint32)) #define MAGIC_DATA_LEN (sizeof(cc_uint32)) #define MAGIC_HEAD_LEN (sizeof(cc_uint32)) @@ -143,4 +141,21 @@ cc_int32 cci_msg_verify(void* flat, int flat_len, cc_uint32 * sizep); cc_int32 cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp); cc_int32 cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **); cc_int32 cci_msg_destroy(cc_msg_t* msg); + +/* Add missing byte swapping macros for 64-bit values */ +#ifdef MAC +#define htonll(x) OSSwapHostToBigInt64(x) +#define ntohll(x) OSSwapBigToHostInt64(x) +#else +#ifdef _WIN32 +#ifdef _M_IX86 +#define htonll(x) _byteswap_uint64(x) +#define ntohll(x) _byteswap_uint64(x) +#else +#define htonll(x) (x) +#define ntohll(x) (x) +#endif +#endif +#endif + #endif /*__CC_MSG_H__*/ diff --git a/src/lib/ccapi/include/msg_headers.h b/src/lib/ccapi/include/msg_headers.h index a27c2d2f1..b5a9acd6d 100644 --- a/src/lib/ccapi/include/msg_headers.h +++ b/src/lib/ccapi/include/msg_headers.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -57,6 +57,8 @@ * size divisible by 4. This is to ensure correct alignment * and stop different compilers from inserting padding bytes in * different places. + * + * All values are stored in network byte order. */ struct ccmsg_ctx_only_t { @@ -81,18 +83,18 @@ struct ccmsg_init_resp_t { typedef struct ccmsg_init_t ccmsg_init_t; typedef struct ccmsg_init_resp_t ccmsg_init_resp_t; -struct ccmsg_clone_t { +struct ccmsg_ctx_clone_t { cc_handle ctx; cc_uint32 in_version; /*client API version*/ }; -struct ccmsg_clone_resp_t { +struct ccmsg_ctx_clone_resp_t { cc_handle out_ctx; /*handle on this ctx*/ cc_uint32 out_version; /*server API version*/ cc_uint32 vendor_offset; /*offset of vendor blob*/ cc_uint32 vendor_length; /*length of vendor blob*/ }; -typedef struct ccmsg_clone_t ccmsg_clone_t; -typedef struct ccmsg_clone_resp_t ccmsg_clone_resp_t; +typedef struct ccmsg_ctx_clone_t ccmsg_ctx_clone_t; +typedef struct ccmsg_ctx_clone_resp_t ccmsg_ctx_clone_resp_t; struct ccmsg_ctx_release_t { cc_handle ctx; /*# of ctx to release*/ @@ -103,7 +105,7 @@ struct ccmsg_ctx_get_change_time_t { cc_handle ctx; }; struct ccmsg_ctx_get_change_time_resp_t { - cc_time_t time; + cc_time64 time; }; typedef struct ccmsg_ctx_get_change_time_t ccmsg_ctx_get_change_time_t; typedef struct ccmsg_ctx_get_change_time_resp_t ccmsg_ctx_get_change_time_resp_t; @@ -304,7 +306,7 @@ struct ccmsg_ccache_get_last_default_time_t { cc_handle ccache; }; struct ccmsg_ccache_get_last_default_time_resp_t { - cc_time_t last_default_time; + cc_time64 last_default_time; }; typedef struct ccmsg_ccache_get_last_default_time_t ccmsg_ccache_get_last_default_time_t; typedef struct ccmsg_ccache_get_last_default_time_resp_t ccmsg_ccache_get_last_default_time_resp_t; @@ -314,7 +316,7 @@ struct ccmsg_ccache_get_change_time_t { cc_handle ccache; }; struct ccmsg_ccache_get_change_time_resp_t { - cc_time_t time; + cc_time64 time; }; typedef struct ccmsg_ccache_get_change_time_t ccmsg_ccache_get_change_time_t; typedef struct ccmsg_ccache_get_change_time_resp_t ccmsg_ccache_get_change_time_resp_t; @@ -336,7 +338,7 @@ struct ccmsg_ccache_get_kdc_time_offset_t { cc_int32 creds_version; }; struct ccmsg_ccache_get_kdc_time_offset_resp_t { - cc_time_t offset; + cc_time64 offset; }; typedef struct ccmsg_ccache_get_kdc_time_offset_t ccmsg_ccache_get_kdc_time_offset_t; typedef struct ccmsg_ccache_get_kdc_time_offset_resp_t ccmsg_ccache_get_kdc_time_offset_resp_t; @@ -344,7 +346,7 @@ typedef struct ccmsg_ccache_get_kdc_time_offset_resp_t ccmsg_ccache_get_kdc_time struct ccmsg_ccache_set_kdc_time_offset_t { cc_handle ctx; cc_handle ccache; - cc_time_t offset; + cc_time64 offset; cc_int32 creds_version; }; typedef struct ccmsg_ccache_set_kdc_time_offset_t ccmsg_ccache_set_kdc_time_offset_t; @@ -372,6 +374,16 @@ struct ccmsg_ccache_iterator_next_resp_t { typedef struct ccmsg_ccache_iterator_next_t ccmsg_ccache_iterator_next_t; typedef struct ccmsg_ccache_iterator_next_resp_t ccmsg_ccache_iterator_next_resp_t; +struct ccmsg_ccache_iterator_clone_t { + cc_handle ctx; + cc_handle iterator; +}; +struct ccmsg_ccache_iterator_clone_resp_t { + cc_handle iterator; +}; +typedef struct ccmsg_ccache_iterator_clone_t ccmsg_ccache_iterator_clone_t; +typedef struct ccmsg_ccache_iterator_clone_resp_t ccmsg_ccache_iterator_clone_resp_t; + struct ccmsg_creds_iterator_release_t { cc_handle ctx; cc_handle ccache; @@ -393,37 +405,14 @@ struct ccmsg_creds_iterator_next_resp_t { typedef struct ccmsg_creds_iterator_next_t ccmsg_creds_iterator_next_t; typedef struct ccmsg_creds_iterator_next_resp_t ccmsg_creds_iterator_next_resp_t; -struct ccmsg_creds_v4_t { - cc_uint32 offset; - cc_uint32 len; -}; -typedef struct ccmsg_creds_v4_t ccmsg_creds_v4_t; - -struct ccmsg_creds_v5_t { - cc_uint32 client_offset; - cc_uint32 client_len; - cc_uint32 server_offset; - cc_uint32 server_len; - cc_uint32 keyblock_offset; - cc_uint32 keyblock_len; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renewtime; - cc_uint32 is_skey; - cc_uint32 ticket_flags; - cc_uint32 address_count; - cc_uint32 address_offset; - cc_uint32 address_len; - cc_uint32 ticket_offset; - cc_uint32 ticket_len; - cc_uint32 ticket2_offset; - cc_uint32 ticket2_len; - cc_uint32 authdata_count; - cc_uint32 authdata_offset; - cc_uint32 authdata_len; -}; -typedef struct ccmsg_creds_v5_t ccmsg_creds_v5_t; - +struct ccmsg_creds_iterator_clone_t { + cc_handle ctx; + cc_handle iterator; +}; +struct ccmsg_creds_iterator_clone_resp_t { + cc_handle iterator; +}; +typedef struct ccmsg_creds_iterator_clone_t ccmsg_creds_iterator_clone_t; +typedef struct ccmsg_creds_iterator_clone_resp_t ccmsg_creds_iterator_clone_resp_t; #endif /*__MSG_HEADERS_H__*/ diff --git a/src/lib/ccapi/marshall.c b/src/lib/ccapi/marshall.c deleted file mode 100644 index 7027d6561..000000000 --- a/src/lib/ccapi/marshall.c +++ /dev/null @@ -1,378 +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). - * $ - */ - -/* marshall.c */ - -#include -#include -#include -#include "msg.h" -#include "msg_headers.h" -#include "marshall.h" - -cc_int32 -cci_creds_v4_marshall( cc_credentials_v4_t * creds, - char ** flat, - cc_uint32 * len) -{ - cc_msg_t * msg; - ccmsg_creds_v4_t * header; - cc_uint32 blob_pos; - cc_int32 code; - - if ( creds == NULL || flat == NULL || len == NULL ) - return ccErrBadParam; - - header = (ccmsg_creds_v4_t *)malloc(sizeof(ccmsg_creds_v4_t)); - if ( header == NULL ) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CREDS_V4, &msg); - - code = cci_msg_add_header(msg, header, sizeof(ccmsg_creds_v4_t)); - - code = cci_msg_add_data_blob(msg, creds, sizeof(cc_credentials_v4_t), &blob_pos); - - header->offset = blob_pos; - header->len = sizeof(cc_credentials_v4_t); - - code = cci_msg_flatten( msg, NULL ); - - *flat = msg->flat; - *len = msg->flat_len; - msg->flat = NULL; - msg->flat_len = 0; - - cci_msg_destroy(msg); - - return ccNoError; -} - -cc_int32 -cci_creds_v4_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds) -{ - cc_msg_t * msg; - ccmsg_creds_v4_t * header; - cc_int32 code; - - if ( flat == NULL || len == 0 || creds == NULL ) - return ccErrBadParam; - - code = cci_msg_unflatten( flat, len, &msg ); - - header = (ccmsg_creds_v4_t *)msg->header; - - creds->version = cc_credentials_v4; - code = cci_msg_retrieve_blob(msg, header->offset, header->len, &creds->credentials.credentials_v4); - - cci_msg_destroy(msg); - - return ccNoError; -} - - -cc_int32 -cci_creds_cc_data_array_count_entries( cc_data ** array, cc_uint32 * pcount) -{ - cc_uint32 count; - - if (array == NULL) { - *pcount = 0; - return ccNoError; - } - - for ( count=0; array[count] != NULL ; count++) ; - - *pcount = count; - return ccNoError; -} - -cc_int32 -cci_creds_v5_compute_flat_size( cc_credentials_v5_t * creds, cc_uint32 * plen) -{ - cc_uint32 len; - cc_uint32 i, count; - - len = sizeof(struct cci_flat_creds_v5); - - if (creds->client) - len += strlen(creds->client) + 1; - - if (creds->server) - len += strlen(creds->server) + 1; - - len += creds->keyblock.length; - - cci_creds_cc_data_array_count_entries( creds->addresses, &count ); - len += count * sizeof(cc_flat_data); - for ( i=0; iaddresses[i]->length; - } - - len += creds->ticket.length; - len += creds->second_ticket.length; - - cci_creds_cc_data_array_count_entries( creds->authdata, &count ); - len += count * sizeof(cc_flat_data); - for ( i=0; iauthdata[i]->length; - } - - *plen = len; - return ccNoError; -} - -cc_int32 -cci_creds_v5_marshall( cc_credentials_v5_t * creds, - char ** pflat, - cc_uint32 * plen) -{ - cc_uint32 len; - char * flat; - struct cci_flat_creds_v5 * header; - cc_uint32 offset; - cc_uint32 i; - - if ( creds == NULL || pflat == NULL || plen == NULL ) - return ccErrBadParam; - - cci_creds_v5_compute_flat_size(creds, &len); - - flat = (char *)malloc(len); - if ( flat == NULL ) - return ccErrNoMem; - memset(flat, 0, len); - - offset = sizeof(struct cci_flat_creds_v5); - header = (struct cci_flat_creds_v5 *)flat; - header->version = FLAT_CREDS_V5_VERSION; - if (creds->client) { - header->client.length = strlen(creds->client) + 1; - header->client.data = offset; - memcpy(flat + offset, creds->client, header->client.length); - offset += header->client.length; - } - - if (creds->server) { - header->server.length = strlen(creds->server) + 1; - header->server.data = offset; - memcpy(flat + offset, creds->server, header->server.length); - offset += header->server.length; - } - - header->keyblock.type = creds->keyblock.type; - if (creds->keyblock.length) { - header->keyblock.length = creds->keyblock.length; - header->keyblock.data = offset; - memcpy(flat + offset, creds->keyblock.data, header->keyblock.length); - offset += header->keyblock.length; - } - - header->authtime = creds->authtime; - header->starttime = creds->starttime; - header->endtime = creds->endtime; - header->renew_till = creds->renew_till; - header->is_skey = creds->is_skey; - header->ticket_flags = creds->ticket_flags; - - cci_creds_cc_data_array_count_entries( creds->addresses, &header->address_count ); - if ( header->address_count ) { - cc_flat_data * addresses = (cc_flat_data *)flat + offset; - header->addresses = offset; - offset += header->address_count * sizeof(cc_flat_data); - - for ( i=0; iaddress_count; i++ ) { - addresses[i].type = creds->addresses[i]->type; - if (creds->addresses[i]->length) { - addresses[i].length = creds->addresses[i]->length; - addresses[i].data = offset; - memcpy(flat + offset, creds->addresses[i]->data, addresses[i].length); - offset += addresses[i].length; - } - } - } - - header->ticket.type = creds->ticket.type; - if (creds->ticket.length) { - header->ticket.length = creds->ticket.length; - header->ticket.data = offset; - memcpy(flat + offset, creds->ticket.data, header->ticket.length); - offset += header->ticket.length; - } - - header->second_ticket.type = creds->second_ticket.type; - if (creds->second_ticket.length) { - header->second_ticket.length = creds->second_ticket.length; - header->second_ticket.data = offset; - memcpy(flat + offset, creds->second_ticket.data, header->second_ticket.length); - offset += header->second_ticket.length; - } - - cci_creds_cc_data_array_count_entries( creds->authdata, &header->authdata_count ); - if ( header->authdata_count ) { - cc_flat_data * authdata = (cc_flat_data *)flat + offset; - header->authdata = offset; - offset += header->authdata_count * sizeof(cc_flat_data); - - for ( i=0; iauthdata_count; i++ ) { - authdata[i].type = creds->authdata[i]->type; - if (creds->authdata[i]->length) { - authdata[i].length = creds->authdata[i]->length; - authdata[i].data = offset; - memcpy(flat + offset, creds->authdata[i]->data, authdata[i].length); - offset += authdata[i].length; - } - } - } - - *pflat = flat; - *plen = len; - return ccNoError; -} - - -// TODO: a much better job of checking for out of memory errors -// and validating that we do not read beyond the flat input -// data buffer - -cc_int32 -cci_creds_v5_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds_union) -{ - struct cci_flat_creds_v5 * header; - cc_credentials_v5_t * creds; - cc_flat_data * flat_data; - cc_uint32 i; - cc_int32 code; - - if ( flat == NULL || len == 0 || creds_union == NULL ) - return ccErrBadParam; - - creds_union->version = cc_credentials_v5; - - header = (struct cci_flat_creds_v5 *)flat; - - if ( header->version != FLAT_CREDS_V5_VERSION ) - return ccErrBadParam; - - creds = (cc_credentials_v5_t *)malloc(sizeof(cc_credentials_v5_t)); - if ( creds == NULL ) - return ccErrNoMem; - memset(creds, 0, sizeof(ccmsg_creds_v5_t)); - - if ( header->client.length ) { - creds->client = (char *)malloc(header->client.length); - memcpy(creds->client, flat + header->client.data, header->client.length); - } - - if ( header->server.length ) { - creds->server = (char *)malloc(header->server.length); - memcpy(creds->server, flat + header->server.data, header->server.length); - } - - creds->keyblock.type = header->keyblock.type; - if ( header->keyblock.length ) { - creds->keyblock.length = header->keyblock.length; - creds->keyblock.data = malloc(creds->keyblock.length); - memcpy(creds->keyblock.data, flat + header->keyblock.data, creds->keyblock.length); - } - - creds->authtime = header->authtime; - creds->starttime = header->starttime; - creds->endtime = header->endtime; - creds->renew_till = header->renew_till; - creds->is_skey = header->is_skey; - creds->ticket_flags = header->ticket_flags; - - creds->addresses = (cc_data **) malloc((header->address_count + 1) * sizeof(cc_data *)); - flat_data = (cc_flat_data *)flat + header->addresses; - for ( i=0 ; i < header->address_count ; i++ ) { - creds->addresses[i] = (cc_data *)malloc(sizeof(cc_data)); - creds->addresses[i]->type = flat_data[i].type; - creds->addresses[i]->length = flat_data[i].length; - if ( flat_data[i].length ) { - creds->addresses[i]->data = malloc(flat_data[i].length); - memcpy(creds->addresses[i]->data, flat + flat_data[i].data, flat_data[i].length); - } else { - creds->addresses[i]->data = NULL; - } - } - creds->addresses[i] = NULL; - - creds->ticket.type = header->ticket.type; - if ( header->ticket.length ) { - creds->ticket.length = header->ticket.length; - creds->ticket.data = malloc(creds->ticket.length); - memcpy(creds->ticket.data, flat + header->ticket.data, creds->ticket.length); - } - - creds->second_ticket.type = header->second_ticket.type; - if ( header->second_ticket.length ) { - creds->second_ticket.length = header->second_ticket.length; - creds->second_ticket.data = malloc(creds->second_ticket.length); - memcpy(creds->second_ticket.data, flat + header->second_ticket.data, creds->second_ticket.length); - } - - creds->authdata = (cc_data **) malloc((header->authdata_count + 1) * sizeof(cc_data *)); - flat_data = (cc_flat_data *)flat + header->authdata; - for ( i=0 ; i < header->authdata_count ; i++ ) { - creds->authdata[i] = (cc_data *)malloc(sizeof(cc_data)); - creds->authdata[i]->type = flat_data[i].type; - creds->authdata[i]->length = flat_data[i].length; - if ( flat_data[i].length ) { - creds->authdata[i]->data = malloc(flat_data[i].length); - memcpy(creds->authdata[i]->data, flat + flat_data[i].data, flat_data[i].length); - } else { - creds->authdata[i]->data = NULL; - } - } - creds->authdata[i] = NULL; - - creds_union->credentials.credentials_v5 = creds; - - return ccNoError; -} - diff --git a/src/lib/ccapi/msg.c b/src/lib/ccapi/msg.c deleted file mode 100644 index f5f074aa0..000000000 --- a/src/lib/ccapi/msg.c +++ /dev/null @@ -1,582 +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). - * $ - */ - -/* - * Verifiable, extensible message format. - */ - -#include "CredentialsCache.h" -#include "msg.h" -#include "datastore.h" - -#include -#include -#include -#include - -/** - * cci_msg_new() - * - * Purpose: Allocate and initialize a new cc_msg_t structure - * - * Return: non-NULL, the msg - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_msg_new(cc_uint32 type, cc_msg_t** msgpp) -{ - // type should be validated. If invalid set error to ccErrBadParam - cc_msg_t* msg; - - if ( type > CC_MSG_MAX_TYPE || msgpp == NULL ) - return ccErrBadParam; - - msg = (cc_msg_t*)malloc(sizeof(cc_msg_t)); - if (msg == NULL) - return ccErrNoMem; - - msg->type = type; - msg->flat = NULL; - msg->header = NULL; - msg->flat_len = 0; - msg->header_len = 0; - msg->magic = 0; - cci_generic_list_new(&msg->data_blobs); - if (msg->data_blobs == NULL) { - // pass on error from previous call - free(msg); - return ccErrNoMem; - } - - *msgpp = msg; - return ccNoError; -} - -/** - * cci_msg_calc_header_size() - * - * Purpose: Calculates the size of the header - * - * Return: the size in bytes - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_msg_calc_header_size(cc_msg_t* msg, cc_uint32 * lenp) -{ - int header_len = 12; /* header size, entire size, type */ - - if ( msg == NULL || lenp == NULL ) - return ccErrBadParam; - - header_len += msg->header_len; - *lenp = header_len; - return ccNoError; -} - -/** - * cci_msg_calc_size() - * - * Purpose: Calculates the size of the message - * (does not include the magic bytes) - * - * Return: the size in bytes - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_msg_calc_size(cc_msg_t* msg, cc_uint32 * lenp) -{ - cc_uint32 flat_len; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - if ( msg == NULL || lenp == NULL ) - return ccErrBadParam; - - code = cci_msg_calc_header_size(msg, &flat_len); - if (code != ccNoError) - goto bad; - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - if ( code != ccNoError ) - goto bad; - - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (code != ccNoError) - break; - flat_len += gen_node->len + BLOB_LEN; - } - cci_generic_free_iterator(gen_iterator); - if (code != ccNoError) - goto bad; - - flat_len += MAGIC_HEAD_LEN + MAGIC_DATA_LEN; - *lenp = flat_len; - - bad: - return code; -} - -/** - * cci_msg_add_data_blob() - * - * Purpose: Adds 'len' bytes of data to the msg - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_add_data_blob(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 *lenp) -{ - cc_int32 code; - - if (msg == NULL || data == NULL || len <= 0 || lenp == NULL) - return ccErrBadParam; - - code = cci_generic_list_append(msg->data_blobs, data, len, NULL); - if ( code != ccNoError ) - return code; - return cci_msg_calc_blob_pos(msg, data, len, lenp); -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_calc_blob_pos(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 * posp) -{ - cc_uint32 pos; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - code = cci_msg_calc_header_size(msg, &pos); - pos += sizeof(cc_uint32); /*+ sizeof(cc_uint32) for magic*/ - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (gen_node->len != len && gen_node->data != data) { - pos += gen_node->len + sizeof(cc_uint32); - } else { - cci_generic_free_iterator(gen_iterator); - *posp = pos + sizeof(cc_uint32); - return ccNoError; - } - } - - cci_generic_free_iterator(gen_iterator); - return ccIteratorEnd; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_add_header(cc_msg_t* msg, void *header, cc_uint32 header_len) -{ - if ( msg == NULL || header == NULL ) - return ccErrBadParam; - - msg->header = header; - msg->header_len = header_len; - return ccNoError; -} - - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_flatten(cc_msg_t* msg, void **flatpp) -{ - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - char *cur_pos; - cc_uint32 zero = 0; - cc_uint32 magic = 0; - cc_uint32 msg_len; - cc_int32 code; - - if (msg == NULL || flatpp == NULL) - return ccErrBadParam; - - code = cci_msg_calc_size(msg,&msg->flat_len); - if ( code != ccNoError ) - return code; - - if (msg->flat_len > CC_MSG_MAX_SIZE) - return ccErrBadParam; - - msg->flat = (void *)malloc(msg->flat_len); - if (msg->flat == NULL) - return ccErrNoMem; - - cur_pos = msg->flat; - - memcpy(cur_pos,&msg->header_len,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos,&msg->flat_len,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos,&msg->type,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos, msg->header, msg->header_len); - cur_pos += msg->header_len; - - memcpy(cur_pos, &zero, sizeof(cc_uint32)); /*will be magic number later*/ - cur_pos += sizeof(cc_uint32); - - code = cci_generic_list_iterator(msg->data_blobs,&gen_iterator); - if ( code != ccNoError ) { - free(msg->flat); - return code; - } - - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (code != ccNoError) { - free(gen_iterator); - free(msg->flat); - return code; - } - memcpy(cur_pos, &gen_node->len, sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos, gen_node->data, gen_node->len); - cur_pos += gen_node->len; - } - free(gen_iterator); - - memcpy(cur_pos, &zero, sizeof(cc_uint32)); /*magic number will go here later*/ - cur_pos += sizeof(cc_uint32); - - if (cur_pos - (char *)msg->flat != msg->flat_len) { - printf("ERRORR cur_pos - msg->flat = %d\n",msg->flat_len); - } - - cci_msg_calc_magic(msg->flat, msg->flat_len, &magic); - printf("magic = %d\n",magic); - - cci_msg_calc_header_size(msg, &msg_len); - memcpy((char *)msg->flat + msg_len, &magic, sizeof(cc_uint32)); - memcpy((char *)msg->flat + msg->flat_len - sizeof(cc_uint32), &magic, sizeof(cc_uint32)); - - if ( flatpp != NULL ) - *flatpp = msg->flat; - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * magicp) -{ - cc_uint32 magic = 0; - int i; - - for (i = 0; i < flat_len; i += sizeof(cc_uint32)) { - magic = magic ^ *(int *)((char *)flat + i); - } - *magicp = magic; - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_verify(void *flat, int flat_len, cc_uint32 * validp) -{ - cc_uint32 *magic1, *magic2; - cc_uint32 *pheader_len; - cc_uint32 *ptotal_len; - cc_uint32 *pblob_len; - cc_uint32 *ptype; - cc_uint32 num_blobs = 0; - cc_uint32 zero = 0; - cc_uint32 msg_magic, msg_magic2; - - if (flat == NULL || flat_len <= 0 || validp == NULL) - return ccErrBadParam; - - pheader_len = flat; - ptotal_len = (cc_uint32 *)((char *)pheader_len + sizeof(cc_uint32)); - ptype = (cc_uint32 *)((char *)ptotal_len + sizeof(cc_uint32)); - - if (*ptotal_len != flat_len) { - *validp = 0; - return ccNoError; - } - - if (*pheader_len > flat_len) { - /*too weak. We could verify header_len against type spec header.*/ - *validp = 0; - return ccNoError; - } - if (*ptype > CC_MSG_MAX_TYPE) { - *validp = 0; - return ccNoError; - } - - magic1 = (cc_uint32 *)((char *)ptype + sizeof(cc_uint32) + *pheader_len); - if ((char *)magic1 - (char *)flat == (flat_len - 8)) { - /*There are no data blobs*/ - magic2 = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); - num_blobs = 0; - } else { - pblob_len = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); - num_blobs = 1; - - while (*pblob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) < (flat_len - sizeof(cc_uint32))) { - pblob_len = (cc_uint32 *)((char *)pblob_len + *pblob_len + sizeof(cc_uint32)); - num_blobs++; - } - - if (*pblob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) != (flat_len - sizeof(cc_uint32))) { - /*blobs didn't line up*/ - *validp = 0; - return ccNoError; - } - magic2 = (cc_uint32 *)((char *)pblob_len + *pblob_len + sizeof(cc_uint32)); /*2nd magic should be directly after the last blob*/ - } - - if (*magic1 != *magic2) { - *validp = 0; - return ccNoError; - } - msg_magic = *magic1; - - printf("%d %d\n", (char *)magic1 - (char *)flat, (char *)magic2 - (char *)flat); - - memcpy(magic1, &zero, sizeof(cc_uint32)); - memcpy(magic2, &zero, sizeof(cc_uint32)); - cci_msg_calc_magic(flat, flat_len, &msg_magic2); - if (msg_magic != msg_magic2) { - *validp = 0; - return ccNoError; - } - memcpy(magic1, &msg_magic, sizeof(cc_uint32)); - memcpy(magic2, &msg_magic, sizeof(cc_uint32)); - - *validp = 1; - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp) -{ - cc_msg_t* msg; - char *cur_pos; - cc_uint32 blob_len; - char *blob; - cc_uint32 valid; - cc_int32 code; - - if ( flat == NULL || flat_len <= 0 || msgpp == NULL ) - return ccErrBadParam; - - code = cci_msg_new(0, &msg); - if (code) - return code; - - cci_msg_verify(flat, flat_len, &valid); - if (valid != 1) { - cci_msg_destroy(msg); - return ccErrBadParam; - } - - cur_pos = flat; - msg->flat = flat; - - msg->header_len = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - msg->flat_len = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - msg->type = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - msg->header = (void *)malloc(msg->header_len); - if (msg->header == NULL) { - cci_msg_destroy(msg); - return ccErrNoMem; - } - memcpy(msg->header, cur_pos, msg->header_len); - cur_pos += msg->header_len; - - msg->magic = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - if (cur_pos - (char *)flat != flat_len - 8) { /*at least 1 blob*/ - blob_len = *(cc_uint32 *)cur_pos; - while (blob_len + (cur_pos - (char *)flat) + sizeof(cc_uint32) <= flat_len - sizeof(cc_uint32)) { - blob = (void *)malloc(blob_len); - if (blob == NULL) { - cci_msg_destroy(msg); - return ccErrNoMem; - } - memcpy(blob, cur_pos + sizeof(cc_uint32), blob_len); - cci_generic_list_append(msg->data_blobs, blob, blob_len, NULL); - - cur_pos += sizeof(cc_uint32) + blob_len; - blob_len = *(int *)cur_pos; - } - } - *msgpp = msg; - return ccNoError; -} - -cc_int32 -cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **blobp) -{ - cc_generic_iterate_t* gen_iterator; - cc_generic_list_node_t* gen_node; - void *ret; - cc_uint32 blob_pos; - cc_int32 code; - - /*Ensure that the message has been unflattened*/ - if ( msg == NULL || msg->flat == NULL || blob_offset > msg->flat_len || - blob_len > msg->flat_len - blob_offset || blobp == NULL) - return ccErrBadParam; - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - code = cci_msg_calc_blob_pos(msg, gen_node->data, gen_node->len, &blob_pos); - if (blob_pos == blob_offset && gen_node->len == blob_len) { - free(gen_iterator); - ret = (void *)malloc(blob_len); - if (ret == NULL) - return ccErrNoMem; - memcpy(ret,(char *)msg->flat + blob_offset, blob_len); - *blobp = ret; - return ccNoError; - } - } - free(gen_iterator); - return ccIteratorEnd; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_destroy(cc_msg_t* msg) -{ - if (msg->flat != NULL) - free(msg->flat); - if (msg->header != NULL) - free(msg->flat); - cci_generic_list_destroy(msg->data_blobs); - free(msg); - return ccNoError; -} - diff --git a/src/lib/ccapi/server/NTMakefile b/src/lib/ccapi/server/NTMakefile index 671b6905f..b221bcb94 100644 --- a/src/lib/ccapi/server/NTMakefile +++ b/src/lib/ccapi/server/NTMakefile @@ -4,23 +4,11 @@ CFLAGS = -I../include -CCAPI_LIB = ../lib/ccapi.lib +CCAPI_LIB = ../client/ccapi.lib WINLIBS = user32.lib advapi32.lib -CCSOBJS = context.obj ccache.obj lists.obj rpc_auth.obj serv_ops.obj +CCSOBJS = ccs_context.obj ccs_ccache.obj ccs_lists.obj rpc_auth.obj serv_ops.obj -all: t_lists.exe t_msg.exe t_ccache.exe t_context.exe ccapi_server.exe - -t_lists.exe: t_lists.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_lists.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) - -t_msg.exe: t_msg.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_msg.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) - -t_ccache.exe: t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) - -t_context.exe: t_context.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_context.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +all: ccapi_server.exe ccapi_server.exe: main.obj $(CCSOBJS) $(CCAPI_LIB) link -out:$@ main.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) diff --git a/src/lib/ccapi/server/ccache.c b/src/lib/ccapi/server/ccache.c deleted file mode 100644 index 2c3a745af..000000000 --- a/src/lib/ccapi/server/ccache.c +++ /dev/null @@ -1,703 +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). - * $ - */ - -/* - * Manages ccache objects. - * - */ - -#include -#include -#include -#include -#include "CredentialsCache.h" -#include "datastore.h" - -/** - * ccache_new() - * - * Purpose: Allocate and initialize new credentials cache for the specified principal - * and version - * - * Return: ccNoError - success - * ccErrInvalidString - name or principal is NULL - * ccErrBadCredentialsVersion - unsupported creds type - * ccErrBadParam - outCcachepp is NULL - * ccErrNoMem - malloc failed - */ -cc_int32 -cci_ccache_new( char *name, char *principal, int cred_vers, - cc_server_ccache_t** outCCachepp) -{ - cc_server_ccache_t* ccache; - - if (name == NULL || principal == NULL) - return ccErrInvalidString; - - if (cred_vers != cc_credentials_v4 && cred_vers != cc_credentials_v5 && - cred_vers != cc_credentials_v4_v5) - return ccErrBadCredentialsVersion; - - if (outCCachepp == NULL) - return ccErrBadParam; - - ccache = (cc_server_ccache_t*)malloc(sizeof(cc_server_ccache_t)); - if (ccache == NULL) - return ccErrNoMem; - - ccache->name = name; - ccache->principal_v4 = NULL; - ccache->principal_v5 = NULL; - ccache->changed = time(NULL); - ccache->kdc_offset = 0; - ccache->last_default = 0; - cci_generic_list_new(&ccache->active_iterators); - cci_credentials_list_new(&ccache->creds); - ccache->is_default = 0; - ccache->kdc_set = 0; - ccache->versions = cred_vers; - ccache->mycontext = NULL; - - cci_ccache_set_principal(ccache, cred_vers, principal); - *outCCachepp = ccache; - return ccNoError; -} - -/** - * cci_ccache_check_version() - * - * Purpose: Check to see if the ccache and the creds have compatible versions. - * - * Return: ccNoError and compat = 1 if they are compatible - * ccNoError and compat = 0 if they are not compatible - * - * Errors: ccErrInvalidCCache - ccache is NULL - * ccErrBadParam - either creds or compat are NULL - */ -cc_int32 -cci_ccache_check_version( const cc_server_ccache_t *ccache, - const cc_credentials_union* creds, - cc_uint32* compat) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - if (creds == NULL || compat == NULL) - return ccErrBadParam; - - if (ccache->versions == cc_credentials_v4_v5) - *compat = 1; - else if (ccache->versions == creds->version) - *compat = 1; - else - *compat = 0; - - return ccNoError; -} - -/** -cci_ccache_check_principal() - -Check to see if the client principal from the credentials matches -the principal associated with the cache. - -* Return: ccNoError and compat = 1 if they are compatible -* ccNoError and compat = 0 if they are not compatible -* -* Errors: ccErrInvalidCCache - ccache is NULL -* ccErrBadParam - either creds or compat are NULL -* ccErrBadCredentialVersion - unsupported credential type -*/ -cc_int32 -cci_ccache_check_principal( const cc_server_ccache_t *ccache, - const cc_credentials_union* creds, - cc_uint32* compat) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - if (creds == NULL || compat == NULL) - return ccErrBadParam; - - if (creds->version == cc_credentials_v4) { - if (strcmp(creds->credentials.credentials_v4->principal, ccache->principal_v4) == 0) - *compat = 1; - else - *compat = 0; - } else if (creds->version == cc_credentials_v5) { - if (strcmp(creds->credentials.credentials_v5->client, ccache->principal_v5) == 0) - *compat = 1; - else - *compat = 0; - } else { - return ccErrBadCredentialsVersion; - } - return ccNoError; -} - - -/** - * cci_ccache_store_creds() - * - * Purpose: Stores the provided credentials into the provided cache. Validates the - * ability of the cache to store credentials of the given version and client - * principal. - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrNoMem - * ccErrBadCredentialsVersion - * ccErrBadInvalidCredentials - * ccErrInvalidCache - * ccErrBadParam - */ -cc_int32 -cci_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) -{ - cc_server_credentials_t* stored_cred=NULL; - cc_uint32 valid_version, valid_principal; - cc_int32 code; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (credentials == NULL) - return ccErrBadParam; - - code = cci_ccache_check_version(ccache, credentials, &valid_version); - if (code != ccNoError) { - /* pass error on to caller */ - goto bad; - } - code = cci_ccache_check_principal(ccache, credentials, &valid_principal); - if (code != ccNoError) { - /* pass error on to caller */ - goto bad; - } - if (valid_version && valid_principal) { - stored_cred = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t)); - if (stored_cred == NULL) { - code = ccErrNoMem; - goto bad; - } - memcpy(&stored_cred->creds, credentials, sizeof(cc_credentials_union)); - - if (credentials->version == cc_credentials_v4) { - stored_cred->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); - if (stored_cred->creds.credentials.credentials_v4 == NULL) { - code = ccErrNoMem; - goto bad; - } - - memcpy(stored_cred->creds.credentials.credentials_v4, credentials->credentials.credentials_v4, sizeof(cc_credentials_v4_t)); - } else if (credentials->version == cc_credentials_v5) { - stored_cred->creds.credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t)); - if (stored_cred->creds.credentials.credentials_v5 == NULL) { - code = ccErrNoMem; - goto bad; - } - - memcpy(stored_cred->creds.credentials.credentials_v5, credentials->credentials.credentials_v5, sizeof(cc_credentials_v5_t)); - } else { - code = ccErrBadCredentialsVersion; - goto bad; - } - - code = cci_credentials_list_append(ccache->creds, stored_cred, NULL); - if ( code != ccNoError ) { - /* pass error on to caller */ - goto bad; - } - if (ccache->creds->head->data == (cc_uint8 *)stored_cred) - stored_cred->is_default = 1; /*we're first on the list, so we're default*/ - - cci_ccache_changed(ccache); - return ccNoError; - } else { -#ifdef DEBUG - printf("vers: %d\tprincipal: %d\n", - valid_version, valid_principal); -#endif /* DEBUG */ - code = ccErrInvalidCredentials; - goto bad; - } - - bad: - if (stored_cred) - free(stored_cred); - return code; /* error */ -} - -/** - * cci_ccache_changed() - * - * Purpose: Updates the last update time for the ccache and its associated context. - * Provides a location from which interested parties should be notified - * of cache updates. - * - * Return: none - * - * Errors: none - */ -void -cci_ccache_changed(cc_server_ccache_t* ccache) -{ - ccache->changed = time(NULL); - if (ccache->mycontext != NULL) - ccache->mycontext->changed = time(NULL); - - /* XXX - notify registered listeners when implemented */ -} - -/** - * cci_ccache_rem_creds() - * - * Purpose: Removes the specified credential object from the specified cache if - * it exists - * - * Return: 0 on success (credential is not in the cache) - * -1 on error - * - * Errors: ccErrBadParam, ccErrNoMem (from cc_credentials_list_iterator) - * - * Verify: does the memory associated with stored_cred->creds need to be freed? - * - */ -cc_int32 -cci_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) -{ - cc_credentials_iterate_t* credentials_iterator=NULL, *active; - cc_generic_iterate_t* generic_iterator=NULL; - cc_credentials_list_node_t* credentials_node; - cc_generic_list_node_t* generic_node; - cc_server_credentials_t* stored_cred; - cc_int8 changed = 0; - cc_int32 code = 0; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (credentials == NULL) - return ccErrBadParam; - - code = cci_credentials_list_iterator(ccache->creds, &credentials_iterator); - if (code != ccNoError) { - /* pass error to caller */ - goto cleanup; - } - - while (cci_credentials_iterate_has_next(credentials_iterator)) { - code = cci_credentials_iterate_next(credentials_iterator, &credentials_node); - stored_cred = (cc_server_credentials_t*)credentials_node->data; - if (memcmp(&stored_cred->creds,credentials,sizeof(cc_credentials_union)) == 0) { - /* XXX - do we need to free(stored_cred->creds) ? */ - free(credentials_node->data); - changed = 1; - - /*If any iterator's next points to the deleted node, make it point to the next node*/ - code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); - while (cci_generic_iterate_has_next(generic_iterator)) { - code = cci_generic_iterate_next(generic_iterator, &generic_node); - active = (cc_credentials_iterate_t*)generic_node->data; - if (active->next == credentials_node) - active->next = active->next->next; - } - code = cci_generic_free_iterator(generic_iterator); - generic_iterator = NULL; - - if (credentials_node == ccache->creds->head) { /*removing the default, must make next cred default*/ - code = cci_credentials_list_remove_element(ccache->creds, credentials_node); - - if (ccache->creds->head != NULL) - ((cc_server_credentials_t*)ccache->creds->head->data)->is_default = 1; - } else { - code = cci_credentials_list_remove_element(ccache->creds, credentials_node); - } - break; - } - } - - cleanup: - if (changed) - cci_ccache_changed(ccache); - if (credentials_iterator) - cci_credentials_free_iterator(credentials_iterator); - if (generic_iterator) - cci_generic_free_iterator(generic_iterator); - return code; -} - -/** - * cci_ccache_move() - * - * Purpose: Destroys the existing contents of the destination and copies - * all credentials from the source to the destination - * - * Return: 0 on success - * -1 on error - * - * Errors: ccBadNoMem - * - */ - -cc_int32 -cci_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination) -{ - cc_generic_list_node_t* node; - cc_generic_iterate_t* iterator; - cc_credentials_iterate_t* cur; - cc_int32 code; - - if (source == NULL || destination == NULL) - return ccErrBadParam; - - code = cci_credentials_list_destroy(destination->creds); - if ( code != ccNoError ) - return code; - - code = cci_credentials_list_copy(source->creds, &destination->creds); - if ( code != ccNoError ) - return code; - - destination->versions = source->versions; - destination->kdc_offset = source->kdc_offset; - destination->last_default = 0; - - /*reset all active iterators to point to the head of the new creds list*/ - if (destination->active_iterators->head != NULL) { - code = cci_generic_list_iterator(destination->active_iterators, &iterator); - while (cci_generic_iterate_has_next(iterator)) { - code = cci_generic_iterate_next(iterator, &node); - cur = (cc_credentials_iterate_t*)node->data; - cur->next = destination->creds->head; - } - code = cci_generic_free_iterator(iterator); - } - - cci_ccache_changed(destination); - return code; -} - -/** - * cci_ccache_get_kdc_time_offset() - * - * Purpose: Retrieves the kdc_time_offset from the ccache if set - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam, ccErrTimeOffsetNotSet - * - */ -cc_int32 -cci_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t* offset) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - if (offset == NULL) - return ccErrBadParam; - - if (!ccache->kdc_set) - return ccErrTimeOffsetNotSet; - - *offset = ccache->kdc_offset; - return ccNoError; -} - -/** - * cci_ccache_set_kdc_time_offset() - * - * Purpose: Sets the kdc time offset in the designated ccache - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t offset) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - ccache->kdc_offset = offset; - ccache->kdc_set = 1; - cci_ccache_changed(ccache); - - return ccNoError; -} - -/** - * cci_ccache_clear_kdc_time_offset() - * - * Purpose: Clear the kdc time offset in the designated ccache - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - ccache->kdc_offset = 0; - ccache->kdc_set = 0; - cci_ccache_changed(ccache); - - return ccNoError; -} - -/** - * cci_ccache_new_iterator() - * - * Purpose: Retrieve an iterator for the designated cache - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam, ccBadNoMem - */ -cc_int32 -cci_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator) -{ - cc_int32 code; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (iterator == NULL) - return ccErrBadParam; - - code = cci_credentials_list_iterator(ccache->creds, iterator); - if (code != ccNoError) - return code; - - code = cci_generic_list_prepend(ccache->active_iterators, *iterator, sizeof(cc_credentials_iterate_t), NULL); - if (code != ccNoError) - return code; - - return ccNoError; -} - -/** - * cci_ccache_get_principal() - * - * Purpose: Retrieves the client principal associated with the designated cache. - * The value is returned - * Return: - * - * Errors: - */ -cc_int32 -cci_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal) -{ - char *p = NULL; - - switch ( version ) { - case cc_credentials_v4: - p = ccache->principal_v4; - break; - case cc_credentials_v5: - p = ccache->principal_v5; - break; - default: - return ccErrBadCredentialsVersion; - } - - *principal = (char *)malloc(strlen(p)+1); - if ( *principal == NULL ) - return ccErrNoMem; - - strcpy(*principal, p); - return ccNoError; -} - -/** - * Purpose: Releases the memory associated with a ccache principal - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_ccache_free_principal(char * principal) -{ - if ( principal == NULL ) - return ccErrBadParam; - - free(principal); - return ccNoError; -} - -/** - * ccache_set_principal() - * - * Purpose: Assigns a principal to the designated ccache and credential version. - * If the api version is 2, the cache is cleared of all existing - * credentials. - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrNoMem, ccErrBadCredentialsVersion - */ -cc_int32 -cci_ccache_set_principal( cc_server_ccache_t* ccache, cc_int32 cred_version, - char* principal) -{ - cc_generic_iterate_t* generic_iterator; - cc_generic_list_node_t* generic_node; - cc_ccache_iterate_t* ccache_iterator; - cc_int32 code = ccNoError; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (principal == NULL) - return ccErrInvalidString; - - switch (cred_version) { - case cc_credentials_v4: - case cc_credentials_v4_v5: - ccache->principal_v4 = (char *)malloc(strlen(principal) + 1); - if (ccache->principal_v4 == NULL) - return ccErrNoMem; - strcpy(ccache->principal_v4, principal); - if (cred_version != cc_credentials_v4_v5) - break; - /* fall-through if we are v4_v5 */ - case cc_credentials_v5: - ccache->principal_v5 = (char *)malloc(strlen(principal) + 1); - if (ccache->principal_v5 == NULL) { - if (cred_version == cc_credentials_v4_v5) { - free(ccache->principal_v4); - ccache->principal_v4 = NULL; - } - return ccErrNoMem; - } - strcpy(ccache->principal_v5, principal); - break; - default: - return ccErrBadCredentialsVersion; - } - - /*For API version 2 clients set_principal implies a flush of all creds*/ - if (ccache->mycontext != NULL && ccache->mycontext->api_version == ccapi_version_2) { - cci_credentials_list_destroy(ccache->creds); - cci_credentials_list_new(&ccache->creds); - - /*clean up active_iterators*/ - code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); - if (code == ccNoError) { - while (cci_generic_iterate_has_next(generic_iterator)) { - code = cci_generic_iterate_next(generic_iterator, &generic_node); - ccache_iterator = (cc_ccache_iterate_t*)generic_node->data; - ccache_iterator->next = NULL; - } - } - } - - cci_ccache_changed(ccache); - - return code; -} - -/** - * cci_ccache_destroy() - * - * Purpose: Destroys an existing ccache - * - * Return: 0 on success - * -1 on errors - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_ccache_destroy(cc_server_ccache_t* ccache) -{ - cc_int32 code; - - if ( ccache == NULL ) - return ccErrInvalidCCache; - - code = cci_generic_list_destroy(ccache->active_iterators); - code = cci_credentials_list_destroy(ccache->creds); - - if (ccache->mycontext != NULL) - code = cci_context_rem_ccache(ccache->mycontext, ccache); - - return code; -} - -/** - * cci_ccache_compare() - * - * Purpose: Returns a boolean value indicating if two caches are identical - * Implemented as pointer equivalence. - * - * Return: 1 if TRUE - * 0 if FALSE - * - * Errors: No errors - */ -cc_int32 -cci_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result) -{ - if ( ccache1 == NULL || ccache2 == NULL ) - return ccErrInvalidCCache; - - if (ccache1 == ccache2) - *result = 1; - else - *result = 0; - - return ccNoError; -} - diff --git a/src/lib/ccapi/server/ccs_ccache.c b/src/lib/ccapi/server/ccs_ccache.c new file mode 100644 index 000000000..d632ee349 --- /dev/null +++ b/src/lib/ccapi/server/ccs_ccache.c @@ -0,0 +1,703 @@ +/* $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). + * $ + */ + +/* + * Manages ccache objects. + * + */ + +#include +#include +#include +#include +#include "CredentialsCache.h" +#include "datastore.h" + +/** + * ccache_new() + * + * Purpose: Allocate and initialize new credentials cache for the specified principal + * and version + * + * Return: ccNoError - success + * ccErrInvalidString - name or principal is NULL + * ccErrBadCredentialsVersion - unsupported creds type + * ccErrBadParam - outCcachepp is NULL + * ccErrNoMem - malloc failed + */ +cc_int32 +ccs_ccache_new( char *name, char *principal, int cred_vers, + cc_server_ccache_t** outCCachepp) +{ + cc_server_ccache_t* ccache; + + if (name == NULL || principal == NULL) + return ccErrInvalidString; + + if (cred_vers != cc_credentials_v4 && cred_vers != cc_credentials_v5 && + cred_vers != cc_credentials_v4_v5) + return ccErrBadCredentialsVersion; + + if (outCCachepp == NULL) + return ccErrBadParam; + + ccache = (cc_server_ccache_t*)malloc(sizeof(cc_server_ccache_t)); + if (ccache == NULL) + return ccErrNoMem; + + ccache->name = name; + ccache->principal_v4 = NULL; + ccache->principal_v5 = NULL; + ccache->changed = time(NULL); + ccache->kdc_offset = 0; + ccache->last_default = 0; + cci_generic_list_new(&ccache->active_iterators); + ccs_credentials_list_new(&ccache->creds); + ccache->is_default = 0; + ccache->kdc_set = 0; + ccache->versions = cred_vers; + ccache->mycontext = NULL; + + ccs_ccache_set_principal(ccache, cred_vers, principal); + *outCCachepp = ccache; + return ccNoError; +} + +/** + * ccs_ccache_check_version() + * + * Purpose: Check to see if the ccache and the creds have compatible versions. + * + * Return: ccNoError and compat = 1 if they are compatible + * ccNoError and compat = 0 if they are not compatible + * + * Errors: ccErrInvalidCCache - ccache is NULL + * ccErrBadParam - either creds or compat are NULL + */ +cc_int32 +ccs_ccache_check_version( const cc_server_ccache_t *ccache, + const cc_credentials_union* creds, + cc_uint32* compat) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + if (creds == NULL || compat == NULL) + return ccErrBadParam; + + if (ccache->versions == cc_credentials_v4_v5) + *compat = 1; + else if (ccache->versions == creds->version) + *compat = 1; + else + *compat = 0; + + return ccNoError; +} + +/** +ccs_ccache_check_principal() + +Check to see if the client principal from the credentials matches +the principal associated with the cache. + +* Return: ccNoError and compat = 1 if they are compatible +* ccNoError and compat = 0 if they are not compatible +* +* Errors: ccErrInvalidCCache - ccache is NULL +* ccErrBadParam - either creds or compat are NULL +* ccErrBadCredentialVersion - unsupported credential type +*/ +cc_int32 +ccs_ccache_check_principal( const cc_server_ccache_t *ccache, + const cc_credentials_union* creds, + cc_uint32* compat) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + if (creds == NULL || compat == NULL) + return ccErrBadParam; + + if (creds->version == cc_credentials_v4) { + if (strcmp(creds->credentials.credentials_v4->principal, ccache->principal_v4) == 0) + *compat = 1; + else + *compat = 0; + } else if (creds->version == cc_credentials_v5) { + if (strcmp(creds->credentials.credentials_v5->client, ccache->principal_v5) == 0) + *compat = 1; + else + *compat = 0; + } else { + return ccErrBadCredentialsVersion; + } + return ccNoError; +} + + +/** + * ccs_ccache_store_creds() + * + * Purpose: Stores the provided credentials into the provided cache. Validates the + * ability of the cache to store credentials of the given version and client + * principal. + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrNoMem + * ccErrBadCredentialsVersion + * ccErrBadInvalidCredentials + * ccErrInvalidCache + * ccErrBadParam + */ +cc_int32 +ccs_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) +{ + cc_server_credentials_t* stored_cred=NULL; + cc_uint32 valid_version, valid_principal; + cc_int32 code; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (credentials == NULL) + return ccErrBadParam; + + code = ccs_ccache_check_version(ccache, credentials, &valid_version); + if (code != ccNoError) { + /* pass error on to caller */ + goto bad; + } + code = ccs_ccache_check_principal(ccache, credentials, &valid_principal); + if (code != ccNoError) { + /* pass error on to caller */ + goto bad; + } + if (valid_version && valid_principal) { + stored_cred = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t)); + if (stored_cred == NULL) { + code = ccErrNoMem; + goto bad; + } + memcpy(&stored_cred->creds, credentials, sizeof(cc_credentials_union)); + + if (credentials->version == cc_credentials_v4) { + stored_cred->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); + if (stored_cred->creds.credentials.credentials_v4 == NULL) { + code = ccErrNoMem; + goto bad; + } + + memcpy(stored_cred->creds.credentials.credentials_v4, credentials->credentials.credentials_v4, sizeof(cc_credentials_v4_t)); + } else if (credentials->version == cc_credentials_v5) { + stored_cred->creds.credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t)); + if (stored_cred->creds.credentials.credentials_v5 == NULL) { + code = ccErrNoMem; + goto bad; + } + + memcpy(stored_cred->creds.credentials.credentials_v5, credentials->credentials.credentials_v5, sizeof(cc_credentials_v5_t)); + } else { + code = ccErrBadCredentialsVersion; + goto bad; + } + + code = ccs_credentials_list_append(ccache->creds, stored_cred, NULL); + if ( code != ccNoError ) { + /* pass error on to caller */ + goto bad; + } + if (ccache->creds->head->data == (cc_uint8 *)stored_cred) + stored_cred->is_default = 1; /*we're first on the list, so we're default*/ + + ccs_ccache_changed(ccache); + return ccNoError; + } else { +#ifdef DEBUG + printf("vers: %d\tprincipal: %d\n", + valid_version, valid_principal); +#endif /* DEBUG */ + code = ccErrInvalidCredentials; + goto bad; + } + + bad: + if (stored_cred) + free(stored_cred); + return code; /* error */ +} + +/** + * ccs_ccache_changed() + * + * Purpose: Updates the last update time for the ccache and its associated context. + * Provides a location from which interested parties should be notified + * of cache updates. + * + * Return: none + * + * Errors: none + */ +void +ccs_ccache_changed(cc_server_ccache_t* ccache) +{ + ccache->changed = time(NULL); + if (ccache->mycontext != NULL) + ccache->mycontext->changed = time(NULL); + + /* XXX - notify registered listeners when implemented */ +} + +/** + * ccs_ccache_rem_creds() + * + * Purpose: Removes the specified credential object from the specified cache if + * it exists + * + * Return: 0 on success (credential is not in the cache) + * -1 on error + * + * Errors: ccErrBadParam, ccErrNoMem (from cc_credentials_list_iterator) + * + * Verify: does the memory associated with stored_cred->creds need to be freed? + * + */ +cc_int32 +ccs_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) +{ + cc_credentials_iterate_t* credentials_iterator=NULL, *active; + cc_generic_iterate_t* generic_iterator=NULL; + cc_credentials_list_node_t* credentials_node; + cc_generic_list_node_t* generic_node; + cc_server_credentials_t* stored_cred; + cc_int8 changed = 0; + cc_int32 code = 0; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (credentials == NULL) + return ccErrBadParam; + + code = ccs_credentials_list_iterator(ccache->creds, &credentials_iterator); + if (code != ccNoError) { + /* pass error to caller */ + goto cleanup; + } + + while (ccs_credentials_iterate_has_next(credentials_iterator)) { + code = ccs_credentials_iterate_next(credentials_iterator, &credentials_node); + stored_cred = (cc_server_credentials_t*)credentials_node->data; + if (memcmp(&stored_cred->creds,credentials,sizeof(cc_credentials_union)) == 0) { + /* XXX - do we need to free(stored_cred->creds) ? */ + free(credentials_node->data); + changed = 1; + + /*If any iterator's next points to the deleted node, make it point to the next node*/ + code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); + while (cci_generic_iterate_has_next(generic_iterator)) { + code = cci_generic_iterate_next(generic_iterator, &generic_node); + active = (cc_credentials_iterate_t*)generic_node->data; + if (active->next == credentials_node) + active->next = active->next->next; + } + code = cci_generic_free_iterator(generic_iterator); + generic_iterator = NULL; + + if (credentials_node == ccache->creds->head) { /*removing the default, must make next cred default*/ + code = ccs_credentials_list_remove_element(ccache->creds, credentials_node); + + if (ccache->creds->head != NULL) + ((cc_server_credentials_t*)ccache->creds->head->data)->is_default = 1; + } else { + code = ccs_credentials_list_remove_element(ccache->creds, credentials_node); + } + break; + } + } + + cleanup: + if (changed) + ccs_ccache_changed(ccache); + if (credentials_iterator) + ccs_credentials_free_iterator(credentials_iterator); + if (generic_iterator) + cci_generic_free_iterator(generic_iterator); + return code; +} + +/** + * ccs_ccache_move() + * + * Purpose: Destroys the existing contents of the destination and copies + * all credentials from the source to the destination + * + * Return: 0 on success + * -1 on error + * + * Errors: ccBadNoMem + * + */ + +cc_int32 +ccs_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination) +{ + cc_generic_list_node_t* node; + cc_generic_iterate_t* iterator; + cc_credentials_iterate_t* cur; + cc_int32 code; + + if (source == NULL || destination == NULL) + return ccErrBadParam; + + code = ccs_credentials_list_destroy(destination->creds); + if ( code != ccNoError ) + return code; + + code = ccs_credentials_list_copy(source->creds, &destination->creds); + if ( code != ccNoError ) + return code; + + destination->versions = source->versions; + destination->kdc_offset = source->kdc_offset; + destination->last_default = 0; + + /*reset all active iterators to point to the head of the new creds list*/ + if (destination->active_iterators->head != NULL) { + code = cci_generic_list_iterator(destination->active_iterators, &iterator); + while (cci_generic_iterate_has_next(iterator)) { + code = cci_generic_iterate_next(iterator, &node); + cur = (cc_credentials_iterate_t*)node->data; + cur->next = destination->creds->head; + } + code = cci_generic_free_iterator(iterator); + } + + ccs_ccache_changed(destination); + return code; +} + +/** + * ccs_ccache_get_kdc_time_offset() + * + * Purpose: Retrieves the kdc_time_offset from the ccache if set + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam, ccErrTimeOffsetNotSet + * + */ +cc_int32 +ccs_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64* offset) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + if (offset == NULL) + return ccErrBadParam; + + if (!ccache->kdc_set) + return ccErrTimeOffsetNotSet; + + *offset = ccache->kdc_offset; + return ccNoError; +} + +/** + * ccs_ccache_set_kdc_time_offset() + * + * Purpose: Sets the kdc time offset in the designated ccache + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64 offset) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + ccache->kdc_offset = offset; + ccache->kdc_set = 1; + ccs_ccache_changed(ccache); + + return ccNoError; +} + +/** + * ccs_ccache_clear_kdc_time_offset() + * + * Purpose: Clear the kdc time offset in the designated ccache + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + ccache->kdc_offset = 0; + ccache->kdc_set = 0; + ccs_ccache_changed(ccache); + + return ccNoError; +} + +/** + * ccs_ccache_new_iterator() + * + * Purpose: Retrieve an iterator for the designated cache + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam, ccBadNoMem + */ +cc_int32 +ccs_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator) +{ + cc_int32 code; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (iterator == NULL) + return ccErrBadParam; + + code = ccs_credentials_list_iterator(ccache->creds, iterator); + if (code != ccNoError) + return code; + + code = cci_generic_list_prepend(ccache->active_iterators, *iterator, sizeof(cc_credentials_iterate_t), NULL); + if (code != ccNoError) + return code; + + return ccNoError; +} + +/** + * ccs_ccache_get_principal() + * + * Purpose: Retrieves the client principal associated with the designated cache. + * The value is returned + * Return: + * + * Errors: + */ +cc_int32 +ccs_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal) +{ + char *p = NULL; + + switch ( version ) { + case cc_credentials_v4: + p = ccache->principal_v4; + break; + case cc_credentials_v5: + p = ccache->principal_v5; + break; + default: + return ccErrBadCredentialsVersion; + } + + *principal = (char *)malloc(strlen(p)+1); + if ( *principal == NULL ) + return ccErrNoMem; + + strcpy(*principal, p); + return ccNoError; +} + +/** + * Purpose: Releases the memory associated with a ccache principal + * + * Return: + * + * Errors: + * + */ +cc_int32 +ccs_ccache_free_principal(char * principal) +{ + if ( principal == NULL ) + return ccErrBadParam; + + free(principal); + return ccNoError; +} + +/** + * ccache_set_principal() + * + * Purpose: Assigns a principal to the designated ccache and credential version. + * If the api version is 2, the cache is cleared of all existing + * credentials. + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrNoMem, ccErrBadCredentialsVersion + */ +cc_int32 +ccs_ccache_set_principal( cc_server_ccache_t* ccache, cc_int32 cred_version, + char* principal) +{ + cc_generic_iterate_t* generic_iterator; + cc_generic_list_node_t* generic_node; + cc_ccache_iterate_t* ccache_iterator; + cc_int32 code = ccNoError; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (principal == NULL) + return ccErrInvalidString; + + switch (cred_version) { + case cc_credentials_v4: + case cc_credentials_v4_v5: + ccache->principal_v4 = (char *)malloc(strlen(principal) + 1); + if (ccache->principal_v4 == NULL) + return ccErrNoMem; + strcpy(ccache->principal_v4, principal); + if (cred_version != cc_credentials_v4_v5) + break; + /* fall-through if we are v4_v5 */ + case cc_credentials_v5: + ccache->principal_v5 = (char *)malloc(strlen(principal) + 1); + if (ccache->principal_v5 == NULL) { + if (cred_version == cc_credentials_v4_v5) { + free(ccache->principal_v4); + ccache->principal_v4 = NULL; + } + return ccErrNoMem; + } + strcpy(ccache->principal_v5, principal); + break; + default: + return ccErrBadCredentialsVersion; + } + + /*For API version 2 clients set_principal implies a flush of all creds*/ + if (ccache->mycontext != NULL && ccache->mycontext->api_version == ccapi_version_2) { + ccs_credentials_list_destroy(ccache->creds); + ccs_credentials_list_new(&ccache->creds); + + /*clean up active_iterators*/ + code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); + if (code == ccNoError) { + while (cci_generic_iterate_has_next(generic_iterator)) { + code = cci_generic_iterate_next(generic_iterator, &generic_node); + ccache_iterator = (cc_ccache_iterate_t*)generic_node->data; + ccache_iterator->next = NULL; + } + } + } + + ccs_ccache_changed(ccache); + + return code; +} + +/** + * ccs_ccache_destroy() + * + * Purpose: Destroys an existing ccache + * + * Return: 0 on success + * -1 on errors + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_ccache_destroy(cc_server_ccache_t* ccache) +{ + cc_int32 code; + + if ( ccache == NULL ) + return ccErrInvalidCCache; + + code = cci_generic_list_destroy(ccache->active_iterators); + code = ccs_credentials_list_destroy(ccache->creds); + + if (ccache->mycontext != NULL) + code = ccs_context_rem_ccache(ccache->mycontext, ccache); + + return code; +} + +/** + * ccs_ccache_compare() + * + * Purpose: Returns a boolean value indicating if two caches are identical + * Implemented as pointer equivalence. + * + * Return: 1 if TRUE + * 0 if FALSE + * + * Errors: No errors + */ +cc_int32 +ccs_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result) +{ + if ( ccache1 == NULL || ccache2 == NULL ) + return ccErrInvalidCCache; + + if (ccache1 == ccache2) + *result = 1; + else + *result = 0; + + return ccNoError; +} + diff --git a/src/lib/ccapi/server/ccs_context.c b/src/lib/ccapi/server/ccs_context.c new file mode 100644 index 000000000..a16814794 --- /dev/null +++ b/src/lib/ccapi/server/ccs_context.c @@ -0,0 +1,325 @@ +/* $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). + * $ + */ + +/* + * Functions to manipulate datastore layer contexts. + * + */ + +#include +#include +#include +#include + +#include "CredentialsCache.h" +#include "datastore.h" + +int cc_myversion = 5; +char cc_vendor[] = "MIT C lang CCache V5"; +char cc_default_ccache_name[] = "krb5cc"; + + +cc_int32 +ccs_context_new( int api_version, cc_auth_info_t* auth_info, + cc_session_info_t* session_info, cc_server_context_t** outContextpp ) +{ + cc_server_context_t* ctx; + + if ( outContextpp == NULL ) + return ccErrBadParam; + + ctx = (cc_server_context_t*)malloc(sizeof(cc_server_context_t)); + if (ctx == NULL) + return ccErrNoMem; + + ccs_ccache_list_new(&ctx->ccaches); + cci_generic_list_new(&ctx->active_iterators); + ctx->api_version = api_version; + ctx->auth_info = auth_info; + ctx->session_info = session_info; + ctx->changed = time(NULL); + + *outContextpp = ctx; + return ccNoError; +} + +cc_int32 +ccs_context_get_default_ccache_name(cc_server_context_t* ctx, char ** outNamepp) +{ + cc_server_ccache_t* default_ccache; + + if (outNamepp == NULL) + return ccErrBadParam; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (ctx->ccaches->head != NULL) { + default_ccache = (cc_server_ccache_t*)ctx->ccaches->head->data; + *outNamepp = default_ccache->name; + } else { + *outNamepp = cc_default_ccache_name; + } + return ccNoError; +} + + +cc_int32 +ccs_context_find_ccache( cc_server_context_t* ctx, char *name, + cc_server_ccache_t** outCcachepp ) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_ccache_list_node_t* ccache_node; + cc_server_ccache_t* ccache; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (name == NULL) + return ccErrInvalidString; + + if (outCcachepp == NULL) + return ccErrBadParam; + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); + ccache = (cc_server_ccache_t *)ccache_node->data; + if (strcmp(ccache->name, name) == 0) { + free(ccache_iterator); + *outCcachepp = ccache; + return ccNoError; + } + } + free(ccache_iterator); + return ccErrCCacheNotFound; +} + +cc_int32 +ccs_context_open_ccache( cc_server_context_t* ctx, char *name, + cc_server_ccache_t** outCcachepp ) +{ + return ccs_context_find_ccache(ctx, name, outCcachepp); +} + + +cc_int32 +ccs_context_create_ccache( cc_server_context_t* ctx, char *name, int creds_version, + char *principal, cc_server_ccache_t** outCcachepp ) +{ + cc_server_ccache_t* ccache; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (outCcachepp == NULL) + return ccErrBadParam; + + if (name == NULL || principal == NULL) + return ccErrInvalidString; + + if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && + creds_version != cc_credentials_v4_v5) + return ccErrBadCredentialsVersion; + + code = ccs_context_find_ccache(ctx, name, &ccache); + if (code == ccNoError) { + code = ccs_ccache_set_principal(ccache, creds_version, principal); + } else { + code = ccs_ccache_new(name, principal, creds_version, &ccache); + if (code != ccNoError) + return code; /*let caller deal with error*/ + + ccache->mycontext = ctx; + ctx->changed = time(NULL); + ccs_ccache_list_append(ctx->ccaches, ccache, NULL); + + if (ctx->ccaches->head->data == (cc_uint8 *)ccache) { + ccache->is_default = 1; + } + } + *outCcachepp = ccache; + return ccNoError; +} + +cc_int32 +ccs_context_create_default_ccache( cc_server_context_t* ctx, int creds_version, + char *principal, cc_server_ccache_t** outCcachepp ) +{ + cc_server_ccache_t* ccache, *old_default; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (outCcachepp == NULL) + return ccErrBadParam; + + if (principal == NULL) + return ccErrInvalidString; + + if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && + creds_version != cc_credentials_v4_v5) + return ccErrBadCredentialsVersion; + + code = ccs_context_find_ccache(ctx, cc_default_ccache_name, &ccache); + if (code == ccNoError) { + ccs_ccache_set_principal(ccache, creds_version, principal); + } else { + code = ccs_ccache_new(cc_default_ccache_name, principal, creds_version, &ccache); + if (code != ccNoError) + return code; /*let caller deal with error*/ + + ccache->mycontext = ctx; + ccache->is_default = 1; + ctx->changed = time(NULL); + + if (ctx->ccaches->head != NULL) { + old_default = (cc_server_ccache_t *)ctx->ccaches->head->data; + old_default->is_default = 0; + old_default->last_default = time(NULL); + } + + ccs_ccache_list_prepend(ctx->ccaches, ccache, NULL); + } + *outCcachepp = ccache; + return ccNoError; +} + +cc_int32 +ccs_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t** iterpp) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (iterpp == NULL) + return ccErrBadParam; + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + if (code != ccNoError) + return code; + cci_generic_list_prepend(ctx->active_iterators, ccache_iterator, sizeof(cc_ccache_iterate_t), NULL); + + *iterpp = ccache_iterator; + return ccNoError; +} + +cc_int32 +ccs_context_compare(cc_server_context_t* a, cc_server_context_t* b) +{ + if (a == b) + return 1; + else + return 0; +} + +cc_int32 +ccs_context_destroy(cc_server_context_t* ctx) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_ccache_list_node_t* ccache_node; + cc_server_ccache_t* ccache; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + cci_generic_list_destroy(ctx->active_iterators); + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); + ccache = (cc_server_ccache_t *)ccache_node->data; + ccache_node->data = NULL; + ccs_ccache_destroy(ccache); + } + ccs_ccache_list_destroy(ctx->ccaches); + + return ccNoError; +} + +cc_int32 +ccs_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_ccache_iterate_t* active_ccache_iterator; + cc_ccache_list_node_t* ccache_node; + cc_server_ccache_t* list_ccache; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (ccache == NULL) + return ccErrInvalidCCache; + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); + list_ccache = (cc_server_ccache_t *)ccache_node->data; + + if (list_ccache == ccache) { + code = cci_generic_list_iterator(ctx->active_iterators, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + active_ccache_iterator = (cc_ccache_iterate_t *)gen_node->data; + if (active_ccache_iterator->next == ccache_node) { + active_ccache_iterator->next = active_ccache_iterator->next->next; + } + } + free(gen_iterator); + code = ccs_ccache_list_remove_element(ctx->ccaches, ccache_node); + break; + } + } + free(ccache_iterator); + return ccNoError; +} + diff --git a/src/lib/ccapi/server/ccs_lists.c b/src/lib/ccapi/server/ccs_lists.c new file mode 100644 index 000000000..06f8ced87 --- /dev/null +++ b/src/lib/ccapi/server/ccs_lists.c @@ -0,0 +1,996 @@ +/* $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). + * $ + */ + + +/* + * Lists implementation. + * + */ + +#include +#include +#include + +#include "CredentialsCache.h" +#include "datastore.h" + +/** + * cci_generic_iterate_has_next() + * + * Purpose: Determine if an iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + * + * Errors: None + * + */ +cc_int32 +cci_generic_iterate_has_next(cc_generic_iterate_t *iterate) +{ + return ((iterate == NULL || iterate->next == NULL) ? 0 : 1); +} + +/** + * cci_generic_iterate_next() + * + * Purpose: Retrieve the next element from an iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_iterate_next(cc_generic_iterate_t *iterator, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* ret; + + if (iterator == NULL || nodepp == NULL) + return ccErrBadParam; + + ret = iterator->next; + if (iterator->next != NULL) + iterator->next = iterator->next->next; + + *nodepp = ret; + return ccNoError; +} + +/** + * ccs_context_iterate_has_next() + * + * Purpose: Determine if a context iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + */ +cc_int32 +ccs_context_iterate_has_next(cc_context_iterate_t *iterate) +{ + if ( iterate == NULL ) + return 0; + + return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); +} + +/** + * ccs_context_iterate_next() + * + * Purpose: Retrieve the next element from a context iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_context_iterate_next(cc_context_iterate_t *iterate, cc_context_list_node_t ** nodepp) +{ + if ( iterate == NULL || nodepp == NULL) + return ccErrBadParam; + + return cci_generic_iterate_next((cc_generic_iterate_t*)iterate,(cc_context_list_node_t**)nodepp); +} + +/** + * ccs_ccache_iterate_has_next() + * + * Purpose: Determine if a cache iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + * -1 if error + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_iterate_has_next(cc_ccache_iterate_t *iterate) +{ + if ( iterate == NULL ) + return 0; + return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); +} + +/** + * ccs_ccache_iterate_next() + * + * Purpose: Retrieve the next element from a ccache iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_iterate_next(cc_ccache_iterate_t *iterate, cc_ccache_list_node_t ** nodepp) +{ + if ( iterate == NULL || nodepp == NULL) + return ccErrBadParam; + + return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_ccache_list_node_t**)nodepp); +} + +/** + * ccs_credentials_iterate_has_next() + * + * Purpose: Determine if a credentials iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + * -1 if error + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_iterate_has_next(cc_credentials_iterate_t *iterate) +{ + if ( iterate == NULL ) + return 0; + + return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); +} + +/** + * ccs_credentials_iterate_next() + * + * Purpose: Retrieve the next element from a credentials iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t** nodepp) +{ + if ( iterate == NULL || nodepp == NULL ) + return ccErrBadParam; + return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_credentials_list_node_t**)nodepp); +} + +/** + * cci_generic_list_new() + * + * Purpose: Allocate new generic list + * + * Return: non-NULL, an empty list + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_generic_list_new(cc_generic_list_head_t ** listpp) +{ + cc_generic_list_head_t* ret = (cc_generic_list_head_t *)malloc(sizeof(cc_generic_list_head_t)); + if (ret == NULL) + return ccErrNoMem; + + ret->type = generic; + ret->head = ret->tail = NULL; + *listpp = ret; + + return ccNoError; +} + +/** + * cci_generic_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* new_node; + + if ( data == NULL || len == 0 ) + return ccErrBadParam; + + new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); + if (new_node == NULL) + return ccErrNoMem; + + new_node->data = malloc(len); + if ( new_node->data == NULL ) { + free(new_node); + return ccErrNoMem; + } + + memcpy(new_node->data,data,len); + new_node->len = len; + + if (head->head == NULL) { /*empty list*/ + head->head = new_node; + head->tail = new_node; + new_node->next = new_node->prev = NULL; + } else { + new_node->prev = head->tail; + head->tail->next = new_node; + head->tail = new_node; + new_node->next = NULL; + } + if (nodepp != NULL) + *nodepp = new_node; + return ccNoError; +} + +/** + * cci_generic_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem, ccErrBadParam + * + */ +cc_int32 +cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* new_node; + + if ( data == NULL || len == 0 ) + return ccErrBadParam; + + new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); + if (new_node == NULL) + return ccErrNoMem; + + new_node->data = malloc(len); + if ( new_node->data == NULL ) { + free(new_node); + return ccErrNoMem; + } + + memcpy(new_node->data,data,len); + new_node->len = len; + + if (head->head == NULL) { /*empty list*/ + head->head = new_node; + head->tail = new_node; + new_node->prev = new_node->next = NULL; + } else { + new_node->next = head->head; + head->head->prev = new_node; + new_node->prev = NULL; + head->head = new_node; + } + + if (nodepp != NULL) + *nodepp = new_node; + + return ccNoError; +} + +/** + * cci_generic_list_remove_element() + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem) +{ + if (head->head == NULL || rem == NULL) + return ccErrBadParam; + + if (head->head == rem && head->tail == rem) { /*removing only element of list*/ + head->head = head->tail = NULL; + } else if (head->head == rem) { /*removing head*/ + head->head = head->head->next; + } else if (head->tail == rem) { /*removing tail*/ + head->tail = head->tail->prev; + head->tail->next = NULL; + } else { + rem->prev->next = rem->next; + rem->next->prev = rem->prev; + } + free(rem); + return ccNoError; +} + +/** + * cci_generic_free_element() + * + * Purpose: Free the memory associated with a node + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_free_element(cc_generic_list_node_t* node) +{ + if ( node == NULL ) + return ccErrBadParam; + + if ( node->data ) { + free(node->data); + node->data = NULL; + } + node->len = 0; + node->next = node->prev = NULL; + free(node); + return ccNoError; +} + + +/** + * cci_generic_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +cci_generic_list_destroy(cc_generic_list_head_t* head) +{ + cc_generic_list_node_t *cur, *next; + cc_int32 ret = ccNoError; + + if ( head == NULL ) + return ccErrBadParam; + + for (cur = head->head; ret == ccNoError && cur != NULL; cur = next) { + next = cur->next; + ret = cci_generic_free_element(cur); + } + free(head); + return(ret); +} + +/** + * ccs_context_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_context_list_destroy(cc_context_list_head_t* head) +{ + return cci_generic_list_destroy((cc_generic_list_head_t*)head); +} + +/** + * ccs_ccache_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_ccache_list_destroy(cc_ccache_list_head_t* head) +{ + return cci_generic_list_destroy((cc_generic_list_head_t*)head); +} + +/** + * ccs_credentials_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_credentials_list_destroy(cc_credentials_list_head_t* head) +{ + return cci_generic_list_destroy((cc_generic_list_head_t*)head); +} + +/** + * cci_generic_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + * + */ +cc_int32 +cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t** headpp) +{ + cc_generic_list_head_t* copy; + cc_generic_list_node_t *src_node, *dst_node; + cc_int32 code; + + if (head == NULL || headpp == NULL) + return ccErrBadParam; + + code = cci_generic_list_new(©); + if (code != ccNoError) + return code; + + for (src_node = head->head; src_node != NULL; src_node = src_node->next) { + code = cci_generic_list_append(copy, src_node->data, src_node->len, &dst_node); + if (code != ccNoError) { + cci_generic_list_destroy(copy); + return code; + } + } + *headpp = copy; + return ccNoError; +} + +/** + * ccs_context_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + * + */ +cc_int32 +ccs_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t** headpp ) +{ + return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_context_list_head_t **)headpp); +} + +/** + * ccs_ccache_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + */ +cc_int32 +ccs_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t** headpp) +{ + return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_ccache_list_head_t **)headpp); +} + +/** + * ccs_credentials_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + * + */ +cc_int32 +ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t** headpp) +{ + return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_credentials_list_head_t **)headpp); +} + + +/** + * cci_generic_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t** headpp) +{ + cc_generic_iterate_t* iterator; + + if ( head == NULL || headpp == NULL ) + return ccErrBadParam; + + iterator = (cc_generic_iterate_t*)malloc(sizeof(cc_generic_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *headpp = iterator; + return ccNoError; +} + +/** + * cci_generic_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_free_iterator(cc_generic_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + + +/** + * ccs_context_list_new() + * + * Purpose: Allocate a new context list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_context_list_new(cc_context_list_head_t ** headpp) +{ + cc_context_list_head_t *ret; + + if ( headpp == NULL ) + return ccErrBadParam; + + ret = (cc_context_list_head_t *)malloc(sizeof(cc_context_list_head_t)); + if (ret == NULL) + return ccErrNoMem; + ret->head = ret->tail = NULL; + *headpp = ret; + return ccNoError; +} + +/** + * ccs_context_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp) +{ + return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); +} + +/** + * ccs_context_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp ) +{ + return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); +} + +/** + * ccs_context_list_remove_element + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem) +{ + return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); +} + +/** + * ccs_context_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_context_list_iterator(cc_context_list_head_t *head, cc_context_iterate_t** iterpp) +{ + cc_context_iterate_t* iterator; + + if ( head == NULL || iterpp == NULL ) + return ccErrBadParam; + + iterator = (cc_context_iterate_t*)malloc(sizeof(cc_context_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *iterpp = iterator; + return ccNoError; +} + +/** + * ccs_context_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_context_free_iterator(cc_context_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + +/** + * ccs_ccache_list_new() + * + * Purpose: Allocate a new ccache list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrNoMem + */ +cc_int32 +ccs_ccache_list_new(cc_ccache_list_head_t ** listpp) +{ + cc_ccache_list_head_t *ret; + + if ( listpp == NULL ) + return ccErrBadParam; + + ret = (cc_ccache_list_head_t *)malloc(sizeof(cc_ccache_list_head_t)); + if (ret == NULL) + return ccErrNoMem; + + ret->head = ret->tail = NULL; + *listpp = ret; + return ccNoError; +} + +/** + * ccs_ccache_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) +{ + return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); +} + +/** + * ccs_ccache_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) +{ + return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); +} + +/** + * ccs_ccache_list_remove_element() + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem) +{ + return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); +} + +/** + * ccs_ccache_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_ccache_list_iterator(cc_ccache_list_head_t *head, cc_ccache_iterate_t** iterpp) +{ + cc_ccache_iterate_t* iterator; + + if ( head == NULL || iterpp == NULL ) + return ccErrBadParam; + + iterator = (cc_ccache_iterate_t*)malloc(sizeof(cc_ccache_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *iterpp = iterator; + return ccNoError; +} + +/** + * ccs_ccache_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_free_iterator(cc_ccache_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + +/** + * ccs_credentials_list_new() + * + * Purpose: Allocate a new ccache list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_credentials_list_new(cc_credentials_list_head_t ** list) +{ + if ( list == NULL ) + return ccErrBadParam; + + *list = (cc_credentials_list_head_t *)malloc(sizeof(cc_credentials_list_head_t)); + if (*list == NULL) + return ccErrNoMem; + + (*list)->head = (*list)->tail = NULL; + return ccNoError; +} + +/** + * ccs_credentials_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp ) +{ + return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); +} + +/** + * ccs_credentials_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp) +{ + return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); +} + +/** + * ccs_credentials_list_remove_element() + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem) +{ + return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); +} + +/** + * ccs_credentials_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t** iterpp) +{ + cc_credentials_iterate_t* iterator; + + if ( head == NULL || iterpp == NULL ) + return ccErrBadParam; + + iterator = (cc_credentials_iterate_t*)malloc(sizeof(cc_credentials_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *iterpp = iterator; + return ccNoError; +} + +/** + * ccs_credentials_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_free_iterator(cc_credentials_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + diff --git a/src/lib/ccapi/server/context.c b/src/lib/ccapi/server/context.c deleted file mode 100644 index f405a4def..000000000 --- a/src/lib/ccapi/server/context.c +++ /dev/null @@ -1,325 +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). - * $ - */ - -/* - * Functions to manipulate datastore layer contexts. - * - */ - -#include -#include -#include -#include - -#include "CredentialsCache.h" -#include "datastore.h" - -int cc_myversion = 5; -char cc_vendor[] = "MIT C lang CCache V5"; -char cc_default_ccache_name[] = "krb5cc"; - - -cc_int32 -cci_context_new( int api_version, cc_auth_info_t* auth_info, - cc_session_info_t* session_info, cc_server_context_t** outContextpp ) -{ - cc_server_context_t* ctx; - - if ( outContextpp == NULL ) - return ccErrBadParam; - - ctx = (cc_server_context_t*)malloc(sizeof(cc_server_context_t)); - if (ctx == NULL) - return ccErrNoMem; - - cci_ccache_list_new(&ctx->ccaches); - cci_generic_list_new(&ctx->active_iterators); - ctx->api_version = api_version; - ctx->auth_info = auth_info; - ctx->session_info = session_info; - ctx->changed = time(NULL); - - *outContextpp = ctx; - return ccNoError; -} - -cc_int32 -cci_context_get_default_ccache_name(cc_server_context_t* ctx, char ** outNamepp) -{ - cc_server_ccache_t* default_ccache; - - if (outNamepp == NULL) - return ccErrBadParam; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (ctx->ccaches->head != NULL) { - default_ccache = (cc_server_ccache_t*)ctx->ccaches->head->data; - *outNamepp = default_ccache->name; - } else { - *outNamepp = cc_default_ccache_name; - } - return ccNoError; -} - - -cc_int32 -cci_context_find_ccache( cc_server_context_t* ctx, char *name, - cc_server_ccache_t** outCcachepp ) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_ccache_list_node_t* ccache_node; - cc_server_ccache_t* ccache; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (name == NULL) - return ccErrInvalidString; - - if (outCcachepp == NULL) - return ccErrBadParam; - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); - ccache = (cc_server_ccache_t *)ccache_node->data; - if (strcmp(ccache->name, name) == 0) { - free(ccache_iterator); - *outCcachepp = ccache; - return ccNoError; - } - } - free(ccache_iterator); - return ccErrCCacheNotFound; -} - -cc_int32 -cci_context_open_ccache( cc_server_context_t* ctx, char *name, - cc_server_ccache_t** outCcachepp ) -{ - return cci_context_find_ccache(ctx, name, outCcachepp); -} - - -cc_int32 -cci_context_create_ccache( cc_server_context_t* ctx, char *name, int creds_version, - char *principal, cc_server_ccache_t** outCcachepp ) -{ - cc_server_ccache_t* ccache; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (outCcachepp == NULL) - return ccErrBadParam; - - if (name == NULL || principal == NULL) - return ccErrInvalidString; - - if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && - creds_version != cc_credentials_v4_v5) - return ccErrBadCredentialsVersion; - - code = cci_context_find_ccache(ctx, name, &ccache); - if (code == ccNoError) { - code = cci_ccache_set_principal(ccache, creds_version, principal); - } else { - code = cci_ccache_new(name, principal, creds_version, &ccache); - if (code != ccNoError) - return code; /*let caller deal with error*/ - - ccache->mycontext = ctx; - ctx->changed = time(NULL); - cci_ccache_list_append(ctx->ccaches, ccache, NULL); - - if (ctx->ccaches->head->data == (cc_uint8 *)ccache) { - ccache->is_default = 1; - } - } - *outCcachepp = ccache; - return ccNoError; -} - -cc_int32 -cci_context_create_default_ccache( cc_server_context_t* ctx, int creds_version, - char *principal, cc_server_ccache_t** outCcachepp ) -{ - cc_server_ccache_t* ccache, *old_default; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (outCcachepp == NULL) - return ccErrBadParam; - - if (principal == NULL) - return ccErrInvalidString; - - if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && - creds_version != cc_credentials_v4_v5) - return ccErrBadCredentialsVersion; - - code = cci_context_find_ccache(ctx, cc_default_ccache_name, &ccache); - if (code == ccNoError) { - cci_ccache_set_principal(ccache, creds_version, principal); - } else { - code = cci_ccache_new(cc_default_ccache_name, principal, creds_version, &ccache); - if (code != ccNoError) - return code; /*let caller deal with error*/ - - ccache->mycontext = ctx; - ccache->is_default = 1; - ctx->changed = time(NULL); - - if (ctx->ccaches->head != NULL) { - old_default = (cc_server_ccache_t *)ctx->ccaches->head->data; - old_default->is_default = 0; - old_default->last_default = time(NULL); - } - - cci_ccache_list_prepend(ctx->ccaches, ccache, NULL); - } - *outCcachepp = ccache; - return ccNoError; -} - -cc_int32 -cci_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t** iterpp) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (iterpp == NULL) - return ccErrBadParam; - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - if (code != ccNoError) - return code; - cci_generic_list_prepend(ctx->active_iterators, ccache_iterator, sizeof(cc_ccache_iterate_t), NULL); - - *iterpp = ccache_iterator; - return ccNoError; -} - -cc_int32 -cci_context_compare(cc_server_context_t* a, cc_server_context_t* b) -{ - if (a == b) - return 1; - else - return 0; -} - -cc_int32 -cci_context_destroy(cc_server_context_t* ctx) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_ccache_list_node_t* ccache_node; - cc_server_ccache_t* ccache; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - cci_generic_list_destroy(ctx->active_iterators); - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); - ccache = (cc_server_ccache_t *)ccache_node->data; - ccache_node->data = NULL; - cci_ccache_destroy(ccache); - } - cci_ccache_list_destroy(ctx->ccaches); - - return ccNoError; -} - -cc_int32 -cci_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_ccache_iterate_t* active_ccache_iterator; - cc_ccache_list_node_t* ccache_node; - cc_server_ccache_t* list_ccache; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (ccache == NULL) - return ccErrInvalidCCache; - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); - list_ccache = (cc_server_ccache_t *)ccache_node->data; - - if (list_ccache == ccache) { - code = cci_generic_list_iterator(ctx->active_iterators, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - active_ccache_iterator = (cc_server_ccache_t *)gen_node->data; - if (active_ccache_iterator->next == ccache_node) { - active_ccache_iterator->next = active_ccache_iterator->next->next; - } - } - free(gen_iterator); - code = cci_ccache_list_remove_element(ctx->ccaches, ccache_node); - break; - } - } - free(ccache_iterator); - return ccNoError; -} - diff --git a/src/lib/ccapi/server/datastore.h b/src/lib/ccapi/server/datastore.h index a92c60636..4f119f969 100644 --- a/src/lib/ccapi/server/datastore.h +++ b/src/lib/ccapi/server/datastore.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -51,6 +51,7 @@ #include "CredentialsCache.h" #include "rpc_auth.h" +#include "generic_lists.h" enum cc_list_type { generic = 0, @@ -59,36 +60,6 @@ enum cc_list_type { credentials }; -struct cc_generic_list_node_t { - cc_uint8* data; - cc_uint32 len; - struct cc_generic_list_node_t* next; - struct cc_generic_list_node_t* prev; -}; -typedef struct cc_generic_list_node_t cc_generic_list_node_t; - -struct cc_generic_list_head_t { - enum cc_list_type type; - cc_generic_list_node_t* head; - cc_generic_list_node_t* tail; -}; -typedef struct cc_generic_list_head_t cc_generic_list_head_t; - - -struct cc_generic_iterate_t { - cc_generic_list_node_t* next; -}; -typedef struct cc_generic_iterate_t cc_generic_iterate_t; - -typedef cc_generic_list_head_t cc_context_list_head_t; -typedef cc_generic_list_node_t cc_context_list_node_t; - -typedef cc_generic_list_head_t cc_ccache_list_head_t; -typedef cc_generic_list_node_t cc_ccache_list_node_t; - -typedef cc_generic_list_head_t cc_credentials_list_head_t; -typedef cc_generic_list_node_t cc_credentials_list_node_t; - struct cc_context_iterate_t { cc_context_list_node_t* next; }; @@ -104,7 +75,7 @@ struct cc_credentials_iterate_t { }; typedef struct cc_credentials_iterate_t cc_credentials_iterate_t; -struct cc_lock_t { +struct cc_lock { cc_uint32 read_locks; /* count of read locks (>= 0) */ cc_uint32 write_locks; /* count of write locks (0 or 1) */ void * platform_data; /* platform specific implementation data */ @@ -118,7 +89,7 @@ struct cc_server_context_t { cc_int32 api_version; /*Version our client passed in on init (ccapi_version_X) */ cc_auth_info_t* auth_info; /*auth info passed in from RPC*/ cc_session_info_t* session_info; /*session info passed in from RPC*/ - cc_time_t changed; /*date of last change to this context*/ + cc_time64 changed; /*date of last change to this context*/ cc_int32 error; /*last error code*/ cc_lock_t locks; /*are we locked?*/ }; @@ -129,10 +100,10 @@ struct cc_server_ccache_t { char* principal_v4; /*v4 principal associated with this cache*/ char* principal_v5; /*v5 principal associated with this cache*/ cc_uint32 versions; /*versions of creds supported (from cc_credentials enum in CredentialsCache.h)*/ - cc_time_t changed; /*date of last change to ccache*/ + cc_time64 changed; /*date of last change to ccache*/ cc_int32 kdc_set; /*is the KDC time offset initialized?*/ - cc_time_t kdc_offset; /*offset of our clock relative kdc*/ - cc_time_t last_default; /*the last date when we were default*/ + cc_time64 kdc_offset; /*offset of our clock relative kdc*/ + cc_time64 last_default; /*the last date when we were default*/ cc_int32 is_default; /*is this the default cred on this ccache?*/ cc_generic_list_head_t* active_iterators; /*iterators which clients have opened on this cache*/ cc_credentials_list_head_t* creds; /*list of creds stored in this ccache*/ @@ -150,82 +121,69 @@ typedef struct cc_server_credentials_t cc_server_credentials_t; /*Note: cci means Credential Cache Internal, to differentiate from exported API macros*/ -cc_int32 cci_generic_iterate_has_next(cc_generic_iterate_t *iterate); -cc_int32 cci_generic_iterate_next(cc_generic_iterate_t *iterate, cc_generic_list_node_t**); - -cc_int32 cci_generic_list_new(cc_generic_list_head_t **); -cc_int32 cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); -cc_int32 cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); -cc_int32 cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem); -cc_int32 cci_generic_free_element(cc_generic_list_node_t* node); -cc_int32 cci_generic_list_destroy(cc_generic_list_head_t* head); -cc_int32 cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t**); -cc_int32 cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t**); -cc_int32 cci_generic_free_iterator(cc_generic_iterate_t* iterator); - -cc_int32 cci_context_iterate_has_next(struct cc_context_iterate_t *iterate); -cc_int32 cci_context_iterate_next(struct cc_context_iterate_t *iterate, cc_context_list_node_t**); - -cc_int32 cci_ccache_iterate_has_next(struct cc_ccache_iterate_t *iterate); -cc_int32 cci_ccache_iterate_next(struct cc_ccache_iterate_t *iterate, cc_ccache_list_node_t**); - -cc_int32 cci_credentials_iterate_has_next(cc_credentials_iterate_t *iterate); -cc_int32 cci_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t **); - -cc_int32 cci_context_list_new(cc_context_list_head_t**); -cc_int32 cci_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); -cc_int32 cci_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); -cc_int32 cci_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem); -cc_int32 cci_context_list_iterator(cc_context_list_head_t *head, struct cc_context_iterate_t**); -cc_int32 cci_context_free_iterator(struct cc_context_iterate_t *iterator); -cc_int32 cci_context_list_destroy(cc_context_list_head_t* head) ; -cc_int32 cci_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t**); - -cc_int32 cci_ccache_list_new(cc_ccache_list_head_t**); -cc_int32 cci_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); -cc_int32 cci_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); -cc_int32 cci_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem); -cc_int32 cci_ccache_list_iterator(cc_ccache_list_head_t *head, struct cc_ccache_iterate_t**); -cc_int32 cci_ccache_free_iterator(struct cc_ccache_iterate_t *iterator); -cc_int32 cci_ccache_list_destroy(cc_ccache_list_head_t* head) ; -cc_int32 cci_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t**); - - -cc_int32 cci_credentials_list_new(cc_credentials_list_head_t**); -cc_int32 cci_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); -cc_int32 cci_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); -cc_int32 cci_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem); -cc_int32 cci_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t**); -cc_int32 cci_credentials_free_iterator(cc_credentials_iterate_t* iterator); -cc_int32 cci_credentials_list_destroy(cc_credentials_list_head_t* head) ; -cc_int32 cci_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t**) ; - - -cc_int32 cci_context_new(int api_version, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ) ; -cc_int32 cci_context_get_default_ccache_name(cc_server_context_t* ctx, char **); -cc_int32 cci_context_find_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t**); -cc_int32 cci_context_open_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t** ); -cc_int32 cci_context_create_ccache(cc_server_context_t* ctx, char *name, int creds_version, char *principal, cc_server_ccache_t**); -cc_int32 cci_context_create_default_ccache(cc_server_context_t* ctx, int creds_version, char *principal, cc_server_ccache_t**); -cc_int32 cci_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t**); -cc_int32 cci_context_compare(cc_server_context_t* a, cc_server_context_t* b); -cc_int32 cci_context_destroy(cc_server_context_t* ctx); -cc_int32 cci_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache); - -cc_int32 cci_ccache_new(char *name, char *principal, int cred_vers, cc_server_ccache_t**); -cc_int32 cci_ccache_check_version(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); -cc_int32 cci_ccache_check_principal(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); -cc_int32 cci_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); -cc_int32 cci_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); -cc_int32 cci_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination); -cc_int32 cci_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t* offset); -cc_int32 cci_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t offset); -cc_int32 cci_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache); -cc_int32 cci_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator); -cc_int32 cci_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal); -cc_int32 cci_ccache_set_principal(cc_server_ccache_t* ccache, cc_int32 version, char * principal); -cc_int32 cci_ccache_free_principal(char * principal); -cc_int32 cci_ccache_destroy(cc_server_ccache_t* ccache); -void cci_ccache_changed(cc_server_ccache_t* ccache); -cc_int32 cci_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result); +cc_int32 ccs_context_iterate_has_next(struct cc_context_iterate_t *iterate); +cc_int32 ccs_context_iterate_next(struct cc_context_iterate_t *iterate, cc_context_list_node_t**); + +cc_int32 ccs_ccache_iterate_has_next(struct cc_ccache_iterate_t *iterate); +cc_int32 ccs_ccache_iterate_next(struct cc_ccache_iterate_t *iterate, cc_ccache_list_node_t**); + +cc_int32 ccs_credentials_iterate_has_next(cc_credentials_iterate_t *iterate); +cc_int32 ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t **); + +cc_int32 ccs_context_list_new(cc_context_list_head_t**); +cc_int32 ccs_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); +cc_int32 ccs_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); +cc_int32 ccs_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem); +cc_int32 ccs_context_list_iterator(cc_context_list_head_t *head, struct cc_context_iterate_t**); +cc_int32 ccs_context_free_iterator(struct cc_context_iterate_t *iterator); +cc_int32 ccs_context_list_destroy(cc_context_list_head_t* head) ; +cc_int32 ccs_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t**); + +cc_int32 ccs_ccache_list_new(cc_ccache_list_head_t**); +cc_int32 ccs_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); +cc_int32 ccs_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); +cc_int32 ccs_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem); +cc_int32 ccs_ccache_list_iterator(cc_ccache_list_head_t *head, struct cc_ccache_iterate_t**); +cc_int32 ccs_ccache_free_iterator(struct cc_ccache_iterate_t *iterator); +cc_int32 ccs_ccache_list_destroy(cc_ccache_list_head_t* head) ; +cc_int32 ccs_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t**); + + +cc_int32 ccs_credentials_list_new(cc_credentials_list_head_t**); +cc_int32 ccs_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); +cc_int32 ccs_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); +cc_int32 ccs_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem); +cc_int32 ccs_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t**); +cc_int32 ccs_credentials_free_iterator(cc_credentials_iterate_t* iterator); +cc_int32 ccs_credentials_list_destroy(cc_credentials_list_head_t* head) ; +cc_int32 ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t**) ; + + +cc_int32 ccs_context_new(int api_version, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ) ; +cc_int32 ccs_context_get_default_ccache_name(cc_server_context_t* ctx, char **); +cc_int32 ccs_context_find_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t**); +cc_int32 ccs_context_open_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t** ); +cc_int32 ccs_context_create_ccache(cc_server_context_t* ctx, char *name, int creds_version, char *principal, cc_server_ccache_t**); +cc_int32 ccs_context_create_default_ccache(cc_server_context_t* ctx, int creds_version, char *principal, cc_server_ccache_t**); +cc_int32 ccs_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t**); +cc_int32 ccs_context_compare(cc_server_context_t* a, cc_server_context_t* b); +cc_int32 ccs_context_destroy(cc_server_context_t* ctx); +cc_int32 ccs_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache); + +cc_int32 ccs_ccache_new(char *name, char *principal, int cred_vers, cc_server_ccache_t**); +cc_int32 ccs_ccache_check_version(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); +cc_int32 ccs_ccache_check_principal(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); +cc_int32 ccs_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); +cc_int32 ccs_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); +cc_int32 ccs_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination); +cc_int32 ccs_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64* offset); +cc_int32 ccs_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64 offset); +cc_int32 ccs_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache); +cc_int32 ccs_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator); +cc_int32 ccs_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal); +cc_int32 ccs_ccache_set_principal(cc_server_ccache_t* ccache, cc_int32 version, char * principal); +cc_int32 ccs_ccache_free_principal(char * principal); +cc_int32 ccs_ccache_destroy(cc_server_ccache_t* ccache); +void ccs_ccache_changed(cc_server_ccache_t* ccache); +cc_int32 ccs_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result); #endif /*__CCDATASTOREH__*/ diff --git a/src/lib/ccapi/server/lists.c b/src/lib/ccapi/server/lists.c deleted file mode 100644 index 882ecb7a0..000000000 --- a/src/lib/ccapi/server/lists.c +++ /dev/null @@ -1,996 +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). - * $ - */ - - -/* - * Lists implementation. - * - */ - -#include -#include -#include - -#include "CredentialsCache.h" -#include "datastore.h" - -/** - * cci_generic_iterate_has_next() - * - * Purpose: Determine if an iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - * - * Errors: None - * - */ -cc_int32 -cci_generic_iterate_has_next(cc_generic_iterate_t *iterate) -{ - return ((iterate == NULL || iterate->next == NULL) ? 0 : 1); -} - -/** - * cci_generic_iterate_next() - * - * Purpose: Retrieve the next element from an iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_iterate_next(cc_generic_iterate_t *iterator, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* ret; - - if (iterator == NULL || nodepp == NULL) - return ccErrBadParam; - - ret = iterator->next; - if (iterator->next != NULL) - iterator->next = iterator->next->next; - - *nodepp = ret; - return ccNoError; -} - -/** - * cci_context_iterate_has_next() - * - * Purpose: Determine if a context iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - */ -cc_int32 -cci_context_iterate_has_next(cc_context_iterate_t *iterate) -{ - if ( iterate == NULL ) - return 0; - - return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); -} - -/** - * cci_context_iterate_next() - * - * Purpose: Retrieve the next element from a context iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_context_iterate_next(cc_context_iterate_t *iterate, cc_context_list_node_t ** nodepp) -{ - if ( iterate == NULL || nodepp == NULL) - return ccErrBadParam; - - return cci_generic_iterate_next((cc_generic_iterate_t*)iterate,(cc_context_list_node_t**)nodepp); -} - -/** - * cci_ccache_iterate_has_next() - * - * Purpose: Determine if a cache iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - * -1 if error - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_iterate_has_next(cc_ccache_iterate_t *iterate) -{ - if ( iterate == NULL ) - return 0; - return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); -} - -/** - * cci_ccache_iterate_next() - * - * Purpose: Retrieve the next element from a ccache iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_iterate_next(cc_ccache_iterate_t *iterate, cc_ccache_list_node_t ** nodepp) -{ - if ( iterate == NULL || nodepp == NULL) - return ccErrBadParam; - - return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_ccache_list_node_t**)nodepp); -} - -/** - * cci_credentials_iterate_has_next() - * - * Purpose: Determine if a credentials iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - * -1 if error - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_iterate_has_next(cc_credentials_iterate_t *iterate) -{ - if ( iterate == NULL ) - return 0; - - return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); -} - -/** - * cci_credentials_iterate_next() - * - * Purpose: Retrieve the next element from a credentials iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t** nodepp) -{ - if ( iterate == NULL || nodepp == NULL ) - return ccErrBadParam; - return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_credentials_list_node_t**)nodepp); -} - -/** - * cci_generic_list_new() - * - * Purpose: Allocate new generic list - * - * Return: non-NULL, an empty list - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_generic_list_new(cc_generic_list_head_t ** listpp) -{ - cc_generic_list_head_t* ret = (cc_generic_list_head_t *)malloc(sizeof(cc_generic_list_head_t)); - if (ret == NULL) - return ccErrNoMem; - - ret->type = generic; - ret->head = ret->tail = NULL; - *listpp = ret; - - return ccNoError; -} - -/** - * cci_generic_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* new_node; - - if ( data == NULL || len == 0 ) - return ccErrBadParam; - - new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); - if (new_node == NULL) - return ccErrNoMem; - - new_node->data = malloc(len); - if ( new_node->data == NULL ) { - free(new_node); - return ccErrNoMem; - } - - memcpy(new_node->data,data,len); - new_node->len = len; - - if (head->head == NULL) { /*empty list*/ - head->head = new_node; - head->tail = new_node; - new_node->next = new_node->prev = NULL; - } else { - new_node->prev = head->tail; - head->tail->next = new_node; - head->tail = new_node; - new_node->next = NULL; - } - if (nodepp != NULL) - *nodepp = new_node; - return ccNoError; -} - -/** - * cci_generic_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem, ccErrBadParam - * - */ -cc_int32 -cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* new_node; - - if ( data == NULL || len == 0 ) - return ccErrBadParam; - - new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); - if (new_node == NULL) - return ccErrNoMem; - - new_node->data = malloc(len); - if ( new_node->data == NULL ) { - free(new_node); - return ccErrNoMem; - } - - memcpy(new_node->data,data,len); - new_node->len = len; - - if (head->head == NULL) { /*empty list*/ - head->head = new_node; - head->tail = new_node; - new_node->prev = new_node->next = NULL; - } else { - new_node->next = head->head; - head->head->prev = new_node; - new_node->prev = NULL; - head->head = new_node; - } - - if (nodepp != NULL) - *nodepp = new_node; - - return ccNoError; -} - -/** - * cci_generic_list_remove_element() - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem) -{ - if (head->head == NULL || rem == NULL) - return ccErrBadParam; - - if (head->head == rem && head->tail == rem) { /*removing only element of list*/ - head->head = head->tail = NULL; - } else if (head->head == rem) { /*removing head*/ - head->head = head->head->next; - } else if (head->tail == rem) { /*removing tail*/ - head->tail = head->tail->prev; - head->tail->next = NULL; - } else { - rem->prev->next = rem->next; - rem->next->prev = rem->prev; - } - free(rem); - return ccNoError; -} - -/** - * cci_generic_free_element() - * - * Purpose: Free the memory associated with a node - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_free_element(cc_generic_list_node_t* node) -{ - if ( node == NULL ) - return ccErrBadParam; - - if ( node->data ) { - free(node->data); - node->data = NULL; - } - node->len = 0; - node->next = node->prev = NULL; - free(node); - return ccNoError; -} - - -/** - * cci_generic_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_generic_list_destroy(cc_generic_list_head_t* head) -{ - cc_generic_list_node_t *cur, *next; - cc_int32 ret = ccNoError; - - if ( head == NULL ) - return ccErrBadParam; - - for (cur = head->head; ret == ccNoError && cur != NULL; cur = next) { - next = cur->next; - ret = cci_generic_free_element(cur); - } - free(head); - return(ret); -} - -/** - * cci_context_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_context_list_destroy(cc_context_list_head_t* head) -{ - return cci_generic_list_destroy((cc_generic_list_head_t*)head); -} - -/** - * cci_ccache_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_ccache_list_destroy(cc_ccache_list_head_t* head) -{ - return cci_generic_list_destroy((cc_generic_list_head_t*)head); -} - -/** - * cci_credentials_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_credentials_list_destroy(cc_credentials_list_head_t* head) -{ - return cci_generic_list_destroy((cc_generic_list_head_t*)head); -} - -/** - * cci_generic_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - * - */ -cc_int32 -cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t** headpp) -{ - cc_generic_list_head_t* copy; - cc_generic_list_node_t *src_node, *dst_node; - cc_int32 code; - - if (head == NULL || headpp == NULL) - return ccErrBadParam; - - code = cci_generic_list_new(©); - if (code != ccNoError) - return code; - - for (src_node = head->head; src_node != NULL; src_node = src_node->next) { - code = cci_generic_list_append(copy, src_node->data, src_node->len, &dst_node); - if (code != ccNoError) { - cci_generic_list_destroy(copy); - return code; - } - } - *headpp = copy; - return ccNoError; -} - -/** - * cci_context_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - * - */ -cc_int32 -cci_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t** headpp ) -{ - return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_context_list_head_t **)headpp); -} - -/** - * cci_ccache_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - */ -cc_int32 -cci_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t** headpp) -{ - return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_ccache_list_head_t **)headpp); -} - -/** - * cci_credentials_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - * - */ -cc_int32 -cci_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t** headpp) -{ - return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_credentials_list_head_t **)headpp); -} - - -/** - * cci_generic_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t** headpp) -{ - cc_generic_iterate_t* iterator; - - if ( head == NULL || headpp == NULL ) - return ccErrBadParam; - - iterator = (cc_generic_iterate_t*)malloc(sizeof(cc_generic_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *headpp = iterator; - return ccNoError; -} - -/** - * cci_generic_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_free_iterator(cc_generic_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - - -/** - * cci_context_list_new() - * - * Purpose: Allocate a new context list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_context_list_new(cc_context_list_head_t ** headpp) -{ - cc_context_list_head_t *ret; - - if ( headpp == NULL ) - return ccErrBadParam; - - ret = (cc_context_list_head_t *)malloc(sizeof(cc_context_list_head_t)); - if (ret == NULL) - return ccErrNoMem; - ret->head = ret->tail = NULL; - *headpp = ret; - return ccNoError; -} - -/** - * cci_context_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp) -{ - return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); -} - -/** - * cci_context_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp ) -{ - return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); -} - -/** - * cci_context_list_remove_element - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem) -{ - return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); -} - -/** - * cci_context_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_context_list_iterator(cc_context_list_head_t *head, cc_context_iterate_t** iterpp) -{ - cc_context_iterate_t* iterator; - - if ( head == NULL || iterpp == NULL ) - return ccErrBadParam; - - iterator = (cc_context_iterate_t*)malloc(sizeof(cc_context_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *iterpp = iterator; - return ccNoError; -} - -/** - * cci_context_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_context_free_iterator(cc_context_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - -/** - * cci_ccache_list_new() - * - * Purpose: Allocate a new ccache list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrNoMem - */ -cc_int32 -cci_ccache_list_new(cc_ccache_list_head_t ** listpp) -{ - cc_ccache_list_head_t *ret; - - if ( listpp == NULL ) - return ccErrBadParam; - - ret = (cc_ccache_list_head_t *)malloc(sizeof(cc_ccache_list_head_t)); - if (ret == NULL) - return ccErrNoMem; - - ret->head = ret->tail = NULL; - *listpp = ret; - return ccNoError; -} - -/** - * cci_ccache_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) -{ - return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); -} - -/** - * cci_ccache_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) -{ - return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); -} - -/** - * cci_ccache_list_remove_element() - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem) -{ - return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); -} - -/** - * cci_ccache_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_ccache_list_iterator(cc_ccache_list_head_t *head, cc_ccache_iterate_t** iterpp) -{ - cc_ccache_iterate_t* iterator; - - if ( head == NULL || iterpp == NULL ) - return ccErrBadParam; - - iterator = (cc_ccache_iterate_t*)malloc(sizeof(cc_ccache_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *iterpp = iterator; - return ccNoError; -} - -/** - * cci_ccache_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_free_iterator(cc_ccache_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - -/** - * cci_credentials_list_new() - * - * Purpose: Allocate a new ccache list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_credentials_list_new(cc_credentials_list_head_t ** list) -{ - if ( list == NULL ) - return ccErrBadParam; - - *list = (cc_credentials_list_head_t *)malloc(sizeof(cc_credentials_list_head_t)); - if (*list == NULL) - return ccErrNoMem; - - (*list)->head = (*list)->tail = NULL; - return ccNoError; -} - -/** - * cci_credentials_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp ) -{ - return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); -} - -/** - * cci_credentials_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp) -{ - return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); -} - -/** - * cci_credentials_list_remove_element() - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem) -{ - return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); -} - -/** - * cci_credentials_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t** iterpp) -{ - cc_credentials_iterate_t* iterator; - - if ( head == NULL || iterpp == NULL ) - return ccErrBadParam; - - iterator = (cc_credentials_iterate_t*)malloc(sizeof(cc_credentials_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *iterpp = iterator; - return ccNoError; -} - -/** - * cci_credentials_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_free_iterator(cc_credentials_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - diff --git a/src/lib/ccapi/server/main.c b/src/lib/ccapi/server/main.c new file mode 100644 index 000000000..cf69af312 --- /dev/null +++ b/src/lib/ccapi/server/main.c @@ -0,0 +1,12 @@ +#include +#include + +int main( int argc, char *argv[] ) +{ + /* we need a set of functions we want to support. + * so we can provide an abstract platform independent + * interface. + */ + + return 0; +} diff --git a/src/lib/ccapi/server/serv_ops.c b/src/lib/ccapi/server/serv_ops.c index 30a108a34..360536a92 100644 --- a/src/lib/ccapi/server/serv_ops.c +++ b/src/lib/ccapi/server/serv_ops.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -62,33 +62,36 @@ extern int cc_myversion; extern char cc_vendor[]; cc_int32 -cci_serv_initialize(void) +ccs_serv_initialize(void) { cc_int32 code; - code = cci_context_list_new(&AllContexts); + code = ccs_context_list_new(&AllContexts); if ( code != ccNoError ) return code; TypeToOpMapping = (type_to_op_mapping_t*)malloc(sizeof(type_to_op_mapping_t)); if (TypeToOpMapping == NULL) { - cci_context_list_destroy(AllContexts); + ccs_context_list_destroy(AllContexts); return ccErrNoMem; } +#if 0 + TypeToOpMapping->operations[ccmsg_ACK] = ccop_ACK; + TypeToOpMapping->operations[ccmsg_NACK] = ccop_NACK; +#endif TypeToOpMapping->operations[ccmsg_INIT] = ccop_INIT; TypeToOpMapping->operations[ccmsg_CTX_RELEASE] = ccop_CTX_RELEASE; TypeToOpMapping->operations[ccmsg_CTX_GET_CHANGE_TIME] = ccop_CTX_GET_CHANGE_TIME; TypeToOpMapping->operations[ccmsg_CTX_GET_DEFAULT_CCACHE_NAME] = ccop_CTX_GET_DEFAULT_CCACHE_NAME; - TypeToOpMapping->operations[ccmsg_CTX_COMPARE] = ccop_CTX_COMPARE; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_OPEN] = ccop_CTX_CCACHE_OPEN; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_OPEN_DEFAULT] = ccop_CTX_CCACHE_OPEN_DEFAULT; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_CREATE] = ccop_CTX_CCACHE_CREATE; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_CREATE_DEFAULT] = ccop_CTX_CCACHE_CREATE_DEFAULT; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_CREATE_UNIQUE] = ccop_CTX_CCACHE_CREATE_UNIQUE; TypeToOpMapping->operations[ccmsg_CTX_NEW_CCACHE_ITERATOR] = ccop_CTX_NEW_CCACHE_ITERATOR; TypeToOpMapping->operations[ccmsg_CTX_LOCK] = ccop_CTX_LOCK; TypeToOpMapping->operations[ccmsg_CTX_UNLOCK] = ccop_CTX_UNLOCK; - TypeToOpMapping->operations[ccmsg_CTX_CLONE] = ccop_CTX_CLONE; - TypeToOpMapping->operations[ccmsg_CCACHE_OPEN] = ccop_CCACHE_OPEN; - TypeToOpMapping->operations[ccmsg_CCACHE_OPEN_DEFAULT] = ccop_CCACHE_OPEN_DEFAULT; - TypeToOpMapping->operations[ccmsg_CCACHE_CREATE] = ccop_CCACHE_CREATE; - TypeToOpMapping->operations[ccmsg_CCACHE_CREATE_DEFAULT] = ccop_CCACHE_CREATE_DEFAULT; - TypeToOpMapping->operations[ccmsg_CCACHE_CREATE_UNIQUE] = ccop_CCACHE_CREATE_UNIQUE; + TypeToOpMapping->operations[ccmsg_CTX_COMPARE] = ccop_CTX_COMPARE; TypeToOpMapping->operations[ccmsg_CCACHE_RELEASE] = ccop_CCACHE_RELEASE; TypeToOpMapping->operations[ccmsg_CCACHE_DESTROY] = ccop_CCACHE_DESTROY; TypeToOpMapping->operations[ccmsg_CCACHE_SET_DEFAULT] = ccop_CCACHE_SET_DEFAULT; @@ -96,9 +99,12 @@ cci_serv_initialize(void) TypeToOpMapping->operations[ccmsg_CCACHE_GET_NAME] = ccop_CCACHE_GET_NAME; TypeToOpMapping->operations[ccmsg_CCACHE_GET_PRINCIPAL] = ccop_CCACHE_GET_PRINCIPAL; TypeToOpMapping->operations[ccmsg_CCACHE_SET_PRINCIPAL] = ccop_CCACHE_SET_PRINCIPAL; - TypeToOpMapping->operations[ccmsg_CCACHE_CREDS_ITERATOR] = ccop_CCACHE_CREDS_ITERATOR; + TypeToOpMapping->operations[ccmsg_CCACHE_NEW_CREDS_ITERATOR] = ccop_CCACHE_NEW_CREDS_ITERATOR; TypeToOpMapping->operations[ccmsg_CCACHE_STORE_CREDS] = ccop_CCACHE_STORE_CREDS; TypeToOpMapping->operations[ccmsg_CCACHE_REM_CREDS] = ccop_CCACHE_REM_CREDS; + TypeToOpMapping->operations[ccmsg_CCACHE_MOVE] = ccop_CCACHE_MOVE; + TypeToOpMapping->operations[ccmsg_CCACHE_LOCK] = ccop_CCACHE_LOCK; + TypeToOpMapping->operations[ccmsg_CCACHE_UNLOCK] = ccop_CCACHE_UNLOCK; TypeToOpMapping->operations[ccmsg_CCACHE_GET_LAST_DEFAULT_TIME] = ccop_CCACHE_GET_LAST_DEFAULT_TIME; TypeToOpMapping->operations[ccmsg_CCACHE_GET_CHANGE_TIME] = ccop_CCACHE_GET_CHANGE_TIME; TypeToOpMapping->operations[ccmsg_CCACHE_COMPARE] = ccop_CCACHE_COMPARE; @@ -107,15 +113,16 @@ cci_serv_initialize(void) TypeToOpMapping->operations[ccmsg_CCACHE_CLEAR_KDC_TIME_OFFSET] = ccop_CCACHE_CLEAR_KDC_TIME_OFFSET; TypeToOpMapping->operations[ccmsg_CCACHE_ITERATOR_RELEASE] = ccop_CCACHE_ITERATOR_RELEASE; TypeToOpMapping->operations[ccmsg_CCACHE_ITERATOR_NEXT] = ccop_CCACHE_ITERATOR_NEXT; + TypeToOpMapping->operations[ccmsg_CCACHE_ITERATOR_CLONE] = ccop_CCACHE_ITERATOR_CLONE; TypeToOpMapping->operations[ccmsg_CREDS_ITERATOR_RELEASE] = ccop_CREDS_ITERATOR_RELEASE; TypeToOpMapping->operations[ccmsg_CREDS_ITERATOR_NEXT] = ccop_CREDS_ITERATOR_NEXT; - TypeToOpMapping->operations[ccmsg_CREDS_RELEASE] = ccop_CREDS_RELEASE; + TypeToOpMapping->operations[ccmsg_CREDS_ITERATOR_CLONE] = ccop_CREDS_ITERATOR_CLONE; return ccNoError; }; cc_int32 -cci_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) +ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) { cc_server_context_t* ctx; ccmsg_ctx_only_t* header = (ccmsg_ctx_only_t *)msg->header; @@ -125,7 +132,7 @@ cci_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_ return ccErrBadParam; if (AllContexts == NULL) { - code = cci_serv_initialize(); + code = ccs_serv_initialize(); if ( code != ccNoError ) return code; } @@ -137,9 +144,9 @@ cci_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_ return ccErrBadParam; } - code = cci_serv_find_ctx_by_handle(header->ctx, auth_info, session_info, &ctx); + code = ccs_serv_find_ctx_by_handle(header->ctx, auth_info, session_info, &ctx); if (code != ccNoError) { - cci_serv_make_nack(ccErrContextNotFound, auth_info, session_info, resp_msg); + ccs_serv_make_nack(ccErrContextNotFound, auth_info, session_info, resp_msg); return code; } return TypeToOpMapping->operations[msg->type] (ctx, auth_info, session_info, msg, resp_msg); @@ -148,7 +155,7 @@ cci_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_ /*deprecated*/ cc_int32 -cci_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, +ccs_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ctxpp) { cc_context_iterate_t* ctx_iterator; @@ -157,35 +164,35 @@ cci_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_int32 code; cc_uint32 authorized; - code = cci_context_list_iterator(AllContexts, &ctx_iterator); + code = ccs_context_list_iterator(AllContexts, &ctx_iterator); if (code != ccNoError) return code; - while (cci_context_iterate_has_next(ctx_iterator)) { - code = cci_context_iterate_next(ctx_iterator, &ctx_node); + while (ccs_context_iterate_has_next(ctx_iterator)) { + code = ccs_context_iterate_next(ctx_iterator, &ctx_node); if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } ctx = (cc_server_context_t *)ctx_node->data; code = cci_rpc_is_authorized(auth_info, session_info, ctx->auth_info, ctx->session_info, &authorized); if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } if (authorized) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); *ctxpp = ctx; return ccNoError; } } - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return ccIteratorEnd; } cc_int32 -cci_serv_find_ctx_by_handle(cc_handle ctx_num, cc_auth_info_t* auth, cc_session_info_t* session, cc_server_context_t** ctxpp) +ccs_serv_find_ctx_by_handle(cc_handle ctx_num, cc_auth_info_t* auth, cc_session_info_t* session, cc_server_context_t** ctxpp) { cc_server_context_t* input_ctx = (cc_server_context_t*)ctx_num; cc_context_iterate_t* ctx_iterator; @@ -194,36 +201,36 @@ cci_serv_find_ctx_by_handle(cc_handle ctx_num, cc_auth_info_t* auth, cc_session_ cc_uint32 authorized; cc_int32 code; - code = cci_context_list_iterator(AllContexts, &ctx_iterator); + code = ccs_context_list_iterator(AllContexts, &ctx_iterator); if (code != ccNoError) return code; - while (cci_context_iterate_has_next(ctx_iterator)) { - code = cci_context_iterate_next(ctx_iterator, &ctx_node); + while (ccs_context_iterate_has_next(ctx_iterator)) { + code = ccs_context_iterate_next(ctx_iterator, &ctx_node); ctx = (cc_server_context_t *)ctx_node->data; if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } code = cci_rpc_is_authorized(auth, session, ctx->auth_info, ctx->session_info, &authorized); if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } if (ctx == input_ctx && authorized) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); *ctxpp = ctx; return ccNoError; } } - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return ccIteratorEnd; } cc_int32 -cci_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache, cc_server_ccache_t** ccachepp ) +ccs_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache, cc_server_ccache_t** ccachepp ) { cc_ccache_iterate_t* ccache_iterator; cc_ccache_list_node_t* ccache_node; @@ -231,31 +238,31 @@ cci_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache, cc_se cc_server_ccache_t* target_ccache = (cc_server_ccache_t*)ccache; cc_int32 code; - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); if (code != ccNoError) return code; - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); if (code != ccNoError) { - cci_ccache_free_iterator(ccache_iterator); + ccs_ccache_free_iterator(ccache_iterator); return code; } stored_ccache = (cc_server_ccache_t *)ccache_node->data; if (stored_ccache == target_ccache) { - cci_ccache_free_iterator(ccache_iterator); + ccs_ccache_free_iterator(ccache_iterator); *ccachepp = stored_ccache; return ccNoError; } } - cci_ccache_free_iterator(ccache_iterator); + ccs_ccache_free_iterator(ccache_iterator); return ccIteratorEnd; } cc_int32 -cci_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodepp ) +ccs_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodepp ) { cc_generic_iterate_t* gen_iterator; cc_generic_list_node_t* gen_node; @@ -286,7 +293,7 @@ cci_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iter } cc_int32 -cci_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodepp) +ccs_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodepp) { cc_generic_iterate_t* gen_iterator; cc_generic_list_node_t* gen_node; @@ -317,7 +324,7 @@ cci_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle ite } cc_int32 -cci_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) +ccs_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) { ccmsg_nack_t* nack_header; cc_int32 code; @@ -345,7 +352,7 @@ cci_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info } cc_int32 -cci_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) +ccs_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) { cc_int32 code; @@ -383,46 +390,46 @@ ccop_INIT( cc_server_context_t* ctx, /* not used */ return ccErrBadParam; } - code = cci_context_new(header->in_version, auth_info, session_info, &new_ctx); + code = ccs_context_new(header->in_version, auth_info, session_info, &new_ctx); if (code != ccNoError) { return code; } - code = cci_context_list_append(AllContexts, ctx, &ctx_node); + code = ccs_context_list_append(AllContexts, ctx, &ctx_node); if (code != ccNoError) { - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); return code; } resp_header = (ccmsg_init_resp_t*)malloc(sizeof(ccmsg_init_resp_t)); if (resp_header == NULL) { - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); return ccErrNoMem; } code = cci_msg_new(ccmsg_ACK, resp_msg); if (code != ccNoError) { free(resp_header); - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); return code; } code = cci_msg_add_data_blob(*resp_msg, cc_vendor, strlen(cc_vendor) + 1, &blob_pos); if (code != ccNoError) { free(resp_header); - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); cci_msg_destroy(*resp_msg); *resp_msg = 0; return code; } - resp_header->out_ctx = new_ctx; + resp_header->out_ctx = (cc_handle) new_ctx; resp_header->out_version = cc_myversion; resp_header->vendor_offset = blob_pos; resp_header->vendor_length = strlen(cc_vendor) + 1; code = cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_init_resp_t)); if (code != ccNoError) { free(resp_header); - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); cci_msg_destroy(*resp_msg); *resp_msg = 0; return code; @@ -446,8 +453,8 @@ ccop_CTX_RELEASE( cc_server_context_t* ctx, return ccErrBadParam; } - code = cci_context_destroy(header->ctx); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + code = ccs_context_destroy((cc_server_context_t *)header->ctx); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -471,7 +478,7 @@ ccop_CTX_GET_CHANGE_TIME( cc_server_context_t* ctx, } resp_header->time = ctx->changed; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ctx_get_change_time_resp_t), auth_info, session_info, resp_msg); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_get_change_time_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -491,7 +498,7 @@ ccop_CTX_GET_DEFAULT_CCACHE_NAME( cc_server_context_t* ctx, return ccErrBadParam; } - code = cci_context_get_default_ccache_name(ctx, &name); + code = ccs_context_get_default_ccache_name(ctx, &name); if (code != ccNoError) return code; @@ -527,14 +534,14 @@ ccop_CTX_COMPARE(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ctx_compare_t)) return ccErrBadParam; - code = cci_serv_find_ctx_by_handle(header->ctx2, auth_info, session_info, &ctx2); + code = ccs_serv_find_ctx_by_handle(header->ctx2, auth_info, session_info, &ctx2); resp_header = (ccmsg_ctx_compare_resp_t*)malloc(sizeof(ccmsg_ctx_compare_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->is_equal = cci_context_compare(ctx, ctx2); - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ctx_compare_resp_t), auth_info, session_info, resp_msg); + resp_header->is_equal = ccs_context_compare(ctx, ctx2); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_compare_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -553,15 +560,15 @@ ccop_CTX_NEW_CCACHE_ITERATOR(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ctx_new_ccache_iterator_t)) return ccErrBadParam; - code = cci_context_ccache_iterator(ctx,&ccache_iterator); + code = ccs_context_ccache_iterator(ctx,&ccache_iterator); resp_header = (ccmsg_ctx_new_ccache_iterator_resp_t*)malloc(sizeof(ccmsg_ctx_new_ccache_iterator_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->iterator = ccache_iterator; + resp_header->iterator = (cc_handle) ccache_iterator; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ctx_new_ccache_iterator_resp_t), auth_info, session_info, resp_msg); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_new_ccache_iterator_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -571,7 +578,7 @@ ccop_CTX_LOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -581,7 +588,7 @@ ccop_CTX_UNLOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -591,11 +598,11 @@ ccop_CTX_CLONE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_OPEN(cc_server_context_t* ctx, +ccop_CTX_CCACHE_OPEN(cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -612,24 +619,24 @@ ccop_CCACHE_OPEN(cc_server_context_t* ctx, return ccErrBadParam; code = cci_msg_retrieve_blob(msg, header->name_offset, header->name_len, &name); - code = cci_context_find_ccache(ctx, name, &ccache); + code = ccs_context_find_ccache(ctx, name, &ccache); free(name); if (ccache == NULL) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_open_resp_t*)malloc(sizeof(ccmsg_ccache_open_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = (cc_handle) ccache; + ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); return ccNoError; } cc_int32 -ccop_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, +ccop_CTX_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -644,7 +651,7 @@ ccop_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, return ccErrBadParam; if (ctx->ccaches->head->data == NULL) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); ccache = (cc_server_ccache_t*) ctx->ccaches->head->data; @@ -652,12 +659,12 @@ ccop_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = (cc_handle) ccache; + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREATE(cc_server_context_t* ctx, +ccop_CTX_CCACHE_CREATE(cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -684,7 +691,7 @@ ccop_CCACHE_CREATE(cc_server_context_t* ctx, return code; name[header->name_len] = '\0'; /*Ensure null termination*/ - code = cci_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, header->version, principal, &ccache); if (code != ccNoError) return code; @@ -692,12 +699,12 @@ ccop_CCACHE_CREATE(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = (cc_handle) ccache; + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, +ccop_CTX_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -719,11 +726,11 @@ ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, return code; principal[header->principal_len] = '\0'; /*Ensure null termination*/ - code = cci_context_get_default_ccache_name(ctx, &name); + code = ccs_context_get_default_ccache_name(ctx, &name); if (code != ccNoError) return code; - code = cci_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, header->version, principal, &ccache); if (code != ccNoError) return code; @@ -731,12 +738,12 @@ ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = (cc_handle) ccache; + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, +ccop_CTX_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -758,9 +765,10 @@ ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, return code; principal[header->principal_len] = '\0'; /*Ensure null termination*/ - // TODO: Generate a unique ccache name + // TODO: Generate a unique ccache name + name = "unique"; - code = cci_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, header->version, principal, &ccache); if (code != ccNoError) return code; @@ -768,8 +776,8 @@ ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = (cc_handle) ccache; + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -797,13 +805,13 @@ ccop_CCACHE_DESTROY( cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_release_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - cci_ccache_destroy(ccache); + ccs_ccache_destroy(ccache); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -823,32 +831,32 @@ ccop_CCACHE_SET_DEFAULT(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_set_default_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); if (ccache == (cc_server_ccache_t*)ctx->ccaches->head->data) /*already default*/ - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); old_default = (cc_server_ccache_t*)ctx->ccaches->head->data; old_default->last_default = time(NULL); - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator,&ccache_node); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator,&ccache_node); stored_ccache = (cc_server_ccache_t*)ccache_node->data; if (stored_ccache == ccache) { ccache_node->data = NULL; /*don't want list removal code free()ing ccache*/ - cci_ccache_list_remove_element(ctx->ccaches, ccache_node); - cci_ccache_list_prepend(ctx->ccaches, ccache, NULL); + ccs_ccache_list_remove_element(ctx->ccaches, ccache_node); + ccs_ccache_list_prepend(ctx->ccaches, ccache, NULL); break; } } - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -867,16 +875,16 @@ ccop_CCACHE_GET_CREDS_VERSION(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_get_creds_version_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_creds_version_resp_t*)malloc(sizeof(ccmsg_ccache_get_creds_version_resp_t)); if (resp_header == NULL) return ccErrNoMem; resp_header->version = ccache->versions; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_creds_version_resp_t), auth_info, session_info, resp_msg); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_creds_version_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -895,9 +903,9 @@ ccop_CCACHE_GET_NAME(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_get_name_resp_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (ccache == NULL) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_name_resp_t*)malloc(sizeof(ccmsg_ccache_get_name_resp_t)); if (resp_header == NULL) @@ -931,13 +939,13 @@ ccop_CCACHE_GET_PRINCIPAL(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_get_principal_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_ccache_get_principal(ccache, header->version, &principal); + code = ccs_ccache_get_principal(ccache, header->version, &principal); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); code = cci_msg_new(ccmsg_ACK, resp_msg); if (code != ccNoError) @@ -969,26 +977,26 @@ ccop_CCACHE_SET_PRINCIPAL(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_set_principal_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); - code = cci_ccache_set_principal(ccache, header->version, principal); + code = ccs_ccache_set_principal(ccache, header->version, principal); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREDS_ITERATOR(cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, cc_msg_t **resp_msg) +ccop_CCACHE_NEW_CREDS_ITERATOR( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, cc_msg_t **resp_msg) { cc_server_ccache_t* ccache; cc_credentials_iterate_t* creds_iterator; @@ -1001,11 +1009,11 @@ ccop_CCACHE_CREDS_ITERATOR(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_creds_iterator_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_ccache_new_iterator(ccache, &creds_iterator); + code = ccs_ccache_new_iterator(ccache, &creds_iterator); if (code != ccNoError) return code; @@ -1013,13 +1021,13 @@ ccop_CCACHE_CREDS_ITERATOR(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->iterator = creds_iterator; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_creds_iterator_resp_t), auth_info, session_info, resp_msg); + resp_header->iterator = (cc_handle) creds_iterator; + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_creds_iterator_resp_t), auth_info, session_info, resp_msg); } static cc_int32 -cci_credentials_union_release( cc_credentials_union * creds ) +ccs_credentials_union_release( cc_credentials_union * creds ) { int i; @@ -1076,9 +1084,9 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_store_creds_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO: This code is too simplistic. cc_credential_unions are not flat // structures and must be flattened. That means that although we can @@ -1086,7 +1094,7 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, // into the actual object. code = cci_msg_retrieve_blob(msg, header->creds_offset, header->creds_len, &flat_creds); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); creds = (cc_credentials_union *)malloc(sizeof(cc_credentials_union)); if ( creds == NULL ) @@ -1100,18 +1108,18 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, code = cci_creds_v5_unmarshall(flat_creds, header->creds_len, creds); break; default: - return cci_serv_make_nack(ccErrBadCredentialsVersion, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadCredentialsVersion, auth_info, session_info, resp_msg); } if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - code = cci_ccache_store_creds(ccache, creds); - cci_credentials_union_release(creds); + code = ccs_ccache_store_creds(ccache, creds); + ccs_credentials_union_release(creds); if (code != ccNoError) { - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); } - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1129,15 +1137,15 @@ ccop_CCACHE_REM_CREDS(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_rem_creds_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_ccache_rem_creds(ccache, header->creds); + code = ccs_ccache_rem_creds(ccache, (const cc_credentials_union *)header->creds); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1147,7 +1155,7 @@ ccop_CCACHE_LOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -1157,7 +1165,7 @@ ccop_CCACHE_UNLOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -1167,7 +1175,7 @@ ccop_CCACHE_MOVE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } @@ -1187,16 +1195,16 @@ ccop_CCACHE_GET_LAST_DEFAULT_TIME(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_get_last_default_time_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_last_default_time_resp_t*)malloc(sizeof(ccmsg_ccache_get_last_default_time_resp_t)); if (resp_header == NULL) return ccErrNoMem; resp_header->last_default_time = ccache->last_default; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_last_default_time_resp_t), auth_info, session_info, resp_msg); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_last_default_time_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1221,7 +1229,7 @@ ccop_CCACHE_GET_CHANGE_TIME( cc_server_context_t* ctx, } resp_header->time = ccache->changed; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_change_time_resp_t), auth_info, session_info, resp_msg); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_change_time_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1240,20 +1248,20 @@ ccop_CCACHE_COMPARE(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_compare_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache1, &ccache1); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache1, &ccache1); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_serv_find_ccache_by_handle(ctx, header->ccache2, &ccache2); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache2, &ccache2); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_compare_resp_t*)malloc(sizeof(ccmsg_ccache_compare_resp_t)); if (resp_header == NULL) return ccErrNoMem; - cci_ccache_compare(ccache1, ccache2, &resp_header->is_equal); - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_compare_resp_t), auth_info, session_info, resp_msg); + ccs_ccache_compare(ccache1, ccache2, &resp_header->is_equal); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_compare_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1265,7 +1273,7 @@ ccop_CCACHE_GET_KDC_TIME_OFFSET(cc_server_context_t* ctx, ccmsg_ccache_get_kdc_time_offset_t* header = (ccmsg_ccache_get_kdc_time_offset_t*)msg->header; ccmsg_ccache_get_kdc_time_offset_resp_t* resp_header; cc_server_ccache_t* ccache; - cc_time_t offset; + cc_time64 offset; cc_int32 code; *resp_msg = 0; @@ -1273,22 +1281,22 @@ ccop_CCACHE_GET_KDC_TIME_OFFSET(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_get_kdc_time_offset_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO How is the header->creds_version supposed to be used? - code = cci_ccache_get_kdc_time_offset(ccache, &offset); + code = ccs_ccache_get_kdc_time_offset(ccache, &offset); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_kdc_time_offset_resp_t*)malloc(sizeof(ccmsg_ccache_get_kdc_time_offset_resp_t)); if (resp_header == NULL) return ccErrNoMem; resp_header->offset = offset; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_kdc_time_offset_resp_t), auth_info, session_info, resp_msg); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_kdc_time_offset_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1306,14 +1314,14 @@ ccop_CCACHE_SET_KDC_TIME_OFFSET(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_set_kdc_time_offset_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO How is the header->creds_version supposed to be used? - cci_ccache_set_kdc_time_offset(ccache, header->offset); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + ccs_ccache_set_kdc_time_offset(ccache, header->offset); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1331,14 +1339,14 @@ ccop_CCACHE_CLEAR_KDC_TIME_OFFSET(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_clear_kdc_time_offset_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO How is the header->creds_version supposed to be used? - cci_ccache_clear_kdc_time_offset(ccache); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + ccs_ccache_clear_kdc_time_offset(ccache); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1356,17 +1364,27 @@ ccop_CCACHE_ITERATOR_RELEASE(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_iterator_release_t)) return ccErrBadParam; - code = cci_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); + code = ccs_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); code = cci_generic_list_remove_element(ctx->active_iterators, gen_node); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } +cc_int32 +ccop_CCACHE_ITERATOR_CLONE( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, cc_msg_t **resp_msg) +{ + // TODO + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); +} + cc_int32 ccop_CCACHE_ITERATOR_NEXT(cc_server_context_t* ctx, cc_auth_info_t* auth_info, @@ -1385,24 +1403,24 @@ ccop_CCACHE_ITERATOR_NEXT(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_ccache_iterator_next_t)) return ccErrBadParam; - code = cci_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); + code = ccs_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); ccache_iterator = (cc_ccache_iterate_t*)gen_node->data; - if (cci_ccache_iterate_has_next(ccache_iterator)) { + if (ccs_ccache_iterate_has_next(ccache_iterator)) { resp_header = (ccmsg_ccache_iterator_next_resp_t*)malloc(sizeof(ccmsg_ccache_iterator_next_resp_t)); if (resp_header == NULL) return ccErrNoMem; - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - resp_header->ccache = ccache_node; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_iterator_next_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = (cc_handle) ccache_node; + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_iterator_next_resp_t), auth_info, session_info, resp_msg); } else { - return cci_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); } } @@ -1422,21 +1440,32 @@ ccop_CREDS_ITERATOR_RELEASE(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_creds_iterator_release_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); + code = ccs_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); code = cci_generic_list_remove_element(ccache->active_iterators, gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } +cc_int32 +ccop_CREDS_ITERATOR_CLONE( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, cc_msg_t **resp_msg) +{ + // TODO + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); +} + + cc_int32 ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, cc_auth_info_t* auth_info, @@ -1458,16 +1487,16 @@ ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, if (msg->header_len != sizeof(ccmsg_creds_iterator_next_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); + code = ccs_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); creds_iterator = (cc_credentials_iterate_t*)gen_node->data; - if (cci_credentials_iterate_has_next(creds_iterator)) { + if (ccs_credentials_iterate_has_next(creds_iterator)) { code = cci_msg_new(ccmsg_ACK, resp_msg); if (code != ccNoError) return code; @@ -1476,14 +1505,14 @@ ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - code = cci_credentials_iterate_next(creds_iterator, &creds_node); + code = ccs_credentials_iterate_next(creds_iterator, &creds_node); stored_creds = (cc_server_credentials_t*)creds_node->data; creds_union = &stored_creds->creds; code = cci_msg_add_data_blob(*resp_msg, creds_union, sizeof(cc_credentials_union), &resp_header->creds_offset); code = cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_creds_iterator_next_resp_t)); } else { - cci_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); + ccs_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); } return ccNoError; } @@ -1495,6 +1524,6 @@ ccop_CREDS_RELEASE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { - cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); return ccNoError; } diff --git a/src/lib/ccapi/server/serv_ops.h b/src/lib/ccapi/server/serv_ops.h index f43956685..152188636 100644 --- a/src/lib/ccapi/server/serv_ops.h +++ b/src/lib/ccapi/server/serv_ops.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -63,52 +63,88 @@ struct type_to_op_mapping_t { }; typedef struct type_to_op_mapping_t type_to_op_mapping_t; -cc_int32 cci_serv_initialize(void); -cc_int32 cci_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg); -cc_int32 cci_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** contextp); -cc_int32 cci_serv_find_ctx_by_handle(cc_handle ctx_handle, cc_auth_info_t *auth, cc_session_info_t* session, cc_server_context_t** contextp); -cc_int32 cci_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache_handle, cc_server_ccache_t** ccachep) ; -cc_int32 cci_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodep); -cc_int32 cci_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodep); -cc_int32 cci_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); -cc_int32 cci_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); - -cc_int32 ccop_INIT( +cc_int32 ccs_serv_initialize(void); +cc_int32 ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg); +cc_int32 ccs_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** contextp); +cc_int32 ccs_serv_find_ctx_by_handle(cc_handle ctx_handle, cc_auth_info_t *auth, cc_session_info_t* session, cc_server_context_t** contextp); +cc_int32 ccs_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache_handle, cc_server_ccache_t** ccachep) ; +cc_int32 ccs_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodep); +cc_int32 ccs_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodep); +cc_int32 ccs_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); +cc_int32 ccs_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); + +cc_int32 +ccop_INIT( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CTX_RELEASE( +cc_int32 +ccop_CTX_RELEASE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CTX_GET_CHANGE_TIME( +cc_int32 +ccop_CTX_GET_CHANGE_TIME( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CTX_GET_DEFAULT_CCACHE_NAME( +cc_int32 +ccop_CTX_GET_DEFAULT_CCACHE_NAME( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CTX_COMPARE( +cc_int32 +ccop_CTX_CCACHE_OPEN( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CTX_NEW_CCACHE_ITERATOR( +cc_int32 +ccop_CTX_CCACHE_OPEN_DEFAULT( + cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, + cc_msg_t **resp_msg); + +cc_int32 +ccop_CTX_CCACHE_CREATE( + cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, + cc_msg_t **resp_msg); + +cc_int32 +ccop_CTX_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, + cc_msg_t **resp_msg); + +cc_int32 +ccop_CTX_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, + cc_msg_t **resp_msg); + +cc_int32 +ccop_CTX_NEW_CCACHE_ITERATOR( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, @@ -129,28 +165,24 @@ ccop_CTX_UNLOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 -ccop_CTX_CLONE( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_OPEN( +cc_int32 +ccop_CTX_COMPARE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_OPEN_DEFAULT( +cc_int32 +ccop_CCACHE_RELEASE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_CREATE( +cc_int32 +ccop_CCACHE_DESTROY( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, @@ -158,90 +190,95 @@ cc_int32 ccop_CCACHE_CREATE( cc_msg_t **resp_msg); cc_int32 -ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_RELEASE( +ccop_CCACHE_SET_DEFAULT( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_DESTROY( +cc_int32 +ccop_CCACHE_GET_CREDS_VERSION( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_SET_DEFAULT( +cc_int32 +ccop_CCACHE_GET_NAME( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_GET_CREDS_VERSION( +cc_int32 +ccop_CCACHE_GET_PRINCIPAL( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_GET_NAME( +cc_int32 +ccop_CCACHE_SET_PRINCIPAL( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_GET_PRINCIPAL( +cc_int32 +ccop_CCACHE_STORE_CREDS( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_SET_PRINCIPAL( +cc_int32 +ccop_CCACHE_REM_CREDS( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_CREDS_ITERATOR( +cc_int32 +ccop_CCACHE_NEW_CREDS_ITERATOR( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_STORE_CREDS( +cc_int32 +ccop_CCACHE_MOVE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_REM_CREDS( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); +cc_int32 +ccop_CCACHE_LOCK( + cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, + cc_msg_t **resp_msg); + +cc_int32 +ccop_CCACHE_UNLOCK( + cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, + cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_GET_LAST_DEFAULT_TIME( +cc_int32 +ccop_CCACHE_GET_LAST_DEFAULT_TIME( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, @@ -256,63 +293,80 @@ ccop_CCACHE_GET_CHANGE_TIME( cc_msg_t *msg, cc_msg_t **resp_msg) ; -cc_int32 ccop_CCACHE_COMPARE( +cc_int32 +ccop_CCACHE_COMPARE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_GET_KDC_TIME_OFFSET( +cc_int32 +ccop_CCACHE_GET_KDC_TIME_OFFSET( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_SET_KDC_TIME_OFFSET( +cc_int32 +ccop_CCACHE_SET_KDC_TIME_OFFSET( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_CLEAR_KDC_TIME_OFFSET( +cc_int32 +ccop_CCACHE_CLEAR_KDC_TIME_OFFSET( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_ITERATOR_RELEASE( +cc_int32 +ccop_CCACHE_ITERATOR_RELEASE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CCACHE_ITERATOR_NEXT( +cc_int32 +ccop_CCACHE_ITERATOR_NEXT( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CREDS_ITERATOR_RELEASE( +cc_int32 +ccop_CCACHE_ITERATOR_CLONE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CREDS_ITERATOR_NEXT( +cc_int32 +ccop_CREDS_ITERATOR_RELEASE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg); -cc_int32 ccop_CREDS_RELEASE( +cc_int32 +ccop_CREDS_ITERATOR_NEXT( + cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, + cc_msg_t **resp_msg); + +cc_int32 +ccop_CREDS_ITERATOR_CLONE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, diff --git a/src/lib/ccapi/unit-test/NTMakefile b/src/lib/ccapi/unit-test/NTMakefile new file mode 100644 index 000000000..eb2fd53e2 --- /dev/null +++ b/src/lib/ccapi/unit-test/NTMakefile @@ -0,0 +1,30 @@ +# Makefile for the CCAPI Generic Server + +!INCLUDE + +CFLAGS = -I../include + +CCAPI_LIB = ../lib/ccapi.lib +WINLIBS = user32.lib advapi32.lib +CCSOBJS = context.obj ccache.obj lists.obj rpc_auth.obj serv_ops.obj + +all: t_lists.exe t_msg.exe t_ccache.exe t_context.exe ccapi_server.exe + +t_lists.exe: t_lists.obj $(CCSOBJS) $(CCAPI_LIB) + link -out:$@ t_lists.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) + +t_msg.exe: t_msg.obj $(CCSOBJS) $(CCAPI_LIB) + link -out:$@ t_msg.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) + +t_ccache.exe: t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) + link -out:$@ t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) + +t_context.exe: t_context.obj $(CCSOBJS) $(CCAPI_LIB) + link -out:$@ t_context.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) + +ccapi_server.exe: main.obj $(CCSOBJS) $(CCAPI_LIB) + link -out:$@ main.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) + +clean: + del *.obj *.exe + diff --git a/src/lib/ccapi/windows/rpcsstest/NTMakefile b/src/lib/ccapi/windows/rpcsstest/NTMakefile new file mode 100644 index 000000000..0e2330707 --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/NTMakefile @@ -0,0 +1,24 @@ + +!include + +{}.c{}.obj: + $(CC) $(cdebug) $(cflags) /Fo"$@" /c $** + +EXECONLINK=link /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** + +CLIENTEXE=csclient.exe + +SERVEREXE=csserver.exe + +SDKLIBS=rpcrt4.lib + +cstest_c.c cstest_s.c cstest.h: cstest.idl cstest.acf + midl cstest.idl /acf cstest.acf + +$(CLIENTEXE): client.obj cstest_c.obj + $(EXECONLINK) $(SDKLIBS) + +$(SERVEREXE): server.obj cstest_s.obj + $(EXECONLINK) $(SDKLIBS) + +all: $(SERVEREXE) $(CLIENTEXE) diff --git a/src/lib/ccapi/windows/rpcsstest/client.c b/src/lib/ccapi/windows/rpcsstest/client.c new file mode 100644 index 000000000..a25e8d1ad --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/client.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include"cstest.h" +#include + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +int main(int argc, char ** argv) { + RPC_STATUS status; + RPC_BINDING_HANDLE h; + TCHAR * bindstring = NULL; + RPC_SECURITY_QOS sqos; + char inbuf[256]; + char outbuf[256]; + long cb_out; + + status = RpcStringBindingCompose(NULL, + _T("ncalrpc"), + NULL, + NULL, + NULL, + &bindstring); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcStringBindingCompose failed: %d\n", + status); + return 1; + } + + status = RpcBindingFromStringBinding(bindstring, + &h); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingFromStringBinding failed: %d\n", + status); + return 1; + } + + ZeroMemory(&sqos, sizeof(sqos)); + + sqos.Version = 1; + sqos.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT; + sqos.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC; + sqos.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE; + + status = RpcBindingSetAuthInfoEx(h, + NULL, + RPC_C_AUTHN_LEVEL_CALL, + RPC_C_AUTHN_WINNT, + NULL, + 0, + &sqos); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingSetAuthInfoEx failed: %d\n", + status); + return 1; + } + + StringCbCopyA(inbuf, sizeof(inbuf), "Echo Test 1"); + StringCbCopyA(outbuf, sizeof(outbuf), "Blank blank blank"); + + printf("Before call: in[%s], out[%s]\n", inbuf, outbuf); + cb_out = 0; + + status = EchoString(h, inbuf, sizeof(outbuf), &cb_out, outbuf); + + if (status) { + printf("Call failed: status = %d\n", status); + } else { + printf("After call: out[%s], outlen[%d]\n", outbuf, cb_out); + } + + status = RpcBindingFree(&h); + + status = RpcStringFree(&bindstring); + + return 0; +} diff --git a/src/lib/ccapi/windows/rpcsstest/cstest.acf b/src/lib/ccapi/windows/rpcsstest/cstest.acf new file mode 100644 index 000000000..3c2ae73ab --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/cstest.acf @@ -0,0 +1,8 @@ +[ + explicit_handle +] + +interface ccapi_cstest +{ + +} \ No newline at end of file diff --git a/src/lib/ccapi/windows/rpcsstest/cstest.idl b/src/lib/ccapi/windows/rpcsstest/cstest.idl new file mode 100644 index 000000000..c51b8ee82 --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/cstest.idl @@ -0,0 +1,14 @@ +[ +uuid(c8b4a635-e9e4-4650-a073-b25610324950), + version(1.0), + pointer_default(unique) +] + +interface ccapi_cstest +{ + long EchoString([in] handle_t h, + [in, string] unsigned char * in_str, + [in] long cb_buffer, + [out] long * cb_len, + [out, string, size_is(cb_buffer)] unsigned char buffer[*]); +} diff --git a/src/lib/ccapi/windows/rpcsstest/server.c b/src/lib/ccapi/windows/rpcsstest/server.c new file mode 100644 index 000000000..f127434b5 --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/server.c @@ -0,0 +1,537 @@ +#include +#include +#include +#include +#include +#include"cstest.h" +#include + +#define SVCNAME "CCAPICSTest" + +SERVICE_STATUS_HANDLE h_service_status = NULL; +SERVICE_STATUS service_status; +FILE * logfile = NULL; + +void begin_log(void) { + char temppath[512]; + + temppath[0] = L'\0'; + + GetTempPathA(sizeof(temppath), temppath); + StringCbCatA(temppath, sizeof(temppath), "csserverconn.log"); + logfile = fopen(temppath, "w"); +} + +void end_log(void) { + if (logfile) { + fclose(logfile); + logfile = NULL; + } +} + +BOOL report_status(DWORD state, + DWORD exit_code, + DWORD wait_hint) { + static DWORD checkpoint = 1; + BOOL rv = TRUE; + + if (state == SERVICE_START_PENDING) + service_status.dwControlsAccepted = 0; + else + service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP; + + service_status.dwCurrentState = state; + service_status.dwWin32ExitCode = exit_code; + service_status.dwWaitHint = wait_hint; + + if (state == SERVICE_RUNNING || + state == SERVICE_STOPPED) + service_status.dwCheckPoint = 0; + else + service_status.dwCheckPoint = checkpoint++; + + rv = SetServiceStatus(h_service_status, &service_status); + + return rv; +} + +void service_start(DWORD argc, LPTSTR * argv) { + RPC_STATUS status; + RPC_BINDING_VECTOR * bv; + + status = RpcServerUseProtseq("ncalrpc", + RPC_C_PROTSEQ_MAX_REQS_DEFAULT, + NULL); + + if (status != RPC_S_OK) { + return; + } + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterIf(ccapi_cstest_v1_0_s_ifspec, + 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerInqBindings(&bv); + + if (status != RPC_S_OK) + return; + + status = RpcEpRegister(ccapi_cstest_v1_0_s_ifspec, + bv, 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterAuthInfo(NULL, + RPC_C_AUTHN_WINNT, + 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerListen(1, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, + TRUE); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_RUNNING, NO_ERROR, 0); + + begin_log(); + + status = RpcMgmtWaitServerListen(); + + end_log(); + + RpcEpUnregister(ccapi_cstest_v1_0_s_ifspec, bv, 0); + + RpcBindingVectorFree(&bv); +} + +void service_stop(void) { + RpcMgmtStopServerListening(0); +} + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +typedef struct tag_client_info { + char client_name[512]; + LUID luid; +} client_info_t; + +RPC_STATUS check_auth(handle_t h, client_info_t * client_info) { + RPC_BINDING_HANDLE bh = (RPC_BINDING_HANDLE) h; + RPC_STATUS status; + HANDLE htoken = NULL; + char name[256]; + char domain[256]; + DWORD name_len; + DWORD domain_len; + SID_NAME_USE snu = 0; + + struct { + TOKEN_ORIGIN origin; + char pad[512]; + } torigin; + + struct { + TOKEN_OWNER owner; + char pad[4096]; + } towner; + + DWORD len; + + status = RpcImpersonateClient(bh); + + if (status != RPC_S_OK) + return status; + + if (!OpenThreadToken(GetCurrentThread(), + TOKEN_READ | TOKEN_QUERY_SOURCE, + FALSE, + &htoken)) { + status = GetLastError(); + goto _cleanup; + } + + len = 0; + + if (!GetTokenInformation(htoken, + TokenOrigin, + &torigin.origin, + sizeof(torigin), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + if (!GetTokenInformation(htoken, + TokenOwner, + &towner.owner, + sizeof(towner), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + + name_len = sizeof(name)/sizeof(name[0]); + domain_len = sizeof(domain)/sizeof(domain[0]); + + if (!LookupAccountSidA(NULL, + towner.owner.Owner, + name, + &name_len, + domain, + &domain_len, + &snu)) { + status = GetLastError(); + goto _cleanup; + } + + client_info->luid = torigin.origin.OriginatingLogonSession; + StringCbPrintfA(client_info->client_name, + sizeof(client_info->client_name), + "%s\\%s", domain, name); + + status = 0; + + _cleanup: + + RpcRevertToSelf(); + + return status; +} + +long EchoString( + /* [in] */ handle_t h, + /* [string][in] */ unsigned char *in_str, + /* [in] */ long cb_buffer, + /* [out] */ long *cb_len, + /* [size_is][string][out] */ unsigned char buffer[ ]) { + + size_t cb; + long rv = 0; + client_info_t client_info; + + rv = check_auth(h, &client_info); + + if (rv == 0 && logfile) { + fprintf(logfile, + "Client name [%s], LUID [%x:%x]\n", + client_info.client_name, + (client_info.luid.HighPart), + (client_info.luid.LowPart)); + fflush(logfile); + } + + if (!in_str) { + rv = 1; + if (cb_len) + *cb_len = 0; + if (buffer) + buffer[0] = '\0'; + } else { + if (FAILED(StringCbLengthA(in_str, 256, &cb))) { + rv = 2; + goto _exit_f; + } + + cb += sizeof(char); + + if (((long)cb) > cb_buffer) { + rv = 3; + goto _exit_f; + } + + *cb_len = cb; + + if (buffer) + StringCbCopyA(buffer, cb_buffer, in_str); + + rv = 0; + } + + _exit_f: + + return rv; +} + +void WINAPI service_control(DWORD ctrl_code) { + switch(ctrl_code) { + case SERVICE_CONTROL_STOP: + report_status(SERVICE_STOP_PENDING, NO_ERROR, 0); + service_stop(); + return; + + /* everything else falls through */ + } + + report_status(service_status.dwCurrentState, NO_ERROR, 0); +} + +void WINAPI service_main(DWORD argc, LPTSTR * argv) { + + h_service_status = RegisterServiceCtrlHandler( _T(SVCNAME), service_control); + + if (!h_service_status) + goto cleanup; + + ZeroMemory(&service_status, sizeof(service_status)); + + service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + service_status.dwServiceSpecificExitCode = 0; + + if (!report_status(SERVICE_START_PENDING, + NO_ERROR, + 3000)) + goto cleanup; + + service_start(argc, argv); + + cleanup: + + if (h_service_status) { + report_status(SERVICE_STOPPED, NO_ERROR, 0); + } +} + + +BOOL +IsInstalled() +{ + BOOL bResult = FALSE; + SC_HANDLE hSCM; + SC_HANDLE hService; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (hSCM) { + + // Try to open the service + hService = OpenService( hSCM, + SVCNAME, + SERVICE_QUERY_CONFIG); + if (hService) { + bResult = TRUE; + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + } + + return bResult; +} + +BOOL +Install() +{ + char szFilePath[_MAX_PATH]; + SC_HANDLE hSCM; + SC_HANDLE hService; + TCHAR szKey[256]; + HKEY hKey = NULL; + DWORD dwData; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + // Get the executable file path + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + + // Create the service + hService = CreateService( hSCM, + SVCNAME, + SVCNAME, + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, + SERVICE_AUTO_START, // start condition + SERVICE_ERROR_NORMAL, + szFilePath, + NULL, + NULL, + NULL, + NULL, + NULL); + if (!hService) { + CloseServiceHandle(hSCM); + return FALSE; + } + + // make registry entries to support logging messages + // Add the source name as a subkey under the Application + // key in the EventLog service portion of the registry. + StringCbCopyA(szKey, 256, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\IKSD"); + if (RegCreateKey(HKEY_LOCAL_MACHINE, szKey, &hKey) != ERROR_SUCCESS) { + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return FALSE; + } + + // Add the Event ID message-file name to the 'EventMessageFile' subkey. + RegSetValueEx( hKey, + "EventMessageFile", + 0, + REG_EXPAND_SZ, + (CONST BYTE*)szFilePath, + strlen(szFilePath) + 1); + + // Set the supported types flags. + dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; + RegSetValueEx( hKey, + "TypesSupported", + 0, + REG_DWORD, + (CONST BYTE*)&dwData, + sizeof(DWORD)); + RegCloseKey(hKey); + + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_INSTALLED, SVCNAME); + + // tidy up + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return TRUE; +} + +BOOL +Uninstall() +{ + BOOL bResult = FALSE; + SC_HANDLE hService; + SC_HANDLE hSCM; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + hService = OpenService( hSCM, + SVCNAME, + DELETE); + if (hService) { + if (DeleteService(hService)) { + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_REMOVED, SVCNAME); + bResult = TRUE; + } else { + // LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_NOTREMOVED, SVCNAME); + } + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + return bResult; +} + + +// Returns TRUE if it found an arg it recognised, FALSE if not +// Note: processing some arguments causes output to stdout to be generated. +BOOL +ParseStandardArgs(int argc, char* argv[]) +{ + char szFilePath[_MAX_PATH]; + + // See if we have any command line args we recognize + if (argc <= 1) + return FALSE; + + if ( _stricmp(argv[1], "-h") == 0 || + _stricmp(argv[1], "-?") == 0 || + _stricmp(argv[1], "/h") == 0 || + _stricmp(argv[1], "/?") == 0) { + + // + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "usage: %s [-v | -i | -u | -h]\r\n",szFilePath); + return TRUE; + } else if (_stricmp(argv[1], "-v") == 0 || + _stricmp(argv[1], "/v") == 0 ) { + + // Spit out version info + fprintf(stderr, "%s Version 0.1\n",_T(SVCNAME)); + fprintf(stderr, "The service is %s installed\n", + IsInstalled() ? "currently" : "not"); + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-i") == 0 || + _stricmp(argv[1], "/i") == 0) { + + // Request to install. + if (IsInstalled()) { + fprintf(stderr, "%s is already installed\n", _T(SVCNAME)); + } else { + // Try and install the copy that's running + if (Install()) { + fprintf(stderr, "%s installed\n", _T(SVCNAME)); + } else { + fprintf(stderr, "%s failed to install. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-u") == 0 || + _stricmp(argv[1], "/u") == 0) { + + // Request to uninstall. + if (!IsInstalled()) { + fprintf(stderr, "%s is not installed\n", _T(SVCNAME)); + } else { + // Try and remove the copy that's installed + if (Uninstall()) { + // Get the executable file path + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "%s removed. (You must delete the file (%s) yourself.)\n" + _T(SVCNAME), szFilePath); + } else { + fprintf(stderr, "Could not remove %s. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } + + // Don't recognise the args + return FALSE; +} + +int main(int argc, char ** argv) { + + SERVICE_TABLE_ENTRY dispatch_table[] = { + { _T(SVCNAME), (LPSERVICE_MAIN_FUNCTION) service_main }, + { NULL, NULL } + }; + + if ( ParseStandardArgs(argc, argv) ) + return 0; + + if (!StartServiceCtrlDispatcher(dispatch_table)) { + fprintf(stderr, "Can't start service control dispatcher\n"); + } + + return 0; +} -- cgit From d68adb389e9c1926f4f8c9a0e6132e6dd97ed32b Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 21 May 2006 03:48:39 +0000 Subject: Construct an outline of a sample platform specific main.c Add ccs_serv_cleanup() routine. Currently does nothing. Correct field names used within the authorization check. git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18025 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/server/main.c | 52 +++++++++++++++++++++++++++++++++++++++++ src/lib/ccapi/server/rpc_auth.c | 7 ++++-- src/lib/ccapi/server/rpc_auth.h | 4 ++-- src/lib/ccapi/server/serv_ops.c | 13 +++++++++-- src/lib/ccapi/server/serv_ops.h | 1 + 5 files changed, 71 insertions(+), 6 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/server/main.c b/src/lib/ccapi/server/main.c index cf69af312..dbd447f66 100644 --- a/src/lib/ccapi/server/main.c +++ b/src/lib/ccapi/server/main.c @@ -1,12 +1,64 @@ #include #include +#include "CredentialsCache.h" +#include "msg.h" +#include "rpc_auth.h" + +/* This object module is platform dependent. */ int main( int argc, char *argv[] ) { + cc_int32 code; + int running = 1; + /* we need a set of functions we want to support. * so we can provide an abstract platform independent * interface. */ + code = ccs_serv_initialize(); + if (code) { + /* ok. we failed to initialize the ccs data structures. + * terminate service start. Log the result. + */ + fprintf(stderr, "ccs_serv_initialize failure: %d\n", code); + return -1; + } + + /* initialize the IPC mechanism for this platform */ + + /* implement a message loop that receives in-bound requests + * processes them, and sends back responses. + */ + while ( running ) { + cc_msg_t * req_msg, *resp_msg; + cc_auth_info_t* auth_info; + cc_session_info_t* session_info; + char * data; + int len; + + /* accept IPC request */ + + /* unflatten input stream to msg */ + code = cci_msg_unflatten(data, len, &req_msg); + + /* process request */ + code = ccs_serv_process_msg(req_msg, auth_info, session_info, &resp_msg); + + code = cci_msg_flatten(resp_msg, NULL); + + /* send response (resp_msg->flat, resp_msg->flat_len) */ + + /* cleanup */ + cci_msg_destroy(req_msg); + cci_msg_destroy(resp_msg); + } + + /* de-register IPC mechanism */ + + /* cleanup ccs resources */ + ccs_serv_cleanup(); + + /* exit */ return 0; } diff --git a/src/lib/ccapi/server/rpc_auth.c b/src/lib/ccapi/server/rpc_auth.c index dd338e010..66bc6aee9 100644 --- a/src/lib/ccapi/server/rpc_auth.c +++ b/src/lib/ccapi/server/rpc_auth.c @@ -49,10 +49,13 @@ #include "rpc_auth.h" cc_int32 -cci_rpc_is_authorized( cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, +ccs_rpc_is_authorized( cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 * authorizedp) { - if (msg_auth == stored_auth && msg_session == stored_session) + if (msg_auth->len == stored_auth->len && + !memcmp(msg_auth->info, stored_auth->info, msg_auth->len) && + msg_session->len == stored_session->len && + !memcmp(msg_session->info, stored_session->info, msg_session->len)) *authorizedp = 1; else *authorizedp = 0; diff --git a/src/lib/ccapi/server/rpc_auth.h b/src/lib/ccapi/server/rpc_auth.h index 21d7db501..010a1e2a5 100644 --- a/src/lib/ccapi/server/rpc_auth.h +++ b/src/lib/ccapi/server/rpc_auth.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -66,6 +66,6 @@ struct cc_session_info_t { }; typedef struct cc_session_info_t cc_session_info_t; -cc_int32 cci_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp); +cc_int32 ccs_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp); #endif /*__RPC_AUTH_H__*/ diff --git a/src/lib/ccapi/server/serv_ops.c b/src/lib/ccapi/server/serv_ops.c index 360536a92..fb279e694 100644 --- a/src/lib/ccapi/server/serv_ops.c +++ b/src/lib/ccapi/server/serv_ops.c @@ -76,6 +76,9 @@ ccs_serv_initialize(void) } #if 0 + /* These message types are only generated by the server in response + * to a request. They are never received. + */ TypeToOpMapping->operations[ccmsg_ACK] = ccop_ACK; TypeToOpMapping->operations[ccmsg_NACK] = ccop_NACK; #endif @@ -121,6 +124,12 @@ ccs_serv_initialize(void) return ccNoError; }; +cc_int32 +ccs_serv_cleanup(void) +{ + return ccNoError; +} + cc_int32 ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) { @@ -175,7 +184,7 @@ ccs_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, return code; } ctx = (cc_server_context_t *)ctx_node->data; - code = cci_rpc_is_authorized(auth_info, session_info, ctx->auth_info, ctx->session_info, &authorized); + code = ccs_rpc_is_authorized(auth_info, session_info, ctx->auth_info, ctx->session_info, &authorized); if (code != ccNoError) { ccs_context_free_iterator(ctx_iterator); return code; @@ -213,7 +222,7 @@ ccs_serv_find_ctx_by_handle(cc_handle ctx_num, cc_auth_info_t* auth, cc_session_ return code; } - code = cci_rpc_is_authorized(auth, session, ctx->auth_info, ctx->session_info, &authorized); + code = ccs_rpc_is_authorized(auth, session, ctx->auth_info, ctx->session_info, &authorized); if (code != ccNoError) { ccs_context_free_iterator(ctx_iterator); return code; diff --git a/src/lib/ccapi/server/serv_ops.h b/src/lib/ccapi/server/serv_ops.h index 152188636..1433e0f15 100644 --- a/src/lib/ccapi/server/serv_ops.h +++ b/src/lib/ccapi/server/serv_ops.h @@ -64,6 +64,7 @@ struct type_to_op_mapping_t { typedef struct type_to_op_mapping_t type_to_op_mapping_t; cc_int32 ccs_serv_initialize(void); +cc_int32 ccs_serv_cleanup(void); cc_int32 ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg); cc_int32 ccs_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** contextp); cc_int32 ccs_serv_find_ctx_by_handle(cc_handle ctx_handle, cc_auth_info_t *auth, cc_session_info_t* session, cc_server_context_t** contextp); -- cgit From 79cff381ad80f2c017268b6b9d01b828e7aafc34 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 22 May 2006 06:25:43 +0000 Subject: More byte order conversions in the server operations code git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18026 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/server/serv_ops.c | 265 +++++++++++++++++++++++----------------- 1 file changed, 156 insertions(+), 109 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/server/serv_ops.c b/src/lib/ccapi/server/serv_ops.c index fb279e694..01a9742cd 100644 --- a/src/lib/ccapi/server/serv_ops.c +++ b/src/lib/ccapi/server/serv_ops.c @@ -135,6 +135,9 @@ ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_ { cc_server_context_t* ctx; ccmsg_ctx_only_t* header = (ccmsg_ctx_only_t *)msg->header; + cc_uint32 type; + cc_uint32 header_len; + cc_handle handle; cc_int32 code; if (msg == NULL || msg->header == NULL || auth_info == NULL || session_info == NULL) @@ -146,19 +149,22 @@ ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_ return code; } - if (msg->type == ccmsg_INIT) { - return TypeToOpMapping->operations[msg->type] (NULL, auth_info, session_info, msg, resp_msg); + type = ntohl(msg->type); + if (type == ccmsg_INIT) { + return TypeToOpMapping->operations[type] (NULL, auth_info, session_info, msg, resp_msg); } else { - if (msg->header_len < sizeof(ccmsg_ctx_only_t)) { + header_len = ntohl(msg->header_len); + if (header_len < sizeof(ccmsg_ctx_only_t)) { return ccErrBadParam; } - code = ccs_serv_find_ctx_by_handle(header->ctx, auth_info, session_info, &ctx); + handle = ntohll(header->ctx); + code = ccs_serv_find_ctx_by_handle(handle, auth_info, session_info, &ctx); if (code != ccNoError) { ccs_serv_make_nack(ccErrContextNotFound, auth_info, session_info, resp_msg); return code; } - return TypeToOpMapping->operations[msg->type] (ctx, auth_info, session_info, msg, resp_msg); + return TypeToOpMapping->operations[type] (ctx, auth_info, session_info, msg, resp_msg); } } @@ -349,7 +355,7 @@ ccs_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info return ccErrNoMem; } - nack_header->err_code = err_code;; + nack_header->err_code = htonl(err_code); code = cci_msg_add_header(*resp_msg, nack_header, sizeof(ccmsg_nack_t)); if (code != ccNoError) { cci_msg_destroy(*resp_msg); @@ -391,15 +397,19 @@ ccop_INIT( cc_server_context_t* ctx, /* not used */ ccmsg_init_resp_t *resp_header; ccmsg_init_t *header = (ccmsg_init_t *)msg->header; cc_context_list_node_t* ctx_node; + cc_uint32 header_len, in_version; + cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_init_t)) { + header_len = ntohl(msg->header_len); + if (header_len != sizeof(ccmsg_init_t)) { return ccErrBadParam; } - code = ccs_context_new(header->in_version, auth_info, session_info, &new_ctx); + in_version = ntohl(header->in_version); + code = ccs_context_new(in_version, auth_info, session_info, &new_ctx); if (code != ccNoError) { return code; } @@ -431,10 +441,10 @@ ccop_INIT( cc_server_context_t* ctx, /* not used */ return code; } - resp_header->out_ctx = (cc_handle) new_ctx; - resp_header->out_version = cc_myversion; - resp_header->vendor_offset = blob_pos; - resp_header->vendor_length = strlen(cc_vendor) + 1; + resp_header->out_ctx = htonll((cc_handle) new_ctx); + resp_header->out_version = htonl(cc_myversion); + resp_header->vendor_offset = htonl(blob_pos); + resp_header->vendor_length = htonl(strlen(cc_vendor) + 1); code = cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_init_resp_t)); if (code != ccNoError) { free(resp_header); @@ -454,15 +464,17 @@ ccop_CTX_RELEASE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { ccmsg_ctx_release_t* header = (ccmsg_ctx_release_t *)msg->header; + cc_uint32 header_len = ntohl(msg->header_len); + cc_handle handle = ntohll(header->ctx); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_release_t)) { + if (header_len != sizeof(ccmsg_ctx_release_t)) { return ccErrBadParam; } - code = ccs_context_destroy((cc_server_context_t *)header->ctx); + code = ccs_context_destroy((cc_server_context_t *)handle); return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } @@ -474,10 +486,11 @@ ccop_CTX_GET_CHANGE_TIME( cc_server_context_t* ctx, { ccmsg_ctx_get_change_time_resp_t* resp_header; ccmsg_ctx_get_change_time_t *header = (ccmsg_ctx_get_change_time_t *)msg->header; + cc_uint32 header_len = ntohl(msg->header_len); *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_get_change_time_t)) { + if (header_len != sizeof(ccmsg_ctx_get_change_time_t)) { return ccErrBadParam; } @@ -486,7 +499,7 @@ ccop_CTX_GET_CHANGE_TIME( cc_server_context_t* ctx, return ccErrNoMem; } - resp_header->time = ctx->changed; + resp_header->time = htonll(ctx->changed); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_get_change_time_resp_t), auth_info, session_info, resp_msg); } @@ -499,11 +512,12 @@ ccop_CTX_GET_DEFAULT_CCACHE_NAME( cc_server_context_t* ctx, char * name; ccmsg_ctx_get_default_ccache_name_resp_t* resp_header; ccmsg_ctx_get_default_ccache_name_t* header = (ccmsg_ctx_get_default_ccache_name_t *)msg->header; + cc_uint32 header_len = htonl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_get_default_ccache_name_t)) { + if (header_len != sizeof(ccmsg_ctx_get_default_ccache_name_t)) { return ccErrBadParam; } @@ -523,7 +537,7 @@ ccop_CTX_GET_DEFAULT_CCACHE_NAME( cc_server_context_t* ctx, } code = cci_msg_add_data_blob(*resp_msg, name, strlen(name) + 1, &resp_header->name_offset); - resp_header->name_len = strlen(name) + 1; + resp_header->name_len = htonl(strlen(name) + 1); return ccNoError; } @@ -535,12 +549,13 @@ ccop_CTX_COMPARE(cc_server_context_t* ctx, { cc_server_context_t *ctx2; ccmsg_ctx_compare_resp_t* resp_header; - ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)msg->header; + ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)(ntohll(msg->header)); + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_compare_t)) + if (header_len != sizeof(ccmsg_ctx_compare_t)) return ccErrBadParam; code = ccs_serv_find_ctx_by_handle(header->ctx2, auth_info, session_info, &ctx2); @@ -549,7 +564,7 @@ ccop_CTX_COMPARE(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->is_equal = ccs_context_compare(ctx, ctx2); + resp_header->is_equal = htonl(ccs_context_compare(ctx, ctx2)); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_compare_resp_t), auth_info, session_info, resp_msg); } @@ -562,20 +577,21 @@ ccop_CTX_NEW_CCACHE_ITERATOR(cc_server_context_t* ctx, cc_ccache_iterate_t* ccache_iterator; ccmsg_ctx_new_ccache_iterator_resp_t* resp_header; ccmsg_ctx_new_ccache_iterator_t* header = (ccmsg_ctx_new_ccache_iterator_t*)msg->header; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_new_ccache_iterator_t)) + if (header_len != sizeof(ccmsg_ctx_new_ccache_iterator_t)) return ccErrBadParam; - code = ccs_context_ccache_iterator(ctx,&ccache_iterator); + code = ccs_context_ccache_iterator(ctx, &ccache_iterator); resp_header = (ccmsg_ctx_new_ccache_iterator_resp_t*)malloc(sizeof(ccmsg_ctx_new_ccache_iterator_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->iterator = (cc_handle) ccache_iterator; + resp_header->iterator = htonll((cc_handle) ccache_iterator); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_new_ccache_iterator_resp_t), auth_info, session_info, resp_msg); } @@ -620,14 +636,15 @@ ccop_CTX_CCACHE_OPEN(cc_server_context_t* ctx, cc_server_ccache_t* ccache; ccmsg_ccache_open_resp_t* resp_header; ccmsg_ccache_open_t* header = (ccmsg_ccache_open_t*)msg->header; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_open_t)) + if (header_len != sizeof(ccmsg_ccache_open_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->name_offset, header->name_len, &name); + code = cci_msg_retrieve_blob(msg, ntohl(header->name_offset), ntohl(header->name_len), &name); code = ccs_context_find_ccache(ctx, name, &ccache); free(name); @@ -639,7 +656,7 @@ ccop_CTX_CCACHE_OPEN(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = (cc_handle) ccache; + resp_header->ccache = htonll((cc_handle) ccache); ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); return ccNoError; } @@ -653,10 +670,11 @@ ccop_CTX_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, ccmsg_ccache_open_default_t* header = (ccmsg_ccache_open_default_t*)msg->header; ccmsg_ccache_open_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = ntohl(msg->header_len); *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_open_default_t)) + if (header_len != sizeof(ccmsg_ccache_open_default_t)) return ccErrBadParam; if (ctx->ccaches->head->data == NULL) @@ -668,7 +686,7 @@ ccop_CTX_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = (cc_handle) ccache; + resp_header->ccache = htonll((cc_handle) ccache); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); } @@ -683,24 +701,25 @@ ccop_CTX_CCACHE_CREATE(cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_create_t)) + if (header_len != sizeof(ccmsg_ccache_create_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), ntohl(header->principal_len), &principal); if (code != ccNoError) return code; - principal[header->principal_len] = '\0'; /*Ensure null termination*/ + principal[ntohl(header->principal_len)] = '\0'; /*Ensure null termination*/ - code = cci_msg_retrieve_blob(msg, header->name_offset, header->name_len, &name); + code = cci_msg_retrieve_blob(msg, ntohl(header->name_offset), ntohl(header->name_len), &name); if (code != ccNoError) return code; - name[header->name_len] = '\0'; /*Ensure null termination*/ + name[ntohl(header->name_len)] = '\0'; /*Ensure null termination*/ - code = ccs_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, ntohl(header->version), principal, &ccache); if (code != ccNoError) return code; @@ -708,7 +727,7 @@ ccop_CTX_CCACHE_CREATE(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = (cc_handle) ccache; + resp_header->ccache = htonll((cc_handle) ccache); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } @@ -723,23 +742,24 @@ ccop_CTX_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_create_t)) + if (header_len != sizeof(ccmsg_ccache_create_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), ntohl(header->principal_len), &principal); if (code != ccNoError) return code; - principal[header->principal_len] = '\0'; /*Ensure null termination*/ + principal[ntohl(header->principal_len)] = '\0'; /*Ensure null termination*/ code = ccs_context_get_default_ccache_name(ctx, &name); if (code != ccNoError) return code; - code = ccs_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, ntohl(header->version), principal, &ccache); if (code != ccNoError) return code; @@ -747,7 +767,7 @@ ccop_CTX_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = (cc_handle) ccache; + resp_header->ccache = htonll((cc_handle) ccache); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } @@ -762,22 +782,23 @@ ccop_CTX_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_create_t)) + if (header_len != sizeof(ccmsg_ccache_create_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), htonl(header->principal_len), &principal); if (code != ccNoError) return code; - principal[header->principal_len] = '\0'; /*Ensure null termination*/ + principal[ntohl(header->principal_len)] = '\0'; /*Ensure null termination*/ // TODO: Generate a unique ccache name name = "unique"; - code = ccs_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, ntohl(header->version), principal, &ccache); if (code != ccNoError) return code; @@ -785,7 +806,7 @@ ccop_CTX_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = (cc_handle) ccache; + resp_header->ccache = htonll((cc_handle) ccache); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } @@ -807,14 +828,15 @@ ccop_CCACHE_DESTROY( cc_server_context_t* ctx, { ccmsg_ccache_release_t* header = (ccmsg_ccache_release_t*)msg->header; cc_server_ccache_t* ccache; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_release_t)) + if (header_len != sizeof(ccmsg_ccache_release_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -833,14 +855,15 @@ ccop_CCACHE_SET_DEFAULT(cc_server_context_t* ctx, ccmsg_ccache_set_default_t* header = (ccmsg_ccache_set_default_t*)msg->header; cc_ccache_iterate_t* ccache_iterator; cc_ccache_list_node_t* ccache_node; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_set_default_t)) + if (header_len != sizeof(ccmsg_ccache_set_default_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -877,14 +900,15 @@ ccop_CCACHE_GET_CREDS_VERSION(cc_server_context_t* ctx, ccmsg_ccache_get_creds_version_t* header = (ccmsg_ccache_get_creds_version_t*)msg->header; ccmsg_ccache_get_creds_version_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_creds_version_t)) + if (header_len != sizeof(ccmsg_ccache_get_creds_version_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -892,7 +916,7 @@ ccop_CCACHE_GET_CREDS_VERSION(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->version = ccache->versions; + resp_header->version = htonl(ccache->versions); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_creds_version_resp_t), auth_info, session_info, resp_msg); } @@ -905,14 +929,16 @@ ccop_CCACHE_GET_NAME(cc_server_context_t* ctx, ccmsg_ccache_get_name_t* header = (ccmsg_ccache_get_name_t*)msg->header; ccmsg_ccache_get_name_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 name_offset; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_name_resp_t)) + if (header_len != sizeof(ccmsg_ccache_get_name_resp_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (ccache == NULL) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -924,8 +950,11 @@ ccop_CCACHE_GET_NAME(cc_server_context_t* ctx, if (code != ccNoError) return code; - code = cci_msg_add_data_blob(*resp_msg, ccache->name, strlen(ccache->name) + 1, &resp_header->name_offset); - resp_header->name_len = strlen(ccache->name) + 1; + code = cci_msg_add_data_blob(*resp_msg, ccache->name, strlen(ccache->name) + 1, &name_offset); + if (code == 0) { + resp_header->name_len = htonl(strlen(ccache->name) + 1); + resp_header->name_offset = htonl(name_offset); + } cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_ccache_get_name_resp_t)); return ccNoError; @@ -941,18 +970,20 @@ ccop_CCACHE_GET_PRINCIPAL(cc_server_context_t* ctx, ccmsg_ccache_get_principal_resp_t* resp_header; cc_server_ccache_t* ccache; char * principal; + cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 principal_offset; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_principal_t)) + if (header_len != sizeof(ccmsg_ccache_get_principal_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = ccs_ccache_get_principal(ccache, header->version, &principal); + code = ccs_ccache_get_principal(ccache, ntohl(header->version), &principal); if (code != ccNoError) return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); @@ -964,7 +995,11 @@ ccop_CCACHE_GET_PRINCIPAL(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - code = cci_msg_add_data_blob(*resp_msg, principal, strlen(principal) + 1, &resp_header->principal_offset); + code = cci_msg_add_data_blob(*resp_msg, principal, strlen(principal) + 1, &principal_offset); + if (code == 0) { + resp_header->principal_len = htonl(strlen(principal) + 1); + resp_header->principal_offset = htonl(principal_offset); + } cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_ccache_get_principal_resp_t)); return ccNoError; @@ -979,22 +1014,23 @@ ccop_CCACHE_SET_PRINCIPAL(cc_server_context_t* ctx, ccmsg_ccache_set_principal_t* header = (ccmsg_ccache_set_principal_t*)msg->header; cc_server_ccache_t* ccache; char *principal; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_set_principal_t)) + if (header_len != sizeof(ccmsg_ccache_set_principal_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), ntohl(header->principal_len), &principal); if (code != ccNoError) return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); - code = ccs_ccache_set_principal(ccache, header->version, principal); + code = ccs_ccache_set_principal(ccache, ntohl(header->version), principal); if (code != ccNoError) return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); @@ -1011,14 +1047,15 @@ ccop_CCACHE_NEW_CREDS_ITERATOR( cc_server_context_t* ctx, cc_credentials_iterate_t* creds_iterator; ccmsg_ccache_creds_iterator_t* header = (ccmsg_ccache_creds_iterator_t*)msg->header; ccmsg_ccache_creds_iterator_resp_t* resp_header; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_creds_iterator_t)) + if (header_len != sizeof(ccmsg_ccache_creds_iterator_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -1030,7 +1067,7 @@ ccop_CCACHE_NEW_CREDS_ITERATOR( cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->iterator = (cc_handle) creds_iterator; + resp_header->iterator = htonll((cc_handle) creds_iterator); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_creds_iterator_resp_t), auth_info, session_info, resp_msg); } @@ -1086,22 +1123,19 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, cc_server_ccache_t* ccache; char *flat_creds; cc_credentials_union *creds; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_store_creds_t)) + if (header_len != sizeof(ccmsg_ccache_store_creds_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - // TODO: This code is too simplistic. cc_credential_unions are not flat - // structures and must be flattened. That means that although we can - // store a flat blob in the message we will need to decode the blob - // into the actual object. - code = cci_msg_retrieve_blob(msg, header->creds_offset, header->creds_len, &flat_creds); + code = cci_msg_retrieve_blob(msg, ntohl(header->creds_offset), ntohl(header->creds_len), &flat_creds); if (code != ccNoError) return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); @@ -1111,10 +1145,10 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, switch ( creds->version ) { case cc_credentials_v4: - code = cci_creds_v4_unmarshall(flat_creds, header->creds_len, creds); + code = cci_creds_v4_unmarshall(flat_creds, ntohl(header->creds_len), creds); break; case cc_credentials_v5: - code = cci_creds_v5_unmarshall(flat_creds, header->creds_len, creds); + code = cci_creds_v5_unmarshall(flat_creds, ntohl(header->creds_len), creds); break; default: return ccs_serv_make_nack(ccErrBadCredentialsVersion, auth_info, session_info, resp_msg); @@ -1140,17 +1174,18 @@ ccop_CCACHE_REM_CREDS(cc_server_context_t* ctx, ccmsg_ccache_rem_creds_t* header = (ccmsg_ccache_rem_creds_t*)msg->header; cc_server_ccache_t* ccache; cc_credentials_union *creds; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_rem_creds_t)) + if (header_len != sizeof(ccmsg_ccache_rem_creds_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = ccs_ccache_rem_creds(ccache, (const cc_credentials_union *)header->creds); + code = ccs_ccache_rem_creds(ccache, (const cc_credentials_union *)(ntohll(header->creds))); if (code != ccNoError) return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); @@ -1197,14 +1232,15 @@ ccop_CCACHE_GET_LAST_DEFAULT_TIME(cc_server_context_t* ctx, ccmsg_ccache_get_last_default_time_t* header = (ccmsg_ccache_get_last_default_time_t*)msg->header; ccmsg_ccache_get_last_default_time_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_last_default_time_t)) + if (header_len != sizeof(ccmsg_ccache_get_last_default_time_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -1212,7 +1248,7 @@ ccop_CCACHE_GET_LAST_DEFAULT_TIME(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->last_default_time = ccache->last_default; + resp_header->last_default_time = htonll(ccache->last_default); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_last_default_time_resp_t), auth_info, session_info, resp_msg); } @@ -1225,10 +1261,11 @@ ccop_CCACHE_GET_CHANGE_TIME( cc_server_context_t* ctx, ccmsg_ccache_get_change_time_resp_t* resp_header; ccmsg_ccache_get_change_time_t *header = (ccmsg_ccache_get_change_time_t *)msg->header; cc_server_ccache_t* ccache = (cc_server_ccache_t *)header->ccache; + cc_uint32 header_len = ntohl(msg->header_len); *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_change_time_t)) { + if (header_len != sizeof(ccmsg_ccache_get_change_time_t)) { return ccErrBadParam; } @@ -1237,7 +1274,7 @@ ccop_CCACHE_GET_CHANGE_TIME( cc_server_context_t* ctx, return ccErrNoMem; } - resp_header->time = ccache->changed; + resp_header->time = htonll(ccache->changed); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_change_time_resp_t), auth_info, session_info, resp_msg); } @@ -1250,18 +1287,20 @@ ccop_CCACHE_COMPARE(cc_server_context_t* ctx, ccmsg_ccache_compare_t* header = (ccmsg_ccache_compare_t*)msg->header; ccmsg_ccache_compare_resp_t* resp_header; cc_server_ccache_t* ccache1, *ccache2; + cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 is_equal; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_compare_t)) + if (header_len != sizeof(ccmsg_ccache_compare_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache1, &ccache1); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache1), &ccache1); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache2, &ccache2); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache2), &ccache2); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -1269,7 +1308,8 @@ ccop_CCACHE_COMPARE(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - ccs_ccache_compare(ccache1, ccache2, &resp_header->is_equal); + ccs_ccache_compare(ccache1, ccache2, &is_equal); + resp_header->is_equal = htonl(is_equal); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_compare_resp_t), auth_info, session_info, resp_msg); } @@ -1283,14 +1323,15 @@ ccop_CCACHE_GET_KDC_TIME_OFFSET(cc_server_context_t* ctx, ccmsg_ccache_get_kdc_time_offset_resp_t* resp_header; cc_server_ccache_t* ccache; cc_time64 offset; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_kdc_time_offset_t)) + if (header_len != sizeof(ccmsg_ccache_get_kdc_time_offset_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -1304,7 +1345,7 @@ ccop_CCACHE_GET_KDC_TIME_OFFSET(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->offset = offset; + resp_header->offset = htonll(offset); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_kdc_time_offset_resp_t), auth_info, session_info, resp_msg); } @@ -1316,20 +1357,21 @@ ccop_CCACHE_SET_KDC_TIME_OFFSET(cc_server_context_t* ctx, { ccmsg_ccache_set_kdc_time_offset_t* header = (ccmsg_ccache_set_kdc_time_offset_t*)msg->header; cc_server_ccache_t* ccache; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_set_kdc_time_offset_t)) + if (header_len != sizeof(ccmsg_ccache_set_kdc_time_offset_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO How is the header->creds_version supposed to be used? - ccs_ccache_set_kdc_time_offset(ccache, header->offset); + ccs_ccache_set_kdc_time_offset(ccache, htonll(header->offset)); return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } @@ -1341,14 +1383,15 @@ ccop_CCACHE_CLEAR_KDC_TIME_OFFSET(cc_server_context_t* ctx, { ccmsg_ccache_clear_kdc_time_offset_t* header = (ccmsg_ccache_clear_kdc_time_offset_t*)msg->header; cc_server_ccache_t* ccache; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_clear_kdc_time_offset_t)) + if (header_len != sizeof(ccmsg_ccache_clear_kdc_time_offset_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); @@ -1366,14 +1409,15 @@ ccop_CCACHE_ITERATOR_RELEASE(cc_server_context_t* ctx, { cc_generic_list_node_t* gen_node; ccmsg_ccache_iterator_release_t* header = (ccmsg_ccache_iterator_release_t*)msg->header; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_iterator_release_t)) + if (header_len != sizeof(ccmsg_ccache_iterator_release_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); + code = ccs_serv_find_ccache_iterator_by_handle(ctx, ntohll(header->iterator), &gen_node); if (code != ccNoError) return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); @@ -1404,15 +1448,16 @@ ccop_CCACHE_ITERATOR_NEXT(cc_server_context_t* ctx, ccmsg_ccache_iterator_next_resp_t* resp_header; cc_generic_list_node_t* gen_node; cc_ccache_iterate_t* ccache_iterator; - cc_ccache_list_node_t *ccache_node; + cc_ccache_list_node_t *ccache_node; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_iterator_next_t)) + if (header_len != sizeof(ccmsg_ccache_iterator_next_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); + code = ccs_serv_find_ccache_iterator_by_handle(ctx, ntohll(header->iterator), &gen_node); if (code != ccNoError) return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); @@ -1426,7 +1471,7 @@ ccop_CCACHE_ITERATOR_NEXT(cc_server_context_t* ctx, if (code != ccNoError) return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - resp_header->ccache = (cc_handle) ccache_node; + resp_header->ccache = htonll((cc_handle) ccache_node); return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_iterator_next_resp_t), auth_info, session_info, resp_msg); } else { return ccs_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); @@ -1442,18 +1487,19 @@ ccop_CREDS_ITERATOR_RELEASE(cc_server_context_t* ctx, cc_generic_list_node_t* gen_node; cc_server_ccache_t* ccache; ccmsg_creds_iterator_release_t* header = (ccmsg_creds_iterator_release_t*)msg->header; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_creds_iterator_release_t)) + if (header_len != sizeof(ccmsg_creds_iterator_release_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = ccs_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); + code = ccs_serv_find_creds_iterator_by_handle(ccache, ntohll(header->iterator), &gen_node); if (code != ccNoError) return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); @@ -1489,18 +1535,19 @@ ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, cc_server_ccache_t* ccache; cc_server_credentials_t* stored_creds; cc_credentials_union *creds_union; + cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_creds_iterator_next_t)) + if (header_len != sizeof(ccmsg_creds_iterator_next_t)) return ccErrBadParam; - code = ccs_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = ccs_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); + code = ccs_serv_find_creds_iterator_by_handle(ccache, ntohll(header->iterator), &gen_node); if (code != ccNoError) return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); -- cgit From ecf87aec8e5fde32f8f3e72849b434308900917d Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 22 May 2006 17:12:49 +0000 Subject: Source files containing common routines used by both the client and the server. git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18027 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/common/NTMakefile | 15 + src/lib/ccapi/common/generic_lists.c | 402 ++++++++++++++++++++++ src/lib/ccapi/common/marshall.c | 440 ++++++++++++++++++++++++ src/lib/ccapi/common/msg.c | 628 +++++++++++++++++++++++++++++++++++ 4 files changed, 1485 insertions(+) create mode 100644 src/lib/ccapi/common/NTMakefile create mode 100644 src/lib/ccapi/common/generic_lists.c create mode 100644 src/lib/ccapi/common/marshall.c create mode 100644 src/lib/ccapi/common/msg.c (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/common/NTMakefile b/src/lib/ccapi/common/NTMakefile new file mode 100644 index 000000000..d0d92fcbd --- /dev/null +++ b/src/lib/ccapi/common/NTMakefile @@ -0,0 +1,15 @@ +!INCLUDE + +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsdll) + +CC_COMMON_OBJS = marshall.obj msg.obj generic_lists.obj + +CC_COMMON_LIB = cc_common.lib + +$(CC_COMMON_LIB): $(CC_COMMON_OBJS) + $(implib) /NOLOGO /OUT:$@ $** + +all: $(CC_COMMON_LIB) + +clean: + del *.obj *.lib diff --git a/src/lib/ccapi/common/generic_lists.c b/src/lib/ccapi/common/generic_lists.c new file mode 100644 index 000000000..a48c528f9 --- /dev/null +++ b/src/lib/ccapi/common/generic_lists.c @@ -0,0 +1,402 @@ +/* $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). +* $ +*/ + + +/* + * Lists implementation. + * + */ + +#include +#include +#include + +#include "CredentialsCache.h" +#include "generic_lists.h" + +/* this is an incomplete enumeration just including the generic type */ +enum cc_list_type { + generic = 0 +}; + +/** + * cci_generic_iterate_has_next() + * + * Purpose: Determine if an iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + * + * Errors: None + * + */ +cc_int32 +cci_generic_iterate_has_next(cc_generic_iterate_t *iterate) +{ + return ((iterate == NULL || iterate->next == NULL) ? 0 : 1); +} + +/** + * cci_generic_iterate_next() + * + * Purpose: Retrieve the next element from an iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_iterate_next(cc_generic_iterate_t *iterator, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* ret; + + if (iterator == NULL || nodepp == NULL) + return ccErrBadParam; + + ret = iterator->next; + if (iterator->next != NULL) + iterator->next = iterator->next->next; + + *nodepp = ret; + return ccNoError; +} + +/** + * cci_generic_list_new() + * + * Purpose: Allocate new generic list + * + * Return: non-NULL, an empty list + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_generic_list_new(cc_generic_list_head_t ** listpp) +{ + cc_generic_list_head_t* ret = (cc_generic_list_head_t *)malloc(sizeof(cc_generic_list_head_t)); + if (ret == NULL) + return ccErrNoMem; + + ret->type = generic; + ret->head = ret->tail = NULL; + *listpp = ret; + + return ccNoError; +} + +/** + * cci_generic_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* new_node; + + if ( data == NULL || len == 0 ) + return ccErrBadParam; + + new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); + if (new_node == NULL) + return ccErrNoMem; + + new_node->data = malloc(len); + if ( new_node->data == NULL ) { + free(new_node); + return ccErrNoMem; + } + + memcpy(new_node->data,data,len); + new_node->len = len; + + if (head->head == NULL) { /*empty list*/ + head->head = new_node; + head->tail = new_node; + new_node->next = new_node->prev = NULL; + } else { + new_node->prev = head->tail; + head->tail->next = new_node; + head->tail = new_node; + new_node->next = NULL; + } + if (nodepp != NULL) + *nodepp = new_node; + return ccNoError; +} + +/** + * cci_generic_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem, ccErrBadParam + * + */ +cc_int32 +cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* new_node; + + if ( data == NULL || len == 0 ) + return ccErrBadParam; + + new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); + if (new_node == NULL) + return ccErrNoMem; + + new_node->data = malloc(len); + if ( new_node->data == NULL ) { + free(new_node); + return ccErrNoMem; + } + + memcpy(new_node->data,data,len); + new_node->len = len; + + if (head->head == NULL) { /*empty list*/ + head->head = new_node; + head->tail = new_node; + new_node->prev = new_node->next = NULL; + } else { + new_node->next = head->head; + head->head->prev = new_node; + new_node->prev = NULL; + head->head = new_node; + } + + if (nodepp != NULL) + *nodepp = new_node; + + return ccNoError; +} + +/** + * cci_generic_list_remove_element() + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem) +{ + if (head->head == NULL || rem == NULL) + return ccErrBadParam; + + if (head->head == rem && head->tail == rem) { /*removing only element of list*/ + head->head = head->tail = NULL; + } else if (head->head == rem) { /*removing head*/ + head->head = head->head->next; + } else if (head->tail == rem) { /*removing tail*/ + head->tail = head->tail->prev; + head->tail->next = NULL; + } else { + rem->prev->next = rem->next; + rem->next->prev = rem->prev; + } + free(rem); + return ccNoError; +} + +/** + * cci_generic_free_element() + * + * Purpose: Free the memory associated with a node + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_free_element(cc_generic_list_node_t* node) +{ + if ( node == NULL ) + return ccErrBadParam; + + if ( node->data ) { + free(node->data); + node->data = NULL; + } + node->len = 0; + node->next = node->prev = NULL; + free(node); + return ccNoError; +} + + +/** + * cci_generic_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +cci_generic_list_destroy(cc_generic_list_head_t* head) +{ + cc_generic_list_node_t *cur, *next; + cc_int32 ret = ccNoError; + + if ( head == NULL ) + return ccErrBadParam; + + for (cur = head->head; ret == ccNoError && cur != NULL; cur = next) { + next = cur->next; + ret = cci_generic_free_element(cur); + } + free(head); + return(ret); +} + +/** + * cci_generic_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + * + */ +cc_int32 +cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t** headpp) +{ + cc_generic_list_head_t* copy; + cc_generic_list_node_t *src_node, *dst_node; + cc_int32 code; + + if (head == NULL || headpp == NULL) + return ccErrBadParam; + + code = cci_generic_list_new(©); + if (code != ccNoError) + return code; + + for (src_node = head->head; src_node != NULL; src_node = src_node->next) { + code = cci_generic_list_append(copy, src_node->data, src_node->len, &dst_node); + if (code != ccNoError) { + cci_generic_list_destroy(copy); + return code; + } + } + *headpp = copy; + return ccNoError; +} + +/** + * cci_generic_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t** headpp) +{ + cc_generic_iterate_t* iterator; + + if ( head == NULL || headpp == NULL ) + return ccErrBadParam; + + iterator = (cc_generic_iterate_t*)malloc(sizeof(cc_generic_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *headpp = iterator; + return ccNoError; +} + +/** + * cci_generic_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_free_iterator(cc_generic_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + + + diff --git a/src/lib/ccapi/common/marshall.c b/src/lib/ccapi/common/marshall.c new file mode 100644 index 000000000..960019cb0 --- /dev/null +++ b/src/lib/ccapi/common/marshall.c @@ -0,0 +1,440 @@ +/* $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). + * $ + */ + +/* marshall.c */ + +#include +#include +#include +#include "msg.h" +#include "msg_headers.h" +#include "marshall.h" + +cc_int32 +cci_creds_v4_marshall( cc_credentials_v4_t * creds, + char ** pflat, + cc_uint32 * plen) +{ + cc_uint32 len; + char * flat; + cci_flat_creds_v4_t * header; + cc_time64 t64; + + if ( creds == NULL || pflat == NULL || plen == NULL ) + return ccErrBadParam; + + len = sizeof(cci_flat_creds_v4_t); + flat = (char *)malloc(len); + if ( flat == NULL ) + return ccErrNoMem; + memset(flat, 0, len); + + header = (cci_flat_creds_v4_t *)flat; + header->version = htonl(creds->version); + memcpy(header->principal, creds->principal, cc_v4_name_size); + memcpy(header->principal_instance, creds->principal_instance, cc_v4_instance_size); + memcpy(header->service, creds->service, cc_v4_name_size); + memcpy(header->service_instance, creds->service_instance, cc_v4_instance_size); + memcpy(header->realm, creds->realm, cc_v4_realm_size); + memcpy(header->session_key, creds->session_key, cc_v4_key_size); + header->kvno = htonl(creds->kvno); + header->string_to_key_type = htonl(creds->string_to_key_type); + t64 = creds->issue_date; + header->issue_date = htonll(t64); + header->lifetime = htonl(creds->lifetime); + /* TODO: verify that address is stored in host order */ + header->address = htonl(creds->address); + header->ticket_size = htonl(creds->ticket_size); + memcpy(header->ticket, creds->ticket, cc_v4_ticket_size); + + *pflat = flat; + *plen = len; + + return ccNoError; +} + +cc_int32 +cci_creds_v4_unmarshall( char * flat, + cc_uint32 len, + cc_credentials_union * creds_union) +{ + struct cci_flat_creds_v4 * header; + cc_credentials_v4_t * creds; + cc_time64 t64; + + if ( flat == NULL || len == 0 || creds_union == NULL ) + return ccErrBadParam; + + creds_union->version = cc_credentials_v4; + + header = (cci_flat_creds_v4_t *)flat; + + creds = (cc_credentials_v4_t *)malloc(sizeof(cc_credentials_v4_t)); + if ( creds == NULL ) + return ccErrNoMem; + + creds->version = ntohl(header->version); + memcpy(creds->principal, header->principal, cc_v4_name_size); + memcpy(creds->principal_instance, header->principal_instance, cc_v4_instance_size); + memcpy(creds->service, header->service, cc_v4_name_size); + memcpy(creds->service_instance, header->service_instance, cc_v4_instance_size); + memcpy(creds->realm, header->realm, cc_v4_realm_size); + memcpy(creds->session_key, header->session_key, cc_v4_key_size); + creds->kvno = htonl(header->kvno); + creds->string_to_key_type = htonl(header->string_to_key_type); + t64 = header->issue_date; + creds->issue_date = (cc_time64)ntohll(t64); + creds->lifetime = (cc_int32)ntohl(header->lifetime); + /* TODO: verify that address is stored in host order */ + creds->address = ntohl(header->address); + creds->ticket_size = ntohl(header->ticket_size); + memcpy(creds->ticket, header->ticket, cc_v4_ticket_size); + + creds_union->credentials.credentials_v4 = creds; + + return ccNoError; +} + + +cc_int32 +cci_creds_cc_data_array_count_entries( cc_data ** array, cc_uint32 * pcount) +{ + cc_uint32 count; + + if (array == NULL) { + *pcount = 0; + return ccNoError; + } + + for ( count=0; array[count] != NULL ; count++) ; + + *pcount = count; + return ccNoError; +} + +cc_int32 +cci_creds_v5_compute_flat_size( cc_credentials_v5_t * creds, cc_uint32 * plen) +{ + cc_uint32 len; + cc_uint32 i, count; + + len = sizeof(struct cci_flat_creds_v5); + + if (creds->client) + len += strlen(creds->client) + 1; + + if (creds->server) + len += strlen(creds->server) + 1; + + len += creds->keyblock.length; + + cci_creds_cc_data_array_count_entries( creds->addresses, &count ); + len += count * sizeof(cc_flat_data); + for ( i=0; iaddresses[i]->length; + } + + len += creds->ticket.length; + len += creds->second_ticket.length; + + cci_creds_cc_data_array_count_entries( creds->authdata, &count ); + len += count * sizeof(cc_flat_data); + for ( i=0; iauthdata[i]->length; + } + + *plen = len; + return ccNoError; +} + +cc_int32 +cci_creds_v5_marshall( cc_credentials_v5_t * creds, + char ** pflat, + cc_uint32 * plen) +{ + cc_uint32 len; + char * flat; + struct cci_flat_creds_v5 * header; + cc_uint32 length; + cc_uint32 offset; + cc_time64 t64; + cc_uint32 count; + cc_uint32 i; + + if ( creds == NULL || pflat == NULL || plen == NULL ) + return ccErrBadParam; + + cci_creds_v5_compute_flat_size(creds, &len); + + flat = (char *)malloc(len); + if ( flat == NULL ) + return ccErrNoMem; + memset(flat, 0, len); + + offset = sizeof(struct cci_flat_creds_v5); + header = (struct cci_flat_creds_v5 *)flat; + header->version = htonl(FLAT_CREDS_V5_VERSION); + if (creds->client) { + length = strlen(creds->client) + 1; + header->client.length = htonl(length); + header->client.data = htonl(offset); + memcpy(flat + offset, creds->client, length); + offset += length; + } + + if (creds->server) { + length = strlen(creds->server) + 1; + header->server.length = htonl(length); + header->server.data = htonl(offset); + memcpy(flat + offset, creds->server, length); + offset += length; + } + + header->keyblock.type = htonl(creds->keyblock.type); + if (creds->keyblock.length) { + length = creds->keyblock.length; + header->keyblock.length = htonl(length); + header->keyblock.data = htonl(offset); + memcpy(flat + offset, creds->keyblock.data, length); + offset += length; + } + + t64 = creds->authtime; + header->authtime = htonll(t64); + t64 = creds->starttime; + header->starttime = htonll(t64); + t64 = creds->endtime; + header->endtime = htonll(t64); + t64 = creds->renew_till; + header->renew_till = htonll(t64); + + header->is_skey = htonl(creds->is_skey); + header->ticket_flags = htonl(creds->ticket_flags); + + cci_creds_cc_data_array_count_entries( creds->addresses, &count ); + if ( count ) { + cc_flat_data * addresses = (cc_flat_data *)flat + offset; + header->address_count = htonl(count); + header->addresses = htonl(offset); + offset += count * sizeof(cc_flat_data); + + for ( i=0; i < count; i++ ) { + addresses[i].type = htonl(creds->addresses[i]->type); + if (creds->addresses[i]->length) { + length = creds->addresses[i]->length; + addresses[i].length = htonl(length); + addresses[i].data = htonl(offset); + /* TODO: verify that addresses are stored in network order */ + memcpy(flat + offset, creds->addresses[i]->data, length); + offset += length; + } + } + } + + header->ticket.type = htonl(creds->ticket.type); + if (creds->ticket.length) { + length = creds->ticket.length; + header->ticket.length = htonl(length); + header->ticket.data = htonl(offset); + memcpy(flat + offset, creds->ticket.data, length); + offset += length; + } + + header->second_ticket.type = htonl(creds->second_ticket.type); + if (creds->second_ticket.length) { + length = creds->second_ticket.length; + header->second_ticket.length = htonl(length); + header->second_ticket.data = htonl(offset); + memcpy(flat + offset, creds->second_ticket.data, length); + offset += length; + } + + cci_creds_cc_data_array_count_entries( creds->authdata, &count ); + if ( count ) { + cc_flat_data * authdata = (cc_flat_data *)flat + offset; + + header->authdata_count = htonl(count); + header->authdata = (offset); + offset += count * sizeof(cc_flat_data); + + for ( i=0; i < count; i++ ) { + authdata[i].type = htonl(creds->authdata[i]->type); + if (creds->authdata[i]->length) { + length = creds->authdata[i]->length; + authdata[i].length = htonl(length); + authdata[i].data = htonl(offset); + memcpy(flat + offset, creds->authdata[i]->data, length); + offset += length; + } + } + } + + *pflat = flat; + *plen = len; + return ccNoError; +} + + +// TODO: a much better job of checking for out of memory errors +// and validating that we do not read beyond the flat input +// data buffer + +cc_int32 +cci_creds_v5_unmarshall( char * flat, + cc_uint32 len, + cc_credentials_union * creds_union) +{ + struct cci_flat_creds_v5 * header; + cc_credentials_v5_t * creds; + cc_flat_data * flat_data; + cc_time64 t64; + cc_uint32 length; + cc_uint32 count; + cc_uint32 i; + + if ( flat == NULL || len == 0 || creds_union == NULL ) + return ccErrBadParam; + + creds_union->version = cc_credentials_v5; + + header = (struct cci_flat_creds_v5 *)flat; + + if ( ntohl(header->version) != FLAT_CREDS_V5_VERSION ) + return ccErrBadParam; + + creds = (cc_credentials_v5_t *)malloc(sizeof(cc_credentials_v5_t)); + if ( creds == NULL ) + return ccErrNoMem; + memset(creds, 0, sizeof(cc_credentials_v5_t)); + + if ( header->client.length ) { + length = ntohl(header->client.length); + creds->client = (char *)malloc(length); + memcpy(creds->client, flat + header->client.data, length); + } + + if ( header->server.length ) { + length = ntohl(header->server.length); + creds->server = (char *)malloc(length); + memcpy(creds->server, flat + header->server.data, length); + } + + creds->keyblock.type = ntohl(header->keyblock.type); + if ( header->keyblock.length ) { + length = ntohl(header->keyblock.length); + creds->keyblock.length = length; + creds->keyblock.data = malloc(length); + memcpy(creds->keyblock.data, flat + header->keyblock.data, length); + } + + /* TODO: need to perform overflow validation checks to ensure + * that we do not attempt to store too large a value into cc_time_t + * when it is a 32-bit field. + */ + t64 = ntohll(header->authtime); + creds->authtime = (cc_time)t64; + t64 = ntohll(header->starttime); + creds->starttime = (cc_time)t64; + t64 = ntohll(header->endtime); + creds->endtime = (cc_time)t64; + t64 = ntohll(header->renew_till); + creds->renew_till = (cc_time)t64; + + creds->is_skey = ntohl(header->is_skey); + creds->ticket_flags = ntohl(header->ticket_flags); + + count = ntohl(header->address_count); + creds->addresses = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); + flat_data = (cc_flat_data *)flat + header->addresses; + for ( i=0 ; i < count ; i++ ) { + creds->addresses[i] = (cc_data *)malloc(sizeof(cc_data)); + creds->addresses[i]->type = ntohl(flat_data[i].type); + length = ntohl(flat_data[i].length); + creds->addresses[i]->length = length; + if ( length ) { + creds->addresses[i]->data = malloc(length); + /* TODO: verify that addresses are stored in network order */ + memcpy(creds->addresses[i]->data, flat + flat_data[i].data, length); + } else { + creds->addresses[i]->data = NULL; + } + } + creds->addresses[i] = NULL; + + creds->ticket.type = ntohl(header->ticket.type); + length = ntohl(header->ticket.length); + if ( length ) { + creds->ticket.length = length; + creds->ticket.data = malloc(length); + memcpy(creds->ticket.data, flat + header->ticket.data, length); + } + + creds->second_ticket.type = header->second_ticket.type; + if ( header->second_ticket.length ) { + creds->second_ticket.length = header->second_ticket.length; + creds->second_ticket.data = malloc(creds->second_ticket.length); + memcpy(creds->second_ticket.data, flat + header->second_ticket.data, creds->second_ticket.length); + } + + count = ntohl(header->authdata_count); + creds->authdata = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); + flat_data = (cc_flat_data *)flat + header->authdata; + for ( i=0 ; i < count ; i++ ) { + creds->authdata[i] = (cc_data *)malloc(sizeof(cc_data)); + creds->authdata[i]->type = ntohl(flat_data[i].type); + length = ntohl(flat_data[i].length); + creds->authdata[i]->length = length; + if ( length ) { + creds->authdata[i]->data = malloc(length); + memcpy(creds->authdata[i]->data, flat + flat_data[i].data, length); + } else { + creds->authdata[i]->data = NULL; + } + } + creds->authdata[i] = NULL; + + creds_union->credentials.credentials_v5 = creds; + + return ccNoError; +} + diff --git a/src/lib/ccapi/common/msg.c b/src/lib/ccapi/common/msg.c new file mode 100644 index 000000000..b7f60dd07 --- /dev/null +++ b/src/lib/ccapi/common/msg.c @@ -0,0 +1,628 @@ +/* $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). + * $ + */ + +/* + * Verifiable, extensible message format. + * + * Format: + * + * + * + * + * + * + * + * + * + * ... + * + * + * If the header has variable length data it is included in the data blobs. + * The header field has the offset from the beginning of the message of the 1st + * byte of the data and the length of the data. + */ + +#include "CredentialsCache.h" +#include "msg.h" +#include "generic_lists.h" + +#include +#include +#include +#include + +/** + * cci_msg_new() + * + * Purpose: Allocate and initialize a new cc_msg_t structure + * + * Input parameter (type) in host order + * + * Return: non-NULL, the msg + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_msg_new(cc_uint32 type, cc_msg_t** msgpp) +{ + // type should be validated. If invalid set error to ccErrBadParam + cc_msg_t* msg; + + if ( type > CC_MSG_MAX_TYPE || msgpp == NULL ) + return ccErrBadParam; + + msg = (cc_msg_t*)malloc(sizeof(cc_msg_t)); + if (msg == NULL) + return ccErrNoMem; + + msg->type = htonl(type); + msg->flat = NULL; + msg->header = NULL; + msg->flat_len = 0; + msg->header_len = 0; + msg->magic = 0; + cci_generic_list_new(&msg->data_blobs); + if (msg->data_blobs == NULL) { + // pass on error from previous call + free(msg); + return ccErrNoMem; + } + + *msgpp = msg; + return ccNoError; +} + +/** + * cci_msg_calc_header_size() + * + * Purpose: Calculates the size of the header + * + * Return: the size in bytes + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_msg_calc_header_size(cc_msg_t* msg, cc_uint32 * lenp) +{ + int header_len = 12; /* header size, entire size, type */ + + if ( msg == NULL || lenp == NULL ) + return ccErrBadParam; + + header_len += msg->header_len; + *lenp = header_len; + return ccNoError; +} + +/** + * cci_msg_calc_size() + * + * Purpose: Calculates the size of the message + * (does not include the magic bytes) + * + * Return: the size in bytes + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_msg_calc_size(cc_msg_t* msg, cc_uint32 * lenp) +{ + cc_uint32 flat_len; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + if ( msg == NULL || lenp == NULL ) + return ccErrBadParam; + + code = cci_msg_calc_header_size(msg, &flat_len); + if (code != ccNoError) + goto bad; + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + if ( code != ccNoError ) + goto bad; + + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (code != ccNoError) + break; + flat_len += gen_node->len + BLOB_LEN; + } + cci_generic_free_iterator(gen_iterator); + if (code != ccNoError) + goto bad; + + flat_len += MAGIC_HEAD_LEN + MAGIC_DATA_LEN; + *lenp = flat_len; + + bad: + return code; +} + +/** + * cci_msg_add_data_blob() + * + * Purpose: Adds 'len' bytes of data to the msg + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_add_data_blob(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 *lenp) +{ + cc_int32 code; + + if (msg == NULL || data == NULL || len <= 0 || lenp == NULL) + return ccErrBadParam; + + code = cci_generic_list_append(msg->data_blobs, data, len, NULL); + if ( code != ccNoError ) + return code; + return cci_msg_calc_blob_pos(msg, data, len, lenp); +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_calc_blob_pos(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 * posp) +{ + cc_uint32 pos; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + code = cci_msg_calc_header_size(msg, &pos); + pos += sizeof(cc_uint32); /*+ sizeof(cc_uint32) for magic*/ + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (gen_node->len != len && gen_node->data != data) { + pos += gen_node->len + sizeof(cc_uint32); + } else { + cci_generic_free_iterator(gen_iterator); + *posp = pos + sizeof(cc_uint32); + return ccNoError; + } + } + + cci_generic_free_iterator(gen_iterator); + return ccIteratorEnd; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_add_header(cc_msg_t* msg, void *header, cc_uint32 header_len) +{ + if ( msg == NULL || header == NULL ) + return ccErrBadParam; + + msg->header = header; + msg->header_len = header_len; + return ccNoError; +} + + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_flatten(cc_msg_t* msg, void **flatpp) +{ + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + char *cur_pos; + cc_uint32 zero = 0; + cc_uint32 magic = 0; + cc_uint32 msg_len; + cc_uint32 u32; + cc_int32 code; + + if (msg == NULL || flatpp == NULL) + return ccErrBadParam; + + code = cci_msg_calc_size(msg,&msg->flat_len); + if ( code != ccNoError ) + return code; + + if (msg->flat_len > CC_MSG_MAX_SIZE) + return ccErrBadParam; + + msg->flat = (void *)malloc(msg->flat_len); + if (msg->flat == NULL) + return ccErrNoMem; + + cur_pos = msg->flat; + + u32 = msg->header_len; + htonl(u32); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + u32 = msg->flat_len; + htonl(u32); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + u32 = msg->type; + htonl(u32); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + /* header data is already in network order */ + memcpy(cur_pos, msg->header, msg->header_len); + cur_pos += msg->header_len; + + u32 = zero; + htonl(zero); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*will be magic number later*/ + cur_pos += sizeof(cc_uint32); + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + if ( code != ccNoError ) { + free(msg->flat); + return code; + } + + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (code != ccNoError) { + free(gen_iterator); + free(msg->flat); + return code; + } + u32 = gen_node->len; + htonl(u32); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + /* data already in network order */ + memcpy(cur_pos, gen_node->data, gen_node->len); + cur_pos += gen_node->len; + } + free(gen_iterator); + + u32 = zero; + htonl(zero); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*magic number will go here later*/ + cur_pos += sizeof(cc_uint32); + + if (cur_pos - (char *)msg->flat != msg->flat_len) { + fprintf(stderr, "ERROR cur_pos - msg->flat = %d\n",msg->flat_len); + } + + cci_msg_calc_magic(msg->flat, msg->flat_len, &magic); + printf("magic = %d\n",magic); + + cci_msg_calc_header_size(msg, &msg_len); + memcpy((char *)msg->flat + msg_len, &magic, sizeof(cc_uint32)); + memcpy((char *)msg->flat + msg->flat_len - sizeof(cc_uint32), &magic, sizeof(cc_uint32)); + + if ( flatpp != NULL ) + *flatpp = msg->flat; + + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * magicp) +{ + cc_uint32 magic = 0; + int i; + + for (i = 0; i < flat_len; i += sizeof(cc_uint32)) { + magic = magic ^ *(int *)((char *)flat + i); + } + *magicp = htonl(magic); + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_verify(void *flat, int flat_len, cc_uint32 * validp) +{ + cc_uint32 *magic1, *magic2; + cc_uint32 *pheader_len; + cc_uint32 header_len; + cc_uint32 *ptotal_len; + cc_uint32 total_len; + cc_uint32 *pblob_len; + cc_uint32 blob_len; + cc_uint32 *ptype; + cc_uint32 type; + cc_uint32 num_blobs = 0; + cc_uint32 zero = 0; + cc_uint32 msg_magic, msg_magic2; + + if (flat == NULL || flat_len <= 0 || validp == NULL) + return ccErrBadParam; + + pheader_len = flat; + ptotal_len = (cc_uint32 *)((char *)pheader_len + sizeof(cc_uint32)); + ptype = (cc_uint32 *)((char *)ptotal_len + sizeof(cc_uint32)); + + header_len = ntohl(*pheader_len); + total_len = ntohl(*ptotal_len); + type = ntohl(*ptype); + + if (total_len != flat_len) { + *validp = 0; + return ccNoError; + } + + if (header_len > flat_len) { + /*too weak. We could verify header_len against type spec header.*/ + *validp = 0; + return ccNoError; + } + if (type > CC_MSG_MAX_TYPE) { + *validp = 0; + return ccNoError; + } + + magic1 = (cc_uint32 *)((char *)ptype + sizeof(cc_uint32) + header_len); + if ((char *)magic1 - (char *)flat == (flat_len - 8)) { + /*There are no data blobs*/ + magic2 = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); + num_blobs = 0; + } else { + pblob_len = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); + num_blobs = 1; + blob_len = ntohl(*pblob_len); + + while (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) < (flat_len - sizeof(cc_uint32))) { + pblob_len = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); + num_blobs++; + blob_len = ntohl(*pblob_len); + } + + if (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) != (flat_len - sizeof(cc_uint32))) { + /*blobs didn't line up*/ + *validp = 0; + return ccNoError; + } + magic2 = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); /*2nd magic should be directly after the last blob*/ + } + + if (*magic1 != *magic2) { + *validp = 0; + return ccNoError; + } + msg_magic = *magic1; + + printf("%d %d\n", (char *)magic1 - (char *)flat, (char *)magic2 - (char *)flat); + + memcpy(magic1, &zero, sizeof(cc_uint32)); + memcpy(magic2, &zero, sizeof(cc_uint32)); + cci_msg_calc_magic(flat, flat_len, &msg_magic2); + /* both msg_magic and msg_magic2 are in network order */ + if (msg_magic != msg_magic2) { + *validp = 0; + return ccNoError; + } + memcpy(magic1, &msg_magic, sizeof(cc_uint32)); + memcpy(magic2, &msg_magic, sizeof(cc_uint32)); + + *validp = 1; + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp) +{ + cc_msg_t* msg; + char *cur_pos; + cc_uint32 blob_len; + char *blob; + cc_uint32 valid; + cc_int32 code; + + if ( flat == NULL || flat_len <= 0 || msgpp == NULL ) + return ccErrBadParam; + + code = cci_msg_new(0, &msg); + if (code) + return code; + + cci_msg_verify(flat, flat_len, &valid); + if (valid != 1) { + cci_msg_destroy(msg); + return ccErrBadParam; + } + + cur_pos = flat; + msg->flat = flat; + + msg->header_len = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->flat_len = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->type = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->header = (void *)malloc(msg->header_len); + if (msg->header == NULL) { + cci_msg_destroy(msg); + return ccErrNoMem; + } + memcpy(msg->header, cur_pos, msg->header_len); + cur_pos += msg->header_len; + + msg->magic = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + if (cur_pos - (char *)flat != flat_len - 8) { /*at least 1 blob*/ + blob_len = ntohl(*(cc_uint32 *)cur_pos); + while (blob_len + (cur_pos - (char *)flat) + sizeof(cc_uint32) <= flat_len - sizeof(cc_uint32)) { + blob = (void *)malloc(blob_len); + if (blob == NULL) { + cci_msg_destroy(msg); + return ccErrNoMem; + } + memcpy(blob, cur_pos + sizeof(cc_uint32), blob_len); + cci_generic_list_append(msg->data_blobs, blob, blob_len, NULL); + + cur_pos += sizeof(cc_uint32) + blob_len; + blob_len = ntohl(*(int *)cur_pos); + } + } + *msgpp = msg; + return ccNoError; +} + +cc_int32 +cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **blobp) +{ + cc_generic_iterate_t* gen_iterator; + cc_generic_list_node_t* gen_node; + void *ret; + cc_uint32 blob_pos; + cc_int32 code; + + /*Ensure that the message has been unflattened*/ + if ( msg == NULL || msg->flat == NULL || blob_offset > msg->flat_len || + blob_len > msg->flat_len - blob_offset || blobp == NULL) + return ccErrBadParam; + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + code = cci_msg_calc_blob_pos(msg, gen_node->data, gen_node->len, &blob_pos); + if (blob_pos == blob_offset && gen_node->len == blob_len) { + free(gen_iterator); + ret = (void *)malloc(blob_len); + if (ret == NULL) + return ccErrNoMem; + memcpy(ret,(char *)msg->flat + blob_offset, blob_len); + *blobp = ret; + return ccNoError; + } + } + free(gen_iterator); + return ccIteratorEnd; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_destroy(cc_msg_t* msg) +{ + if (msg->flat != NULL) + free(msg->flat); + if (msg->header != NULL) + free(msg->flat); + cci_generic_list_destroy(msg->data_blobs); + free(msg); + return ccNoError; +} + -- cgit From 46feb62dc0a36171dd14d33a9aab8b9af42fc595 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 22 May 2006 17:17:07 +0000 Subject: Move msg.c and marshall.c to common library Add dllmain.c which contains the Windows DllMain() entry point. This must be moved later to a Windows specific directory. Cleanup type usage and function name references. All that is missing now from the client DLL is a definition of cci_perform_rpc() which is the entry point to the IPC routine. git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18028 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/NTMakefile | 21 +- src/lib/ccapi/client/cacheapi.c | 2 +- src/lib/ccapi/client/ccache.c | 8 +- src/lib/ccapi/client/ccache_iterator.c | 1 + src/lib/ccapi/client/ccapiv2.c | 11 +- src/lib/ccapi/client/ccstring.c | 12 +- src/lib/ccapi/client/ccstring.h | 10 +- src/lib/ccapi/client/context.c | 27 +- src/lib/ccapi/client/credentials.c | 4 +- src/lib/ccapi/client/credentials_iterator.c | 1 + src/lib/ccapi/client/dllmain.c | 15 + src/lib/ccapi/client/marshall.c | 445 -------------------- src/lib/ccapi/client/msg.c | 628 ---------------------------- 13 files changed, 72 insertions(+), 1113 deletions(-) create mode 100644 src/lib/ccapi/client/dllmain.c delete mode 100644 src/lib/ccapi/client/marshall.c delete mode 100644 src/lib/ccapi/client/msg.c (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/client/NTMakefile b/src/lib/ccapi/client/NTMakefile index 57ff87416..f9d85b463 100644 --- a/src/lib/ccapi/client/NTMakefile +++ b/src/lib/ccapi/client/NTMakefile @@ -1,22 +1,25 @@ !INCLUDE -CFLAGS = -I../include +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsdll) -CCAPI_OBJS = cacheapi.obj context.obj ccache.obj credentials.obj ccache_iterator.obj \ - credentials_iterator.obj ccstring.obj marshall.obj msg.obj +CC_CLIENT_OBJS = cacheapi.obj context.obj ccache.obj credentials.obj ccache_iterator.obj \ + credentials_iterator.obj ccstring.obj ccapiv2.obj -CCAPI_LIB = ccapi.lib +CC_CLIENT_LIB = cc_client.lib -$(CCAPI_LIB): $(CCAPI_OBJS) +CC_COMMON_LIB = ..\common\cc_common.lib + +$(CC_CLIENT_LIB): $(CC_CLIENT_OBJS) $(implib) /NOLOGO /OUT:$@ $** CCAPI_DLLFILE = krbcc32.dll -$(CCAPI_DLLFILE): $(CCAPI_LIB) - $(DLLGUILINK) -def:windows\krbcc32.def - $(DLLPREP) +WINLIBS = ws2_32.lib $(guilibsdll) msvcrt.lib + +$(CCAPI_DLLFILE): dllmain.obj $(CC_CLIENT_LIB) $(CC_COMMON_LIB) + $(link) /OUT:$@ $(ldebug) $(dlllflags) /NODEFAULTLIB:libcmt.lib -def:cacheapi.def $** $(WINLIBS) all: $(CCAPI_DLLFILE) clean: - del *.obj *.lib + del *.obj *.lib *.dll *.exp diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index 704925dfd..14a1eb476 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -116,7 +116,7 @@ cc_initialize ( cc_context_t* outContext, } 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, ntohl(response_header->out_ctx), 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; diff --git a/src/lib/ccapi/client/ccache.c b/src/lib/ccapi/client/ccache.c index 42064d54d..790ff6f67 100644 --- a/src/lib/ccapi/client/ccache.c +++ b/src/lib/ccapi/client/ccache.c @@ -48,10 +48,12 @@ #include #include #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 @@ -345,7 +347,7 @@ cc_int_ccache_get_name( cc_ccache_t ccache, cc_string_t* name ) code = cci_msg_retrieve_blob(response, response_header->name_offset, response_header->name_len, &string); if (code == ccNoError) { - code = cc_string_new(&name, string); + code = cci_string_new(name, string); free(string); } } else { @@ -403,7 +405,7 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, code = cci_msg_retrieve_blob(response, response_header->principal_offset, response_header->principal_len, &string); if (code == ccNoError) { - code = cc_string_new(&principal, string); + code = cci_string_new(principal, string); free(string); } } else { @@ -1035,7 +1037,7 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, 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 = ntohll(response_header->offset); + *time_offset = (cc_time64)ntohll(response_header->offset); code = ccNoError; } else { code = ccErrBadInternalMessage; diff --git a/src/lib/ccapi/client/ccache_iterator.c b/src/lib/ccapi/client/ccache_iterator.c index 3f3e1675e..b0ccbe610 100644 --- a/src/lib/ccapi/client/ccache_iterator.c +++ b/src/lib/ccapi/client/ccache_iterator.c @@ -46,6 +46,7 @@ #include #include #include +#include "ccache.h" #include "ccache_iterator.h" #include "cc_rpc.h" #include "msg.h" diff --git a/src/lib/ccapi/client/ccapiv2.c b/src/lib/ccapi/client/ccapiv2.c index ffbb589a2..82b04c2c8 100644 --- a/src/lib/ccapi/client/ccapiv2.c +++ b/src/lib/ccapi/client/ccapiv2.c @@ -69,7 +69,7 @@ CCACHE_API cc_int32 cc_get_NC_info ( CCACHE_API cc_int32 cc_get_change_time ( apiCB* inContext, - cc_time_t* outTime) + cc_time* outTime) { /* replace this return value when the function is implemented */ @@ -279,6 +279,15 @@ CCACHE_API cc_int32 cc_free_NC_info ( 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 } diff --git a/src/lib/ccapi/client/ccstring.c b/src/lib/ccapi/client/ccstring.c index 419bfef77..6f3fa2bcb 100644 --- a/src/lib/ccapi/client/ccstring.c +++ b/src/lib/ccapi/client/ccstring.c @@ -50,9 +50,9 @@ #include "ccstring.h" cc_int32 -cc_int_string_new( cc_string_t * pstring, char * data ) +cci_string_new( cc_string_t * pstring, char * data ) { - cc_int_string_t string = (cc_int_string_t)malloc(sizeof(cc_int_string_d)); + cci_string_t string = (cci_string_t)malloc(sizeof(cci_string_d)); if ( string == NULL ) return ccErrNoMem; @@ -63,7 +63,7 @@ cc_int_string_new( cc_string_t * pstring, char * data ) } string->magic = CC_STRING_MAGIC; - string->functions->release = cc_int_string_release; + string->functions->release = cci_string_release; string->data = strdup(data); if ( string->data == NULL ) { @@ -77,13 +77,13 @@ cc_int_string_new( cc_string_t * pstring, char * data ) } cc_int32 -cc_int_string_release( cc_string_t str ) +cci_string_release( cc_string_t str ) { - cc_int_string_t int_string; + cci_string_t int_string; if ( str == NULL ) return ccErrBadParam; - int_string = (cc_int_string_t)str; + int_string = (cci_string_t)str; if ( int_string->magic != CC_STRING_MAGIC ) return ccErrInvalidString; diff --git a/src/lib/ccapi/client/ccstring.h b/src/lib/ccapi/client/ccstring.h index 9e0ad223f..2c973afbb 100644 --- a/src/lib/ccapi/client/ccstring.h +++ b/src/lib/ccapi/client/ccstring.h @@ -45,7 +45,7 @@ #define CC_STRING_MAGIC ('S'<<24 | 'T'<<16 | 'R'<<8 | 'I') -struct cc_int_string_d { +struct cci_string_d { char* data; cc_string_f* functions; #if TARGET_OS_MAC @@ -53,13 +53,13 @@ struct cc_int_string_d { #endif cc_uint32 magic; }; -typedef struct cc_int_string_d cc_int_string_d; -typedef cc_int_string_d* cc_int_string_t; +typedef struct cci_string_d cci_string_d; +typedef cci_string_d* cci_string_t; cc_int32 -cc_int_string_new( cc_string_t * pstring, char * data ); +cci_string_new( cc_string_t * pstring, char * data ); cc_int32 -cc_int_string_release( cc_string_t string ); +cci_string_release( cc_string_t string ); diff --git a/src/lib/ccapi/client/context.c b/src/lib/ccapi/client/context.c index efac3020c..8515f695b 100644 --- a/src/lib/ccapi/client/context.c +++ b/src/lib/ccapi/client/context.c @@ -47,9 +47,12 @@ #include #include #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 * @@ -98,7 +101,6 @@ cc_int_context_release( cc_context_t context ) ccmsg_ctx_release_t *request_header; cc_msg_t *response; cc_uint32 type; - cc_time64 t64; cc_int32 code; if ( context == NULL ) @@ -112,7 +114,7 @@ cc_int_context_release( cc_context_t context ) request_header = (ccmsg_ctx_release_t*)malloc(sizeof(ccmsg_ctx_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = htonl(int_context->handle); + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_RELEASE, &request); if (code != ccNoError) { @@ -239,7 +241,7 @@ cc_int_context_get_default_ccache_name( cc_context_t context, code = cci_msg_retrieve_blob(response, response_header->name_offset, response_header->name_len, &string); if (code == ccNoError) { - code = cc_string_new(&name, string); + code = cci_string_new(name, string); free(string); } } else { @@ -277,8 +279,8 @@ cc_int_context_compare( cc_context_t context, request_header = (ccmsg_ctx_compare_t*)malloc(sizeof(ccmsg_ctx_compare_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx1 = htonl(int_context->handle); - request_header->ctx2 = htonl(int_compare_to->handle); + 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) { @@ -411,7 +413,7 @@ cc_int_context_open_ccache( cc_context_t context, code = ntohl(nack_header->err_code); } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -462,7 +464,7 @@ cc_int_context_open_default_ccache( cc_context_t context, code = ntohl(nack_header->err_code); } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -538,7 +540,7 @@ cc_int_context_create_ccache( cc_context_t context, code = ntohl(nack_header->err_code); } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -604,7 +606,7 @@ cc_int_context_create_default_ccache( cc_context_t context, code = ntohl(nack_header->err_code); } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -670,7 +672,7 @@ cc_int_context_create_new_ccache( cc_context_t context, code = ntohl(nack_header->err_code); } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response-> header; - code = cc_int_cache_new(ccache, int_context->handle, ntohll(response_header->ccache)); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } @@ -790,7 +792,7 @@ cc_int_context_clone( cc_context_t inContext, cc_int32* supportedVersion, char const** vendor ) { - cc_int_context_t int_context, new_context; + cc_int_context_t int_context; static char vendor_st[128] = ""; cc_msg_t *request; ccmsg_ctx_clone_t *request_header; @@ -845,7 +847,7 @@ cc_int_context_clone( cc_context_t inContext, } 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), nthol(response_header->out_version)); + code = cc_int_context_new(outContext, ntohll(response_header->out_ctx), ntohl(response_header->out_version)); if (!vendor_st[0]) { char * string; @@ -870,7 +872,6 @@ cc_int_context_get_version( cc_context_t context, cc_int32* version ) { cc_int_context_t int_context; - cc_int32 code; if ( context == NULL || version == NULL ) diff --git a/src/lib/ccapi/client/credentials.c b/src/lib/ccapi/client/credentials.c index 8b8867689..dbdf6345e 100644 --- a/src/lib/ccapi/client/credentials.c +++ b/src/lib/ccapi/client/credentials.c @@ -88,10 +88,10 @@ cc_int_credentials_new( cc_credentials_t *pcredentials, cc_uint32 version, switch ( version ) { case cc_credentials_v4: - code = cci_cred_v4_unmarshall(data, len, credentials->data); + code = cci_creds_v4_unmarshall(data, len, credentials->data); break; case cc_credentials_v5: - code = cci_cred_v5_unmarshall(data, len, credentials->data); + code = cci_creds_v5_unmarshall(data, len, credentials->data); break; default: free(credentials); diff --git a/src/lib/ccapi/client/credentials_iterator.c b/src/lib/ccapi/client/credentials_iterator.c index bae60ffdf..f61d0ade8 100644 --- a/src/lib/ccapi/client/credentials_iterator.c +++ b/src/lib/ccapi/client/credentials_iterator.c @@ -46,6 +46,7 @@ #include #include #include +#include "credentials.h" #include "credentials_iterator.h" #include "cc_rpc.h" #include "msg.h" diff --git a/src/lib/ccapi/client/dllmain.c b/src/lib/ccapi/client/dllmain.c new file mode 100644 index 000000000..6b4d6bfdd --- /dev/null +++ b/src/lib/ccapi/client/dllmain.c @@ -0,0 +1,15 @@ +#include + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + default: + return TRUE; + } +} + diff --git a/src/lib/ccapi/client/marshall.c b/src/lib/ccapi/client/marshall.c deleted file mode 100644 index 31ebacd7b..000000000 --- a/src/lib/ccapi/client/marshall.c +++ /dev/null @@ -1,445 +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). - * $ - */ - -/* marshall.c */ - -#include -#include -#include -#include "msg.h" -#include "msg_headers.h" -#include "marshall.h" - -cc_int32 -cci_creds_v4_marshall( cc_credentials_v4_t * creds, - char ** pflat, - cc_uint32 * plen) -{ - cc_uint32 len; - char * flat; - cci_flat_creds_v4_t * header; - cc_uint32 length; - cc_time64 t64; - - if ( creds == NULL || pflat == NULL || plen == NULL ) - return ccErrBadParam; - - len = sizeof(cci_flat_creds_v4_t); - flat = (char *)malloc(len); - if ( flat == NULL ) - return ccErrNoMem; - memset(flat, 0, len); - - header = (cci_flat_creds_v4_t *)flat; - header->version = htonl(creds->version); - memcpy(header->principal, creds->principal, cc_v4_name_size); - memcpy(header->principal_instance, creds->principal_instance, cc_v4_instance_size); - memcpy(header->service, creds->service, cc_v4_name_size); - memcpy(header->service_instance, creds->service_instance, cc_v4_instance_size); - memcpy(header->realm, creds->realm, cc_v4_realm_size); - memcpy(header->session_key, creds->session_key, cc_v4_key_size); - header->kvno = htonl(creds->kvno); - header->string_to_key_type = htonl(creds->string_to_key_type); - t64 = creds->issue_date; - header->issue_date = htonll(t64); - header->lifetime = htonl(creds->lifetime); - /* TODO: verify that address is stored in host order */ - header->address = htonl(creds->address); - header->ticket_size = htonl(creds->ticket_size); - memcpy(header->ticket, creds->ticket, cc_v4_ticket_size); - - *pflat = flat; - *plen = len; - - return ccNoError; -} - -cc_int32 -cci_creds_v4_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds_union) -{ - struct cci_flat_creds_v4 * header; - cc_credentials_v4_t * creds; - cc_flat_data * flat_data; - cc_time64 t64; - cc_uint32 length; - cc_int32 code; - - if ( flat == NULL || len == 0 || creds_union == NULL ) - return ccErrBadParam; - - creds_union->version = cc_credentials_v4; - - header = (cci_flat_creds_v4_t *)flat; - - creds = (cc_credentials_v4_t *)malloc(sizeof(cc_credentials_v4_t)); - if ( creds == NULL ) - return ccErrNoMem; - - creds->version = ntohl(header->version); - memcpy(creds->principal, header->principal, cc_v4_name_size); - memcpy(creds->principal_instance, header->principal_instance, cc_v4_instance_size); - memcpy(creds->service, header->service, cc_v4_name_size); - memcpy(creds->service_instance, header->service_instance, cc_v4_instance_size); - memcpy(creds->realm, header->realm, cc_v4_realm_size); - memcpy(creds->session_key, header->session_key, cc_v4_key_size); - creds->kvno = htonl(header->kvno); - creds->string_to_key_type = htonl(header->string_to_key_type); - t64 = header->issue_date; - creds->issue_date = ntohll(t64); - creds->lifetime = ntohl(header->lifetime); - /* TODO: verify that address is stored in host order */ - creds->address = ntohl(header->address); - creds->ticket_size = ntohl(header->ticket_size); - memcpy(creds->ticket, header->ticket, cc_v4_ticket_size); - - creds_union->credentials.credentials_v4 = creds; - - return ccNoError; -} - - -cc_int32 -cci_creds_cc_data_array_count_entries( cc_data ** array, cc_uint32 * pcount) -{ - cc_uint32 count; - - if (array == NULL) { - *pcount = 0; - return ccNoError; - } - - for ( count=0; array[count] != NULL ; count++) ; - - *pcount = count; - return ccNoError; -} - -cc_int32 -cci_creds_v5_compute_flat_size( cc_credentials_v5_t * creds, cc_uint32 * plen) -{ - cc_uint32 len; - cc_uint32 i, count; - - len = sizeof(struct cci_flat_creds_v5); - - if (creds->client) - len += strlen(creds->client) + 1; - - if (creds->server) - len += strlen(creds->server) + 1; - - len += creds->keyblock.length; - - cci_creds_cc_data_array_count_entries( creds->addresses, &count ); - len += count * sizeof(cc_flat_data); - for ( i=0; iaddresses[i]->length; - } - - len += creds->ticket.length; - len += creds->second_ticket.length; - - cci_creds_cc_data_array_count_entries( creds->authdata, &count ); - len += count * sizeof(cc_flat_data); - for ( i=0; iauthdata[i]->length; - } - - *plen = len; - return ccNoError; -} - -cc_int32 -cci_creds_v5_marshall( cc_credentials_v5_t * creds, - char ** pflat, - cc_uint32 * plen) -{ - cc_uint32 len; - char * flat; - struct cci_flat_creds_v5 * header; - cc_uint32 length; - cc_uint32 offset; - cc_time64 t64; - cc_uint32 count; - cc_uint32 i; - - if ( creds == NULL || pflat == NULL || plen == NULL ) - return ccErrBadParam; - - cci_creds_v5_compute_flat_size(creds, &len); - - flat = (char *)malloc(len); - if ( flat == NULL ) - return ccErrNoMem; - memset(flat, 0, len); - - offset = sizeof(struct cci_flat_creds_v5); - header = (struct cci_flat_creds_v5 *)flat; - header->version = htonl(FLAT_CREDS_V5_VERSION); - if (creds->client) { - length = strlen(creds->client) + 1; - header->client.length = htonl(length); - header->client.data = htonl(offset); - memcpy(flat + offset, creds->client, length); - offset += length; - } - - if (creds->server) { - length = strlen(creds->server) + 1; - header->server.length = htonl(length); - header->server.data = htonl(offset); - memcpy(flat + offset, creds->server, length); - offset += length; - } - - header->keyblock.type = htonl(creds->keyblock.type); - if (creds->keyblock.length) { - length = creds->keyblock.length; - header->keyblock.length = htonl(length); - header->keyblock.data = htonl(offset); - memcpy(flat + offset, creds->keyblock.data, length); - offset += length; - } - - t64 = creds->authtime; - header->authtime = htonll(t64); - t64 = creds->starttime; - header->starttime = htonll(t64); - t64 = creds->endtime; - header->endtime = htonll(t64); - t64 = creds->renew_till; - header->renew_till = htonll(t64); - - header->is_skey = htonl(creds->is_skey); - header->ticket_flags = htonl(creds->ticket_flags); - - cci_creds_cc_data_array_count_entries( creds->addresses, &count ); - if ( count ) { - cc_flat_data * addresses = (cc_flat_data *)flat + offset; - header->address_count = htonl(count); - header->addresses = htonl(offset); - offset += count * sizeof(cc_flat_data); - - for ( i=0; i < count; i++ ) { - addresses[i].type = htonl(creds->addresses[i]->type); - if (creds->addresses[i]->length) { - length = creds->addresses[i]->length; - addresses[i].length = htonl(length); - addresses[i].data = htonl(offset); - /* TODO: verify that addresses are stored in network order */ - memcpy(flat + offset, creds->addresses[i]->data, length); - offset += length; - } - } - } - - header->ticket.type = htonl(creds->ticket.type); - if (creds->ticket.length) { - length = creds->ticket.length; - header->ticket.length = htonl(length); - header->ticket.data = htonl(offset); - memcpy(flat + offset, creds->ticket.data, length); - offset += length; - } - - header->second_ticket.type = htonl(creds->second_ticket.type); - if (creds->second_ticket.length) { - length = creds->second_ticket.length; - header->second_ticket.length = htonl(length); - header->second_ticket.data = htonl(offset); - memcpy(flat + offset, creds->second_ticket.data, length); - offset += length; - } - - cci_creds_cc_data_array_count_entries( creds->authdata, &count ); - if ( count ) { - cc_flat_data * authdata = (cc_flat_data *)flat + offset; - - header->authdata_count = htonl(count); - header->authdata = (offset); - offset += count * sizeof(cc_flat_data); - - for ( i=0; i < count; i++ ) { - authdata[i].type = htonl(creds->authdata[i]->type); - if (creds->authdata[i]->length) { - length = creds->authdata[i]->length; - authdata[i].length = htonl(length); - authdata[i].data = htonl(offset); - memcpy(flat + offset, creds->authdata[i]->data, length); - offset += length; - } - } - } - - *pflat = flat; - *plen = len; - return ccNoError; -} - - -// TODO: a much better job of checking for out of memory errors -// and validating that we do not read beyond the flat input -// data buffer - -cc_int32 -cci_creds_v5_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds_union) -{ - struct cci_flat_creds_v5 * header; - cc_credentials_v5_t * creds; - cc_flat_data * flat_data; - cc_time64 t64; - cc_uint32 length; - cc_uint32 count; - cc_uint32 i; - cc_int32 code; - - if ( flat == NULL || len == 0 || creds_union == NULL ) - return ccErrBadParam; - - creds_union->version = cc_credentials_v5; - - header = (struct cci_flat_creds_v5 *)flat; - - if ( ntohl(header->version) != FLAT_CREDS_V5_VERSION ) - return ccErrBadParam; - - creds = (cc_credentials_v5_t *)malloc(sizeof(cc_credentials_v5_t)); - if ( creds == NULL ) - return ccErrNoMem; - memset(creds, 0, sizeof(cc_credentials_v5_t)); - - if ( header->client.length ) { - length = ntohl(header->client.length); - creds->client = (char *)malloc(length); - memcpy(creds->client, flat + header->client.data, length); - } - - if ( header->server.length ) { - length = ntohl(header->server.length); - creds->server = (char *)malloc(length); - memcpy(creds->server, flat + header->server.data, length); - } - - creds->keyblock.type = ntohl(header->keyblock.type); - if ( header->keyblock.length ) { - length = ntohl(header->keyblock.length); - creds->keyblock.length = length; - creds->keyblock.data = malloc(length); - memcpy(creds->keyblock.data, flat + header->keyblock.data, length); - } - - /* TODO: need to perform overflow validation checks to ensure - * that we do not attempt to store too large a value into cc_time_t - * when it is a 32-bit field. - */ - t64 = ntohll(header->authtime); - creds->authtime = (cc_time)t64; - t64 = ntohll(header->starttime); - creds->starttime = (cc_time)t64; - t64 = ntohll(header->endtime); - creds->endtime = (cc_time)t64; - t64 = ntohll(header->renew_till); - creds->renew_till = (cc_time)t64; - - creds->is_skey = ntohl(header->is_skey); - creds->ticket_flags = ntohl(header->ticket_flags); - - count = ntohl(header->address_count); - creds->addresses = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); - flat_data = (cc_flat_data *)flat + header->addresses; - for ( i=0 ; i < count ; i++ ) { - creds->addresses[i] = (cc_data *)malloc(sizeof(cc_data)); - creds->addresses[i]->type = ntohl(flat_data[i].type); - length = ntohl(flat_data[i].length); - creds->addresses[i]->length = length; - if ( length ) { - creds->addresses[i]->data = malloc(length); - /* TODO: verify that addresses are stored in network order */ - memcpy(creds->addresses[i]->data, flat + flat_data[i].data, length); - } else { - creds->addresses[i]->data = NULL; - } - } - creds->addresses[i] = NULL; - - creds->ticket.type = ntohl(header->ticket.type); - length = ntohl(header->ticket.length); - if ( length ) { - creds->ticket.length = length; - creds->ticket.data = malloc(length); - memcpy(creds->ticket.data, flat + header->ticket.data, length); - } - - creds->second_ticket.type = header->second_ticket.type; - if ( header->second_ticket.length ) { - creds->second_ticket.length = header->second_ticket.length; - creds->second_ticket.data = malloc(creds->second_ticket.length); - memcpy(creds->second_ticket.data, flat + header->second_ticket.data, creds->second_ticket.length); - } - - count = ntohl(header->authdata_count); - creds->authdata = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); - flat_data = (cc_flat_data *)flat + header->authdata; - for ( i=0 ; i < count ; i++ ) { - creds->authdata[i] = (cc_data *)malloc(sizeof(cc_data)); - creds->authdata[i]->type = ntohl(flat_data[i].type); - length = ntohl(flat_data[i].length); - creds->authdata[i]->length = length; - if ( length ) { - creds->authdata[i]->data = malloc(length); - memcpy(creds->authdata[i]->data, flat + flat_data[i].data, length); - } else { - creds->authdata[i]->data = NULL; - } - } - creds->authdata[i] = NULL; - - creds_union->credentials.credentials_v5 = creds; - - return ccNoError; -} - diff --git a/src/lib/ccapi/client/msg.c b/src/lib/ccapi/client/msg.c deleted file mode 100644 index facaffffc..000000000 --- a/src/lib/ccapi/client/msg.c +++ /dev/null @@ -1,628 +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). - * $ - */ - -/* - * Verifiable, extensible message format. - * - * Format: - * - * - * - * - * - * - * - * - * - * ... - * - * - * If the header has variable length data it is included in the data blobs. - * The header field has the offset from the beginning of the message of the 1st - * byte of the data and the length of the data. - */ - -#include "CredentialsCache.h" -#include "msg.h" -#include "generic_lists.h" - -#include -#include -#include -#include - -/** - * cci_msg_new() - * - * Purpose: Allocate and initialize a new cc_msg_t structure - * - * Input parameter (type) in host order - * - * Return: non-NULL, the msg - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_msg_new(cc_uint32 type, cc_msg_t** msgpp) -{ - // type should be validated. If invalid set error to ccErrBadParam - cc_msg_t* msg; - - if ( type > CC_MSG_MAX_TYPE || msgpp == NULL ) - return ccErrBadParam; - - msg = (cc_msg_t*)malloc(sizeof(cc_msg_t)); - if (msg == NULL) - return ccErrNoMem; - - msg->type = htonl(type); - msg->flat = NULL; - msg->header = NULL; - msg->flat_len = 0; - msg->header_len = 0; - msg->magic = 0; - cci_generic_list_new(&msg->data_blobs); - if (msg->data_blobs == NULL) { - // pass on error from previous call - free(msg); - return ccErrNoMem; - } - - *msgpp = msg; - return ccNoError; -} - -/** - * cci_msg_calc_header_size() - * - * Purpose: Calculates the size of the header - * - * Return: the size in bytes - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_msg_calc_header_size(cc_msg_t* msg, cc_uint32 * lenp) -{ - int header_len = 12; /* header size, entire size, type */ - - if ( msg == NULL || lenp == NULL ) - return ccErrBadParam; - - header_len += msg->header_len; - *lenp = header_len; - return ccNoError; -} - -/** - * cci_msg_calc_size() - * - * Purpose: Calculates the size of the message - * (does not include the magic bytes) - * - * Return: the size in bytes - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_msg_calc_size(cc_msg_t* msg, cc_uint32 * lenp) -{ - cc_uint32 flat_len; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - if ( msg == NULL || lenp == NULL ) - return ccErrBadParam; - - code = cci_msg_calc_header_size(msg, &flat_len); - if (code != ccNoError) - goto bad; - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - if ( code != ccNoError ) - goto bad; - - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (code != ccNoError) - break; - flat_len += gen_node->len + BLOB_LEN; - } - cci_generic_free_iterator(gen_iterator); - if (code != ccNoError) - goto bad; - - flat_len += MAGIC_HEAD_LEN + MAGIC_DATA_LEN; - *lenp = flat_len; - - bad: - return code; -} - -/** - * cci_msg_add_data_blob() - * - * Purpose: Adds 'len' bytes of data to the msg - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_add_data_blob(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 *lenp) -{ - cc_int32 code; - - if (msg == NULL || data == NULL || len <= 0 || lenp == NULL) - return ccErrBadParam; - - code = cci_generic_list_append(msg->data_blobs, data, len, NULL); - if ( code != ccNoError ) - return code; - return cci_msg_calc_blob_pos(msg, data, len, lenp); -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_calc_blob_pos(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 * posp) -{ - cc_uint32 pos; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - code = cci_msg_calc_header_size(msg, &pos); - pos += sizeof(cc_uint32); /*+ sizeof(cc_uint32) for magic*/ - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (gen_node->len != len && gen_node->data != data) { - pos += gen_node->len + sizeof(cc_uint32); - } else { - cci_generic_free_iterator(gen_iterator); - *posp = pos + sizeof(cc_uint32); - return ccNoError; - } - } - - cci_generic_free_iterator(gen_iterator); - return ccIteratorEnd; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_add_header(cc_msg_t* msg, void *header, cc_uint32 header_len) -{ - if ( msg == NULL || header == NULL ) - return ccErrBadParam; - - msg->header = header; - msg->header_len = header_len; - return ccNoError; -} - - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_flatten(cc_msg_t* msg, void **flatpp) -{ - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - char *cur_pos; - cc_uint32 zero = 0; - cc_uint32 magic = 0; - cc_uint32 msg_len; - cc_uint32 u32; - cc_int32 code; - - if (msg == NULL || flatpp == NULL) - return ccErrBadParam; - - code = cci_msg_calc_size(msg,&msg->flat_len); - if ( code != ccNoError ) - return code; - - if (msg->flat_len > CC_MSG_MAX_SIZE) - return ccErrBadParam; - - msg->flat = (void *)malloc(msg->flat_len); - if (msg->flat == NULL) - return ccErrNoMem; - - cur_pos = msg->flat; - - u32 = msg->header_len; - htonl(u32); - memcpy(cur_pos,&u32,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - u32 = msg->flat_len; - htonl(u32); - memcpy(cur_pos,&u32,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - u32 = msg->type; - htonl(u32); - memcpy(cur_pos,&u32,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - /* header data is already in network order */ - memcpy(cur_pos, msg->header, msg->header_len); - cur_pos += msg->header_len; - - u32 = zero; - htonl(zero); - memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*will be magic number later*/ - cur_pos += sizeof(cc_uint32); - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - if ( code != ccNoError ) { - free(msg->flat); - return code; - } - - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (code != ccNoError) { - free(gen_iterator); - free(msg->flat); - return code; - } - u32 = gen_node->len; - htonl(u32); - memcpy(cur_pos, &u32, sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - /* data already in network order */ - memcpy(cur_pos, gen_node->data, gen_node->len); - cur_pos += gen_node->len; - } - free(gen_iterator); - - u32 = zero; - htonl(zero); - memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*magic number will go here later*/ - cur_pos += sizeof(cc_uint32); - - if (cur_pos - (char *)msg->flat != msg->flat_len) { - fprintf(stderr, "ERROR cur_pos - msg->flat = %d\n",msg->flat_len); - } - - cci_msg_calc_magic(msg->flat, msg->flat_len, &magic); - printf("magic = %d\n",magic); - - cci_msg_calc_header_size(msg, &msg_len); - memcpy((char *)msg->flat + msg_len, &magic, sizeof(cc_uint32)); - memcpy((char *)msg->flat + msg->flat_len - sizeof(cc_uint32), &magic, sizeof(cc_uint32)); - - if ( flatpp != NULL ) - *flatpp = msg->flat; - - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * magicp) -{ - cc_uint32 magic = 0; - int i; - - for (i = 0; i < flat_len; i += sizeof(cc_uint32)) { - magic = magic ^ *(int *)((char *)flat + i); - } - *magicp = htonl(magic); - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_verify(void *flat, int flat_len, cc_uint32 * validp) -{ - cc_uint32 *magic1, *magic2; - cc_uint32 *pheader_len; - cc_uint32 header_len; - cc_uint32 *ptotal_len; - cc_uint32 total_len; - cc_uint32 *pblob_len; - cc_uint32 blob_len; - cc_uint32 *ptype; - cc_uint32 type; - cc_uint32 num_blobs = 0; - cc_uint32 zero = 0; - cc_uint32 msg_magic, msg_magic2; - - if (flat == NULL || flat_len <= 0 || validp == NULL) - return ccErrBadParam; - - pheader_len = flat; - ptotal_len = (cc_uint32 *)((char *)pheader_len + sizeof(cc_uint32)); - ptype = (cc_uint32 *)((char *)ptotal_len + sizeof(cc_uint32)); - - header_len = ntohl(*pheader_len); - total_len = ntohl(*ptotal_len); - type = ntohl(*ptype); - - if (total_len != flat_len) { - *validp = 0; - return ccNoError; - } - - if (header_len > flat_len) { - /*too weak. We could verify header_len against type spec header.*/ - *validp = 0; - return ccNoError; - } - if (type > CC_MSG_MAX_TYPE) { - *validp = 0; - return ccNoError; - } - - magic1 = (cc_uint32 *)((char *)ptype + sizeof(cc_uint32) + header_len); - if ((char *)magic1 - (char *)flat == (flat_len - 8)) { - /*There are no data blobs*/ - magic2 = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); - num_blobs = 0; - } else { - pblob_len = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); - num_blobs = 1; - blob_len = nothl(*pblob_len); - - while (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) < (flat_len - sizeof(cc_uint32))) { - pblob_len = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); - num_blobs++; - blob_len = ntohl(*pblob_len); - } - - if (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) != (flat_len - sizeof(cc_uint32))) { - /*blobs didn't line up*/ - *validp = 0; - return ccNoError; - } - magic2 = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); /*2nd magic should be directly after the last blob*/ - } - - if (*magic1 != *magic2) { - *validp = 0; - return ccNoError; - } - msg_magic = *magic1; - - printf("%d %d\n", (char *)magic1 - (char *)flat, (char *)magic2 - (char *)flat); - - memcpy(magic1, &zero, sizeof(cc_uint32)); - memcpy(magic2, &zero, sizeof(cc_uint32)); - cci_msg_calc_magic(flat, flat_len, &msg_magic2); - /* both msg_magic and msg_magic2 are in network order */ - if (msg_magic != msg_magic2) { - *validp = 0; - return ccNoError; - } - memcpy(magic1, &msg_magic, sizeof(cc_uint32)); - memcpy(magic2, &msg_magic, sizeof(cc_uint32)); - - *validp = 1; - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp) -{ - cc_msg_t* msg; - char *cur_pos; - cc_uint32 blob_len; - char *blob; - cc_uint32 valid; - cc_int32 code; - - if ( flat == NULL || flat_len <= 0 || msgpp == NULL ) - return ccErrBadParam; - - code = cci_msg_new(0, &msg); - if (code) - return code; - - cci_msg_verify(flat, flat_len, &valid); - if (valid != 1) { - cci_msg_destroy(msg); - return ccErrBadParam; - } - - cur_pos = flat; - msg->flat = flat; - - msg->header_len = ntohl(*(cc_uint32 *)cur_pos); - cur_pos += sizeof(cc_uint32); - - msg->flat_len = ntohl(*(cc_uint32 *)cur_pos); - cur_pos += sizeof(cc_uint32); - - msg->type = ntohl(*(cc_uint32 *)cur_pos); - cur_pos += sizeof(cc_uint32); - - msg->header = (void *)malloc(msg->header_len); - if (msg->header == NULL) { - cci_msg_destroy(msg); - return ccErrNoMem; - } - memcpy(msg->header, cur_pos, msg->header_len); - cur_pos += msg->header_len; - - msg->magic = nothl(*(cc_uint32 *)cur_pos); - cur_pos += sizeof(cc_uint32); - - if (cur_pos - (char *)flat != flat_len - 8) { /*at least 1 blob*/ - blob_len = ntohl(*(cc_uint32 *)cur_pos); - while (blob_len + (cur_pos - (char *)flat) + sizeof(cc_uint32) <= flat_len - sizeof(cc_uint32)) { - blob = (void *)malloc(blob_len); - if (blob == NULL) { - cci_msg_destroy(msg); - return ccErrNoMem; - } - memcpy(blob, cur_pos + sizeof(cc_uint32), blob_len); - cci_generic_list_append(msg->data_blobs, blob, blob_len, NULL); - - cur_pos += sizeof(cc_uint32) + blob_len; - blob_len = ntohl(*(int *)cur_pos); - } - } - *msgpp = msg; - return ccNoError; -} - -cc_int32 -cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **blobp) -{ - cc_generic_iterate_t* gen_iterator; - cc_generic_list_node_t* gen_node; - void *ret; - cc_uint32 blob_pos; - cc_int32 code; - - /*Ensure that the message has been unflattened*/ - if ( msg == NULL || msg->flat == NULL || blob_offset > msg->flat_len || - blob_len > msg->flat_len - blob_offset || blobp == NULL) - return ccErrBadParam; - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - code = cci_msg_calc_blob_pos(msg, gen_node->data, gen_node->len, &blob_pos); - if (blob_pos == blob_offset && gen_node->len == blob_len) { - free(gen_iterator); - ret = (void *)malloc(blob_len); - if (ret == NULL) - return ccErrNoMem; - memcpy(ret,(char *)msg->flat + blob_offset, blob_len); - *blobp = ret; - return ccNoError; - } - } - free(gen_iterator); - return ccIteratorEnd; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_destroy(cc_msg_t* msg) -{ - if (msg->flat != NULL) - free(msg->flat); - if (msg->header != NULL) - free(msg->flat); - cci_generic_list_destroy(msg->data_blobs); - free(msg); - return ccNoError; -} - -- cgit From 395cb4fe2007693553b37dc53981218e72b3b389 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 22 May 2006 17:18:27 +0000 Subject: Move generic list functions to common/generic_lists.c so they can be used by both the client dll and the server. Fix type utilization in serv_ops.c git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18029 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/server/ccs_lists.c | 340 --------------------------------------- src/lib/ccapi/server/serv_ops.c | 2 +- 2 files changed, 1 insertion(+), 341 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/server/ccs_lists.c b/src/lib/ccapi/server/ccs_lists.c index 06f8ced87..95ca398fb 100644 --- a/src/lib/ccapi/server/ccs_lists.c +++ b/src/lib/ccapi/server/ccs_lists.c @@ -54,51 +54,6 @@ #include "CredentialsCache.h" #include "datastore.h" -/** - * cci_generic_iterate_has_next() - * - * Purpose: Determine if an iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - * - * Errors: None - * - */ -cc_int32 -cci_generic_iterate_has_next(cc_generic_iterate_t *iterate) -{ - return ((iterate == NULL || iterate->next == NULL) ? 0 : 1); -} - -/** - * cci_generic_iterate_next() - * - * Purpose: Retrieve the next element from an iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_iterate_next(cc_generic_iterate_t *iterator, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* ret; - - if (iterator == NULL || nodepp == NULL) - return ccErrBadParam; - - ret = iterator->next; - if (iterator->next != NULL) - iterator->next = iterator->next->next; - - *nodepp = ret; - return ccNoError; -} - /** * ccs_context_iterate_has_next() * @@ -219,214 +174,6 @@ ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_l return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_credentials_list_node_t**)nodepp); } -/** - * cci_generic_list_new() - * - * Purpose: Allocate new generic list - * - * Return: non-NULL, an empty list - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_generic_list_new(cc_generic_list_head_t ** listpp) -{ - cc_generic_list_head_t* ret = (cc_generic_list_head_t *)malloc(sizeof(cc_generic_list_head_t)); - if (ret == NULL) - return ccErrNoMem; - - ret->type = generic; - ret->head = ret->tail = NULL; - *listpp = ret; - - return ccNoError; -} - -/** - * cci_generic_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* new_node; - - if ( data == NULL || len == 0 ) - return ccErrBadParam; - - new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); - if (new_node == NULL) - return ccErrNoMem; - - new_node->data = malloc(len); - if ( new_node->data == NULL ) { - free(new_node); - return ccErrNoMem; - } - - memcpy(new_node->data,data,len); - new_node->len = len; - - if (head->head == NULL) { /*empty list*/ - head->head = new_node; - head->tail = new_node; - new_node->next = new_node->prev = NULL; - } else { - new_node->prev = head->tail; - head->tail->next = new_node; - head->tail = new_node; - new_node->next = NULL; - } - if (nodepp != NULL) - *nodepp = new_node; - return ccNoError; -} - -/** - * cci_generic_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem, ccErrBadParam - * - */ -cc_int32 -cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* new_node; - - if ( data == NULL || len == 0 ) - return ccErrBadParam; - - new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); - if (new_node == NULL) - return ccErrNoMem; - - new_node->data = malloc(len); - if ( new_node->data == NULL ) { - free(new_node); - return ccErrNoMem; - } - - memcpy(new_node->data,data,len); - new_node->len = len; - - if (head->head == NULL) { /*empty list*/ - head->head = new_node; - head->tail = new_node; - new_node->prev = new_node->next = NULL; - } else { - new_node->next = head->head; - head->head->prev = new_node; - new_node->prev = NULL; - head->head = new_node; - } - - if (nodepp != NULL) - *nodepp = new_node; - - return ccNoError; -} - -/** - * cci_generic_list_remove_element() - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem) -{ - if (head->head == NULL || rem == NULL) - return ccErrBadParam; - - if (head->head == rem && head->tail == rem) { /*removing only element of list*/ - head->head = head->tail = NULL; - } else if (head->head == rem) { /*removing head*/ - head->head = head->head->next; - } else if (head->tail == rem) { /*removing tail*/ - head->tail = head->tail->prev; - head->tail->next = NULL; - } else { - rem->prev->next = rem->next; - rem->next->prev = rem->prev; - } - free(rem); - return ccNoError; -} - -/** - * cci_generic_free_element() - * - * Purpose: Free the memory associated with a node - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_free_element(cc_generic_list_node_t* node) -{ - if ( node == NULL ) - return ccErrBadParam; - - if ( node->data ) { - free(node->data); - node->data = NULL; - } - node->len = 0; - node->next = node->prev = NULL; - free(node); - return ccNoError; -} - - -/** - * cci_generic_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_generic_list_destroy(cc_generic_list_head_t* head) -{ - cc_generic_list_node_t *cur, *next; - cc_int32 ret = ccNoError; - - if ( head == NULL ) - return ccErrBadParam; - - for (cur = head->head; ret == ccNoError && cur != NULL; cur = next) { - next = cur->next; - ret = cci_generic_free_element(cur); - } - free(head); - return(ret); -} - /** * ccs_context_list_destroy() * @@ -475,42 +222,6 @@ ccs_credentials_list_destroy(cc_credentials_list_head_t* head) return cci_generic_list_destroy((cc_generic_list_head_t*)head); } -/** - * cci_generic_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - * - */ -cc_int32 -cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t** headpp) -{ - cc_generic_list_head_t* copy; - cc_generic_list_node_t *src_node, *dst_node; - cc_int32 code; - - if (head == NULL || headpp == NULL) - return ccErrBadParam; - - code = cci_generic_list_new(©); - if (code != ccNoError) - return code; - - for (src_node = head->head; src_node != NULL; src_node = src_node->next) { - code = cci_generic_list_append(copy, src_node->data, src_node->len, &dst_node); - if (code != ccNoError) { - cci_generic_list_destroy(copy); - return code; - } - } - *headpp = copy; - return ccNoError; -} - /** * ccs_context_list_copy() * @@ -562,57 +273,6 @@ ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_ } -/** - * cci_generic_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t** headpp) -{ - cc_generic_iterate_t* iterator; - - if ( head == NULL || headpp == NULL ) - return ccErrBadParam; - - iterator = (cc_generic_iterate_t*)malloc(sizeof(cc_generic_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *headpp = iterator; - return ccNoError; -} - -/** - * cci_generic_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_free_iterator(cc_generic_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - - /** * ccs_context_list_new() * diff --git a/src/lib/ccapi/server/serv_ops.c b/src/lib/ccapi/server/serv_ops.c index 01a9742cd..9c544fc58 100644 --- a/src/lib/ccapi/server/serv_ops.c +++ b/src/lib/ccapi/server/serv_ops.c @@ -549,7 +549,7 @@ ccop_CTX_COMPARE(cc_server_context_t* ctx, { cc_server_context_t *ctx2; ccmsg_ctx_compare_resp_t* resp_header; - ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)(ntohll(msg->header)); + ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)msg->header; cc_uint32 header_len = ntohl(msg->header_len); cc_int32 code; -- cgit From 3d6591dd63c23bcc0ae68e94a960c85fd53daad0 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 5 Jun 2006 04:30:35 +0000 Subject: more updates git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18082 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/NTMakefile | 25 ++ src/lib/ccapi/client/NTMakefile | 13 +- src/lib/ccapi/client/cacheapi.def | 29 -- src/lib/ccapi/client/dllmain.c | 15 - src/lib/ccapi/common/NTMakefile | 2 +- src/lib/ccapi/doc/implementation-notes.txt | 156 +++++++ src/lib/ccapi/include/CredentialsCache.h | 4 + src/lib/ccapi/include/CredentialsCache2.h | 22 +- src/lib/ccapi/include/datastore.h | 189 +++++++++ src/lib/ccapi/include/rpc_auth.h | 71 ++++ src/lib/ccapi/server/NTMakefile | 21 +- src/lib/ccapi/server/datastore.h | 189 --------- src/lib/ccapi/server/rpc_auth.h | 71 ---- src/lib/ccapi/unit-test/NTMakefile | 56 ++- src/lib/ccapi/unit-test/t_ccache.c | 24 +- src/lib/ccapi/unit-test/t_context.c | 34 +- src/lib/ccapi/unit-test/t_server.c | 4 +- src/lib/ccapi/windows/NTMakefile | 35 ++ src/lib/ccapi/windows/cacheapi.def | 29 ++ src/lib/ccapi/windows/client.c | 120 ++++++ src/lib/ccapi/windows/dllmain.c | 15 + src/lib/ccapi/windows/ntccrpc.acf | 8 + src/lib/ccapi/windows/ntccrpc.idl | 31 ++ src/lib/ccapi/windows/server.c | 638 +++++++++++++++++++++++++++++ 24 files changed, 1422 insertions(+), 379 deletions(-) create mode 100644 src/lib/ccapi/NTMakefile delete mode 100644 src/lib/ccapi/client/cacheapi.def delete mode 100644 src/lib/ccapi/client/dllmain.c create mode 100644 src/lib/ccapi/doc/implementation-notes.txt create mode 100644 src/lib/ccapi/include/datastore.h create mode 100644 src/lib/ccapi/include/rpc_auth.h delete mode 100644 src/lib/ccapi/server/datastore.h delete mode 100644 src/lib/ccapi/server/rpc_auth.h create mode 100644 src/lib/ccapi/windows/NTMakefile create mode 100644 src/lib/ccapi/windows/cacheapi.def create mode 100644 src/lib/ccapi/windows/client.c create mode 100644 src/lib/ccapi/windows/dllmain.c create mode 100644 src/lib/ccapi/windows/ntccrpc.acf create mode 100644 src/lib/ccapi/windows/ntccrpc.idl create mode 100644 src/lib/ccapi/windows/server.c (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/NTMakefile b/src/lib/ccapi/NTMakefile new file mode 100644 index 000000000..57c42e337 --- /dev/null +++ b/src/lib/ccapi/NTMakefile @@ -0,0 +1,25 @@ +CD = cd + +all: + $(CD) common + $(MAKE) -f NTMakefile all + $(CD) ../client + $(MAKE) -f NTMakefile all + $(CD) ../server + $(MAKE) -f NTMakefile all + $(CD) ../windows + $(MAKE) -f NTMakefile all + $(CD) .. + +clean: + $(CD) common + $(MAKE) -f NTMakefile clean + $(CD) ../client + $(MAKE) -f NTMakefile clean + $(CD) ../server + $(MAKE) -f NTMakefile clean + $(CD) ../windows + $(MAKE) -f NTMakefile clean + $(CD) .. + + diff --git a/src/lib/ccapi/client/NTMakefile b/src/lib/ccapi/client/NTMakefile index f9d85b463..2ce87c350 100644 --- a/src/lib/ccapi/client/NTMakefile +++ b/src/lib/ccapi/client/NTMakefile @@ -1,6 +1,6 @@ !INCLUDE -CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsdll) +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 @@ -12,14 +12,7 @@ CC_COMMON_LIB = ..\common\cc_common.lib $(CC_CLIENT_LIB): $(CC_CLIENT_OBJS) $(implib) /NOLOGO /OUT:$@ $** -CCAPI_DLLFILE = krbcc32.dll - -WINLIBS = ws2_32.lib $(guilibsdll) msvcrt.lib - -$(CCAPI_DLLFILE): dllmain.obj $(CC_CLIENT_LIB) $(CC_COMMON_LIB) - $(link) /OUT:$@ $(ldebug) $(dlllflags) /NODEFAULTLIB:libcmt.lib -def:cacheapi.def $** $(WINLIBS) - -all: $(CCAPI_DLLFILE) +all: $(CC_CLIENT_LIB) clean: - del *.obj *.lib *.dll *.exp + del *.obj *.lib diff --git a/src/lib/ccapi/client/cacheapi.def b/src/lib/ccapi/client/cacheapi.def deleted file mode 100644 index c54cc1106..000000000 --- a/src/lib/ccapi/client/cacheapi.def +++ /dev/null @@ -1,29 +0,0 @@ -EXPORTS - ; ccapi v3 only exports one function - cc_initialize @14 - - ; ccapi v2 compatibility functions - cc_close @2 - cc_create @3 - cc_destroy @4 - cc_free_NC_info @5 - cc_free_creds @6 - cc_free_name @7 - cc_free_principal @8 - cc_get_NC_info @9 - cc_get_change_time @10 - cc_get_cred_version @11 - cc_get_name @12 - cc_get_principal @13 - cc_lock_request @15 - cc_open @16 - cc_remove_cred @17 - cc_seq_fetch_NCs_begin @18 - cc_seq_fetch_NCs_end @19 - cc_seq_fetch_NCs_next @20 - cc_seq_fetch_creds_begin @21 - cc_seq_fetch_creds_end @22 - cc_seq_fetch_creds_next @23 - cc_set_principal @24 - cc_shutdown @25 - cc_store @26 diff --git a/src/lib/ccapi/client/dllmain.c b/src/lib/ccapi/client/dllmain.c deleted file mode 100644 index 6b4d6bfdd..000000000 --- a/src/lib/ccapi/client/dllmain.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, - LPVOID lpvReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - default: - return TRUE; - } -} - diff --git a/src/lib/ccapi/common/NTMakefile b/src/lib/ccapi/common/NTMakefile index d0d92fcbd..a43985af3 100644 --- a/src/lib/ccapi/common/NTMakefile +++ b/src/lib/ccapi/common/NTMakefile @@ -1,6 +1,6 @@ !INCLUDE -CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsdll) +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) CC_COMMON_OBJS = marshall.obj msg.obj generic_lists.obj diff --git a/src/lib/ccapi/doc/implementation-notes.txt b/src/lib/ccapi/doc/implementation-notes.txt new file mode 100644 index 000000000..e6150fb23 --- /dev/null +++ b/src/lib/ccapi/doc/implementation-notes.txt @@ -0,0 +1,156 @@ +The following are notes describing the requirements of the Platform +Specific code necessary for constructing a Portable CCAPI. + +Directory structure: + + lib/ccapi/client - platform independent client library + lib/ccapi/common - platform independent common library + lib/ccapi/include - platform independent header files + lib/ccapi/mac - macosx specific headers, libraries, executables + lib/ccapi/server - platform independent server library + lib/ccapi/windows - windows specific headers, libraries, executables + + +Platform Independent Design: + +The functionality of the Portable CCAPI is implemented in the platform +independent libraries. The common library encapsulates the functions +for managing generic lists, iterators, and messages as well as routines +formarshalling and unmarshalling. The client library provides the +client side routines for issuing requests to the ccapi server minus the +platform dependent glue required for shared library initialization, +cleanup, and interprocess communications. The server library provides +server side functionality for managing credential cache collections, +caches, credentials, iterators, and their handles minus the platform +dependent glue for process initialization, interprocess communication, +session security, and critical section enforcement. + + +Platform Dependent Design Requirements: + +The platform dependent code is responsible for producing a shared +client library: + + + the shared library is built from cc_client.lib and cc_common.lib plus + platform dependent glue + + - [windows] link cc_client.lib and cc_common.lib with platform + dependent routines and export list (.def) to produce + krbcc32.{lib,dll} + + + initialization and cleanup + + - [windows] provide DllMain entry point providing Process and Thread + attachment and detachment routines + + + implement cci_perform_rpc() function used by cc_client.lib + cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response) + + - cci_perform_rpc() takes an input request cc_msg_t object, flattens + it with cci_msg_flatten() and sends the contents of unsigned char + buffer request->flat of length request->flat_len to the server + utilizing a platform specific interprocess communication method. + + - upon IPC success, cci_perform_rpc() unflattens the response buffer + with cci_msg_unflatten() and returns the new cc_msg_t response + object to the caller. + + - cci_perform_rpc() is responsible for performing any necessary + session security management. For example, on Windows the Logon + Provider executes under the local machine's "SYSTEM" account within + session 0 and not under the account of the user that is logging in + nor within the session the user's desktop and applications will be + running within. It is the responsibility of cci_perform_rpc() and + the platform dependent IPC mechanism to communicate the user's + security identifiers to the server. + + For Windows, this means that the platform specific IPC messaging + allows a username and session identifier to be sent separate from + the username and session identifier that will be obtained via the + use of Local RPC. If the Local RPC authenticates the user as + "SYSTEM" and session 0, then the communicated values (if provided) + will be used instead. + + + implement client side of IPC routine. + + - [windows] the client side IPC routine is produced by compiling a + IDL file. The IDL defines an interface with a single function: + + __int32 ccapi_Message ( + [in] handle_t h, + [in, string] unsigned char * client_name, + [in] struct _LUID luid, + [in] __int32 in_len, + [in, string, size_is(in_len)] unsigned char * in_buf, + [in] __int32 out_size, + [out] __int32 * out_len, + [out, string, size_is(out_size)] unsigned char + out_buf[*]); + + The handle is a Local RPC specific handle used to identify the + request. The client_name and luid are the override values for the + username and session identifier for use during Windows login. The + rest of the parameters provide the input and output buffers as well + as allow communication of the actual length of the message data + that is required by cci_msg_unflatten(). + + + if the CCAPI server is per-session, the shared client library is + responsible for ensuring that an instance of the server is running in + the current session. If not, the library must initiate an instance + of the CCAPI server prior to performing any IPC requests. + +The platform dependent code is responsible for producing a server +executable: + + + The server executable is built from cc_server.lib and cc_common.lib + plus platform dependent glue. + + - [windows] The Windows CCAPI Server is being built using the + per-system model. The platform specific code is responsible for + providing NT Service Management routines for installation and + removal as well as the NT Service Entry Points used when the + process is started as an NT Service. + + link cc_server.lib and cc_common.lib with platform dependent + routines to produce krbcc32s.exe. + + + Based upon the platform requirements, the server may be constructed + to be per-session or per-system. The selected IPC mechanism must + enforce the appropriate scoping. + + + The platform dependent startup routines will perform platform + specific initialization including the IPC engine and call the + platform independent initialization routine ccs_serv_initialize() + + + The platform dependent shutdown routines will perform platform + specific cleanup including the IPC engine and call the platform + independent function ccs_serv_cleanup() prior to process termination. + + + For each inbound CCAPI request, the server will unmarshall the + request using cci_msg_unflatten() to produce a cc_msg_t object, + construct cc_auth_info_t and cc_session_info_t objects to represent + the platform dependent authentication and session data, call + ccs_serv_process_msg() to process the request, call cci_msg_flatten() + to marhall the response, transmit the response to the caller, and + then cleanup the request and response cc_msg_t objects with + cci_msg_destroy(). + + + The cc_auth_info_t and cc_session_info_t objects are structures + storing opaque binary (data, length) representations of the + authentication and session data. These are stored as part of ccache + collection and ccaches. ccs_serv_process_msg() will perform a binary + comparison of the stored data with the data provided in the current + request. If they do not match, the request will be denied. It is + necessary that the data generated data always be the same. If + username strings are not case-sensitive, they should be normalized + before being passed to ccs_serv_process_msg(). + + + The current cc_server.lib routines assume that one request at a time + is being processed. If the IPC engine allows for more than one + request to be simultaneously received in separate threads, then the + call to ccs_serv_process_msg() must be wrapped by a critical section. + Future enhancements to cc_server.lib will allow for per-object + mutexes. When available the platform specific glue must provide + functions to create, obtain, release, and destroy mutex objects. + + diff --git a/src/lib/ccapi/include/CredentialsCache.h b/src/lib/ccapi/include/CredentialsCache.h index 7143da4e2..12748bb9d 100644 --- a/src/lib/ccapi/include/CredentialsCache.h +++ b/src/lib/ccapi/include/CredentialsCache.h @@ -69,6 +69,10 @@ #include #endif +#if defined(_WIN32) +#include +#endif + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/src/lib/ccapi/include/CredentialsCache2.h b/src/lib/ccapi/include/CredentialsCache2.h index 214d93a02..706c86913 100644 --- a/src/lib/ccapi/include/CredentialsCache2.h +++ b/src/lib/ccapi/include/CredentialsCache2.h @@ -87,10 +87,10 @@ typedef struct cc_credentials_v5_compat { char* client; char* server; cc_data_compat keyblock; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renew_till; + cc_time authtime; + cc_time starttime; + cc_time endtime; + cc_time renew_till; cc_uint32 is_skey; cc_uint32 ticket_flags; cc_data_compat** addresses; @@ -185,6 +185,13 @@ enum { CC_CRED_MAX }; +enum { + CC_LOCK_UNLOCK = 1, + CC_LOCK_READER = 2, + CC_LOCK_WRITER = 3, + CC_LOCK_NOBLOCK = 16 +}; + CCACHE_API cc_int32 cc_shutdown ( apiCB** ioContext); @@ -194,7 +201,7 @@ CCACHE_API cc_int32 cc_get_NC_info ( CCACHE_API cc_int32 cc_get_change_time ( apiCB* inContext, - cc_time_t* outTime); + cc_time* outTime); CCACHE_API cc_int32 cc_open ( apiCB* inContext, @@ -293,6 +300,11 @@ CCACHE_API cc_int32 cc_free_NC_info ( apiCB* inContext, infoNC*** ioInfo); +CCACHE_API cc_int32 cc_lock_request( + apiCB* inContext, + const ccache_p* inCCache, + const cc_int32 lock_type); + #if TARGET_OS_MAC #if defined(__MWERKS__) #pragma enumsalwaysint reset diff --git a/src/lib/ccapi/include/datastore.h b/src/lib/ccapi/include/datastore.h new file mode 100644 index 000000000..4f119f969 --- /dev/null +++ b/src/lib/ccapi/include/datastore.h @@ -0,0 +1,189 @@ +/* $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). + * $ + */ +/* + * Prototypes and data structures for datastore. + * + */ + + +#ifndef __CCDATASTOREH__ +#define __CCDATASTOREH__ + +#include "CredentialsCache.h" +#include "rpc_auth.h" +#include "generic_lists.h" + +enum cc_list_type { + generic = 0, + context, + cache, + credentials +}; + +struct cc_context_iterate_t { + cc_context_list_node_t* next; +}; +typedef struct cc_context_iterate_t cc_context_iterate_t; + +struct cc_ccache_iterate_t { + cc_ccache_list_node_t* next; +}; +typedef struct cc_ccache_iterate_t cc_ccache_iterate_t; + +struct cc_credentials_iterate_t { + cc_credentials_list_node_t* next; +}; +typedef struct cc_credentials_iterate_t cc_credentials_iterate_t; + +struct cc_lock { + cc_uint32 read_locks; /* count of read locks (>= 0) */ + cc_uint32 write_locks; /* count of write locks (0 or 1) */ + void * platform_data; /* platform specific implementation data */ +}; +typedef struct cc_lock cc_lock_t; + + +struct cc_server_context_t { + cc_ccache_list_head_t* ccaches; /*our ccaches*/ + cc_generic_list_head_t* active_iterators; /*active ccache iterators*/ + cc_int32 api_version; /*Version our client passed in on init (ccapi_version_X) */ + cc_auth_info_t* auth_info; /*auth info passed in from RPC*/ + cc_session_info_t* session_info; /*session info passed in from RPC*/ + cc_time64 changed; /*date of last change to this context*/ + cc_int32 error; /*last error code*/ + cc_lock_t locks; /*are we locked?*/ +}; +typedef struct cc_server_context_t cc_server_context_t; + +struct cc_server_ccache_t { + char* name; /*name of this ccache*/ + char* principal_v4; /*v4 principal associated with this cache*/ + char* principal_v5; /*v5 principal associated with this cache*/ + cc_uint32 versions; /*versions of creds supported (from cc_credentials enum in CredentialsCache.h)*/ + cc_time64 changed; /*date of last change to ccache*/ + cc_int32 kdc_set; /*is the KDC time offset initialized?*/ + cc_time64 kdc_offset; /*offset of our clock relative kdc*/ + cc_time64 last_default; /*the last date when we were default*/ + cc_int32 is_default; /*is this the default cred on this ccache?*/ + cc_generic_list_head_t* active_iterators; /*iterators which clients have opened on this cache*/ + cc_credentials_list_head_t* creds; /*list of creds stored in this ccache*/ + cc_server_context_t* mycontext; /*context to which I belong*/ + cc_lock_t locks; /*are we locked?*/ +}; +typedef struct cc_server_ccache_t cc_server_ccache_t; + +struct cc_server_credentials_t { + cc_int32 is_default; /*Are we the default cred? (first in list)*/ + cc_credentials_union creds; +}; +typedef struct cc_server_credentials_t cc_server_credentials_t; + + +/*Note: cci means Credential Cache Internal, to differentiate from exported API macros*/ + +cc_int32 ccs_context_iterate_has_next(struct cc_context_iterate_t *iterate); +cc_int32 ccs_context_iterate_next(struct cc_context_iterate_t *iterate, cc_context_list_node_t**); + +cc_int32 ccs_ccache_iterate_has_next(struct cc_ccache_iterate_t *iterate); +cc_int32 ccs_ccache_iterate_next(struct cc_ccache_iterate_t *iterate, cc_ccache_list_node_t**); + +cc_int32 ccs_credentials_iterate_has_next(cc_credentials_iterate_t *iterate); +cc_int32 ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t **); + +cc_int32 ccs_context_list_new(cc_context_list_head_t**); +cc_int32 ccs_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); +cc_int32 ccs_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); +cc_int32 ccs_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem); +cc_int32 ccs_context_list_iterator(cc_context_list_head_t *head, struct cc_context_iterate_t**); +cc_int32 ccs_context_free_iterator(struct cc_context_iterate_t *iterator); +cc_int32 ccs_context_list_destroy(cc_context_list_head_t* head) ; +cc_int32 ccs_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t**); + +cc_int32 ccs_ccache_list_new(cc_ccache_list_head_t**); +cc_int32 ccs_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); +cc_int32 ccs_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); +cc_int32 ccs_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem); +cc_int32 ccs_ccache_list_iterator(cc_ccache_list_head_t *head, struct cc_ccache_iterate_t**); +cc_int32 ccs_ccache_free_iterator(struct cc_ccache_iterate_t *iterator); +cc_int32 ccs_ccache_list_destroy(cc_ccache_list_head_t* head) ; +cc_int32 ccs_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t**); + + +cc_int32 ccs_credentials_list_new(cc_credentials_list_head_t**); +cc_int32 ccs_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); +cc_int32 ccs_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); +cc_int32 ccs_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem); +cc_int32 ccs_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t**); +cc_int32 ccs_credentials_free_iterator(cc_credentials_iterate_t* iterator); +cc_int32 ccs_credentials_list_destroy(cc_credentials_list_head_t* head) ; +cc_int32 ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t**) ; + + +cc_int32 ccs_context_new(int api_version, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ) ; +cc_int32 ccs_context_get_default_ccache_name(cc_server_context_t* ctx, char **); +cc_int32 ccs_context_find_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t**); +cc_int32 ccs_context_open_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t** ); +cc_int32 ccs_context_create_ccache(cc_server_context_t* ctx, char *name, int creds_version, char *principal, cc_server_ccache_t**); +cc_int32 ccs_context_create_default_ccache(cc_server_context_t* ctx, int creds_version, char *principal, cc_server_ccache_t**); +cc_int32 ccs_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t**); +cc_int32 ccs_context_compare(cc_server_context_t* a, cc_server_context_t* b); +cc_int32 ccs_context_destroy(cc_server_context_t* ctx); +cc_int32 ccs_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache); + +cc_int32 ccs_ccache_new(char *name, char *principal, int cred_vers, cc_server_ccache_t**); +cc_int32 ccs_ccache_check_version(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); +cc_int32 ccs_ccache_check_principal(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); +cc_int32 ccs_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); +cc_int32 ccs_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); +cc_int32 ccs_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination); +cc_int32 ccs_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64* offset); +cc_int32 ccs_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64 offset); +cc_int32 ccs_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache); +cc_int32 ccs_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator); +cc_int32 ccs_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal); +cc_int32 ccs_ccache_set_principal(cc_server_ccache_t* ccache, cc_int32 version, char * principal); +cc_int32 ccs_ccache_free_principal(char * principal); +cc_int32 ccs_ccache_destroy(cc_server_ccache_t* ccache); +void ccs_ccache_changed(cc_server_ccache_t* ccache); +cc_int32 ccs_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result); +#endif /*__CCDATASTOREH__*/ diff --git a/src/lib/ccapi/include/rpc_auth.h b/src/lib/ccapi/include/rpc_auth.h new file mode 100644 index 000000000..010a1e2a5 --- /dev/null +++ b/src/lib/ccapi/include/rpc_auth.h @@ -0,0 +1,71 @@ +/* $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). + * $ + */ + + +/* + * Types for RPC auth + session info + * + */ + +#ifndef __RPC_AUTH_H__ +#define __RPC_AUTH_H__ + +#include "CredentialsCache.h" + +/*preliminary*/ +struct cc_auth_info_t { + cc_uint8 *info; + cc_uint32 len; +}; +typedef struct cc_auth_info_t cc_auth_info_t; + +/*preliminary*/ +struct cc_session_info_t { + cc_uint8 *info; + cc_uint32 len; +}; +typedef struct cc_session_info_t cc_session_info_t; + +cc_int32 ccs_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp); + +#endif /*__RPC_AUTH_H__*/ diff --git a/src/lib/ccapi/server/NTMakefile b/src/lib/ccapi/server/NTMakefile index b221bcb94..564097c53 100644 --- a/src/lib/ccapi/server/NTMakefile +++ b/src/lib/ccapi/server/NTMakefile @@ -1,18 +1,21 @@ -# Makefile for the CCAPI Generic Server +# Makefile for the CCAPI Server Library !INCLUDE -CFLAGS = -I../include +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) -CCAPI_LIB = ../client/ccapi.lib -WINLIBS = user32.lib advapi32.lib -CCSOBJS = ccs_context.obj ccs_ccache.obj ccs_lists.obj rpc_auth.obj serv_ops.obj +CC_SERVER_OBJS = ccs_context.obj ccs_ccache.obj ccs_lists.obj rpc_auth.obj serv_ops.obj -all: ccapi_server.exe +CC_SERVER_LIB = cc_server.lib -ccapi_server.exe: main.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ main.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +CC_COMMON_LIB = ../common/cc_common.lib + +$(CC_SERVER_LIB): $(CC_SERVER_OBJS) + $(implib) /NOLOGO /OUT:$@ $** + +all: $(CC_SERVER_LIB) clean: - del *.obj *.exe + del *.obj *.lib + \ No newline at end of file diff --git a/src/lib/ccapi/server/datastore.h b/src/lib/ccapi/server/datastore.h deleted file mode 100644 index 4f119f969..000000000 --- a/src/lib/ccapi/server/datastore.h +++ /dev/null @@ -1,189 +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). - * $ - */ -/* - * Prototypes and data structures for datastore. - * - */ - - -#ifndef __CCDATASTOREH__ -#define __CCDATASTOREH__ - -#include "CredentialsCache.h" -#include "rpc_auth.h" -#include "generic_lists.h" - -enum cc_list_type { - generic = 0, - context, - cache, - credentials -}; - -struct cc_context_iterate_t { - cc_context_list_node_t* next; -}; -typedef struct cc_context_iterate_t cc_context_iterate_t; - -struct cc_ccache_iterate_t { - cc_ccache_list_node_t* next; -}; -typedef struct cc_ccache_iterate_t cc_ccache_iterate_t; - -struct cc_credentials_iterate_t { - cc_credentials_list_node_t* next; -}; -typedef struct cc_credentials_iterate_t cc_credentials_iterate_t; - -struct cc_lock { - cc_uint32 read_locks; /* count of read locks (>= 0) */ - cc_uint32 write_locks; /* count of write locks (0 or 1) */ - void * platform_data; /* platform specific implementation data */ -}; -typedef struct cc_lock cc_lock_t; - - -struct cc_server_context_t { - cc_ccache_list_head_t* ccaches; /*our ccaches*/ - cc_generic_list_head_t* active_iterators; /*active ccache iterators*/ - cc_int32 api_version; /*Version our client passed in on init (ccapi_version_X) */ - cc_auth_info_t* auth_info; /*auth info passed in from RPC*/ - cc_session_info_t* session_info; /*session info passed in from RPC*/ - cc_time64 changed; /*date of last change to this context*/ - cc_int32 error; /*last error code*/ - cc_lock_t locks; /*are we locked?*/ -}; -typedef struct cc_server_context_t cc_server_context_t; - -struct cc_server_ccache_t { - char* name; /*name of this ccache*/ - char* principal_v4; /*v4 principal associated with this cache*/ - char* principal_v5; /*v5 principal associated with this cache*/ - cc_uint32 versions; /*versions of creds supported (from cc_credentials enum in CredentialsCache.h)*/ - cc_time64 changed; /*date of last change to ccache*/ - cc_int32 kdc_set; /*is the KDC time offset initialized?*/ - cc_time64 kdc_offset; /*offset of our clock relative kdc*/ - cc_time64 last_default; /*the last date when we were default*/ - cc_int32 is_default; /*is this the default cred on this ccache?*/ - cc_generic_list_head_t* active_iterators; /*iterators which clients have opened on this cache*/ - cc_credentials_list_head_t* creds; /*list of creds stored in this ccache*/ - cc_server_context_t* mycontext; /*context to which I belong*/ - cc_lock_t locks; /*are we locked?*/ -}; -typedef struct cc_server_ccache_t cc_server_ccache_t; - -struct cc_server_credentials_t { - cc_int32 is_default; /*Are we the default cred? (first in list)*/ - cc_credentials_union creds; -}; -typedef struct cc_server_credentials_t cc_server_credentials_t; - - -/*Note: cci means Credential Cache Internal, to differentiate from exported API macros*/ - -cc_int32 ccs_context_iterate_has_next(struct cc_context_iterate_t *iterate); -cc_int32 ccs_context_iterate_next(struct cc_context_iterate_t *iterate, cc_context_list_node_t**); - -cc_int32 ccs_ccache_iterate_has_next(struct cc_ccache_iterate_t *iterate); -cc_int32 ccs_ccache_iterate_next(struct cc_ccache_iterate_t *iterate, cc_ccache_list_node_t**); - -cc_int32 ccs_credentials_iterate_has_next(cc_credentials_iterate_t *iterate); -cc_int32 ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t **); - -cc_int32 ccs_context_list_new(cc_context_list_head_t**); -cc_int32 ccs_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); -cc_int32 ccs_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); -cc_int32 ccs_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem); -cc_int32 ccs_context_list_iterator(cc_context_list_head_t *head, struct cc_context_iterate_t**); -cc_int32 ccs_context_free_iterator(struct cc_context_iterate_t *iterator); -cc_int32 ccs_context_list_destroy(cc_context_list_head_t* head) ; -cc_int32 ccs_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t**); - -cc_int32 ccs_ccache_list_new(cc_ccache_list_head_t**); -cc_int32 ccs_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); -cc_int32 ccs_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); -cc_int32 ccs_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem); -cc_int32 ccs_ccache_list_iterator(cc_ccache_list_head_t *head, struct cc_ccache_iterate_t**); -cc_int32 ccs_ccache_free_iterator(struct cc_ccache_iterate_t *iterator); -cc_int32 ccs_ccache_list_destroy(cc_ccache_list_head_t* head) ; -cc_int32 ccs_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t**); - - -cc_int32 ccs_credentials_list_new(cc_credentials_list_head_t**); -cc_int32 ccs_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); -cc_int32 ccs_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); -cc_int32 ccs_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem); -cc_int32 ccs_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t**); -cc_int32 ccs_credentials_free_iterator(cc_credentials_iterate_t* iterator); -cc_int32 ccs_credentials_list_destroy(cc_credentials_list_head_t* head) ; -cc_int32 ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t**) ; - - -cc_int32 ccs_context_new(int api_version, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ) ; -cc_int32 ccs_context_get_default_ccache_name(cc_server_context_t* ctx, char **); -cc_int32 ccs_context_find_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t**); -cc_int32 ccs_context_open_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t** ); -cc_int32 ccs_context_create_ccache(cc_server_context_t* ctx, char *name, int creds_version, char *principal, cc_server_ccache_t**); -cc_int32 ccs_context_create_default_ccache(cc_server_context_t* ctx, int creds_version, char *principal, cc_server_ccache_t**); -cc_int32 ccs_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t**); -cc_int32 ccs_context_compare(cc_server_context_t* a, cc_server_context_t* b); -cc_int32 ccs_context_destroy(cc_server_context_t* ctx); -cc_int32 ccs_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache); - -cc_int32 ccs_ccache_new(char *name, char *principal, int cred_vers, cc_server_ccache_t**); -cc_int32 ccs_ccache_check_version(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); -cc_int32 ccs_ccache_check_principal(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); -cc_int32 ccs_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); -cc_int32 ccs_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); -cc_int32 ccs_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination); -cc_int32 ccs_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64* offset); -cc_int32 ccs_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64 offset); -cc_int32 ccs_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache); -cc_int32 ccs_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator); -cc_int32 ccs_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal); -cc_int32 ccs_ccache_set_principal(cc_server_ccache_t* ccache, cc_int32 version, char * principal); -cc_int32 ccs_ccache_free_principal(char * principal); -cc_int32 ccs_ccache_destroy(cc_server_ccache_t* ccache); -void ccs_ccache_changed(cc_server_ccache_t* ccache); -cc_int32 ccs_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result); -#endif /*__CCDATASTOREH__*/ diff --git a/src/lib/ccapi/server/rpc_auth.h b/src/lib/ccapi/server/rpc_auth.h deleted file mode 100644 index 010a1e2a5..000000000 --- a/src/lib/ccapi/server/rpc_auth.h +++ /dev/null @@ -1,71 +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). - * $ - */ - - -/* - * Types for RPC auth + session info - * - */ - -#ifndef __RPC_AUTH_H__ -#define __RPC_AUTH_H__ - -#include "CredentialsCache.h" - -/*preliminary*/ -struct cc_auth_info_t { - cc_uint8 *info; - cc_uint32 len; -}; -typedef struct cc_auth_info_t cc_auth_info_t; - -/*preliminary*/ -struct cc_session_info_t { - cc_uint8 *info; - cc_uint32 len; -}; -typedef struct cc_session_info_t cc_session_info_t; - -cc_int32 ccs_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp); - -#endif /*__RPC_AUTH_H__*/ diff --git a/src/lib/ccapi/unit-test/NTMakefile b/src/lib/ccapi/unit-test/NTMakefile index eb2fd53e2..9bb486b6d 100644 --- a/src/lib/ccapi/unit-test/NTMakefile +++ b/src/lib/ccapi/unit-test/NTMakefile @@ -1,30 +1,48 @@ -# Makefile for the CCAPI Generic Server +!include -!INCLUDE +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) -CFLAGS = -I../include +WINLIBS = ws2_32.lib rpcrt4.lib $(guilibsdll) -CCAPI_LIB = ../lib/ccapi.lib -WINLIBS = user32.lib advapi32.lib -CCSOBJS = context.obj ccache.obj lists.obj rpc_auth.obj serv_ops.obj +T_CCACHE = t_ccache.exe -all: t_lists.exe t_msg.exe t_ccache.exe t_context.exe ccapi_server.exe +T_CONTEXT = t_context.exe -t_lists.exe: t_lists.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_lists.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +T_LISTS = t_lists.exe -t_msg.exe: t_msg.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_msg.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +T_MSG = t_msg.exe -t_ccache.exe: t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +T_SERVER = t_server.exe -t_context.exe: t_context.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_context.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +all: $(T_CCACHE) $(T_CONTEXT) $(T_LISTS) $(T_MSG) $(T_SERVER) -ccapi_server.exe: main.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ main.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +ntccrpc_c.c ntccrpc_s.c ntccrpc.h: ntccrpc.idl ntccrpc.acf + midl ntccrpc.idl /acf ntccrpc.acf + +CC_CLIENT_LIB = ..\client\cc_client.lib + +CC_COMMON_LIB = ..\common\cc_common.lib + +CC_SERVER_LIB = ..\server\cc_server.lib + +CC_API_LIB = ..\windows\krbcc32.lib + +$(T_CCACHE): t_ccache.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_CONTEXT): t_context.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_LISTS): t_lists.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_MSG): t_msg.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_SERVER): t_server.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +clean: + del *.exe *.dll *.lib *.exp *.obj ntccrpc_c.c ntccrpc_s.c ntccrpc.h -clean: - del *.obj *.exe diff --git a/src/lib/ccapi/unit-test/t_ccache.c b/src/lib/ccapi/unit-test/t_ccache.c index 6ef33ea23..175764e79 100644 --- a/src/lib/ccapi/unit-test/t_ccache.c +++ b/src/lib/ccapi/unit-test/t_ccache.c @@ -59,8 +59,8 @@ int main() { int i; cc_int32 code; - code = cci_ccache_new("The first", p1, cc_credentials_v4_v5, &c1); - code = cci_ccache_new("The 2nd", p2, cc_credentials_v4_v5, &c2); + code = ccs_ccache_new("The first", p1, cc_credentials_v4_v5, &c1); + code = ccs_ccache_new("The 2nd", p2, cc_credentials_v4_v5, &c2); cred1 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t)); memset(cred1,0,sizeof(cc_server_credentials_t)); @@ -83,30 +83,30 @@ int main() { strncpy(cred2->creds.credentials.credentials_v4->principal, p1, strlen(p1)); cred3->creds.credentials.credentials_v5->client = p1; - code = cci_ccache_store_creds(c1, &cred1->creds); + code = ccs_ccache_store_creds(c1, &cred1->creds); printf("(c1, cred1) -> %d\n",code); - code = cci_ccache_store_creds(c1, &cred2->creds); + code = ccs_ccache_store_creds(c1, &cred2->creds); printf("(c1, cred2) -> %d\n",code); - code = cci_ccache_store_creds(c2, &cred3->creds); + code = ccs_ccache_store_creds(c2, &cred3->creds); printf("(c2, cred3) -> %d\n",code); - code = cci_ccache_store_creds(c1, &cred3->creds); + code = ccs_ccache_store_creds(c1, &cred3->creds); printf("(c1, cred3) -> %d\n",code); i = 0; - code = cci_ccache_move(c1, c2); - code = cci_ccache_destroy(c1); - code = cci_ccache_new_iterator(c2, &iterator); - while (cci_credentials_iterate_has_next(iterator)) { + code = ccs_ccache_move(c1, c2); + code = ccs_ccache_destroy(c1); + code = ccs_ccache_new_iterator(c2, &iterator); + while (ccs_credentials_iterate_has_next(iterator)) { i++; - code = cci_credentials_iterate_next(iterator, &node); + code = ccs_credentials_iterate_next(iterator, &node); stored_cred = (cc_server_credentials_t *)node->data; printf("%d %d %s\n", stored_cred->is_default, stored_cred->creds.version, stored_cred->creds.credentials.credentials_v4->principal); if (i == 1) { - code = cci_ccache_rem_creds(c2,&cred2->creds); + code = ccs_ccache_rem_creds(c2,&cred2->creds); printf("(c2 rem cred2) -> %d\n",code); } } diff --git a/src/lib/ccapi/unit-test/t_context.c b/src/lib/ccapi/unit-test/t_context.c index 9e35d9abf..d76ff78d9 100644 --- a/src/lib/ccapi/unit-test/t_context.c +++ b/src/lib/ccapi/unit-test/t_context.c @@ -68,10 +68,10 @@ int main() { int i; cc_int32 code; - code = cci_context_new(5, auth_info, session_info, &ctx); - code = cci_context_create_default_ccache(ctx, cc_credentials_v4, "Spike", &ccache); - code = cci_context_get_default_ccache_name(ctx, &name); - code = cci_context_open_ccache(ctx, name, &ccache); + code = ccs_context_new(5, auth_info, session_info, &ctx); + code = ccs_context_create_default_ccache(ctx, cc_credentials_v4, "Spike", &ccache); + code = ccs_context_get_default_ccache_name(ctx, &name); + code = ccs_context_open_ccache(ctx, name, &ccache); for (i = 0; i < 5; i++) { creds = (cc_credentials_union*)malloc(sizeof(cc_credentials_union)); @@ -79,32 +79,32 @@ int main() { creds->credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); strcpy(creds->credentials.credentials_v4->principal, "Spike"); - code = cci_ccache_store_creds(ccache, creds); + code = ccs_ccache_store_creds(ccache, creds); } - code = cci_context_create_ccache(ctx, "ccache 2", cc_credentials_v4, "Jeff", &ccache); - code = cci_context_open_ccache(ctx, "ccache 2", &ccache); + code = ccs_context_create_ccache(ctx, "ccache 2", cc_credentials_v4_v5, "Jeff", &ccache); + code = ccs_context_open_ccache(ctx, "ccache 2", &ccache); for (i = 0; i < 5; i++) { creds = (cc_credentials_union*)malloc(sizeof(cc_credentials_union)); - creds->version = cc_credentials_v4; - creds->credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); - strcpy(creds->credentials.credentials_v4->principal, "Jeff"); + creds->version = cc_credentials_v5; + creds->credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t)); + strcpy(creds->credentials.credentials_v5->principal, "Jeff"); - cci_ccache_store_creds(ccache, creds); + ccs_ccache_store_creds(ccache, creds); } - code = cci_context_ccache_iterator(ctx, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); + code = ccs_context_ccache_iterator(ctx, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); ccache = (cc_server_ccache_t *)ccache_node->data; printf("%x for %s %s default = %d v %d\n", ccache, ccache->principal_v4, ccache->principal_v5, ccache->is_default, ccache->versions); - code = cci_ccache_new_iterator(ccache, &creds_iterator); - while (cci_credentials_iterate_has_next(creds_iterator)) { - code = cci_credentials_iterate_next(creds_iterator, &creds_node); + code = ccs_ccache_new_iterator(ccache, &creds_iterator); + while (ccs_credentials_iterate_has_next(creds_iterator)) { + code = ccs_credentials_iterate_next(creds_iterator, &creds_node); server_creds = (cc_server_credentials_t *)creds_node->data; printf("\t%s %d\n", server_creds->creds.credentials.credentials_v4->principal, diff --git a/src/lib/ccapi/unit-test/t_server.c b/src/lib/ccapi/unit-test/t_server.c index d4d998466..d6093941e 100644 --- a/src/lib/ccapi/unit-test/t_server.c +++ b/src/lib/ccapi/unit-test/t_server.c @@ -143,7 +143,7 @@ main(void) cc_session_info_t * session_info; cc_int32 code; - if ( cci_serv_initialize() != ccNoError ) + if ( ccs_serv_initialize() != ccNoError ) return 1; while ( 1 ) { @@ -163,7 +163,7 @@ main(void) code = obtain_session_info(&session_info); /* process message */ - code = cci_serv_process_msg(msg, auth_info, session_info, &resp); + code = ccs_serv_process_msg(msg, auth_info, session_info, &resp); /* flatten response */ code = cci_msg_flatten(resp, NULL); diff --git a/src/lib/ccapi/windows/NTMakefile b/src/lib/ccapi/windows/NTMakefile new file mode 100644 index 000000000..f6fee6f68 --- /dev/null +++ b/src/lib/ccapi/windows/NTMakefile @@ -0,0 +1,35 @@ +!include + +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) + +CCAPI_SERVER = ccapi_server.exe + +CCAPI_DLLFILE = krbcc32.dll + +WINLIBS = ws2_32.lib rpcrt4.lib $(guilibsdll) + +all: $(CCAPI_DLLFILE) $(CCAPI_SERVER) + +ntccrpc_c.c ntccrpc_s.c ntccrpc.h: ntccrpc.idl ntccrpc.acf + midl ntccrpc.idl /acf ntccrpc.acf + +CLIENT_OBJS = ntccrpc_c.obj client.obj dllmain.obj + +SERVER_OBJS = ntccrpc_s.obj server.obj + +CC_CLIENT_LIB = ..\client\cc_client.lib + +CC_COMMON_LIB = ..\common\cc_common.lib + +CC_SERVER_LIB = ..\server\cc_server.lib + +$(CCAPI_DLLFILE): $(CLIENT_OBJS) $(CC_CLIENT_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO /OUT:$@ $(ldebug) $(dlllflags) $(guilibsmt) -def:cacheapi.def $** $(WINLIBS) + +$(CCAPI_SERVER): $(SERVER_OBJS) $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +clean: + del *.exe *.dll *.lib *.exp *.obj ntccrpc_c.c ntccrpc_s.c ntccrpc.h + + diff --git a/src/lib/ccapi/windows/cacheapi.def b/src/lib/ccapi/windows/cacheapi.def new file mode 100644 index 000000000..c54cc1106 --- /dev/null +++ b/src/lib/ccapi/windows/cacheapi.def @@ -0,0 +1,29 @@ +EXPORTS + ; ccapi v3 only exports one function + cc_initialize @14 + + ; ccapi v2 compatibility functions + cc_close @2 + cc_create @3 + cc_destroy @4 + cc_free_NC_info @5 + cc_free_creds @6 + cc_free_name @7 + cc_free_principal @8 + cc_get_NC_info @9 + cc_get_change_time @10 + cc_get_cred_version @11 + cc_get_name @12 + cc_get_principal @13 + cc_lock_request @15 + cc_open @16 + cc_remove_cred @17 + cc_seq_fetch_NCs_begin @18 + cc_seq_fetch_NCs_end @19 + cc_seq_fetch_NCs_next @20 + cc_seq_fetch_creds_begin @21 + cc_seq_fetch_creds_end @22 + cc_seq_fetch_creds_next @23 + cc_set_principal @24 + cc_shutdown @25 + cc_store @26 diff --git a/src/lib/ccapi/windows/client.c b/src/lib/ccapi/windows/client.c new file mode 100644 index 000000000..db0b63aec --- /dev/null +++ b/src/lib/ccapi/windows/client.c @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include "ntccrpc.h" +#include +#include "CredentialsCache.h" +#include "msg.h" + +static RPC_BINDING_HANDLE hRpcBinding; + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +int cc_rpc_init(void) { + RPC_STATUS status; + TCHAR * bindstring = NULL; + RPC_SECURITY_QOS sqos; + + status = RpcStringBindingCompose(NULL, + _T("ncalrpc"), + NULL, + NULL, + NULL, + &bindstring); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcStringBindingCompose failed: %d\n", + status); + return 1; + } + + status = RpcBindingFromStringBinding(bindstring, + &hRpcBinding); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingFromStringBinding failed: %d\n", + status); + return 1; + } + + status = RpcStringFree(&bindstring); + + ZeroMemory(&sqos, sizeof(sqos)); + + sqos.Version = 1; + sqos.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT; + sqos.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC; + sqos.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE; + + status = RpcBindingSetAuthInfoEx(hRpcBinding, + NULL, + RPC_C_AUTHN_LEVEL_CALL, + RPC_C_AUTHN_WINNT, + NULL, + 0, + &sqos); + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingSetAuthInfoEx failed: %d\n", + status); + return 1; + } + + return 0; +} + +int cc_rpc_cleanup(void) { + RPC_STATUS status; + + status = RpcBindingFree(&hRpcBinding); + + return 0; +} + +cc_int32 cci_set_thread_session_id(unsigned char * client_name, LUID luid) { + +} + +void cci_get_thread_session_id(unsigned char * client_name, int len, LUID *pluid) { + +} + + +/* __int32 ccapi_Message( + * [in] handle_t h, + * [string][in] unsigned char *client_name, + * [in] struct _LUID luid, + * [in] __int32 cb_buffer, + * [out] __int32 *cb_len, + * [size_is][string][out] unsigned char buffer[ ]); + */ + +cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response) +{ + __int32 rpc_code; + unsigned char client_name[256]; + LUID luid; + struct __LUID __luid; + unsigned char out_buf[MAXMSGLEN]; + __int32 out_len = MAXMSGLEN; + + if (!cc_rpc_init()) + return -1; + + cci_get_thread_session_id(client_name, sizeof(client_name), &luid); + + __luid.HighPart = luid.HighPart; + __luid.LowPart = luid.LowPart; + + rpc_code = ccapi_Message(hRpcBinding, client_name, __luid, + request->flat, request->flat_len, + out_buf, &out_len); + + return rpc_code; +} diff --git a/src/lib/ccapi/windows/dllmain.c b/src/lib/ccapi/windows/dllmain.c new file mode 100644 index 000000000..6b4d6bfdd --- /dev/null +++ b/src/lib/ccapi/windows/dllmain.c @@ -0,0 +1,15 @@ +#include + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + default: + return TRUE; + } +} + diff --git a/src/lib/ccapi/windows/ntccrpc.acf b/src/lib/ccapi/windows/ntccrpc.acf new file mode 100644 index 000000000..77216a9ea --- /dev/null +++ b/src/lib/ccapi/windows/ntccrpc.acf @@ -0,0 +1,8 @@ +[ + explicit_handle +] + +interface portable_ccapi +{ + +} \ No newline at end of file diff --git a/src/lib/ccapi/windows/ntccrpc.idl b/src/lib/ccapi/windows/ntccrpc.idl new file mode 100644 index 000000000..0dd038f6f --- /dev/null +++ b/src/lib/ccapi/windows/ntccrpc.idl @@ -0,0 +1,31 @@ +[ + uuid(c8b4a635-e9e4-4650-a073-b25610324950), + version(1.0), + endpoint("ncalrpc:[mit_nt_ccapi]"), + pointer_default(unique) +] + +interface portable_ccapi +{ + const short MAXMSGLEN = 65536; + + // Locally Unique Identifier + // + + struct __LUID { + __int32 LowPart; + long HighPart; + }; + + + // The Generic CCAPI Message RPC + + __int32 ccapi_Message ( + [in] handle_t h, + [in, string] unsigned char * client_name, + [in] struct __LUID luid, + [in, length_is(in_len), size_is(MAXMSGLEN)] unsigned char in_buf[], + [in] __int32 in_len, + [out, length_is(*out_len), size_is(MAXMSGLEN)] unsigned char out_buf[], + [out] __int32 * out_len); +} diff --git a/src/lib/ccapi/windows/server.c b/src/lib/ccapi/windows/server.c new file mode 100644 index 000000000..5ce8e6ebe --- /dev/null +++ b/src/lib/ccapi/windows/server.c @@ -0,0 +1,638 @@ + + +#include +#include "msg.h" +#include "marshall.h" +#include "serv_ops.h" +#include "datastore.h" +#include +#include +#include +#include +#include +#include "ntccrpc.h" +#include + +#define SVCNAME "MIT_CCAPI_NT_Service" + +SERVICE_STATUS_HANDLE h_service_status = NULL; +SERVICE_STATUS service_status; +FILE * logfile = NULL; + +/* Log File */ +void begin_log(void) { + char temppath[512]; + + temppath[0] = L'\0'; + + GetTempPathA(sizeof(temppath), temppath); + StringCbCatA(temppath, sizeof(temppath), "mit_nt_ccapi.log"); + logfile = fopen(temppath, "w"); +} + +void end_log(void) { + if (logfile) { + fclose(logfile); + logfile = NULL; + } +} + +BOOL report_status(DWORD state, + DWORD exit_code, + DWORD wait_hint) { + static DWORD checkpoint = 1; + BOOL rv = TRUE; + + if (state == SERVICE_START_PENDING) + service_status.dwControlsAccepted = 0; + else + service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP; + + service_status.dwCurrentState = state; + service_status.dwWin32ExitCode = exit_code; + service_status.dwWaitHint = wait_hint; + + if (state == SERVICE_RUNNING || + state == SERVICE_STOPPED) + service_status.dwCheckPoint = 0; + else + service_status.dwCheckPoint = checkpoint++; + + rv = SetServiceStatus(h_service_status, &service_status); + + return rv; +} + +void service_start(DWORD argc, LPTSTR * argv) { + RPC_STATUS status; + RPC_BINDING_VECTOR * bv; + + status = RpcServerUseProtseq("ncalrpc", + RPC_C_PROTSEQ_MAX_REQS_DEFAULT, + NULL); + + if (status != RPC_S_OK) { + return; + } + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterIf(portable_ccapi_v1_0_s_ifspec, + 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerInqBindings(&bv); + + if (status != RPC_S_OK) + return; + + status = RpcEpRegister(portable_ccapi_v1_0_s_ifspec, + bv, 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterAuthInfo(NULL, + RPC_C_AUTHN_WINNT, + 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerListen(1, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, + TRUE); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_RUNNING, NO_ERROR, 0); + + begin_log(); + + status = RpcMgmtWaitServerListen(); + + end_log(); + + RpcEpUnregister(portable_ccapi_v1_0_s_ifspec, bv, 0); + + RpcBindingVectorFree(&bv); +} + +void service_stop(void) { + RpcMgmtStopServerListening(0); +} + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +typedef struct tag_client_info { + char client_name[512]; + LUID luid; +} client_info_t; + +int obtain_auth_info(client_info_t * client_info, cc_auth_info_t ** pauth_info) +{ + *pauth_info = (cc_auth_info_t *)malloc(sizeof(cc_auth_info_t)); + if ( !*pauth_info ) + return ccErrNoMem; + + (*pauth_info)->len = strlen(client_info->client_name) + 1; + (*pauth_info)->info = malloc((*pauth_info)->len); + if ( !(*pauth_info)->info ) { + free(*pauth_info); + return ccErrNoMem; + } + + memcpy((*pauth_info)->info, client_info->client_name, (*pauth_info)->len); + + return 0; +} + +void destroy_auth_info(cc_auth_info_t *auth_info) +{ + free(auth_info->info); + free(auth_info); +} + +int obtain_session_info(client_info_t * client_info, cc_session_info_t ** psession_info) +{ + *psession_info = (cc_session_info_t *)malloc(sizeof(cc_session_info_t)); + if ( !*psession_info ) + return ccErrNoMem; + + (*psession_info)->len = sizeof(LUID); + (*psession_info)->info = malloc((*psession_info)->len); + if ( !(*psession_info)->info ) { + free(*psession_info); + return ccErrNoMem; + } + + memcpy((*psession_info)->info, &client_info->luid, (*psession_info)->len); + + return 0; +} + +void destroy_session_info(cc_session_info_t *session_info) +{ + free(session_info->info); + free(session_info); +} + +RPC_STATUS check_auth(handle_t h, client_info_t * client_info) { + RPC_BINDING_HANDLE bh = (RPC_BINDING_HANDLE) h; + RPC_STATUS status; + HANDLE htoken = NULL; + char name[256]; + char domain[256]; + DWORD name_len; + DWORD domain_len; + SID_NAME_USE snu = 0; + + struct { + TOKEN_ORIGIN origin; + char pad[512]; + } torigin; + + struct { + TOKEN_OWNER owner; + char pad[4096]; + } towner; + + DWORD len; + + status = RpcImpersonateClient(bh); + + if (status != RPC_S_OK) + return status; + + if (!OpenThreadToken(GetCurrentThread(), + TOKEN_READ | TOKEN_QUERY_SOURCE, + FALSE, + &htoken)) { + status = GetLastError(); + goto _cleanup; + } + + len = 0; + + if (!GetTokenInformation(htoken, + TokenOrigin, + &torigin.origin, + sizeof(torigin), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + if (!GetTokenInformation(htoken, + TokenOwner, + &towner.owner, + sizeof(towner), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + + name_len = sizeof(name)/sizeof(name[0]); + domain_len = sizeof(domain)/sizeof(domain[0]); + + if (!LookupAccountSidA(NULL, + towner.owner.Owner, + name, + &name_len, + domain, + &domain_len, + &snu)) { + status = GetLastError(); + goto _cleanup; + } + + client_info->luid = torigin.origin.OriginatingLogonSession; + StringCbPrintfA(client_info->client_name, + sizeof(client_info->client_name), + "%s\\%s", domain, name); + + status = 0; + + _cleanup: + + RpcRevertToSelf(); + + return status; +} + +__int32 ccapi_Message( + /* [in] */ handle_t h, + /* [string][in] */ unsigned char *client_name, + /* [in] */ struct __LUID luid, + /* [size_is][length_is][in] */ unsigned char in_buf[], + /* [in] */ __int32 in_len, + /* [size_is][length_is][out] */ unsigned char out_buf[], + /* [out] */ __int32 *out_len) +{ + client_info_t client_info; + cc_msg_t * msg; + cc_msg_t * resp; + cc_auth_info_t * auth_info; + cc_session_info_t * session_info; + cc_int32 code; + + if ( ccs_serv_initialize() != ccNoError ) { + code = ccErrServerUnavailable; + goto done; + } + + code = check_auth(h, &client_info); + if (code == 0) { + if (!strcmp("SYSTEM",client_info.client_name) && + client_info.luid.HighPart == 0 && + client_info.luid.LowPart == 0 && + client_name != NULL && + client_name[0] != '\0') { + StringCbPrintfA(client_info.client_name, + sizeof(client_info.client_name), + "%s", client_name); + client_info.luid.HighPart = luid.HighPart; + client_info.luid.LowPart = luid.LowPart; + } + } else { + code = ccErrServerCantBecomeUID; + goto done; + } + + /* allocate message */ + msg = (cc_msg_t *)malloc(sizeof(cc_msg_t)); + if (!msg) { + code = ccErrNoMem; + goto done; + } + + /* unflatten message */ + code = cci_msg_unflatten(in_buf, in_len, &msg); + if (code) + goto cleanup; + + /* obtain auth info */ + code = obtain_auth_info(&client_info, &auth_info); + if (code) + goto cleanup; + + /* obtain session info */ + code = obtain_session_info(&client_info, &session_info); + if (code) + goto cleanup; + + /* process message */ + code = ccs_serv_process_msg(msg, auth_info, session_info, &resp); + if (code) + goto cleanup; + + /* flatten response */ + code = cci_msg_flatten(resp, NULL); + if (code) + goto cleanup; + + /* send response */ + if (resp->flat_len > MAXMSGLEN) { + code = ccErrBadInternalMessage; + goto cleanup; + } + memcpy(out_buf, resp->flat, resp->flat_len); + *out_len = resp->flat_len; + code = ccNoError; + + cleanup: + if (auth_info) + destroy_auth_info(auth_info); + + if (session_info) + destroy_session_info(session_info); + + /* free message */ + if (msg) + cci_msg_destroy(msg); + + /* free response */ + if (resp) + cci_msg_destroy(resp); + + done: + return code ? -1 : 0; +} + +void WINAPI service_control(DWORD ctrl_code) { + switch(ctrl_code) { + case SERVICE_CONTROL_STOP: + report_status(SERVICE_STOP_PENDING, NO_ERROR, 0); + service_stop(); + return; + + /* everything else falls through */ + } + + report_status(service_status.dwCurrentState, NO_ERROR, 0); +} + +void WINAPI service_main(DWORD argc, LPTSTR * argv) { + + h_service_status = RegisterServiceCtrlHandler( _T(SVCNAME), service_control); + + if (!h_service_status) + goto cleanup; + + ZeroMemory(&service_status, sizeof(service_status)); + + service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + service_status.dwServiceSpecificExitCode = 0; + + if (!report_status(SERVICE_START_PENDING, + NO_ERROR, + 3000)) + goto cleanup; + + service_start(argc, argv); + + cleanup: + + if (h_service_status) { + report_status(SERVICE_STOPPED, NO_ERROR, 0); + } +} + + +BOOL +IsInstalled() +{ + BOOL bResult = FALSE; + SC_HANDLE hSCM; + SC_HANDLE hService; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (hSCM) { + + // Try to open the service + hService = OpenService( hSCM, + SVCNAME, + SERVICE_QUERY_CONFIG); + if (hService) { + bResult = TRUE; + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + } + + return bResult; +} + +BOOL +Install() +{ + char szFilePath[_MAX_PATH]; + SC_HANDLE hSCM; + SC_HANDLE hService; + TCHAR szKey[256]; + HKEY hKey = NULL; + DWORD dwData; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + // Get the executable file path + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + + // Create the service + hService = CreateService( hSCM, + SVCNAME, + SVCNAME, + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, + SERVICE_AUTO_START, // start condition + SERVICE_ERROR_NORMAL, + szFilePath, + NULL, + NULL, + NULL, + NULL, + NULL); + if (!hService) { + CloseServiceHandle(hSCM); + return FALSE; + } + + // make registry entries to support logging messages + // Add the source name as a subkey under the Application + // key in the EventLog service portion of the registry. + StringCbCopyA(szKey, 256, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\IKSD"); + if (RegCreateKey(HKEY_LOCAL_MACHINE, szKey, &hKey) != ERROR_SUCCESS) { + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return FALSE; + } + + // Add the Event ID message-file name to the 'EventMessageFile' subkey. + RegSetValueEx( hKey, + "EventMessageFile", + 0, + REG_EXPAND_SZ, + (CONST BYTE*)szFilePath, + strlen(szFilePath) + 1); + + // Set the supported types flags. + dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; + RegSetValueEx( hKey, + "TypesSupported", + 0, + REG_DWORD, + (CONST BYTE*)&dwData, + sizeof(DWORD)); + RegCloseKey(hKey); + + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_INSTALLED, SVCNAME); + + // tidy up + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return TRUE; +} + +BOOL +Uninstall() +{ + BOOL bResult = FALSE; + SC_HANDLE hService; + SC_HANDLE hSCM; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + hService = OpenService( hSCM, + _T(SVCNAME), + DELETE); + if (hService) { + if (DeleteService(hService)) { + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_REMOVED, SVCNAME); + bResult = TRUE; + } else { + // LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_NOTREMOVED, SVCNAME); + } + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + return bResult; +} + + +// Returns TRUE if it found an arg it recognised, FALSE if not +// Note: processing some arguments causes output to stdout to be generated. +BOOL +ParseStandardArgs(int argc, char* argv[]) +{ + char szFilePath[_MAX_PATH]="not a file name"; + + // See if we have any command line args we recognize + if (argc <= 1) + return FALSE; + + if ( _stricmp(argv[1], "-h") == 0 || + _stricmp(argv[1], "-?") == 0 || + _stricmp(argv[1], "/h") == 0 || + _stricmp(argv[1], "/?") == 0) { + + // + GetModuleFileNameA(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "usage: %s [-v | -i | -u | -h]\r\n",szFilePath); + return TRUE; + } else if (_stricmp(argv[1], "-v") == 0 || + _stricmp(argv[1], "/v") == 0 ) { + + // Spit out version info + fprintf(stderr, "%s Version 0.1\n",_T(SVCNAME)); + fprintf(stderr, "The service is %s installed\n", + IsInstalled() ? "currently" : "not"); + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-i") == 0 || + _stricmp(argv[1], "/i") == 0) { + + // Request to install. + if (IsInstalled()) { + fprintf(stderr, "%s is already installed\n", _T(SVCNAME)); + } else { + // Try and install the copy that's running + if (Install()) { + fprintf(stderr, "%s installed\n", _T(SVCNAME)); + } else { + fprintf(stderr, "%s failed to install. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-u") == 0 || + _stricmp(argv[1], "/u") == 0) { + + // Request to uninstall. + if (!IsInstalled()) { + fprintf(stderr, "%s is not installed\n", _T(SVCNAME)); + } else { + // Try and remove the copy that's installed + if (Uninstall()) { + // Get the executable file path + GetModuleFileNameA(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "%s removed. (You must delete the file (%s) yourself.)\n", + _T(SVCNAME), szFilePath); + } else { + fprintf(stderr, "Could not remove %s. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } + + // Don't recognise the args + return FALSE; +} + +int main(int argc, char ** argv) { + + SERVICE_TABLE_ENTRY dispatch_table[] = { + { _T(SVCNAME), (LPSERVICE_MAIN_FUNCTION) service_main }, + { NULL, NULL } + }; + + if ( ParseStandardArgs(argc, argv) ) + return 0; + + if (!StartServiceCtrlDispatcher(dispatch_table)) { + fprintf(stderr, "Can't start service control dispatcher\n"); + } + + return 0; +} -- cgit From f42fa33b985c230736ad5d9080055916de33be8c Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 5 Jun 2006 17:49:34 +0000 Subject: improved error handling git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18083 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/cacheapi.c | 26 +- src/lib/ccapi/client/ccache.c | 544 ++++++++++++++++++---------- src/lib/ccapi/client/ccache_iterator.c | 91 +++-- src/lib/ccapi/client/context.c | 402 ++++++++++++-------- src/lib/ccapi/client/credentials_iterator.c | 81 +++-- src/lib/ccapi/common/msg.c | 24 +- src/lib/ccapi/unit-test/NTMakefile | 7 +- src/lib/ccapi/windows/client.c | 33 +- src/lib/ccapi/windows/server.c | 77 +++- 9 files changed, 840 insertions(+), 445 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index 14a1eb476..c76ebe457 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -64,9 +64,9 @@ cc_initialize ( cc_context_t* outContext, char const** outVendor) { static char vendor[128] = ""; - cc_msg_t *request; + cc_msg_t *request = NULL; ccmsg_init_t *request_header; - cc_msg_t *response; + cc_msg_t *response = NULL; cc_uint32 type; ccmsg_init_resp_t *response_header; cc_int32 code; @@ -100,14 +100,17 @@ cc_initialize ( cc_context_t* outContext, request_header->in_version = htonl(inVersion); code = cci_msg_new(ccmsg_INIT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -131,8 +134,15 @@ cc_initialize ( cc_context_t* outContext, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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 index 790ff6f67..e4b9673c7 100644 --- a/src/lib/ccapi/client/ccache.c +++ b/src/lib/ccapi/client/ccache.c @@ -107,9 +107,9 @@ cc_int32 cc_int_ccache_release( cc_ccache_t ccache ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_release_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_release_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -128,14 +128,17 @@ cc_int_ccache_release( cc_ccache_t ccache ) request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_RELEASE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -146,9 +149,16 @@ cc_int_ccache_release( cc_ccache_t ccache ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); - free(int_ccache->functions); + + 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; } @@ -158,9 +168,9 @@ cc_int32 cc_int_ccache_destroy( cc_ccache_t ccache ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_destroy_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_destroy_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -179,14 +189,17 @@ cc_int_ccache_destroy( cc_ccache_t ccache ) request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_DESTROY, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -197,8 +210,14 @@ cc_int_ccache_destroy( cc_ccache_t ccache ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); free(ccache); return code; } @@ -208,9 +227,9 @@ cc_int32 cc_int_ccache_set_default( cc_ccache_t ccache ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_set_default_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_set_default_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -229,14 +248,17 @@ cc_int_ccache_set_default( cc_ccache_t ccache ) request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_SET_DEFAULT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -247,8 +269,14 @@ cc_int_ccache_set_default( cc_ccache_t ccache ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -257,9 +285,9 @@ cc_int_ccache_get_credentials_version( cc_ccache_t ccache, cc_uint32* credentials_version) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_creds_version_t *request_header; - cc_msg_t *response; + 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; @@ -278,14 +306,17 @@ cc_int_ccache_get_credentials_version( cc_ccache_t ccache, request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_CREDS_VERSION, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -298,8 +329,14 @@ cc_int_ccache_get_credentials_version( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -307,9 +344,9 @@ 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; - ccmsg_ccache_get_name_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_get_name_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -328,14 +365,17 @@ cc_int_ccache_get_name( cc_ccache_t ccache, cc_string_t* name ) request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_NAME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -353,8 +393,14 @@ cc_int_ccache_get_name( cc_ccache_t ccache, cc_string_t* name ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -364,9 +410,9 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, cc_string_t* principal ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_principal_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_get_principal_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -386,14 +432,17 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, request_header->version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_GET_PRINCIPAL, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -411,8 +460,14 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -423,9 +478,9 @@ cc_int_ccache_set_principal( cc_ccache_t ccache, { cc_uint32 blob_pos; cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_set_principal_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_set_principal_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -445,24 +500,24 @@ cc_int_ccache_set_principal( cc_ccache_t ccache, request_header->version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_GET_PRINCIPAL, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_data_blob(request, (void*)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } + 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) { @@ -473,8 +528,14 @@ cc_int_ccache_set_principal( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -483,9 +544,9 @@ 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; - ccmsg_ccache_creds_iterator_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_creds_iterator_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -504,14 +565,17 @@ cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_NEW_CREDS_ITERATOR, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -524,8 +588,14 @@ cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -534,9 +604,9 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, const cc_credentials_union* credentials ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_store_creds_t *request_header; - cc_msg_t *response; + 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; @@ -558,10 +628,8 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_STORE_CREDS, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; switch ( credentials->version ) { case cc_credentials_v4: @@ -571,30 +639,27 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, code = cci_creds_v5_marshall(credentials->credentials.credentials_v5, &flat_cred, &flat_cred_len); break; default: - cci_msg_destroy(request); - free(request_header); - return ccErrBadCredentialsVersion; - } - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; + 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) { - cci_msg_destroy(request); - free(request_header); - return code; - } + 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) { @@ -605,9 +670,16 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - free(flat_cred); - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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; } @@ -617,9 +689,9 @@ cc_int_ccache_remove_credentials( cc_ccache_t ccache, { cc_int_ccache_t int_ccache; cc_int_credentials_t int_creds; - cc_msg_t *request; - ccmsg_ccache_rem_creds_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_rem_creds_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -644,14 +716,17 @@ cc_int_ccache_remove_credentials( cc_ccache_t ccache, request_header->creds = htonll(int_creds->handle); code = cci_msg_new(ccmsg_CCACHE_REM_CREDS, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -662,8 +737,14 @@ cc_int_ccache_remove_credentials( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -674,9 +755,9 @@ cc_int_ccache_move( cc_ccache_t source, { cc_int_ccache_t int_ccache_source; cc_int_ccache_t int_ccache_dest; - cc_msg_t *request; - ccmsg_ccache_move_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_move_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -698,18 +779,21 @@ cc_int_ccache_move( cc_ccache_t source, return ccErrNoMem; code = cci_msg_new(ccmsg_CCACHE_MOVE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -720,8 +804,14 @@ cc_int_ccache_move( cc_ccache_t source, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -730,9 +820,9 @@ cc_int_ccache_lock( cc_ccache_t ccache, cc_uint32 block ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_lock_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_lock_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -752,18 +842,21 @@ cc_int_ccache_lock( cc_ccache_t ccache, return ccErrNoMem; code = cci_msg_new(ccmsg_CCACHE_LOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -776,8 +869,14 @@ cc_int_ccache_lock( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -785,9 +884,9 @@ cc_int32 cc_int_ccache_unlock( cc_ccache_t ccache ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_unlock_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_unlock_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -804,17 +903,20 @@ cc_int_ccache_unlock( cc_ccache_t ccache ) return ccErrNoMem; code = cci_msg_new(ccmsg_CCACHE_UNLOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -825,8 +927,14 @@ cc_int_ccache_unlock( cc_ccache_t ccache ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -836,9 +944,9 @@ 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; - ccmsg_ccache_get_last_default_time_t *request_header; - cc_msg_t *response; + 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; @@ -858,14 +966,17 @@ cc_int_ccache_get_last_default_time( cc_ccache_t ccache, request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_LAST_DEFAULT_TIME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -880,8 +991,14 @@ cc_int_ccache_get_last_default_time( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -889,9 +1006,9 @@ cc_int32 cc_int_ccache_get_change_time( cc_ccache_t ccache, cc_time* time ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_change_time_t *request_header; - cc_msg_t *response; + 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; @@ -911,14 +1028,17 @@ cc_int_ccache_get_change_time( cc_ccache_t ccache, cc_time* time ) request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_CHANGE_TIME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -933,8 +1053,14 @@ cc_int_ccache_get_change_time( cc_ccache_t ccache, cc_time* time ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -945,9 +1071,9 @@ cc_int_ccache_compare( cc_ccache_t ccache, { cc_int_ccache_t int_ccache; cc_int_ccache_t int_compare_to; - cc_msg_t *request; - ccmsg_ccache_compare_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_compare_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -969,14 +1095,17 @@ cc_int_ccache_compare( cc_ccache_t ccache, request_header->ccache2 = htonll(int_compare_to->handle); code = cci_msg_new(ccmsg_CCACHE_COMPARE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -989,8 +1118,14 @@ cc_int_ccache_compare( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -1000,9 +1135,9 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, cc_time* time_offset ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_kdc_time_offset_t *request_header; - cc_msg_t *response; + 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; @@ -1022,14 +1157,17 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, request_header->creds_version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_GET_KDC_TIME_OFFSET, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -1042,8 +1180,14 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -1053,9 +1197,9 @@ cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, cc_time time_offset ) { cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_set_kdc_time_offset_t *request_header; - cc_msg_t *response; + 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; @@ -1078,14 +1222,17 @@ cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, request_header->offset = htonll(t64); code = cci_msg_new(ccmsg_CCACHE_SET_KDC_TIME_OFFSET, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -1096,8 +1243,14 @@ cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -1106,9 +1259,9 @@ 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; - ccmsg_ccache_clear_kdc_time_offset_t *request_header; - cc_msg_t *response; + 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; @@ -1128,14 +1281,17 @@ cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, request_header->creds_version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_CLEAR_KDC_TIME_OFFSET, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -1146,7 +1302,13 @@ cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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_iterator.c b/src/lib/ccapi/client/ccache_iterator.c index b0ccbe610..3da9b3547 100644 --- a/src/lib/ccapi/client/ccache_iterator.c +++ b/src/lib/ccapi/client/ccache_iterator.c @@ -58,7 +58,7 @@ cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, cc_handle ctx, cc_handle handle ) { - cc_int_ccache_iterator_t iter; + cc_int_ccache_iterator_t iter = NULL; if ( piter == NULL ) return ccErrBadParam; @@ -68,7 +68,7 @@ cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, return ccErrNoMem; iter->functions = (cc_ccache_iterator_f*)malloc( sizeof(cc_ccache_iterator_f)); - if ( iter->functions ) { + if ( iter->functions == NULL ) { free(iter); return ccErrNoMem; } @@ -87,9 +87,9 @@ cc_int32 cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) { cc_int_ccache_iterator_t int_iter; - cc_msg_t *request; - ccmsg_ccache_iterator_release_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_iterator_release_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -108,14 +108,17 @@ cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) 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) { - free(request_header); - return code; - } + 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) { @@ -126,11 +129,19 @@ cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); - free(int_iter->functions); - free(int_iter); + 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; } @@ -139,9 +150,9 @@ 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; - ccmsg_ccache_iterator_next_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_iterator_next_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -160,14 +171,17 @@ cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CCACHE_ITERATOR_NEXT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -179,8 +193,14 @@ cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -189,9 +209,9 @@ 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; - ccmsg_ccache_iterator_clone_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ccache_iterator_clone_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -210,14 +230,17 @@ cc_int_ccache_iterator_clone( cc_ccache_iterator_t iter, request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CCACHE_ITERATOR_CLONE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -229,7 +252,13 @@ cc_int_ccache_iterator_clone( cc_ccache_iterator_t iter, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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/context.c b/src/lib/ccapi/client/context.c index 8515f695b..8a79fcede 100644 --- a/src/lib/ccapi/client/context.c +++ b/src/lib/ccapi/client/context.c @@ -97,9 +97,9 @@ cc_int32 cc_int_context_release( cc_context_t context ) { cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_release_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ctx_release_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -117,14 +117,17 @@ cc_int_context_release( cc_context_t context ) request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_RELEASE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -135,8 +138,14 @@ cc_int_context_release( cc_context_t context ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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; @@ -147,9 +156,9 @@ cc_int_context_get_change_time( cc_context_t context, cc_time* time) { cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_get_change_time_t *request_header; - cc_msg_t *response; + 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; @@ -169,14 +178,17 @@ cc_int_context_get_change_time( cc_context_t context, request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_GET_CHANGE_TIME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -191,8 +203,14 @@ cc_int_context_get_change_time( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -201,10 +219,11 @@ 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; - ccmsg_ctx_get_default_ccache_name_t *request_header; - cc_msg_t *response; + 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; @@ -222,33 +241,41 @@ cc_int_context_get_default_ccache_name( cc_context_t context, request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_GET_DEFAULT_CCACHE_NAME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { - char * string; 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) { + if (code == ccNoError) code = cci_string_new(name, string); - free(string); - } } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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; } @@ -258,9 +285,9 @@ cc_int_context_compare( cc_context_t context, cc_uint32* equal ) { cc_int_context_t int_context, int_compare_to; - cc_msg_t *request; - ccmsg_ctx_compare_t *request_header; - cc_msg_t *response; + 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; @@ -283,14 +310,17 @@ cc_int_context_compare( cc_context_t context, request_header->ctx2 = htonll(int_compare_to->handle); code = cci_msg_new(ccmsg_CTX_COMPARE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -303,8 +333,14 @@ cc_int_context_compare( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -314,9 +350,9 @@ 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; - ccmsg_ctx_new_ccache_iterator_t *request_header; - cc_msg_t *response; + 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; @@ -335,14 +371,17 @@ cc_int_context_new_ccache_iterator( cc_context_t context, request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_NEW_CCACHE_ITERATOR, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -355,8 +394,14 @@ cc_int_context_new_ccache_iterator( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -367,9 +412,9 @@ cc_int_context_open_ccache( cc_context_t context, { cc_uint32 blob_pos; cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_open_t *request_header; - cc_msg_t *response; + 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; @@ -387,25 +432,25 @@ cc_int_context_open_ccache( cc_context_t context, return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } + 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) { @@ -417,8 +462,14 @@ cc_int_context_open_ccache( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -427,9 +478,9 @@ cc_int_context_open_default_ccache( cc_context_t context, cc_ccache_t* ccache) { cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_open_default_t *request_header; - cc_msg_t *response; + 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; @@ -447,16 +498,19 @@ cc_int_context_open_default_ccache( cc_context_t context, return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN_DEFAULT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -468,8 +522,14 @@ cc_int_context_open_default_ccache( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -482,9 +542,9 @@ cc_int_context_create_ccache( cc_context_t context, { cc_uint32 blob_pos; cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_create_t *request_header; - cc_msg_t *response; + 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; @@ -504,17 +564,12 @@ cc_int_context_create_ccache( cc_context_t context, return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; request_header->ctx = htonll(int_context->handle); request_header->version = htonl(cred_vers); @@ -522,17 +577,20 @@ cc_int_context_create_ccache( cc_context_t context, 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) { - cci_msg_destroy(request); - free(request_header); - return code; - } + 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) { @@ -544,8 +602,14 @@ cc_int_context_create_ccache( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -557,9 +621,9 @@ cc_int_context_create_default_ccache( cc_context_t context, { cc_uint32 blob_pos; cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_create_default_t *request_header; - cc_msg_t *response; + 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; @@ -579,26 +643,27 @@ cc_int_context_create_default_ccache( cc_context_t context, return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_DEFAULT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { - cci_msg_destroy(request); - free(request_header); - return code; - } + 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) { @@ -610,8 +675,14 @@ cc_int_context_create_default_ccache( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -623,9 +694,9 @@ cc_int_context_create_new_ccache( cc_context_t context, { cc_uint32 blob_pos; cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_create_unique_t *request_header; - cc_msg_t *response; + 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; @@ -645,26 +716,27 @@ cc_int_context_create_new_ccache( cc_context_t context, return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_UNIQUE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { - cci_msg_destroy(request); - free(request_header); - return code; - } + 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) { @@ -676,8 +748,14 @@ cc_int_context_create_new_ccache( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -687,9 +765,9 @@ cc_int_context_lock( cc_context_t context, cc_uint32 block ) { cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_lock_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ctx_lock_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -709,17 +787,20 @@ cc_int_context_lock( cc_context_t context, return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_LOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -732,8 +813,14 @@ cc_int_context_lock( cc_context_t context, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -741,9 +828,9 @@ cc_int32 cc_int_context_unlock( cc_context_t context ) { cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_unlock_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ctx_unlock_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -760,16 +847,19 @@ cc_int_context_unlock( cc_context_t context ) return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_UNLOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -780,8 +870,14 @@ cc_int_context_unlock( cc_context_t context ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -794,10 +890,11 @@ cc_int_context_clone( cc_context_t inContext, { cc_int_context_t int_context; static char vendor_st[128] = ""; - cc_msg_t *request; - ccmsg_ctx_clone_t *request_header; - cc_msg_t *response; + 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; @@ -831,14 +928,17 @@ cc_int_context_clone( cc_context_t inContext, request_header->in_version = htonl(requestedVersion); code = cci_msg_new(ccmsg_INIT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -850,11 +950,9 @@ cc_int_context_clone( cc_context_t inContext, code = cc_int_context_new(outContext, ntohll(response_header->out_ctx), ntohl(response_header->out_version)); if (!vendor_st[0]) { - char * string; 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'; - free(string); } *vendor = vendor_st; @@ -862,8 +960,16 @@ cc_int_context_clone( cc_context_t inContext, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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; } diff --git a/src/lib/ccapi/client/credentials_iterator.c b/src/lib/ccapi/client/credentials_iterator.c index f61d0ade8..3cdab875a 100644 --- a/src/lib/ccapi/client/credentials_iterator.c +++ b/src/lib/ccapi/client/credentials_iterator.c @@ -90,9 +90,9 @@ cc_int32 cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) { cc_int_credentials_iterator_t int_iter; - cc_msg_t *request; - ccmsg_creds_iterator_release_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_creds_iterator_release_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -112,14 +112,17 @@ cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CREDS_ITERATOR_RELEASE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -130,8 +133,14 @@ cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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); @@ -143,9 +152,9 @@ 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; - ccmsg_creds_iterator_next_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_creds_iterator_next_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -165,14 +174,17 @@ cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CREDS_ITERATOR_NEXT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -189,8 +201,14 @@ cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -199,9 +217,9 @@ 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; - ccmsg_creds_iterator_clone_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_creds_iterator_clone_t *request_header = NULL; + cc_msg_t *response = NULL; cc_uint32 type; cc_int32 code; @@ -220,14 +238,17 @@ cc_int_credentials_iterator_clone( cc_credentials_iterator_t iter, request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CREDS_ITERATOR_CLONE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + 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) { @@ -239,8 +260,14 @@ cc_int_credentials_iterator_clone( cc_credentials_iterator_t iter, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + 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/common/msg.c b/src/lib/ccapi/common/msg.c index b7f60dd07..ed053ada5 100644 --- a/src/lib/ccapi/common/msg.c +++ b/src/lib/ccapi/common/msg.c @@ -289,7 +289,7 @@ cci_msg_flatten(cc_msg_t* msg, void **flatpp) cc_uint32 u32; cc_int32 code; - if (msg == NULL || flatpp == NULL) + if (msg == NULL) return ccErrBadParam; code = cci_msg_calc_size(msg,&msg->flat_len); @@ -305,18 +305,15 @@ cci_msg_flatten(cc_msg_t* msg, void **flatpp) cur_pos = msg->flat; - u32 = msg->header_len; - htonl(u32); + u32 = htonl(msg->header_len); memcpy(cur_pos,&u32,sizeof(cc_uint32)); cur_pos+=sizeof(cc_uint32); - u32 = msg->flat_len; - htonl(u32); + u32 = htonl(msg->flat_len); memcpy(cur_pos,&u32,sizeof(cc_uint32)); cur_pos+=sizeof(cc_uint32); - u32 = msg->type; - htonl(u32); + u32 = htonl(msg->type); memcpy(cur_pos,&u32,sizeof(cc_uint32)); cur_pos+=sizeof(cc_uint32); @@ -324,8 +321,7 @@ cci_msg_flatten(cc_msg_t* msg, void **flatpp) memcpy(cur_pos, msg->header, msg->header_len); cur_pos += msg->header_len; - u32 = zero; - htonl(zero); + u32 = htonl(zero); memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*will be magic number later*/ cur_pos += sizeof(cc_uint32); @@ -342,9 +338,8 @@ cci_msg_flatten(cc_msg_t* msg, void **flatpp) free(msg->flat); return code; } - u32 = gen_node->len; - htonl(u32); - memcpy(cur_pos, &u32, sizeof(cc_uint32)); + u32 = htonl(gen_node->len); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); cur_pos+=sizeof(cc_uint32); /* data already in network order */ @@ -353,8 +348,7 @@ cci_msg_flatten(cc_msg_t* msg, void **flatpp) } free(gen_iterator); - u32 = zero; - htonl(zero); + u32 = htonl(zero); memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*magic number will go here later*/ cur_pos += sizeof(cc_uint32); @@ -620,7 +614,7 @@ cci_msg_destroy(cc_msg_t* msg) if (msg->flat != NULL) free(msg->flat); if (msg->header != NULL) - free(msg->flat); + free(msg->header); cci_generic_list_destroy(msg->data_blobs); free(msg); return ccNoError; diff --git a/src/lib/ccapi/unit-test/NTMakefile b/src/lib/ccapi/unit-test/NTMakefile index 9bb486b6d..73f53f2e4 100644 --- a/src/lib/ccapi/unit-test/NTMakefile +++ b/src/lib/ccapi/unit-test/NTMakefile @@ -14,7 +14,9 @@ T_MSG = t_msg.exe T_SERVER = t_server.exe -all: $(T_CCACHE) $(T_CONTEXT) $(T_LISTS) $(T_MSG) $(T_SERVER) +T_CCAPI = t_ccapi.exe + +all: $(T_CCAPI) $(T_CCACHE) $(T_CONTEXT) $(T_LISTS) $(T_MSG) $(T_SERVER) ntccrpc_c.c ntccrpc_s.c ntccrpc.h: ntccrpc.idl ntccrpc.acf midl ntccrpc.idl /acf ntccrpc.acf @@ -42,6 +44,9 @@ $(T_MSG): t_msg.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) $(T_SERVER): t_server.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) +$(T_CCAPI): t_ccapi.obj $(CC_API_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + clean: del *.exe *.dll *.lib *.exp *.obj ntccrpc_c.c ntccrpc_s.c ntccrpc.h diff --git a/src/lib/ccapi/windows/client.c b/src/lib/ccapi/windows/client.c index db0b63aec..e30801dab 100644 --- a/src/lib/ccapi/windows/client.c +++ b/src/lib/ccapi/windows/client.c @@ -78,11 +78,13 @@ int cc_rpc_cleanup(void) { } cc_int32 cci_set_thread_session_id(unsigned char * client_name, LUID luid) { - + return 0; } void cci_get_thread_session_id(unsigned char * client_name, int len, LUID *pluid) { - + client_name[0] = '\0'; + pluid->HighPart = 0; + pluid->LowPart = 0; } @@ -97,14 +99,14 @@ void cci_get_thread_session_id(unsigned char * client_name, int len, LUID *pluid cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response) { - __int32 rpc_code; + cc_int32 code; unsigned char client_name[256]; LUID luid; struct __LUID __luid; unsigned char out_buf[MAXMSGLEN]; __int32 out_len = MAXMSGLEN; - if (!cc_rpc_init()) + if (cc_rpc_init()) return -1; cci_get_thread_session_id(client_name, sizeof(client_name), &luid); @@ -112,9 +114,28 @@ cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response) __luid.HighPart = luid.HighPart; __luid.LowPart = luid.LowPart; - rpc_code = ccapi_Message(hRpcBinding, client_name, __luid, + /* flatten response */ + code = cci_msg_flatten(request, NULL); + if (code) + goto cleanup; + + RpcTryExcept { + code = ccapi_Message(hRpcBinding, client_name, __luid, request->flat, request->flat_len, out_buf, &out_len); + } + RpcExcept(1) { + code = RpcExceptionCode(); + } + RpcEndExcept; + if (code) + goto cleanup; + + /* unflatten message */ + code = cci_msg_unflatten(out_buf, out_len, response); + if (code) + goto cleanup; - return rpc_code; + cleanup: + return code; } diff --git a/src/lib/ccapi/windows/server.c b/src/lib/ccapi/windows/server.c index 5ce8e6ebe..34d329902 100644 --- a/src/lib/ccapi/windows/server.c +++ b/src/lib/ccapi/windows/server.c @@ -1,5 +1,4 @@ - #include #include "msg.h" #include "marshall.h" @@ -15,6 +14,9 @@ #define SVCNAME "MIT_CCAPI_NT_Service" +HANDLE hMainThread = 0; +HANDLE WaitToTerminate = 0; + SERVICE_STATUS_HANDLE h_service_status = NULL; SERVICE_STATUS service_status; FILE * logfile = NULL; @@ -72,7 +74,8 @@ void service_start(DWORD argc, LPTSTR * argv) { NULL); if (status != RPC_S_OK) { - return; + if (logfile) fprintf(logfile, "service_start RpcServerUseProtseq = 0x%x\n", status); + goto cleanup; } report_status(SERVICE_START_PENDING, NO_ERROR, 3000); @@ -80,21 +83,27 @@ void service_start(DWORD argc, LPTSTR * argv) { status = RpcServerRegisterIf(portable_ccapi_v1_0_s_ifspec, 0, 0); - if (status != RPC_S_OK) - return; + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerRegisterIf = 0x%x\n", status); + goto cleanup; + } report_status(SERVICE_START_PENDING, NO_ERROR, 3000); status = RpcServerInqBindings(&bv); - if (status != RPC_S_OK) - return; + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerInqBindings = 0x%x\n", status); + goto cleanup; + } status = RpcEpRegister(portable_ccapi_v1_0_s_ifspec, bv, 0, 0); - if (status != RPC_S_OK) - return; + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcEpRegister = 0x%x\n", status); + goto cleanup; + } report_status(SERVICE_START_PENDING, NO_ERROR, 3000); @@ -102,32 +111,37 @@ void service_start(DWORD argc, LPTSTR * argv) { RPC_C_AUTHN_WINNT, 0, 0); - if (status != RPC_S_OK) - return; + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerRegisterAuthInfo = 0x%x\n", status); + goto cleanup; + } report_status(SERVICE_START_PENDING, NO_ERROR, 3000); - status = RpcServerListen(1, + status = RpcServerListen(2, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); - if (status != RPC_S_OK) - return; + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerListen = 0x%x\n", status); + goto cleanup; + } report_status(SERVICE_RUNNING, NO_ERROR, 0); - begin_log(); + if (logfile) fprintf(logfile, "service_start calling RpcMgmtWaitServerListen\n"); status = RpcMgmtWaitServerListen(); + if (logfile) fprintf(logfile, "service_start RpcMgmtWaitServerListen = 0x%x\n", status); - end_log(); - + cleanup: RpcEpUnregister(portable_ccapi_v1_0_s_ifspec, bv, 0); RpcBindingVectorFree(&bv); } void service_stop(void) { + if (logfile) fprintf(logfile, "service_stop\n"); RpcMgmtStopServerListening(0); } @@ -292,6 +306,8 @@ __int32 ccapi_Message( cc_session_info_t * session_info; cc_int32 code; + if (logfile) fprintf(logfile, "ccapi_Message\n"); + if ( ccs_serv_initialize() != ccNoError ) { code = ccErrServerUnavailable; goto done; @@ -390,6 +406,8 @@ void WINAPI service_control(DWORD ctrl_code) { void WINAPI service_main(DWORD argc, LPTSTR * argv) { + begin_log(); + h_service_status = RegisterServiceCtrlHandler( _T(SVCNAME), service_control); if (!h_service_status) @@ -412,6 +430,8 @@ void WINAPI service_main(DWORD argc, LPTSTR * argv) { if (h_service_status) { report_status(SERVICE_STOPPED, NO_ERROR, 0); } + + end_log(); } @@ -620,8 +640,16 @@ ParseStandardArgs(int argc, char* argv[]) return FALSE; } -int main(int argc, char ** argv) { +DWORD __stdcall Main_thread(void* notUsed) +{ + char * argv[2] = {SVCNAME, NULL}; + begin_log(); + service_start(1, (LPTSTR*)argv); + end_log(); + return(0); +} +int main(int argc, char ** argv) { SERVICE_TABLE_ENTRY dispatch_table[] = { { _T(SVCNAME), (LPSERVICE_MAIN_FUNCTION) service_main }, { NULL, NULL } @@ -631,8 +659,21 @@ int main(int argc, char ** argv) { return 0; if (!StartServiceCtrlDispatcher(dispatch_table)) { - fprintf(stderr, "Can't start service control dispatcher\n"); + LONG status = GetLastError(); + if (status == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) + { + DWORD tid; + hMainThread = CreateThread(NULL, 0, Main_thread, 0, 0, &tid); + + printf("Hit to terminate MIT CCAPI Server\n"); + getchar(); + service_stop(); + } } + if ( hMainThread ) { + WaitForSingleObject( hMainThread, INFINITE ); + CloseHandle( hMainThread ); + } return 0; } -- cgit From 2e2e04bf3cbf340637fa6ccd3dbdd20b09e57f19 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 9 Jun 2006 14:42:04 +0000 Subject: * corrections to windows rpc layer * corrections to network byte order conversions git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18094 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/common/msg.c | 2 +- src/lib/ccapi/server/ccs_lists.c | 1 + src/lib/ccapi/server/serv_ops.c | 66 +++++++++++++++++++-------------------- src/lib/ccapi/windows/ntccrpc.idl | 3 +- src/lib/ccapi/windows/server.c | 8 ++--- 5 files changed, 40 insertions(+), 40 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/common/msg.c b/src/lib/ccapi/common/msg.c index ed053ada5..8c8cc29de 100644 --- a/src/lib/ccapi/common/msg.c +++ b/src/lib/ccapi/common/msg.c @@ -97,7 +97,7 @@ cci_msg_new(cc_uint32 type, cc_msg_t** msgpp) if (msg == NULL) return ccErrNoMem; - msg->type = htonl(type); + msg->type = type; msg->flat = NULL; msg->header = NULL; msg->flat_len = 0; diff --git a/src/lib/ccapi/server/ccs_lists.c b/src/lib/ccapi/server/ccs_lists.c index 95ca398fb..779c17b7a 100644 --- a/src/lib/ccapi/server/ccs_lists.c +++ b/src/lib/ccapi/server/ccs_lists.c @@ -296,6 +296,7 @@ ccs_context_list_new(cc_context_list_head_t ** headpp) if (ret == NULL) return ccErrNoMem; ret->head = ret->tail = NULL; + ret->type = context; *headpp = ret; return ccNoError; } diff --git a/src/lib/ccapi/server/serv_ops.c b/src/lib/ccapi/server/serv_ops.c index 9c544fc58..5409ef97d 100644 --- a/src/lib/ccapi/server/serv_ops.c +++ b/src/lib/ccapi/server/serv_ops.c @@ -149,11 +149,11 @@ ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_ return code; } - type = ntohl(msg->type); + type = msg->type; if (type == ccmsg_INIT) { return TypeToOpMapping->operations[type] (NULL, auth_info, session_info, msg, resp_msg); } else { - header_len = ntohl(msg->header_len); + header_len = msg->header_len; if (header_len < sizeof(ccmsg_ctx_only_t)) { return ccErrBadParam; } @@ -403,8 +403,8 @@ ccop_INIT( cc_server_context_t* ctx, /* not used */ *resp_msg = 0; - header_len = ntohl(msg->header_len); - if (header_len != sizeof(ccmsg_init_t)) { + header_len = msg->header_len; + if (ctx != NULL || header_len != sizeof(ccmsg_init_t)) { return ccErrBadParam; } @@ -414,7 +414,7 @@ ccop_INIT( cc_server_context_t* ctx, /* not used */ return code; } - code = ccs_context_list_append(AllContexts, ctx, &ctx_node); + code = ccs_context_list_append(AllContexts, new_ctx, &ctx_node); if (code != ccNoError) { ccs_context_destroy(new_ctx); return code; @@ -464,7 +464,7 @@ ccop_CTX_RELEASE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { ccmsg_ctx_release_t* header = (ccmsg_ctx_release_t *)msg->header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_handle handle = ntohll(header->ctx); cc_int32 code; @@ -486,7 +486,7 @@ ccop_CTX_GET_CHANGE_TIME( cc_server_context_t* ctx, { ccmsg_ctx_get_change_time_resp_t* resp_header; ccmsg_ctx_get_change_time_t *header = (ccmsg_ctx_get_change_time_t *)msg->header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; *resp_msg = 0; @@ -550,7 +550,7 @@ ccop_CTX_COMPARE(cc_server_context_t* ctx, cc_server_context_t *ctx2; ccmsg_ctx_compare_resp_t* resp_header; ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)msg->header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -577,7 +577,7 @@ ccop_CTX_NEW_CCACHE_ITERATOR(cc_server_context_t* ctx, cc_ccache_iterate_t* ccache_iterator; ccmsg_ctx_new_ccache_iterator_resp_t* resp_header; ccmsg_ctx_new_ccache_iterator_t* header = (ccmsg_ctx_new_ccache_iterator_t*)msg->header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -636,7 +636,7 @@ ccop_CTX_CCACHE_OPEN(cc_server_context_t* ctx, cc_server_ccache_t* ccache; ccmsg_ccache_open_resp_t* resp_header; ccmsg_ccache_open_t* header = (ccmsg_ccache_open_t*)msg->header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -670,7 +670,7 @@ ccop_CTX_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, ccmsg_ccache_open_default_t* header = (ccmsg_ccache_open_default_t*)msg->header; ccmsg_ccache_open_resp_t* resp_header; cc_server_ccache_t* ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; *resp_msg = 0; @@ -701,7 +701,7 @@ ccop_CTX_CCACHE_CREATE(cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -742,7 +742,7 @@ ccop_CTX_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -782,7 +782,7 @@ ccop_CTX_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -828,7 +828,7 @@ ccop_CCACHE_DESTROY( cc_server_context_t* ctx, { ccmsg_ccache_release_t* header = (ccmsg_ccache_release_t*)msg->header; cc_server_ccache_t* ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -855,7 +855,7 @@ ccop_CCACHE_SET_DEFAULT(cc_server_context_t* ctx, ccmsg_ccache_set_default_t* header = (ccmsg_ccache_set_default_t*)msg->header; cc_ccache_iterate_t* ccache_iterator; cc_ccache_list_node_t* ccache_node; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -900,7 +900,7 @@ ccop_CCACHE_GET_CREDS_VERSION(cc_server_context_t* ctx, ccmsg_ccache_get_creds_version_t* header = (ccmsg_ccache_get_creds_version_t*)msg->header; ccmsg_ccache_get_creds_version_resp_t* resp_header; cc_server_ccache_t* ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -929,7 +929,7 @@ ccop_CCACHE_GET_NAME(cc_server_context_t* ctx, ccmsg_ccache_get_name_t* header = (ccmsg_ccache_get_name_t*)msg->header; ccmsg_ccache_get_name_resp_t* resp_header; cc_server_ccache_t* ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_uint32 name_offset; cc_int32 code; @@ -970,7 +970,7 @@ ccop_CCACHE_GET_PRINCIPAL(cc_server_context_t* ctx, ccmsg_ccache_get_principal_resp_t* resp_header; cc_server_ccache_t* ccache; char * principal; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_uint32 principal_offset; cc_int32 code; @@ -1014,7 +1014,7 @@ ccop_CCACHE_SET_PRINCIPAL(cc_server_context_t* ctx, ccmsg_ccache_set_principal_t* header = (ccmsg_ccache_set_principal_t*)msg->header; cc_server_ccache_t* ccache; char *principal; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1047,7 +1047,7 @@ ccop_CCACHE_NEW_CREDS_ITERATOR( cc_server_context_t* ctx, cc_credentials_iterate_t* creds_iterator; ccmsg_ccache_creds_iterator_t* header = (ccmsg_ccache_creds_iterator_t*)msg->header; ccmsg_ccache_creds_iterator_resp_t* resp_header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1123,7 +1123,7 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, cc_server_ccache_t* ccache; char *flat_creds; cc_credentials_union *creds; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1174,7 +1174,7 @@ ccop_CCACHE_REM_CREDS(cc_server_context_t* ctx, ccmsg_ccache_rem_creds_t* header = (ccmsg_ccache_rem_creds_t*)msg->header; cc_server_ccache_t* ccache; cc_credentials_union *creds; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1232,7 +1232,7 @@ ccop_CCACHE_GET_LAST_DEFAULT_TIME(cc_server_context_t* ctx, ccmsg_ccache_get_last_default_time_t* header = (ccmsg_ccache_get_last_default_time_t*)msg->header; ccmsg_ccache_get_last_default_time_resp_t* resp_header; cc_server_ccache_t* ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1261,7 +1261,7 @@ ccop_CCACHE_GET_CHANGE_TIME( cc_server_context_t* ctx, ccmsg_ccache_get_change_time_resp_t* resp_header; ccmsg_ccache_get_change_time_t *header = (ccmsg_ccache_get_change_time_t *)msg->header; cc_server_ccache_t* ccache = (cc_server_ccache_t *)header->ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; *resp_msg = 0; @@ -1287,7 +1287,7 @@ ccop_CCACHE_COMPARE(cc_server_context_t* ctx, ccmsg_ccache_compare_t* header = (ccmsg_ccache_compare_t*)msg->header; ccmsg_ccache_compare_resp_t* resp_header; cc_server_ccache_t* ccache1, *ccache2; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_uint32 is_equal; cc_int32 code; @@ -1323,7 +1323,7 @@ ccop_CCACHE_GET_KDC_TIME_OFFSET(cc_server_context_t* ctx, ccmsg_ccache_get_kdc_time_offset_resp_t* resp_header; cc_server_ccache_t* ccache; cc_time64 offset; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1357,7 +1357,7 @@ ccop_CCACHE_SET_KDC_TIME_OFFSET(cc_server_context_t* ctx, { ccmsg_ccache_set_kdc_time_offset_t* header = (ccmsg_ccache_set_kdc_time_offset_t*)msg->header; cc_server_ccache_t* ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1383,7 +1383,7 @@ ccop_CCACHE_CLEAR_KDC_TIME_OFFSET(cc_server_context_t* ctx, { ccmsg_ccache_clear_kdc_time_offset_t* header = (ccmsg_ccache_clear_kdc_time_offset_t*)msg->header; cc_server_ccache_t* ccache; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1409,7 +1409,7 @@ ccop_CCACHE_ITERATOR_RELEASE(cc_server_context_t* ctx, { cc_generic_list_node_t* gen_node; ccmsg_ccache_iterator_release_t* header = (ccmsg_ccache_iterator_release_t*)msg->header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1449,7 +1449,7 @@ ccop_CCACHE_ITERATOR_NEXT(cc_server_context_t* ctx, cc_generic_list_node_t* gen_node; cc_ccache_iterate_t* ccache_iterator; cc_ccache_list_node_t *ccache_node; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1487,7 +1487,7 @@ ccop_CREDS_ITERATOR_RELEASE(cc_server_context_t* ctx, cc_generic_list_node_t* gen_node; cc_server_ccache_t* ccache; ccmsg_creds_iterator_release_t* header = (ccmsg_creds_iterator_release_t*)msg->header; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; @@ -1535,7 +1535,7 @@ ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, cc_server_ccache_t* ccache; cc_server_credentials_t* stored_creds; cc_credentials_union *creds_union; - cc_uint32 header_len = ntohl(msg->header_len); + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; diff --git a/src/lib/ccapi/windows/ntccrpc.idl b/src/lib/ccapi/windows/ntccrpc.idl index 0dd038f6f..51ff898d9 100644 --- a/src/lib/ccapi/windows/ntccrpc.idl +++ b/src/lib/ccapi/windows/ntccrpc.idl @@ -1,7 +1,6 @@ [ - uuid(c8b4a635-e9e4-4650-a073-b25610324950), + uuid(0012a1de-f7ad-44b0-b597-8ba53159c6fa), version(1.0), - endpoint("ncalrpc:[mit_nt_ccapi]"), pointer_default(unique) ] diff --git a/src/lib/ccapi/windows/server.c b/src/lib/ccapi/windows/server.c index 34d329902..ac4ab70ab 100644 --- a/src/lib/ccapi/windows/server.c +++ b/src/lib/ccapi/windows/server.c @@ -300,10 +300,10 @@ __int32 ccapi_Message( /* [out] */ __int32 *out_len) { client_info_t client_info; - cc_msg_t * msg; - cc_msg_t * resp; - cc_auth_info_t * auth_info; - cc_session_info_t * session_info; + cc_msg_t * msg = NULL; + cc_msg_t * resp = NULL; + cc_auth_info_t * auth_info = NULL; + cc_session_info_t * session_info = NULL; cc_int32 code; if (logfile) fprintf(logfile, "ccapi_Message\n"); -- cgit From 2ab8b381a83da20415f8b6f52b329154276c59c2 Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 9 Jun 2006 21:46:24 +0000 Subject: cci_msg_retrieve_blob(): changed argument 4 from void** to char** to suppress the warnings from gcc. git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18095 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/common/msg.c | 2 +- src/lib/ccapi/include/msg.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/common/msg.c b/src/lib/ccapi/common/msg.c index 8c8cc29de..789fc8746 100644 --- a/src/lib/ccapi/common/msg.c +++ b/src/lib/ccapi/common/msg.c @@ -567,7 +567,7 @@ cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp) } cc_int32 -cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **blobp) +cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, char **blobp) { cc_generic_iterate_t* gen_iterator; cc_generic_list_node_t* gen_node; diff --git a/src/lib/ccapi/include/msg.h b/src/lib/ccapi/include/msg.h index 182ebc161..79b9a7f72 100644 --- a/src/lib/ccapi/include/msg.h +++ b/src/lib/ccapi/include/msg.h @@ -139,7 +139,7 @@ cc_int32 cci_msg_flatten(cc_msg_t* msg, void **); cc_int32 cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * sizep); cc_int32 cci_msg_verify(void* flat, int flat_len, cc_uint32 * sizep); cc_int32 cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp); -cc_int32 cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **); +cc_int32 cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, char **); cc_int32 cci_msg_destroy(cc_msg_t* msg); /* Add missing byte swapping macros for 64-bit values */ -- cgit From 816c50541d4af289c6dc737ab0cb945457d8bcaa Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 9 Jun 2006 21:55:32 +0000 Subject: moved enum cc_list_type to generic_lists.h to avoid "incomplete enum" warnings when compiling generic_lists.c git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18096 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/common/generic_lists.c | 5 ----- src/lib/ccapi/include/datastore.h | 7 ------- src/lib/ccapi/include/generic_lists.h | 7 +++++++ 3 files changed, 7 insertions(+), 12 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/common/generic_lists.c b/src/lib/ccapi/common/generic_lists.c index a48c528f9..2c7398313 100644 --- a/src/lib/ccapi/common/generic_lists.c +++ b/src/lib/ccapi/common/generic_lists.c @@ -54,11 +54,6 @@ #include "CredentialsCache.h" #include "generic_lists.h" -/* this is an incomplete enumeration just including the generic type */ -enum cc_list_type { - generic = 0 -}; - /** * cci_generic_iterate_has_next() * diff --git a/src/lib/ccapi/include/datastore.h b/src/lib/ccapi/include/datastore.h index 4f119f969..7bb8b093d 100644 --- a/src/lib/ccapi/include/datastore.h +++ b/src/lib/ccapi/include/datastore.h @@ -53,13 +53,6 @@ #include "rpc_auth.h" #include "generic_lists.h" -enum cc_list_type { - generic = 0, - context, - cache, - credentials -}; - struct cc_context_iterate_t { cc_context_list_node_t* next; }; diff --git a/src/lib/ccapi/include/generic_lists.h b/src/lib/ccapi/include/generic_lists.h index 4d49e276b..14b7ae28c 100644 --- a/src/lib/ccapi/include/generic_lists.h +++ b/src/lib/ccapi/include/generic_lists.h @@ -49,6 +49,13 @@ #ifndef __CC_GENERIC_LISTS_H_ #define __CC_GENERIC_LISTS_H_ +enum cc_list_type { + generic = 0, + context, + cache, + credentials +}; + struct cc_generic_list_node_t { cc_uint8* data; cc_uint32 len; -- cgit From 5432daabf38c08ca2d61dbc6aaefc5f1a3586ee3 Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 9 Jun 2006 21:56:15 +0000 Subject: Removed ancient Metrowerks tests from public headers git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18097 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/include/CredentialsCache.h | 25 ++++++------------------- src/lib/ccapi/include/CredentialsCache2.h | 20 +++++--------------- 2 files changed, 11 insertions(+), 34 deletions(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/include/CredentialsCache.h b/src/lib/ccapi/include/CredentialsCache.h index 12748bb9d..45b9ac4c4 100644 --- a/src/lib/ccapi/include/CredentialsCache.h +++ b/src/lib/ccapi/include/CredentialsCache.h @@ -59,14 +59,7 @@ #define __CREDENTIALSCACHE__ #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) - #include - #if TARGET_RT_MAC_CFM - #error "Use KfM 4.0 SDK headers for CFM compilation." - #endif -#endif - -#if TARGET_OS_MAC - #include +#include #endif #if defined(_WIN32) @@ -78,13 +71,9 @@ extern "C" { #endif /* __cplusplus */ #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma import on - #pragma enumsalwaysint on - #endif - #pragma options align=mac68k +#pragma options align=mac68k #endif - + #if defined(_WIN32) #define CCACHE_API __declspec(dllexport) @@ -94,6 +83,8 @@ extern "C" { #endif /* _TIME_T_DEFINED */ #define _USE_32BIT_TIME_T #endif +#else +#define CCACHE_API #endif #include @@ -591,11 +582,7 @@ CCACHE_API cc_int32 cc_initialize ( ((iterator) -> functions -> clone (iterator, new_iter)) #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma enumsalwaysint reset - #pragma import reset - #endif - #pragma options align=reset +#pragma options align=reset #endif #ifdef __cplusplus diff --git a/src/lib/ccapi/include/CredentialsCache2.h b/src/lib/ccapi/include/CredentialsCache2.h index 706c86913..5505bf29f 100644 --- a/src/lib/ccapi/include/CredentialsCache2.h +++ b/src/lib/ccapi/include/CredentialsCache2.h @@ -49,11 +49,9 @@ #define __CREDENTIALSCACHE2__ #include "CredentialsCache.h" + #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) - #include - #if TARGET_RT_MAC_CFM - #error "Use KfM 4.0 SDK headers for CFM compilation." - #endif +#include #endif #ifdef __cplusplus @@ -61,13 +59,9 @@ extern "C" { #endif /* __cplusplus */ #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma import on - #pragma enumsalwaysint on - #endif - #pragma options align=mac68k +#pragma options align=mac68k #endif - + /* Some old types get directly mapped to new types */ typedef cc_context_d apiCB; @@ -306,11 +300,7 @@ CCACHE_API cc_int32 cc_lock_request( const cc_int32 lock_type); #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma enumsalwaysint reset - #pragma import reset - #endif - #pragma options align=reset +#pragma options align=reset #endif #ifdef __cplusplus -- cgit From 350cfced455d45368065095201bc2f674093cf41 Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 9 Jun 2006 21:57:20 +0000 Subject: Include string.h to get memcpy, strlen, etc on BSD OSes git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18098 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/cacheapi.c | 1 + src/lib/ccapi/client/ccache.c | 1 + src/lib/ccapi/client/context.c | 1 + src/lib/ccapi/common/marshall.c | 1 + 4 files changed, 4 insertions(+) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index c76ebe457..89c5e63d1 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -43,6 +43,7 @@ #include #include +#include #include #include "ccache.h" #include "ccache_iterator.h" diff --git a/src/lib/ccapi/client/ccache.c b/src/lib/ccapi/client/ccache.c index e4b9673c7..07e9b8e87 100644 --- a/src/lib/ccapi/client/ccache.c +++ b/src/lib/ccapi/client/ccache.c @@ -46,6 +46,7 @@ #include #include +#include #include #include "credentials.h" #include "credentials_iterator.h" diff --git a/src/lib/ccapi/client/context.c b/src/lib/ccapi/client/context.c index 8a79fcede..5d88d4686 100644 --- a/src/lib/ccapi/client/context.c +++ b/src/lib/ccapi/client/context.c @@ -45,6 +45,7 @@ #include #include +#include #include #include "context.h" #include "ccache.h" diff --git a/src/lib/ccapi/common/marshall.c b/src/lib/ccapi/common/marshall.c index 960019cb0..48abb3370 100644 --- a/src/lib/ccapi/common/marshall.c +++ b/src/lib/ccapi/common/marshall.c @@ -45,6 +45,7 @@ #include #include +#include #include #include "msg.h" #include "msg_headers.h" -- cgit From 3b5e562ae1fca86bb7396ecb0eaf5a7d3a40acfd Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 9 Jun 2006 21:59:36 +0000 Subject: Added Mac OS X project file and Mach-IPC support code git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18099 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/common/mac/mig.defs | 58 + src/lib/ccapi/common/mac/mig_types.h | 48 + src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser | 2005 +++++++++++++++++++++ src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective | 1567 ++++++++++++++++ src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj | 599 ++++++ src/lib/ccapi/server/mac/CCacheServer.plist | 12 + src/lib/ccapi/server/mac/CCacheServerInfo.plist | 38 + src/lib/ccapi/server/mac/main.c | 33 + 8 files changed, 4360 insertions(+) create mode 100755 src/lib/ccapi/common/mac/mig.defs create mode 100644 src/lib/ccapi/common/mac/mig_types.h create mode 100644 src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser create mode 100644 src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective create mode 100644 src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj create mode 100644 src/lib/ccapi/server/mac/CCacheServer.plist create mode 100644 src/lib/ccapi/server/mac/CCacheServerInfo.plist create mode 100644 src/lib/ccapi/server/mac/main.c (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/common/mac/mig.defs b/src/lib/ccapi/common/mac/mig.defs new file mode 100755 index 000000000..dd3ee1b51 --- /dev/null +++ b/src/lib/ccapi/common/mac/mig.defs @@ -0,0 +1,58 @@ +/* $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). + * $ + */ + +import "mig_types.h"; + +#include +#include + +subsystem ccapi 128; + +type msg_request_t = array [] of char; +type msg_reply_t = array [] of char; +type msg_error_t = int32; + +routine ccapi_msg (in_server_port : mach_port_t; + in_request : msg_request_t; + out out_reply : msg_reply_t; + out out_error : msg_error_t); diff --git a/src/lib/ccapi/common/mac/mig_types.h b/src/lib/ccapi/common/mac/mig_types.h new file mode 100644 index 000000000..586a01994 --- /dev/null +++ b/src/lib/ccapi/common/mac/mig_types.h @@ -0,0 +1,48 @@ +/* $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 "CredentialsCache.h" + +typedef const char *msg_request_t; +typedef char *msg_reply_t; +typedef cc_int32 msg_error_t; diff --git a/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser new file mode 100644 index 000000000..ea15e540b --- /dev/null +++ b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser @@ -0,0 +1,2005 @@ +// !$*UTF8*$! +{ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + activeBuildConfigurationName = Debug; + activeExecutable = A1E70D5E0A38B796007BE3E3 /* CCacheServer */; + activeTarget = A1E70D5C0A38B796007BE3E3 /* CCacheServer */; + addToTargets = ( + ); + breakpoints = ( + ); + breakpointsGroup = A1E70D500A38B5F3007BE3E3 /* XCBreakpointsBucket */; + codeSenseManager = A1E70CFE0A38B536007BE3E3 /* Code sense */; + executables = ( + A1E70D5E0A38B796007BE3E3 /* CCacheServer */, + ); + perUserDictionary = { + PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 811, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 200, + 608, + 20, + 48, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 171582174; + PBXWorkspaceStateSaveDate = 171582174; + }; + perUserProjectItems = { + A1E70DF70A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DF70A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DF80A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DF80A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DF90A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DF90A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DFA0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DFA0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DFB0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DFB0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DFD0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DFD0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E010A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E010A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E020A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E020A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E060A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E060A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E090A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E090A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E0A0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E0A0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E0B0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E0B0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E0C0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E0C0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E100A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E100A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E110A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E110A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E120A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E120A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E130A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E130A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E140A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E140A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E150A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E150A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E160A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E160A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E170A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E170A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E180A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E180A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E1B0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E1B0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E1E0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E1E0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E1F0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E1F0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E200A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E200A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E250A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E250A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E260A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E260A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E290A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E290A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2A0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2A0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2B0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2B0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2D0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2D0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2E0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2E0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E380A38C778007BE3E3 /* PBXTextBookmark */ = A1E70E380A38C778007BE3E3 /* PBXTextBookmark */; + A1E70E3D0A38C78C007BE3E3 /* PBXTextBookmark */ = A1E70E3D0A38C78C007BE3E3 /* PBXTextBookmark */; + A1E70E410A38C78C007BE3E3 /* PBXTextBookmark */ = A1E70E410A38C78C007BE3E3 /* PBXTextBookmark */; + A1E70E430A38C791007BE3E3 /* PBXTextBookmark */ = A1E70E430A38C791007BE3E3 /* PBXTextBookmark */; + A1E70E450A38C791007BE3E3 /* PBXTextBookmark */ = A1E70E450A38C791007BE3E3 /* PBXTextBookmark */; + A1E70E4A0A38C7BE007BE3E3 /* PBXTextBookmark */ = A1E70E4A0A38C7BE007BE3E3 /* PBXTextBookmark */; + A1E70E520A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E520A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E530A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E530A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E560A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E560A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E580A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E580A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E6F0A38CA08007BE3E3 /* PBXTextBookmark */ = A1E70E6F0A38CA08007BE3E3 /* PBXTextBookmark */; + A1E70E770A38CA55007BE3E3 /* PBXTextBookmark */ = A1E70E770A38CA55007BE3E3 /* PBXTextBookmark */; + A1E70E7D0A38CA55007BE3E3 /* PBXTextBookmark */ = A1E70E7D0A38CA55007BE3E3 /* PBXTextBookmark */; + A1E70E9C0A38CAF1007BE3E3 /* PBXTextBookmark */ = A1E70E9C0A38CAF1007BE3E3 /* PBXTextBookmark */; + A1E70EA80A38CB24007BE3E3 /* PBXTextBookmark */ = A1E70EA80A38CB24007BE3E3 /* PBXTextBookmark */; + A1E70EAB0A38CB24007BE3E3 /* PBXTextBookmark */ = A1E70EAB0A38CB24007BE3E3 /* PBXTextBookmark */; + A1E70EB50A38CB4D007BE3E3 /* PBXTextBookmark */ = A1E70EB50A38CB4D007BE3E3 /* PBXTextBookmark */; + A1E70EC30A38CC14007BE3E3 /* PBXTextBookmark */ = A1E70EC30A38CC14007BE3E3 /* PBXTextBookmark */; + A1E70ECB0A38CC4C007BE3E3 /* PBXTextBookmark */ = A1E70ECB0A38CC4C007BE3E3 /* PBXTextBookmark */; + A1E70ED70A38CCB6007BE3E3 /* PBXTextBookmark */ = A1E70ED70A38CCB6007BE3E3 /* PBXTextBookmark */; + A1E70EE20A38CCD6007BE3E3 /* PBXTextBookmark */ = A1E70EE20A38CCD6007BE3E3 /* PBXTextBookmark */; + A1E70EFE0A38CD66007BE3E3 /* PBXTextBookmark */ = A1E70EFE0A38CD66007BE3E3 /* PBXTextBookmark */; + A1E70F0F0A38CE21007BE3E3 /* PBXTextBookmark */ = A1E70F0F0A38CE21007BE3E3 /* PBXTextBookmark */; + A1E70F440A38D252007BE3E3 /* PBXTextBookmark */ = A1E70F440A38D252007BE3E3 /* PBXTextBookmark */; + A1E70F450A38D252007BE3E3 /* PBXTextBookmark */ = A1E70F450A38D252007BE3E3 /* PBXTextBookmark */; + A1E70F8B0A38D3B4007BE3E3 /* PBXTextBookmark */ = A1E70F8B0A38D3B4007BE3E3 /* PBXTextBookmark */; + A1E70F9C0A38D41E007BE3E3 /* PBXTextBookmark */ = A1E70F9C0A38D41E007BE3E3 /* PBXTextBookmark */; + A1E70F9D0A38D41E007BE3E3 /* PBXTextBookmark */ = A1E70F9D0A38D41E007BE3E3 /* PBXTextBookmark */; + A1E70FC60A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FC60A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FC80A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FC80A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FC90A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FC90A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FCA0A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FCA0A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FCD0A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FCD0A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FD80A38D573007BE3E3 /* PBXTextBookmark */ = A1E70FD80A38D573007BE3E3 /* PBXTextBookmark */; + A1E70FEE0A38D7C0007BE3E3 /* PBXTextBookmark */ = A1E70FEE0A38D7C0007BE3E3 /* PBXTextBookmark */; + A1E70FEF0A38D7C0007BE3E3 /* PBXTextBookmark */ = A1E70FEF0A38D7C0007BE3E3 /* PBXTextBookmark */; + A1E70FF00A38D7C0007BE3E3 /* PBXTextBookmark */ = A1E70FF00A38D7C0007BE3E3 /* PBXTextBookmark */; + A1E70FFA0A38D806007BE3E3 /* PBXTextBookmark */ = A1E70FFA0A38D806007BE3E3 /* PBXTextBookmark */; + A1E70FFC0A38D806007BE3E3 /* PBXTextBookmark */ = A1E70FFC0A38D806007BE3E3 /* PBXTextBookmark */; + A1E70FFF0A38D806007BE3E3 /* PBXTextBookmark */ = A1E70FFF0A38D806007BE3E3 /* PBXTextBookmark */; + A1E710010A38D814007BE3E3 /* PBXTextBookmark */ = A1E710010A38D814007BE3E3 /* PBXTextBookmark */; + A1E7100A0A38D888007BE3E3 /* PBXTextBookmark */ = A1E7100A0A38D888007BE3E3 /* PBXTextBookmark */; + A1E7100C0A38D888007BE3E3 /* PBXTextBookmark */ = A1E7100C0A38D888007BE3E3 /* PBXTextBookmark */; + A1E7100D0A38D888007BE3E3 /* PBXTextBookmark */ = A1E7100D0A38D888007BE3E3 /* PBXTextBookmark */; + A1E710110A38D888007BE3E3 /* PBXTextBookmark */ = A1E710110A38D888007BE3E3 /* PBXTextBookmark */; + A1E710140A38D888007BE3E3 /* PBXTextBookmark */ = A1E710140A38D888007BE3E3 /* PBXTextBookmark */; + A1E7103C0A38DE0B007BE3E3 /* PBXTextBookmark */ = A1E7103C0A38DE0B007BE3E3 /* PBXTextBookmark */; + A1E710400A38DE0B007BE3E3 /* PBXTextBookmark */ = A1E710400A38DE0B007BE3E3 /* PBXTextBookmark */; + A1E710530A39EC0B007BE3E3 /* PBXTextBookmark */ = A1E710530A39EC0B007BE3E3 /* PBXTextBookmark */; + A1E7105A0A39ED89007BE3E3 /* PBXTextBookmark */ = A1E7105A0A39ED89007BE3E3 /* PBXTextBookmark */; + A1E7105D0A39ED89007BE3E3 /* PBXTextBookmark */ = A1E7105D0A39ED89007BE3E3 /* PBXTextBookmark */; + A1E7105E0A39ED89007BE3E3 /* PBXTextBookmark */ = A1E7105E0A39ED89007BE3E3 /* PBXTextBookmark */; + A1E710680A39F102007BE3E3 /* PBXTextBookmark */ = A1E710680A39F102007BE3E3 /* PBXTextBookmark */; + A1E710840A3A1CFB007BE3E3 /* PBXTextBookmark */ = A1E710840A3A1CFB007BE3E3 /* PBXTextBookmark */; + A1E710860A3A1CFB007BE3E3 /* PBXTextBookmark */ = A1E710860A3A1CFB007BE3E3 /* PBXTextBookmark */; + A1E710870A3A1CFB007BE3E3 /* PBXTextBookmark */ = A1E710870A3A1CFB007BE3E3 /* PBXTextBookmark */; + A1E710890A3A1D04007BE3E3 /* PBXTextBookmark */ = A1E710890A3A1D04007BE3E3 /* PBXTextBookmark */; + A1E7108B0A3A1D04007BE3E3 /* PBXTextBookmark */ = A1E7108B0A3A1D04007BE3E3 /* PBXTextBookmark */; + A1E7108D0A3A1D06007BE3E3 /* PBXTextBookmark */ = A1E7108D0A3A1D06007BE3E3 /* PBXTextBookmark */; + A1E710930A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710930A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710940A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710940A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710950A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710950A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710960A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710960A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710970A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710970A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E7109C0A3A1D2B007BE3E3 /* PBXTextBookmark */ = A1E7109C0A3A1D2B007BE3E3 /* PBXTextBookmark */; + A1E7109D0A3A1D2B007BE3E3 /* PBXTextBookmark */ = A1E7109D0A3A1D2B007BE3E3 /* PBXTextBookmark */; + A1E7109F0A3A1DD0007BE3E3 /* PBXTextBookmark */ = A1E7109F0A3A1DD0007BE3E3 /* PBXTextBookmark */; + A1E710A00A3A1DD0007BE3E3 /* PBXTextBookmark */ = A1E710A00A3A1DD0007BE3E3 /* PBXTextBookmark */; + A1E710A50A3A22E1007BE3E3 /* PBXTextBookmark */ = A1E710A50A3A22E1007BE3E3 /* PBXTextBookmark */; + A1E710AB0A3A22F5007BE3E3 /* PBXTextBookmark */ = A1E710AB0A3A22F5007BE3E3 /* PBXTextBookmark */; + A1E710AC0A3A22F5007BE3E3 /* PBXTextBookmark */ = A1E710AC0A3A22F5007BE3E3 /* PBXTextBookmark */; + A1E710AD0A3A22F5007BE3E3 /* PBXTextBookmark */ = A1E710AD0A3A22F5007BE3E3 /* PBXTextBookmark */; + A1E710AF0A3A22FE007BE3E3 /* PBXTextBookmark */ = A1E710AF0A3A22FE007BE3E3 /* PBXTextBookmark */; + A1E710B30A3A22FF007BE3E3 /* PBXTextBookmark */ = A1E710B30A3A22FF007BE3E3 /* PBXTextBookmark */; + A1E710B90A3A23FB007BE3E3 /* PBXTextBookmark */ = A1E710B90A3A23FB007BE3E3 /* PBXTextBookmark */; + A1E710BC0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BC0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710BD0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BD0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710BE0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BE0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710BF0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BF0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710C00A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710C00A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710C60A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C60A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710C70A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C70A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710C80A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C80A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710C90A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C90A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710CA0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CA0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CB0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CB0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CC0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CC0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CD0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CD0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CE0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CE0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710D00A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D00A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D10A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D10A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D20A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D20A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D30A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D30A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D40A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D40A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D70A3A2465007BE3E3 /* PBXTextBookmark */ = A1E710D70A3A2465007BE3E3 /* PBXTextBookmark */; + A1E710D80A3A2465007BE3E3 /* PBXTextBookmark */ = A1E710D80A3A2465007BE3E3 /* PBXTextBookmark */; + A1E710D90A3A2465007BE3E3 /* PBXTextBookmark */ = A1E710D90A3A2465007BE3E3 /* PBXTextBookmark */; + A1E710DB0A3A246E007BE3E3 /* PBXTextBookmark */ = A1E710DB0A3A246E007BE3E3 /* PBXTextBookmark */; + A1E710DF0A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710DF0A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E00A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E00A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E10A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E10A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E20A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E20A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E30A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E30A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E50A3A248A007BE3E3 /* PBXTextBookmark */ = A1E710E50A3A248A007BE3E3 /* PBXTextBookmark */; + A1E710E60A3A248A007BE3E3 /* PBXTextBookmark */ = A1E710E60A3A248A007BE3E3 /* PBXTextBookmark */; + A1E710E70A3A24A4007BE3E3 /* PBXTextBookmark */ = A1E710E70A3A24A4007BE3E3 /* PBXTextBookmark */; + A1E710E80A3A24A5007BE3E3 /* PBXTextBookmark */ = A1E710E80A3A24A5007BE3E3 /* PBXTextBookmark */; + A1E710E90A3A24A5007BE3E3 /* PBXTextBookmark */ = A1E710E90A3A24A5007BE3E3 /* PBXTextBookmark */; + A1E710EA0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EA0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EB0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EB0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EC0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EC0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710ED0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710ED0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EE0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EE0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EF0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EF0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710F00A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710F00A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710F10A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710F10A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710F40A3A253F007BE3E3 /* PBXTextBookmark */ = A1E710F40A3A253F007BE3E3 /* PBXTextBookmark */; + A1E710F50A3A253F007BE3E3 /* PBXTextBookmark */ = A1E710F50A3A253F007BE3E3 /* PBXTextBookmark */; + }; + sourceControlManager = A1E70CFD0A38B536007BE3E3 /* Source Control */; + userBuildSettings = { + }; + }; + A1E70CFD0A38B536007BE3E3 /* Source Control */ = { + isa = PBXSourceControlManager; + fallbackIsa = XCSourceControlManager; + isSCMEnabled = 0; + scmConfiguration = { + }; + scmType = ""; + }; + A1E70CFE0A38B536007BE3E3 /* Code sense */ = { + isa = PBXCodeSenseManager; + indexTemplatePath = ""; + }; + A1E70D000A38B5BB007BE3E3 /* cacheapi.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1087, 2100}}"; + sepNavSelRange = "{4787, 139}"; + sepNavVisRect = "{{0, 1547}, {1087, 448}}"; + }; + }; + A1E70D010A38B5BB007BE3E3 /* ccache.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 18424}}"; + sepNavSelRange = "{11919, 0}"; + sepNavVisRect = "{{0, 5185}, {1003, 481}}"; + }; + }; + A1E70D020A38B5BB007BE3E3 /* ccache.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 2058}}"; + sepNavSelRange = "{2339, 9}"; + sepNavVisRect = "{{0, 556}, {980, 387}}"; + }; + }; + A1E70D080A38B5BB007BE3E3 /* context.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 13958}}"; + sepNavSelRange = "{29891, 21}"; + sepNavVisRect = "{{0, 13156}, {980, 387}}"; + }; + }; + A1E70D0B0A38B5BB007BE3E3 /* credentials.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 1330}}"; + sepNavSelRange = "{0, 2110}"; + sepNavVisRect = "{{0, 235}, {621, 499}}"; + }; + }; + A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 3836}}"; + sepNavSelRange = "{6723, 21}"; + sepNavVisRect = "{{0, 2544}, {980, 387}}"; + }; + }; + A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {734, 998}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {734, 998}}"; + sepNavWindowFrame = "{{15, 46}, {779, 1127}}"; + }; + }; + A1E70D120A38B5BB007BE3E3 /* generic_lists.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 5572}}"; + sepNavSelRange = "{2282, 0}"; + sepNavVisRect = "{{0, 489}, {1003, 521}}"; + }; + }; + A1E70D130A38B5BB007BE3E3 /* marshall.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 6188}}"; + sepNavSelRange = "{11995, 68}"; + sepNavVisRect = "{{0, 4756}, {980, 387}}"; + }; + }; + A1E70D140A38B5BB007BE3E3 /* msg.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1087, 8722}}"; + sepNavSelRange = "{15262, 21}"; + sepNavVisRect = "{{0, 7868}, {1087, 448}}"; + }; + }; + A1E70D150A38B5BB007BE3E3 /* NTMakefile */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 499}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {888, 742}}"; + sepNavSelRange = "{2202, 18}"; + sepNavVisRect = "{{0, 453}, {888, 289}}"; + }; + }; + A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 8302}}"; + sepNavSelRange = "{2631, 0}"; + sepNavVisRect = "{{0, 958}, {1003, 521}}"; + }; + }; + A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 4340}}"; + sepNavSelRange = "{7813, 0}"; + sepNavVisRect = "{{0, 422}, {1003, 521}}"; + }; + }; + A1E70D1C0A38B5BB007BE3E3 /* datastore.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {888, 2562}}"; + sepNavSelRange = "{2301, 0}"; + sepNavVisRect = "{{0, 573}, {888, 436}}"; + }; + }; + A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 1442}}"; + sepNavSelRange = "{2369, 0}"; + sepNavVisRect = "{{0, 545}, {1003, 521}}"; + }; + }; + A1E70D1F0A38B5BB007BE3E3 /* msg.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 2268}}"; + sepNavSelRange = "{5529, 0}"; + sepNavVisRect = "{{0, 1721}, {1003, 521}}"; + }; + }; + A1E70D260A38B5BB007BE3E3 /* NTMakefile */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 499}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 9856}}"; + sepNavSelRange = "{9783, 0}"; + sepNavVisRect = "{{0, 3674}, {1003, 730}}"; + }; + }; + A1E70D2C0A38B5BB007BE3E3 /* main.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 910}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 134}, {621, 727}}"; + }; + }; + A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1087, 22204}}"; + sepNavSelRange = "{36879, 21}"; + sepNavVisRect = "{{0, 14168}, {1087, 448}}"; + }; + }; + A1E70D3B0A38B5BB007BE3E3 /* client.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 1988}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {804, 503}}"; + }; + }; + A1E70D460A38B5BC007BE3E3 /* server.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 9520}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70D500A38B5F3007BE3E3 /* XCBreakpointsBucket */ = { + isa = XCBreakpointsBucket; + name = CCAPI; + objects = ( + ); + }; + A1E70D5C0A38B796007BE3E3 /* CCacheServer */ = { + activeExec = 0; + executables = ( + A1E70D5E0A38B796007BE3E3 /* CCacheServer */, + ); + }; + A1E70D5E0A38B796007BE3E3 /* CCacheServer */ = { + isa = PBXExecutable; + activeArgIndex = 2147483647; + activeArgIndices = ( + ); + argumentStrings = ( + ); + autoAttachOnCrash = 1; + configStateDict = { + }; + customDataFormattersEnabled = 1; + debuggerPlugin = GDBDebugging; + disassemblyDisplayState = 0; + enableDebugStr = 1; + environmentEntries = ( + ); + executableSystemSymbolLevel = 0; + executableUserSymbolLevel = 0; + libgmallocEnabled = 0; + name = CCacheServer; + sourceDirectories = ( + ); + }; + A1E70D930A38BB67007BE3E3 /* main.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 476}}"; + sepNavSelRange = "{316, 42}"; + sepNavVisRect = "{{0, 24}, {980, 387}}"; + }; + }; + A1E70D9E0A38BCAD007BE3E3 /* mig.defs */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 826}}"; + sepNavSelRange = "{2123, 0}"; + sepNavVisRect = "{{0, 400}, {804, 391}}"; + }; + }; + A1E70DB10A38C01E007BE3E3 /* mig_types.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 686}}"; + sepNavSelRange = "{2188, 0}"; + sepNavVisRect = "{{0, 281}, {804, 391}}"; + }; + }; + A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {888, 1078}}"; + sepNavSelRange = "{1293, 0}"; + sepNavVisRect = "{{0, 206}, {888, 470}}"; + }; + }; + A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 1218}}"; + sepNavSelRange = "{1240, 34}"; + sepNavVisRect = "{{0, 235}, {804, 329}}"; + }; + }; + A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {632, 1316}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {728, 4396}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {698, 1988}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DE80A38C6FD007BE3E3 /* notify.defs */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 518}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DF70A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D150A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 308; + vrLoc = 0; + }; + A1E70DF80A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3B0A38B5BB007BE3E3 /* client.c */; + name = "client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 903; + vrLoc = 0; + }; + A1E70DF90A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */; + name = "dllmain.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 298; + vrLoc = 0; + }; + A1E70DFA0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */; + name = "cacheapi.def: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 847; + vrLoc = 0; + }; + A1E70DFB0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D460A38B5BC007BE3E3 /* server.c */; + name = "server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 756; + vrLoc = 0; + }; + A1E70DFD0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1826; + vrLoc = 0; + }; + A1E70E010A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0B0A38B5BB007BE3E3 /* credentials.h */; + name = "credentials.h: 1"; + rLen = 2110; + rLoc = 0; + rType = 0; + vrLen = 1604; + vrLoc = 749; + }; + A1E70E020A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2C0A38B5BB007BE3E3 /* main.c */; + name = "main.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1306; + vrLoc = 202; + }; + A1E70E060A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 1128; + vrLoc = 6802; + }; + A1E70E090A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE80A38C6FD007BE3E3 /* notify.defs */; + name = "notify.defs: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1437; + vrLoc = 0; + }; + A1E70E0A0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */; + name = "kipc_server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1538; + vrLoc = 0; + }; + A1E70E0B0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; + name = "kipc_session.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1461; + vrLoc = 0; + }; + A1E70E0C0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; + name = "kipc_common.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1496; + vrLoc = 0; + }; + A1E70E100A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D150A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 308; + vrLoc = 0; + }; + A1E70E110A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1826; + vrLoc = 0; + }; + A1E70E120A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3B0A38B5BB007BE3E3 /* client.c */; + name = "client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 903; + vrLoc = 0; + }; + A1E70E130A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */; + name = "dllmain.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 298; + vrLoc = 0; + }; + A1E70E140A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */; + name = "cacheapi.def: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 847; + vrLoc = 0; + }; + A1E70E150A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D460A38B5BC007BE3E3 /* server.c */; + name = "server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 756; + vrLoc = 0; + }; + A1E70E160A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2C0A38B5BB007BE3E3 /* main.c */; + name = "main.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 954; + vrLoc = 0; + }; + A1E70E170A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = "serv_ops.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1825; + vrLoc = 0; + }; + A1E70E180A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1861; + vrLoc = 0; + }; + A1E70E1B0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "main.c: 22"; + rLen = 0; + rLoc = 509; + rType = 0; + vrLen = 954; + vrLoc = 0; + }; + A1E70E1E0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0B0A38B5BB007BE3E3 /* credentials.h */; + name = "credentials.h: 1"; + rLen = 2110; + rLoc = 0; + rType = 0; + vrLen = 1604; + vrLoc = 749; + }; + A1E70E1F0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; + name = cci_creds_v5_marshall; + rLen = 21; + rLoc = 6670; + rType = 0; + vrLen = 1513; + vrLoc = 6116; + }; + A1E70E200A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_flatten; + rLen = 15; + rLoc = 7396; + rType = 0; + vrLen = 1003; + vrLoc = 7034; + }; + A1E70E250A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 583"; + rLen = 0; + rLoc = 20525; + rType = 0; + vrLen = 2454; + vrLoc = 18163; + }; + A1E70E260A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; + name = "ccapi_ipc.defs: 55"; + rLen = 0; + rLoc = 2520; + rType = 0; + vrLen = 1955; + vrLoc = 87; + }; + A1E70E290A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; + name = "kipc_client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1544; + vrLoc = 0; + }; + A1E70E2A0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; + name = "kipc_common.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1496; + vrLoc = 0; + }; + A1E70E2B0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE80A38C6FD007BE3E3 /* notify.defs */; + name = "notify.defs: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1437; + vrLoc = 0; + }; + A1E70E2D0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */; + name = "kipc_server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1538; + vrLoc = 0; + }; + A1E70E2E0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; + name = "kipc_session.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1461; + vrLoc = 0; + }; + A1E70E380A38C778007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "#include "; + rLen = 30; + rLoc = 2170; + rType = 0; + vrLen = 696; + vrLoc = 1821; + }; + A1E70E3D0A38C78C007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D260A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 437; + vrLoc = 0; + }; + A1E70E410A38C78C007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D260A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 437; + vrLoc = 0; + }; + A1E70E430A38C791007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 432; + vrLoc = 0; + }; + A1E70E450A38C791007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 432; + vrLoc = 0; + }; + A1E70E4A0A38C7BE007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 432; + vrLoc = 0; + }; + A1E70E520A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D150A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 308; + vrLoc = 0; + }; + A1E70E530A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1C0A38B5BB007BE3E3 /* datastore.h */; + name = cc_list_type; + rLen = 0; + rLoc = 2301; + rType = 0; + vrLen = 425; + vrLoc = 2113; + }; + A1E70E560A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = cc_list_type; + rLen = 12; + rLoc = 2736; + rType = 0; + vrLen = 728; + vrLoc = 2219; + }; + A1E70E580A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1C0A38B5BB007BE3E3 /* datastore.h */; + name = cc_list_type; + rLen = 0; + rLoc = 2301; + rType = 0; + vrLen = 425; + vrLoc = 2113; + }; + A1E70E6F0A38CA08007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "#include \"generic_lists.h\""; + rLen = 27; + rLoc = 2765; + rType = 0; + vrLen = 755; + vrLoc = 2478; + }; + A1E70E770A38CA55007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */; + name = "#include \"msg.h\""; + rLen = 18; + rLoc = 2202; + rType = 0; + vrLen = 644; + vrLoc = 1674; + }; + A1E70E7D0A38CA55007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */; + name = "#include \"msg.h\""; + rLen = 18; + rLoc = 2202; + rType = 0; + vrLen = 644; + vrLoc = 1674; + }; + A1E70E9C0A38CAF1007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 463; + vrLoc = 2119; + }; + A1E70EA80A38CB24007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: cc_generic_list_node_t"; + rLen = 0; + rLoc = 2452; + rType = 0; + vrLen = 598; + vrLoc = 2206; + }; + A1E70EAB0A38CB24007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D080A38B5BB007BE3E3 /* context.c */; + name = "code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos);"; + rLen = 86; + rLoc = 14073; + rType = 0; + vrLen = 704; + vrLoc = 13925; + }; + A1E70EB50A38CB4D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "strncpy(vendor, string, sizeof(vendor)-1);"; + rLen = 55; + rLoc = 4926; + rType = 0; + vrLen = 780; + vrLoc = 1821; + }; + A1E70EC30A38CC14007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1115; + vrLoc = 0; + }; + A1E70ECB0A38CC4C007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; + name = "#include "; + rLen = 34; + rLoc = 1240; + rType = 0; + vrLen = 891; + vrLoc = 724; + }; + A1E70ED70A38CCB6007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; + name = "#include "; + rLen = 34; + rLoc = 1240; + rType = 0; + vrLen = 1069; + vrLoc = 582; + }; + A1E70EE20A38CCD6007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DB10A38C01E007BE3E3 /* mig_types.h */; + name = "ccapi_ipc.h: 39"; + rLen = 0; + rLoc = 1957; + rType = 0; + vrLen = 892; + vrLoc = 1209; + }; + A1E70EFE0A38CD66007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */; + name = "#include "; + rLen = 36; + rLoc = 1293; + rType = 0; + vrLen = 609; + vrLoc = 1011; + }; + A1E70F0F0A38CE21007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3B0A38B5BB007BE3E3 /* client.c */; + name = "client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 903; + vrLoc = 0; + }; + A1E70F440A38D252007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DB10A38C01E007BE3E3 /* mig_types.h */; + name = "msg_ipc.h: 48"; + rLen = 0; + rLoc = 2188; + rType = 0; + vrLen = 793; + vrLoc = 1409; + }; + A1E70F450A38D252007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */; + name = "kipc_common.h: 32"; + rLen = 0; + rLoc = 1293; + rType = 0; + vrLen = 1252; + vrLoc = 450; + }; + A1E70F8B0A38D3B4007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; + name = "msg_ipc.defs: 43"; + rLen = 0; + rLoc = 2111; + rType = 0; + vrLen = 1149; + vrLoc = 1378; + }; + A1E70F9C0A38D41E007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DB10A38C01E007BE3E3 /* mig_types.h */; + name = "mig_types.h: 48"; + rLen = 0; + rLoc = 2188; + rType = 0; + vrLen = 1178; + vrLoc = 1024; + }; + A1E70F9D0A38D41E007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; + name = "mig.defs: 44"; + rLen = 0; + rLoc = 2123; + rType = 0; + vrLen = 1034; + vrLoc = 1439; + }; + A1E70FC60A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70FC70A38D560007BE3E3 /* migServer.h */; + name = ccapi_server; + rLen = 12; + rLoc = 1268; + rType = 0; + vrLen = 879; + vrLoc = 942; + }; + A1E70FC70A38D560007BE3E3 /* migServer.h */ = { + isa = PBXFileReference; + name = migServer.h; + path = "/Volumes/Ra-Tilt/Users/lxs/Builds/CCAPI.build/Debug/CCacheServer.build/DerivedSources/migServer.h"; + sourceTree = ""; + }; + A1E70FC80A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "main.c: 23"; + rLen = 0; + rLoc = 495; + rType = 0; + vrLen = 691; + vrLoc = 0; + }; + A1E70FC90A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1C0A38B5BB007BE3E3 /* datastore.h */; + name = "datastore.h: 55"; + rLen = 0; + rLoc = 2301; + rType = 0; + vrLen = 805; + vrLoc = 2101; + }; + A1E70FCA0A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 52"; + rLen = 0; + rLoc = 2371; + rType = 0; + vrLen = 757; + vrLoc = 2012; + }; + A1E70FCD0A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "main.c: 23"; + rLen = 0; + rLoc = 495; + rType = 0; + vrLen = 691; + vrLoc = 0; + }; + A1E70FD80A38D573007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "syslog (LOG_INFO, \"Starting up.\");"; + rLen = 42; + rLoc = 316; + rType = 0; + vrLen = 628; + vrLoc = 21; + }; + A1E70FEE0A38D7C0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; + name = "marshall.c: 48"; + rLen = 0; + rLoc = 2234; + rType = 0; + vrLen = 831; + vrLoc = 1674; + }; + A1E70FEF0A38D7C0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 49"; + rLen = 0; + rLoc = 2186; + rType = 0; + vrLen = 432; + vrLoc = 2106; + }; + A1E70FF00A38D7C0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D080A38B5BB007BE3E3 /* context.c */; + name = "code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string);"; + rLen = 139; + rLoc = 29872; + rType = 0; + vrLen = 757; + vrLoc = 27442; + }; + A1E70FFA0A38D806007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; + name = "memcpy(creds->client, flat + header->client.data, length);"; + rLen = 68; + rLoc = 11995; + rType = 0; + vrLen = 1038; + vrLoc = 11543; + }; + A1E70FFC0A38D806007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D020A38B5BB007BE3E3 /* ccache.h */; + name = cc_handle; + rLen = 9; + rLoc = 2339; + rType = 0; + vrLen = 663; + vrLoc = 2042; + }; + A1E70FFF0A38D806007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D020A38B5BB007BE3E3 /* ccache.h */; + name = cc_handle; + rLen = 9; + rLoc = 2339; + rType = 0; + vrLen = 663; + vrLoc = 2042; + }; + A1E710010A38D814007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 617; + vrLoc = 4722; + }; + A1E7100A0A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 619; + vrLoc = 4720; + }; + A1E7100C0A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D080A38B5BB007BE3E3 /* context.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 29891; + rType = 0; + vrLen = 1038; + vrLoc = 29282; + }; + A1E7100D0A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 6723; + rType = 0; + vrLen = 1080; + vrLoc = 6223; + }; + A1E710110A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 22827; + rType = 0; + vrLen = 921; + vrLoc = 22183; + }; + A1E710140A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 6723; + rType = 0; + vrLen = 1080; + vrLoc = 6223; + }; + A1E7103C0A38DE0B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "msg.h: 142"; + rLen = 0; + rLoc = 5529; + rType = 0; + vrLen = 1239; + vrLoc = 4630; + }; + A1E710400A38DE0B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15353; + rType = 0; + vrLen = 962; + vrLoc = 14947; + }; + A1E710530A39EC0B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = "serv_ops.c: 322"; + rLen = 0; + rLoc = 12676; + rType = 0; + vrLen = 1049; + vrLoc = 12199; + }; + A1E7105A0A39ED89007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string);"; + rLen = 139; + rLoc = 4787; + rType = 0; + vrLen = 1079; + vrLoc = 4176; + }; + A1E7105D0A39ED89007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string);"; + rLen = 139; + rLoc = 4787; + rType = 0; + vrLen = 1079; + vrLoc = 4176; + }; + A1E7105E0A39ED89007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "cur_pos = msg->flat;"; + rLen = 25; + rLoc = 7704; + rType = 0; + vrLen = 835; + vrLoc = 7353; + }; + A1E710680A39F102007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = "resp_header->ccache = htonll((cc_handle) ccache);"; + rLen = 54; + rLoc = 23249; + rType = 0; + vrLen = 1200; + vrLoc = 22714; + }; + A1E710840A3A1CFB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 378"; + rLen = 0; + rLoc = 11919; + rType = 0; + vrLen = 1092; + vrLoc = 11685; + }; + A1E710860A3A1CFB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 585"; + rLen = 0; + rLoc = 15353; + rType = 0; + vrLen = 1129; + vrLoc = 14797; + }; + A1E710870A3A1CFB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 378"; + rLen = 0; + rLoc = 11919; + rType = 0; + vrLen = 1092; + vrLoc = 11685; + }; + A1E710890A3A1D04007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 289"; + rLen = 0; + rLoc = 9783; + rType = 0; + vrLen = 919; + vrLoc = 9327; + }; + A1E7108B0A3A1D04007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 289"; + rLen = 0; + rLoc = 9783; + rType = 0; + vrLen = 919; + vrLoc = 9327; + }; + A1E7108D0A3A1D06007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 289"; + rLen = 0; + rLoc = 9783; + rType = 0; + vrLen = 1441; + vrLoc = 9196; + }; + A1E710930A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 36879; + rType = 0; + vrLen = 1393; + vrLoc = 35980; + }; + A1E710940A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "msg.h: 142"; + rLen = 0; + rLoc = 5529; + rType = 0; + vrLen = 1480; + vrLoc = 4457; + }; + A1E710950A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + rLen = 21; + rLoc = 14700; + rType = 0; + }; + A1E710960A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 36879; + rType = 0; + vrLen = 1393; + vrLoc = 35980; + }; + A1E710970A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "msg.h: 142"; + rLen = 0; + rLoc = 5529; + rType = 0; + vrLen = 1480; + vrLoc = 4457; + }; + A1E7109C0A3A1D2B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 36879; + rType = 0; + vrLen = 1196; + vrLoc = 36344; + }; + A1E7109D0A3A1D2B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + comments = "error: conflicting types for 'cci_msg_retrieve_blob'"; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + rLen = 1; + rLoc = 570; + rType = 1; + }; + A1E7109F0A3A1DD0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 1248"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 1576; + vrLoc = 14015; + }; + A1E710A00A3A1DD0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 1248"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 1582; + vrLoc = 0; + }; + A1E710A50A3A22E1007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 623"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 1674; + vrLoc = 0; + }; + A1E710AB0A3A22F5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 623"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 2012; + vrLoc = 0; + }; + A1E710AC0A3A22F5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1284; + vrLoc = 15187; + }; + A1E710AD0A3A22F5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710AF0A3A22FE007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1589; + vrLoc = 14614; + }; + A1E710B30A3A22FF007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710B90A3A23FB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710BC0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1356; + vrLoc = 15083; + }; + A1E710BD0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 873; + vrLoc = 1826; + }; + A1E710BE0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1356; + vrLoc = 15083; + }; + A1E710BF0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 863; + vrLoc = 1826; + }; + A1E710C00A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710C60A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 863; + vrLoc = 1826; + }; + A1E710C70A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 54"; + rLen = 0; + rLoc = 2452; + rType = 0; + vrLen = 1215; + vrLoc = 1674; + }; + A1E710C80A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 863; + vrLoc = 1826; + }; + A1E710C90A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 939; + vrLoc = 1935; + }; + A1E710CA0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710CB0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 696; + vrLoc = 2147; + }; + A1E710CC0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + comments = "error: CredentialsCache.h: No such file or directory"; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + rLen = 1; + rLoc = 53; + rType = 1; + }; + A1E710CD0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 696; + vrLoc = 2147; + }; + A1E710CE0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 608; + vrLoc = 2043; + }; + A1E710D00A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 906; + vrLoc = 2012; + }; + A1E710D10A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 861; + vrLoc = 1792; + }; + A1E710D20A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 822; + vrLoc = 4694; + }; + A1E710D30A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 861; + vrLoc = 1792; + }; + A1E710D40A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 822; + vrLoc = 4694; + }; + A1E710D70A3A2465007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 802; + vrLoc = 4694; + }; + A1E710D80A3A2465007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 683; + vrLoc = 1899; + }; + A1E710D90A3A2465007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 726; + vrLoc = 4701; + }; + A1E710DB0A3A246E007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 726; + vrLoc = 4701; + }; + A1E710DF0A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 786; + vrLoc = 7144; + }; + A1E710E00A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 802; + vrLoc = 4694; + }; + A1E710E10A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 802; + vrLoc = 4694; + }; + A1E710E20A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 786; + vrLoc = 7144; + }; + A1E710E30A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 836; + vrLoc = 2610; + }; + A1E710E50A3A248A007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 1007; + vrLoc = 2180; + }; + A1E710E60A3A248A007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710E70A3A24A4007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710E80A3A24A5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 825; + vrLoc = 2639; + }; + A1E710E90A3A24A5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710EA0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 825; + vrLoc = 2639; + }; + A1E710EB0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 1103; + vrLoc = 1564; + }; + A1E710EC0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 906; + vrLoc = 2012; + }; + A1E710ED0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 825; + vrLoc = 2639; + }; + A1E710EE0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 1103; + vrLoc = 1564; + }; + A1E710EF0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 906; + vrLoc = 2012; + }; + A1E710F00A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 842; + vrLoc = 1792; + }; + A1E710F10A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710F40A3A253F007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 57"; + rLen = 0; + rLoc = 2282; + rType = 0; + vrLen = 861; + vrLoc = 1792; + }; + A1E710F50A3A253F007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + D2AAC045055464E500DB518D /* CCAPI */ = { + activeExec = 0; + }; +} diff --git a/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective new file mode 100644 index 000000000..198370765 --- /dev/null +++ b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective @@ -0,0 +1,1567 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXRunSessionModule + Name + Run Log + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + Description + AIODescriptionKey + DockingSystemVisible + + Extension + perspective + FavBarConfig + + PBXProjectModuleGUID + A1E70E750A38CA08007BE3E3 + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.default + MajorVersion + 33 + MinorVersion + 0 + Name + All-In-One + Notifications + + + XCObserverAutoDisconnectKey + + XCObserverDefintionKey + + XCObserverFactoryKey + XCPerspectivesSpecificationIdentifier + XCObserverGUIDKey + XCObserverProjectIdentifier + XCObserverNotificationKey + PBXStatusBuildStateMessageNotification + XCObserverTargetKey + XCMainBuildResultsModuleGUID + XCObserverTriggerKey + awakenModuleWithObserver: + XCObserverValidationKey + + + + OpenEditors + + PerspectiveWidths + + 1340 + 1340 + 1340 + + Perspectives + + + ChosenToolbarItems + + XCToolbarPerspectiveControl + NSToolbarSeparatorItem + active-target-popup + action + NSToolbarFlexibleSpaceItem + buildOrClean + build-and-runOrDebug + com.apple.ide.PBXToolbarStopButton + get-info + toggle-editor + NSToolbarFlexibleSpaceItem + com.apple.pbx.toolbar.searchfield + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.project + IsVertical + + Layout + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CA23ED40692098700951B8B + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 268 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 08FB7794FE84155DC02AAC07 + A1E70CFF0A38B5BB007BE3E3 + A1E70D110A38B5BB007BE3E3 + A1E70D7E0A38BAC5007BE3E3 + A1E70D180A38B5BB007BE3E3 + A1E70D270A38B5BB007BE3E3 + A1E70D2B0A38B5BB007BE3E3 + A1E70D390A38B5BB007BE3E3 + 1C37FBAC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 24 + 19 + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {268, 841}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {285, 859}} + GroupTreeTableConfiguration + + MainColumn + 268 + + RubberWindowFrame + 170 278 1340 900 0 0 1920 1178 + + Module + PBXSmartGroupTreeModule + Proportion + 285pt + + + Dock + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + A1E70DF50A38C765007BE3E3 + PBXProjectModuleLabel + generic_lists.c + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + A1E70DF60A38C765007BE3E3 + PBXProjectModuleLabel + generic_lists.c + _historyCapacity + 0 + bookmark + A1E710F40A3A253F007BE3E3 + history + + A1E70DF90A38C765007BE3E3 + A1E70DFA0A38C765007BE3E3 + A1E70DFB0A38C765007BE3E3 + A1E70E010A38C765007BE3E3 + A1E70E020A38C765007BE3E3 + A1E70E090A38C765007BE3E3 + A1E70E0A0A38C765007BE3E3 + A1E70E0B0A38C765007BE3E3 + A1E70E0C0A38C765007BE3E3 + A1E70E3D0A38C78C007BE3E3 + A1E70E4A0A38C7BE007BE3E3 + A1E70E520A38C9FD007BE3E3 + A1E70E530A38C9FD007BE3E3 + A1E70E770A38CA55007BE3E3 + A1E70EB50A38CB4D007BE3E3 + A1E70ED70A38CCB6007BE3E3 + A1E70EFE0A38CD66007BE3E3 + A1E70F0F0A38CE21007BE3E3 + A1E70F9C0A38D41E007BE3E3 + A1E70F9D0A38D41E007BE3E3 + A1E70FC60A38D560007BE3E3 + A1E70FD80A38D573007BE3E3 + A1E70FFA0A38D806007BE3E3 + A1E70FFC0A38D806007BE3E3 + A1E7100C0A38D888007BE3E3 + A1E7100D0A38D888007BE3E3 + A1E710840A3A1CFB007BE3E3 + A1E7108D0A3A1D06007BE3E3 + A1E710930A3A1D22007BE3E3 + A1E710940A3A1D22007BE3E3 + A1E710BC0A3A2415007BE3E3 + A1E710EA0A3A2521007BE3E3 + A1E710EB0A3A2521007BE3E3 + A1E710EC0A3A2521007BE3E3 + A1E710D10A3A2456007BE3E3 + + prevStack + + A1E70E100A38C765007BE3E3 + A1E70E110A38C765007BE3E3 + A1E70E120A38C765007BE3E3 + A1E70E130A38C765007BE3E3 + A1E70E140A38C765007BE3E3 + A1E70E150A38C765007BE3E3 + A1E70E160A38C765007BE3E3 + A1E70E180A38C765007BE3E3 + A1E70E1B0A38C765007BE3E3 + A1E70E1E0A38C765007BE3E3 + A1E70E1F0A38C765007BE3E3 + A1E70E200A38C765007BE3E3 + A1E70E250A38C765007BE3E3 + A1E70E260A38C765007BE3E3 + A1E70E290A38C765007BE3E3 + A1E70E2A0A38C765007BE3E3 + A1E70E2B0A38C765007BE3E3 + A1E70E2D0A38C765007BE3E3 + A1E70E2E0A38C765007BE3E3 + A1E70E380A38C778007BE3E3 + A1E70E410A38C78C007BE3E3 + A1E70E450A38C791007BE3E3 + A1E70E560A38C9FD007BE3E3 + A1E70E580A38C9FD007BE3E3 + A1E70E6F0A38CA08007BE3E3 + A1E70E7D0A38CA55007BE3E3 + A1E70EAB0A38CB24007BE3E3 + A1E70EC30A38CC14007BE3E3 + A1E70EE20A38CCD6007BE3E3 + A1E70FFF0A38D806007BE3E3 + A1E710110A38D888007BE3E3 + A1E710140A38D888007BE3E3 + A1E710BE0A3A2415007BE3E3 + A1E710C80A3A2441007BE3E3 + A1E710D30A3A2456007BE3E3 + A1E710E10A3A247D007BE3E3 + A1E710E20A3A247D007BE3E3 + A1E710ED0A3A2521007BE3E3 + A1E710EE0A3A2521007BE3E3 + A1E710EF0A3A2521007BE3E3 + + + SplitCount + 1 + + StatusBarVisibility + + XCSharingToken + com.apple.Xcode.CommonNavigatorGroupSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {1050, 553}} + RubberWindowFrame + 170 278 1340 900 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 553pt + + + Proportion + 301pt + Tabs + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA23EDF0692099D00951B8B + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{10, 27}, {1050, 274}} + RubberWindowFrame + 170 278 1340 900 0 0 1920 1178 + + Module + XCDetailModule + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA23EE00692099D00951B8B + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{10, 27}, {1050, 274}} + + Module + PBXProjectFindModule + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA23EE10692099D00951B8B + PBXProjectModuleLabel + SCM Results + + GeometryConfiguration + + Frame + {{10, 31}, {603, 297}} + + Module + PBXCVSModule + + + + + Proportion + 1050pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDockableTabModule + XCDetailModule + PBXProjectFindModule + PBXCVSModule + + TableOfContents + + A1E710B00A3A22FE007BE3E3 + 1CA23ED40692098700951B8B + A1E710B10A3A22FE007BE3E3 + A1E70DF50A38C765007BE3E3 + A1E710B20A3A22FE007BE3E3 + 1CA23EDF0692099D00951B8B + 1CA23EE00692099D00951B8B + 1CA23EE10692099D00951B8B + + ToolbarConfiguration + xcode.toolbar.config.default + + + ChosenToolbarItems + + XCToolbarPerspectiveControl + NSToolbarSeparatorItem + active-target-popup + active-executable-popup + active-buildstyle-popup + NSToolbarFlexibleSpaceItem + build + clean + NSToolbarSeparatorItem + run + debug + + ControllerClassBaseName + + IconName + BuildTabIcon + Identifier + perspective.build + IsVertical + + Layout + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + PBXProjectModuleGUID + 1CA23EE50692099D00951B8B + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 184 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {184, 841}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {201, 859}} + GroupTreeTableConfiguration + + MainColumn + 184 + + + Module + PBXSmartGroupTreeModule + Proportion + 201pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + A1E70DF50A38C765007BE3E3 + PBXProjectModuleLabel + CredentialsCache.h + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + A1E70DF60A38C765007BE3E3 + PBXProjectModuleLabel + CredentialsCache.h + _historyCapacity + 0 + bookmark + A1E710F50A3A253F007BE3E3 + history + + A1E70DF70A38C765007BE3E3 + A1E70DF80A38C765007BE3E3 + A1E70DF90A38C765007BE3E3 + A1E70DFA0A38C765007BE3E3 + A1E70DFB0A38C765007BE3E3 + A1E70E010A38C765007BE3E3 + A1E70E020A38C765007BE3E3 + A1E70E060A38C765007BE3E3 + A1E70E090A38C765007BE3E3 + A1E70E0A0A38C765007BE3E3 + A1E70E0B0A38C765007BE3E3 + A1E70E0C0A38C765007BE3E3 + A1E70E3D0A38C78C007BE3E3 + A1E70E430A38C791007BE3E3 + A1E70E770A38CA55007BE3E3 + A1E70ECB0A38CC4C007BE3E3 + A1E70F440A38D252007BE3E3 + A1E70F450A38D252007BE3E3 + A1E70F8B0A38D3B4007BE3E3 + A1E70FC60A38D560007BE3E3 + A1E70FC80A38D560007BE3E3 + A1E70FC90A38D560007BE3E3 + A1E70FEE0A38D7C0007BE3E3 + A1E70FEF0A38D7C0007BE3E3 + A1E70FF00A38D7C0007BE3E3 + A1E70FFC0A38D806007BE3E3 + A1E7100D0A38D888007BE3E3 + A1E7103C0A38DE0B007BE3E3 + A1E7105A0A39ED89007BE3E3 + A1E710890A3A1D04007BE3E3 + A1E7109C0A3A1D2B007BE3E3 + A1E710CA0A3A244D007BE3E3 + A1E710CB0A3A244D007BE3E3 + A1E710D80A3A2465007BE3E3 + A1E710E30A3A247D007BE3E3 + + prevStack + + A1E70E100A38C765007BE3E3 + A1E70E110A38C765007BE3E3 + A1E70E120A38C765007BE3E3 + A1E70E130A38C765007BE3E3 + A1E70E140A38C765007BE3E3 + A1E70E150A38C765007BE3E3 + A1E70E160A38C765007BE3E3 + A1E70E170A38C765007BE3E3 + A1E70E180A38C765007BE3E3 + A1E70E1E0A38C765007BE3E3 + A1E70E1F0A38C765007BE3E3 + A1E70E250A38C765007BE3E3 + A1E70E260A38C765007BE3E3 + A1E70E290A38C765007BE3E3 + A1E70E2A0A38C765007BE3E3 + A1E70E2B0A38C765007BE3E3 + A1E70E2D0A38C765007BE3E3 + A1E70E2E0A38C765007BE3E3 + A1E70E380A38C778007BE3E3 + A1E70E410A38C78C007BE3E3 + A1E70E450A38C791007BE3E3 + A1E70E560A38C9FD007BE3E3 + A1E70E580A38C9FD007BE3E3 + A1E70E7D0A38CA55007BE3E3 + A1E70EAB0A38CB24007BE3E3 + A1E70EC30A38CC14007BE3E3 + A1E70EE20A38CCD6007BE3E3 + A1E70FCD0A38D560007BE3E3 + A1E70FFF0A38D806007BE3E3 + A1E710140A38D888007BE3E3 + A1E710400A38DE0B007BE3E3 + A1E70E6F0A38CA08007BE3E3 + A1E710CD0A3A244D007BE3E3 + A1E710E20A3A247D007BE3E3 + + + SplitCount + 1 + + StatusBarVisibility + + XCSharingToken + com.apple.Xcode.CommonNavigatorGroupSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {1134, 480}} + + Module + PBXNavigatorGroup + Proportion + 480pt + + + Proportion + 374pt + Tabs + + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1010 + + GeometryConfiguration + + Frame + {{10, 27}, {1134, 347}} + + Module + PBXBuildResultsModule + + + ContentConfiguration + + LauncherConfigVersion + 3 + PBXProjectModuleGUID + 1CA23EE80692099D00951B8B + PBXProjectModuleLabel + Run + Runner + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {365, 167}} + {{0, 176}, {365, 267}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {405, 443}} + {{414, 0}, {514, 443}} + + + + + GeometryConfiguration + + Frame + {{0, 0}, {0, 0}} + + Module + PBXRunSessionModule + + + + + Proportion + 1134pt + + + Name + Build + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDockableTabModule + PBXBuildResultsModule + PBXRunSessionModule + XCConsole + + TableOfContents + + A1E710B40A3A22FF007BE3E3 + 1CA23EE50692099D00951B8B + A1E710B50A3A22FF007BE3E3 + A1E70DF50A38C765007BE3E3 + A1E710B60A3A22FF007BE3E3 + XCMainBuildResultsModuleGUID + 1CA23EE80692099D00951B8B + A1E710B70A3A22FF007BE3E3 + + ToolbarConfiguration + xcode.toolbar.config.buildAndRun + + + ChosenToolbarItems + + XCToolbarPerspectiveControl + NSToolbarSeparatorItem + build-and-debug + debug + NSToolbarFlexibleSpaceItem + debugger-fix-and-continue + debugger-restart-executable + debugger-pause + debugger-continue + debugger-step-over + debugger-step-into + debugger-step-out + debugger-step-instruction + NSToolbarFlexibleSpaceItem + + ControllerClassBaseName + PBXDebugSessionModule + IconName + DebugTabIcon + Identifier + perspective.debug + IsVertical + 1 + Layout + + + ContentConfiguration + + PBXProjectModuleGUID + 1CCC7628064C1048000F2A68 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {810, 0}} + + Module + PBXDebugCLIModule + Proportion + 0% + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {395, 213}} + {{395, 0}, {415, 213}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {810, 213}} + {{0, 213}, {810, 225}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1CCC7629064C1048000F2A68 + PBXProjectModuleLabel + Debug + + GeometryConfiguration + + DebugConsoleDrawerSize + {100, 120} + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 7}, {810, 438}} + + Module + PBXDebugSessionModule + Proportion + 443pt + + + Name + Debug + ServiceClasses + + XCModuleDock + XCModuleDock + PBXDebugCLIModule + PBXDebugSessionModule + XCConsole + + TableOfContents + + 1CC8E6A5069209BD00BB180A + 1CC8E6A6069209BD00BB180A + 1CCC7628064C1048000F2A68 + 1CCC7629064C1048000F2A68 + 1CC8E6A7069209BD00BB180A + + ToolbarConfiguration + xcode.toolbar.config.debug + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/System/Library/PrivateFrameworks/DevToolsInterface.framework/Versions/A/Resources/XCPerspectivesSpecification.xcperspec' + StatusbarIsVisible + + TimeStamp + 171582783.00723499 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + + WindowJustification + 5 + WindowOrderList + + /Volumes/Ra-Tilt/Users/lxs/KfM/CCAPI/src/lib/ccapi/mac/CCAPI.xcodeproj + + WindowString + 170 278 1340 900 0 0 1920 1178 + WindowTools + + + Identifier + windowTool.find + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CD0528D0623707200166675 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {781, 167}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 781pt + + + Proportion + 50% + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{8, 0}, {773, 254}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXProjectFindModule + Proportion + 50% + + + Proportion + 428pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C530D57069F1CE1000CFCEE + 1C530D58069F1CE1000CFCEE + 1C530D59069F1CE1000CFCEE + 1CDD528C0622207200134675 + 1C530D5A069F1CE1000CFCEE + 1CE0B1FE06471DED0097A5F4 + 1CD0528E0623707200166675 + + WindowString + 62 385 781 470 0 0 1440 878 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + 0 + + + Identifier + windowTool.run + Layout + + + Dock + + + ContentConfiguration + + LauncherConfigVersion + 3 + PBXProjectModuleGUID + 1CD0528B0623707200166675 + PBXProjectModuleLabel + Run - cocoapp112 - cocoapp112 + Runner + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {365, 167}} + {{0, 176}, {365, 267}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {405, 443}} + {{414, 0}, {514, 443}} + + + + + GeometryConfiguration + + Frame + {{0, 0}, {456, 192}} + RubberWindowFrame + 741 130 456 234 0 0 1280 1002 + + Module + PBXRunSessionModule + Proportion + 192pt + + + Proportion + 192pt + + + Name + Run Log + ServiceClasses + + PBXRunSessionModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAAF065D492600B07095 + 1C78EAB0065D492600B07095 + 1CD0528B0623707200166675 + 1C78EAB1065D492600B07095 + + ToolbarConfiguration + xcode.toolbar.config.run + WindowString + 741 130 456 234 0 0 1280 1002 + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.09500122070312 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + Identifier + windowTool.breakpoints + IsVertical + 0 + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 0 + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 2 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + 1 + TableOfContents + + 1CDDB66807F98D9800BB5817 + 1CDDB66907F98D9800BB5817 + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpoints + WindowString + 315 424 744 409 0 0 1440 878 + WindowToolGUID + 1CDDB66807F98D9800BB5817 + WindowToolIsVisible + 1 + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimator + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 166pt + + + Proportion + 166pt + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {369, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {616, 353}} + MembersFrame + {{0, 105}, {369, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 94 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 597 125 616 374 0 0 1280 1002 + + Module + PBXClassBrowserModule + Proportion + 354pt + + + Proportion + 354pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C78EABA065D492600B07095 + 1C78EABB065D492600B07095 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 597 125 616 374 0 0 1280 1002 + + + + diff --git a/src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj b/src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj new file mode 100644 index 000000000..38a73b4c9 --- /dev/null +++ b/src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj @@ -0,0 +1,599 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + A1E70D480A38B5D5007BE3E3 /* cacheapi.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; }; + A1E70D490A38B5D5007BE3E3 /* ccache.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; }; + A1E70D4A0A38B5D5007BE3E3 /* ccache_iterator.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D030A38B5BB007BE3E3 /* ccache_iterator.c */; }; + A1E70D4B0A38B5D5007BE3E3 /* ccapiv2.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D050A38B5BB007BE3E3 /* ccapiv2.c */; }; + A1E70D4C0A38B5D5007BE3E3 /* ccstring.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D060A38B5BB007BE3E3 /* ccstring.c */; }; + A1E70D4D0A38B5D5007BE3E3 /* context.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D080A38B5BB007BE3E3 /* context.c */; }; + A1E70D4E0A38B5D5007BE3E3 /* credentials.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D0A0A38B5BB007BE3E3 /* credentials.c */; }; + A1E70D4F0A38B5D5007BE3E3 /* credentials_iterator.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */; }; + A1E70D510A38B60C007BE3E3 /* generic_lists.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; }; + A1E70D520A38B60C007BE3E3 /* marshall.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; }; + A1E70D530A38B60C007BE3E3 /* msg.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; }; + A1E70D890A38BB47007BE3E3 /* ccs_ccache.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; }; + A1E70D8A0A38BB47007BE3E3 /* ccs_context.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D290A38B5BB007BE3E3 /* ccs_context.c */; }; + A1E70D8B0A38BB47007BE3E3 /* ccs_lists.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D2A0A38B5BB007BE3E3 /* ccs_lists.c */; }; + A1E70D8C0A38BB47007BE3E3 /* rpc_auth.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D2E0A38B5BB007BE3E3 /* rpc_auth.c */; }; + A1E70D8D0A38BB47007BE3E3 /* serv_ops.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; }; + A1E70D8E0A38BB4F007BE3E3 /* generic_lists.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; }; + A1E70D8F0A38BB4F007BE3E3 /* marshall.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; }; + A1E70D900A38BB4F007BE3E3 /* msg.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; }; + A1E70D9B0A38BBE2007BE3E3 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D930A38BB67007BE3E3 /* main.c */; }; + A1E70D9F0A38BCAD007BE3E3 /* mig.defs in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; }; + A1E70DA00A38BCAD007BE3E3 /* mig.defs in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; settings = {ATTRIBUTES = (Server, ); }; }; + A1E70DEA0A38C710007BE3E3 /* kipc_client.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; }; + A1E70DEB0A38C710007BE3E3 /* kipc_common.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; }; + A1E70DEC0A38C710007BE3E3 /* kipc_session.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; }; + A1E70DED0A38C71D007BE3E3 /* kipc_common.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; }; + A1E70DEE0A38C71D007BE3E3 /* kipc_server.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */; }; + A1E70DEF0A38C71D007BE3E3 /* kipc_session.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; }; + A1E70DF00A38C71D007BE3E3 /* notify.defs in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE80A38C6FD007BE3E3 /* notify.defs */; settings = {ATTRIBUTES = (Server, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + A1E70D000A38B5BB007BE3E3 /* cacheapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cacheapi.c; sourceTree = ""; }; + A1E70D010A38B5BB007BE3E3 /* ccache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccache.c; sourceTree = ""; }; + A1E70D020A38B5BB007BE3E3 /* ccache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccache.h; sourceTree = ""; }; + A1E70D030A38B5BB007BE3E3 /* ccache_iterator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccache_iterator.c; sourceTree = ""; }; + A1E70D040A38B5BB007BE3E3 /* ccache_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccache_iterator.h; sourceTree = ""; }; + A1E70D050A38B5BB007BE3E3 /* ccapiv2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccapiv2.c; sourceTree = ""; }; + A1E70D060A38B5BB007BE3E3 /* ccstring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccstring.c; sourceTree = ""; }; + A1E70D070A38B5BB007BE3E3 /* ccstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccstring.h; sourceTree = ""; }; + A1E70D080A38B5BB007BE3E3 /* context.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = context.c; sourceTree = ""; }; + A1E70D090A38B5BB007BE3E3 /* context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = context.h; sourceTree = ""; }; + A1E70D0A0A38B5BB007BE3E3 /* credentials.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = credentials.c; sourceTree = ""; }; + A1E70D0B0A38B5BB007BE3E3 /* credentials.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = credentials.h; sourceTree = ""; }; + A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = credentials_iterator.c; sourceTree = ""; }; + A1E70D0D0A38B5BB007BE3E3 /* credentials_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = credentials_iterator.h; sourceTree = ""; }; + A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D120A38B5BB007BE3E3 /* generic_lists.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = generic_lists.c; sourceTree = ""; }; + A1E70D130A38B5BB007BE3E3 /* marshall.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = marshall.c; sourceTree = ""; }; + A1E70D140A38B5BB007BE3E3 /* msg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = msg.c; sourceTree = ""; }; + A1E70D150A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D170A38B5BB007BE3E3 /* implementation-notes.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "implementation-notes.txt"; sourceTree = ""; }; + A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cc_rpc.h; sourceTree = ""; }; + A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialsCache.h; sourceTree = ""; }; + A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialsCache2.h; sourceTree = ""; }; + A1E70D1C0A38B5BB007BE3E3 /* datastore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = datastore.h; sourceTree = ""; }; + A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = generic_lists.h; sourceTree = ""; }; + A1E70D1E0A38B5BB007BE3E3 /* marshall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = marshall.h; sourceTree = ""; }; + A1E70D1F0A38B5BB007BE3E3 /* msg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msg.h; sourceTree = ""; }; + A1E70D200A38B5BB007BE3E3 /* msg_headers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msg_headers.h; sourceTree = ""; }; + A1E70D210A38B5BB007BE3E3 /* rpc_auth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rpc_auth.h; sourceTree = ""; }; + A1E70D260A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NTMakefile; path = ../NTMakefile; sourceTree = SOURCE_ROOT; }; + A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccs_ccache.c; sourceTree = ""; }; + A1E70D290A38B5BB007BE3E3 /* ccs_context.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccs_context.c; sourceTree = ""; }; + A1E70D2A0A38B5BB007BE3E3 /* ccs_lists.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccs_lists.c; sourceTree = ""; }; + A1E70D2C0A38B5BB007BE3E3 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + A1E70D2D0A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D2E0A38B5BB007BE3E3 /* rpc_auth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rpc_auth.c; sourceTree = ""; }; + A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = serv_ops.c; sourceTree = ""; }; + A1E70D300A38B5BB007BE3E3 /* serv_ops.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = serv_ops.h; sourceTree = ""; }; + A1E70D330A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D340A38B5BB007BE3E3 /* t_ccache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_ccache.c; sourceTree = ""; }; + A1E70D350A38B5BB007BE3E3 /* t_context.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_context.c; sourceTree = ""; }; + A1E70D360A38B5BB007BE3E3 /* t_lists.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_lists.c; sourceTree = ""; }; + A1E70D370A38B5BB007BE3E3 /* t_msg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_msg.c; sourceTree = ""; }; + A1E70D380A38B5BB007BE3E3 /* t_server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_server.c; sourceTree = ""; }; + A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cacheapi.def; sourceTree = ""; }; + A1E70D3B0A38B5BB007BE3E3 /* client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = client.c; sourceTree = ""; }; + A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dllmain.c; sourceTree = ""; }; + A1E70D3D0A38B5BC007BE3E3 /* ntccrpc.acf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ntccrpc.acf; sourceTree = ""; }; + A1E70D3E0A38B5BC007BE3E3 /* ntccrpc.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ntccrpc.idl; sourceTree = ""; }; + A1E70D3F0A38B5BC007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D410A38B5BC007BE3E3 /* client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = client.c; sourceTree = ""; }; + A1E70D420A38B5BC007BE3E3 /* cstest.acf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cstest.acf; sourceTree = ""; }; + A1E70D430A38B5BC007BE3E3 /* cstest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cstest.idl; sourceTree = ""; }; + A1E70D440A38B5BC007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D450A38B5BC007BE3E3 /* server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = server.c; sourceTree = ""; }; + A1E70D460A38B5BC007BE3E3 /* server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = server.c; sourceTree = ""; }; + A1E70D5D0A38B796007BE3E3 /* CCacheServer.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = CCacheServer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A1E70D910A38BB67007BE3E3 /* CCacheServer.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = CCacheServer.plist; sourceTree = ""; }; + A1E70D920A38BB67007BE3E3 /* CCacheServerInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = CCacheServerInfo.plist; sourceTree = ""; }; + A1E70D930A38BB67007BE3E3 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + A1E70D9E0A38BCAD007BE3E3 /* mig.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; path = mig.defs; sourceTree = ""; }; + A1E70DB10A38C01E007BE3E3 /* mig_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mig_types.h; sourceTree = ""; }; + A1E70DE00A38C6FD007BE3E3 /* kipc_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_client.h; sourceTree = ""; }; + A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_common.h; sourceTree = ""; }; + A1E70DE20A38C6FD007BE3E3 /* kipc_server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_server.h; sourceTree = ""; }; + A1E70DE30A38C6FD007BE3E3 /* kipc_session.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_session.h; sourceTree = ""; }; + A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_client.c; sourceTree = ""; }; + A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_common.c; sourceTree = ""; }; + A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_server.c; sourceTree = ""; }; + A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_session.c; sourceTree = ""; }; + A1E70DE80A38C6FD007BE3E3 /* notify.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; path = notify.defs; sourceTree = ""; }; + A1E70DE90A38C6FD007BE3E3 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; + D2AAC046055464E500DB518D /* libCCAPI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCCAPI.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A1E70D5B0A38B796007BE3E3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D289987405E68DCB004EDB86 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* CCAPI */ = { + isa = PBXGroup; + children = ( + A1E70CFF0A38B5BB007BE3E3 /* client */, + A1E70D110A38B5BB007BE3E3 /* common */, + A1E70D160A38B5BB007BE3E3 /* doc */, + A1E70D180A38B5BB007BE3E3 /* include */, + A1E70D260A38B5BB007BE3E3 /* NTMakefile */, + A1E70D270A38B5BB007BE3E3 /* server */, + A1E70D320A38B5BB007BE3E3 /* unit-test */, + A1E70D390A38B5BB007BE3E3 /* windows */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + ); + name = CCAPI; + sourceTree = ""; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + D2AAC046055464E500DB518D /* libCCAPI.a */, + A1E70D5D0A38B796007BE3E3 /* CCacheServer.app */, + ); + name = Products; + sourceTree = ""; + }; + A1E70CFF0A38B5BB007BE3E3 /* client */ = { + isa = PBXGroup; + children = ( + A1E70D000A38B5BB007BE3E3 /* cacheapi.c */, + A1E70D010A38B5BB007BE3E3 /* ccache.c */, + A1E70D020A38B5BB007BE3E3 /* ccache.h */, + A1E70D030A38B5BB007BE3E3 /* ccache_iterator.c */, + A1E70D040A38B5BB007BE3E3 /* ccache_iterator.h */, + A1E70D050A38B5BB007BE3E3 /* ccapiv2.c */, + A1E70D060A38B5BB007BE3E3 /* ccstring.c */, + A1E70D070A38B5BB007BE3E3 /* ccstring.h */, + A1E70D080A38B5BB007BE3E3 /* context.c */, + A1E70D090A38B5BB007BE3E3 /* context.h */, + A1E70D0A0A38B5BB007BE3E3 /* credentials.c */, + A1E70D0B0A38B5BB007BE3E3 /* credentials.h */, + A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */, + A1E70D0D0A38B5BB007BE3E3 /* credentials_iterator.h */, + A1E70D0E0A38B5BB007BE3E3 /* mac */, + A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */, + A1E70D100A38B5BB007BE3E3 /* windows */, + ); + name = client; + path = ../client; + sourceTree = SOURCE_ROOT; + }; + A1E70D0E0A38B5BB007BE3E3 /* mac */ = { + isa = PBXGroup; + children = ( + ); + path = mac; + sourceTree = ""; + }; + A1E70D100A38B5BB007BE3E3 /* windows */ = { + isa = PBXGroup; + children = ( + ); + path = windows; + sourceTree = ""; + }; + A1E70D110A38B5BB007BE3E3 /* common */ = { + isa = PBXGroup; + children = ( + A1E70D7E0A38BAC5007BE3E3 /* mac */, + A1E70D120A38B5BB007BE3E3 /* generic_lists.c */, + A1E70D130A38B5BB007BE3E3 /* marshall.c */, + A1E70D140A38B5BB007BE3E3 /* msg.c */, + A1E70D150A38B5BB007BE3E3 /* NTMakefile */, + ); + name = common; + path = ../common; + sourceTree = SOURCE_ROOT; + }; + A1E70D160A38B5BB007BE3E3 /* doc */ = { + isa = PBXGroup; + children = ( + A1E70D170A38B5BB007BE3E3 /* implementation-notes.txt */, + ); + name = doc; + path = ../doc; + sourceTree = SOURCE_ROOT; + }; + A1E70D180A38B5BB007BE3E3 /* include */ = { + isa = PBXGroup; + children = ( + A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */, + A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */, + A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */, + A1E70D1C0A38B5BB007BE3E3 /* datastore.h */, + A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */, + A1E70D1E0A38B5BB007BE3E3 /* marshall.h */, + A1E70D1F0A38B5BB007BE3E3 /* msg.h */, + A1E70D200A38B5BB007BE3E3 /* msg_headers.h */, + A1E70D210A38B5BB007BE3E3 /* rpc_auth.h */, + ); + name = include; + path = ../include; + sourceTree = SOURCE_ROOT; + }; + A1E70D270A38B5BB007BE3E3 /* server */ = { + isa = PBXGroup; + children = ( + A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */, + A1E70D290A38B5BB007BE3E3 /* ccs_context.c */, + A1E70D2A0A38B5BB007BE3E3 /* ccs_lists.c */, + A1E70D2B0A38B5BB007BE3E3 /* mac */, + A1E70D2C0A38B5BB007BE3E3 /* main.c */, + A1E70D2D0A38B5BB007BE3E3 /* NTMakefile */, + A1E70D2E0A38B5BB007BE3E3 /* rpc_auth.c */, + A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */, + A1E70D300A38B5BB007BE3E3 /* serv_ops.h */, + A1E70D310A38B5BB007BE3E3 /* windows */, + ); + name = server; + path = ../server; + sourceTree = SOURCE_ROOT; + }; + A1E70D2B0A38B5BB007BE3E3 /* mac */ = { + isa = PBXGroup; + children = ( + A1E70D910A38BB67007BE3E3 /* CCacheServer.plist */, + A1E70D920A38BB67007BE3E3 /* CCacheServerInfo.plist */, + A1E70D930A38BB67007BE3E3 /* main.c */, + ); + path = mac; + sourceTree = ""; + }; + A1E70D310A38B5BB007BE3E3 /* windows */ = { + isa = PBXGroup; + children = ( + ); + path = windows; + sourceTree = ""; + }; + A1E70D320A38B5BB007BE3E3 /* unit-test */ = { + isa = PBXGroup; + children = ( + A1E70D330A38B5BB007BE3E3 /* NTMakefile */, + A1E70D340A38B5BB007BE3E3 /* t_ccache.c */, + A1E70D350A38B5BB007BE3E3 /* t_context.c */, + A1E70D360A38B5BB007BE3E3 /* t_lists.c */, + A1E70D370A38B5BB007BE3E3 /* t_msg.c */, + A1E70D380A38B5BB007BE3E3 /* t_server.c */, + ); + name = "unit-test"; + path = "../unit-test"; + sourceTree = SOURCE_ROOT; + }; + A1E70D390A38B5BB007BE3E3 /* windows */ = { + isa = PBXGroup; + children = ( + A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */, + A1E70D3B0A38B5BB007BE3E3 /* client.c */, + A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */, + A1E70D3D0A38B5BC007BE3E3 /* ntccrpc.acf */, + A1E70D3E0A38B5BC007BE3E3 /* ntccrpc.idl */, + A1E70D3F0A38B5BC007BE3E3 /* NTMakefile */, + A1E70D400A38B5BC007BE3E3 /* rpcsstest */, + A1E70D460A38B5BC007BE3E3 /* server.c */, + ); + name = windows; + path = ../windows; + sourceTree = SOURCE_ROOT; + }; + A1E70D400A38B5BC007BE3E3 /* rpcsstest */ = { + isa = PBXGroup; + children = ( + A1E70D410A38B5BC007BE3E3 /* client.c */, + A1E70D420A38B5BC007BE3E3 /* cstest.acf */, + A1E70D430A38B5BC007BE3E3 /* cstest.idl */, + A1E70D440A38B5BC007BE3E3 /* NTMakefile */, + A1E70D450A38B5BC007BE3E3 /* server.c */, + ); + path = rpcsstest; + sourceTree = ""; + }; + A1E70D7E0A38BAC5007BE3E3 /* mac */ = { + isa = PBXGroup; + children = ( + A1E70DDE0A38C6FD007BE3E3 /* KerberosIPC */, + A1E70D9E0A38BCAD007BE3E3 /* mig.defs */, + A1E70DB10A38C01E007BE3E3 /* mig_types.h */, + ); + path = mac; + sourceTree = ""; + }; + A1E70DDE0A38C6FD007BE3E3 /* KerberosIPC */ = { + isa = PBXGroup; + children = ( + A1E70DDF0A38C6FD007BE3E3 /* Kerberos */, + A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */, + A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */, + A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */, + A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */, + A1E70DE80A38C6FD007BE3E3 /* notify.defs */, + A1E70DE90A38C6FD007BE3E3 /* README */, + ); + path = KerberosIPC; + sourceTree = ""; + }; + A1E70DDF0A38C6FD007BE3E3 /* Kerberos */ = { + isa = PBXGroup; + children = ( + A1E70DE00A38C6FD007BE3E3 /* kipc_client.h */, + A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */, + A1E70DE20A38C6FD007BE3E3 /* kipc_server.h */, + A1E70DE30A38C6FD007BE3E3 /* kipc_session.h */, + ); + path = Kerberos; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D2AAC043055464E500DB518D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + A1E70D5C0A38B796007BE3E3 /* CCacheServer */ = { + isa = PBXNativeTarget; + buildConfigurationList = A1E70D600A38B797007BE3E3 /* Build configuration list for PBXNativeTarget "CCacheServer" */; + buildPhases = ( + A1E70D590A38B796007BE3E3 /* Resources */, + A1E70D5A0A38B796007BE3E3 /* Sources */, + A1E70D5B0A38B796007BE3E3 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CCacheServer; + productName = CCacheServer; + productReference = A1E70D5D0A38B796007BE3E3 /* CCacheServer.app */; + productType = "com.apple.product-type.application"; + }; + D2AAC045055464E500DB518D /* CCAPI */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "CCAPI" */; + buildPhases = ( + D2AAC043055464E500DB518D /* Headers */, + D2AAC044055464E500DB518D /* Sources */, + D289987405E68DCB004EDB86 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CCAPI; + productName = CCAPI; + productReference = D2AAC046055464E500DB518D /* libCCAPI.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "CCAPI" */; + hasScannedForEncodings = 1; + mainGroup = 08FB7794FE84155DC02AAC07 /* CCAPI */; + projectDirPath = ""; + targets = ( + D2AAC045055464E500DB518D /* CCAPI */, + A1E70D5C0A38B796007BE3E3 /* CCacheServer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A1E70D590A38B796007BE3E3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A1E70D5A0A38B796007BE3E3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A1E70DA00A38BCAD007BE3E3 /* mig.defs in Sources */, + A1E70DF00A38C71D007BE3E3 /* notify.defs in Sources */, + A1E70D9B0A38BBE2007BE3E3 /* main.c in Sources */, + A1E70D890A38BB47007BE3E3 /* ccs_ccache.c in Sources */, + A1E70D8A0A38BB47007BE3E3 /* ccs_context.c in Sources */, + A1E70D8B0A38BB47007BE3E3 /* ccs_lists.c in Sources */, + A1E70D8C0A38BB47007BE3E3 /* rpc_auth.c in Sources */, + A1E70D8D0A38BB47007BE3E3 /* serv_ops.c in Sources */, + A1E70D8E0A38BB4F007BE3E3 /* generic_lists.c in Sources */, + A1E70D8F0A38BB4F007BE3E3 /* marshall.c in Sources */, + A1E70D900A38BB4F007BE3E3 /* msg.c in Sources */, + A1E70DED0A38C71D007BE3E3 /* kipc_common.c in Sources */, + A1E70DEE0A38C71D007BE3E3 /* kipc_server.c in Sources */, + A1E70DEF0A38C71D007BE3E3 /* kipc_session.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D2AAC044055464E500DB518D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A1E70D9F0A38BCAD007BE3E3 /* mig.defs in Sources */, + A1E70D480A38B5D5007BE3E3 /* cacheapi.c in Sources */, + A1E70D490A38B5D5007BE3E3 /* ccache.c in Sources */, + A1E70D4A0A38B5D5007BE3E3 /* ccache_iterator.c in Sources */, + A1E70D4B0A38B5D5007BE3E3 /* ccapiv2.c in Sources */, + A1E70D4C0A38B5D5007BE3E3 /* ccstring.c in Sources */, + A1E70D4D0A38B5D5007BE3E3 /* context.c in Sources */, + A1E70D4E0A38B5D5007BE3E3 /* credentials.c in Sources */, + A1E70D4F0A38B5D5007BE3E3 /* credentials_iterator.c in Sources */, + A1E70D510A38B60C007BE3E3 /* generic_lists.c in Sources */, + A1E70D520A38B60C007BE3E3 /* marshall.c in Sources */, + A1E70D530A38B60C007BE3E3 /* msg.c in Sources */, + A1E70DEA0A38C710007BE3E3 /* kipc_client.c in Sources */, + A1E70DEB0A38C710007BE3E3 /* kipc_common.c in Sources */, + A1E70DEC0A38C710007BE3E3 /* kipc_session.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB91EC08733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_DYNAMIC_NO_PIC = NO; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../client, + ../client/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + PRODUCT_NAME = CCAPI; + }; + name = Debug; + }; + 1DEB91ED08733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../client, + ../client/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + PRODUCT_NAME = CCAPI; + }; + name = Release; + }; + 1DEB91F008733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + i386, + ppc, + ); + COPY_PHASE_STRIP = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + PREBINDING = NO; + ZERO_LINK = YES; + }; + name = Debug; + }; + 1DEB91F108733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH)"; + COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 3; + PREBINDING = NO; + ZERO_LINK = NO; + }; + name = Release; + }; + A1E70D610A38B797007BE3E3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../server, + ../server/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + INFOPLIST_FILE = ../server/mac/CCacheServerInfo.plist; + INSTALL_PATH = /System/Library/CoreServices; + PRODUCT_NAME = CCacheServer; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + A1E70D620A38B797007BE3E3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../server, + ../server/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + INFOPLIST_FILE = ../server/mac/CCacheServerInfo.plist; + INSTALL_PATH = /System/Library/CoreServices; + PRODUCT_NAME = CCacheServer; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "CCAPI" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91EC08733DB70010E9CD /* Debug */, + 1DEB91ED08733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "CCAPI" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91F008733DB70010E9CD /* Debug */, + 1DEB91F108733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A1E70D600A38B797007BE3E3 /* Build configuration list for PBXNativeTarget "CCacheServer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A1E70D610A38B797007BE3E3 /* Debug */, + A1E70D620A38B797007BE3E3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/src/lib/ccapi/server/mac/CCacheServer.plist b/src/lib/ccapi/server/mac/CCacheServer.plist new file mode 100644 index 000000000..987cf7110 --- /dev/null +++ b/src/lib/ccapi/server/mac/CCacheServer.plist @@ -0,0 +1,12 @@ + + + + + ServiceName + edu.mit.Kerberos.CCacheServer.ipcService + Command + /System/Library/CoreServices/CCacheServer.app/Contents/MacOS/CCacheServer + OnDemand + + + diff --git a/src/lib/ccapi/server/mac/CCacheServerInfo.plist b/src/lib/ccapi/server/mac/CCacheServerInfo.plist new file mode 100644 index 000000000..e03d5f3ff --- /dev/null +++ b/src/lib/ccapi/server/mac/CCacheServerInfo.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + CCacheServer + CFBundleGetInfoString + 4.1 + CFBundleIconFile + + CFBundleIdentifier + edu.mit.Kerberos.CCacheServer + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Kerberos Credentials Cache Server + CFBundlePackageType + APPL + CFBundleSignature + CCSa + CFBundleVersion + 0.0.1d1 + CFBundleShortVersionString + 5.5 + CFBundleGetInfoString + 5.5 Copyright MIT + KfMDisplayVersion + 5.5 Copyright MIT + KfMDisplayCopyright + Copyright MIT + NSHumanReadableCopyright + 5.5 Copyright MIT + LSBackgroundOnly + 1 + + diff --git a/src/lib/ccapi/server/mac/main.c b/src/lib/ccapi/server/mac/main.c new file mode 100644 index 000000000..a9da8da6c --- /dev/null +++ b/src/lib/ccapi/server/mac/main.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include "CredentialsCache.h" +#include "msg.h" +#include "migServer.h" + +#include + +int main (int argc, const char *argv[]) +{ + cc_int32 code = 0; + int running = 1; + + openlog (argv[0], LOG_CONS | LOG_PID, LOG_AUTH); + syslog (LOG_INFO, "Starting up."); + + if (!code) { + code = ccs_serv_initialize(); + } + + if (!code) { + code = kipc_server_run_server (ccapi_server); + } + + /* cleanup ccs resources */ + ccs_serv_cleanup(); + + syslog (LOG_NOTICE, "Exiting: %s (%d)", kipc_error_string (code), code); + + /* exit */ + return code ? 1 : 0; +} -- cgit From 6f294bfe674c557255eca075d2fa2f3064ce4ff5 Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 9 Jun 2006 22:01:11 +0000 Subject: Temporarily copied KerberosIPC libary from the KfM repository for testing purposes. Note that this will be removed when the CCAPI branch is merged onto the trunk. git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18100 dc483132-0cff-0310-8789-dd5450dbe970 --- .../common/mac/KerberosIPC/Kerberos/kipc_client.h | 47 ++++ .../common/mac/KerberosIPC/Kerberos/kipc_common.h | 76 +++++ .../common/mac/KerberosIPC/Kerberos/kipc_server.h | 54 ++++ .../common/mac/KerberosIPC/Kerberos/kipc_session.h | 59 ++++ src/lib/ccapi/common/mac/KerberosIPC/README | 3 + src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c | 86 ++++++ src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c | 93 ++++++ src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c | 313 +++++++++++++++++++++ .../ccapi/common/mac/KerberosIPC/kipc_session.c | 141 ++++++++++ src/lib/ccapi/common/mac/KerberosIPC/notify.defs | 36 +++ 10 files changed, 908 insertions(+) create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/README create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c create mode 100644 src/lib/ccapi/common/mac/KerberosIPC/notify.defs (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h new file mode 100644 index 000000000..89923eb16 --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h @@ -0,0 +1,47 @@ +/* + * kipc_client.h + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#ifndef KIPC_CLIENT_H +#define KIPC_CLIENT_H + +#include + +#if __cplusplus +extern "C" { +#endif + +kipc_err_t +kipc_client_lookup_server (const char *in_service_id, + boolean_t in_launch_if_necessary, + mach_port_t *out_service_port); + +#if __cplusplus +} +#endif + +#endif /* KIPC_CLIENT_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h new file mode 100644 index 000000000..361f7f576 --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h @@ -0,0 +1,76 @@ +/* + * KerberosIPCCommon.h + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#ifndef KIPC_COMMON_H +#define KIPC_COMMON_H + +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#if __cplusplus +extern "C" { +#endif + +typedef kern_return_t kipc_err_t; +typedef boolean_t kipc_boolean_t; +typedef char *kipc_string; + +#define kkipc_max_message_size 2048 + MAX_TRAILER_SIZE +#define kkipc_timeout 200 + +// Debugging API used by library +kipc_err_t __kipc_err (kipc_err_t inError, const char *function, const char *file, int line); +#define kipc_err(err) __kipc_err(err, __FUNCTION__, __FILE__, __LINE__) + +const char *kipc_error_string (kipc_err_t in_error); + +kipc_err_t kipc_get_lookup_name (char **out_lookup_name, const char *in_service_id); +kipc_err_t kipc_get_service_name (char **out_service_name, const char *in_service_id); + +void kipc_free_string (char *io_string); + +#if __cplusplus +} +#endif + +#endif /* KIPC_COMMON_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h new file mode 100644 index 000000000..5d9754758 --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h @@ -0,0 +1,54 @@ +/* + * kipc_server.h + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#ifndef KIPC_SERVER_H +#define KIPC_SERVER_H + +#include + +#define kKerberosIPCMaxMsgSize 2048 + MAX_TRAILER_SIZE +#define kKerberosIPCTimeout 200 + +#if __cplusplus +extern "C" { +#endif + +typedef kipc_boolean_t (*kipc_demux_proc) (mach_msg_header_t *, mach_msg_header_t *); + + +kipc_err_t kipc_server_run_server (kipc_demux_proc in_demux_proc); + +mach_port_t kipc_server_get_service_port (); + +kipc_boolean_t kipc_server_quit (void); + +#if __cplusplus +} +#endif + +#endif /* KIPC_SERVER_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h new file mode 100644 index 000000000..3f259561e --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h @@ -0,0 +1,59 @@ +/* + * kipc_session.h + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#ifndef KIPC_SESSION_H +#define KIPC_SESSION_H + +#include + +#if __cplusplus +extern "C" { +#endif + +#define kkipc_session_has_gui_access 0x00000001 +#define kkipc_session_caller_uses_gui 0x00000002 +#define kkipc_session_has_cli_access 0x00000004 + +typedef u_int32_t kipc_session_attributes_t; + + +kipc_boolean_t kipc_session_is_root_session (void); + +kipc_session_attributes_t kipc_session_get_attributes (void); + +kipc_string kipc_get_session_id_string (void); + +uid_t kipc_session_get_session_uid (void); + +uid_t kipc_session_get_server_uid (void); + +#if __cplusplus +} +#endif + +#endif /* KIPC_SESSION_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/README b/src/lib/ccapi/common/mac/KerberosIPC/README new file mode 100644 index 000000000..2e2d70d4d --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/README @@ -0,0 +1,3 @@ +This is a temporary copy of the KfM KerberosIPC library sources. +Once this gets merged onto the trunk the KfM build will use the +KerberosIPC library instead. diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c new file mode 100644 index 000000000..2e48c42cd --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c @@ -0,0 +1,86 @@ +/* + * kipc_client.c + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#include + +// --------------------------------------------------------------------------- + +kipc_err_t +kipc_client_lookup_server (const char *in_service_id, + boolean_t in_launch_if_necessary, + mach_port_t *out_service_port) +{ + kipc_err_t err = 0; + mach_port_t boot_port = MACH_PORT_NULL; + char *service_name = NULL; + + if (in_service_id == NULL) { err = kipc_err (EINVAL); } + if (out_service_port == NULL) { err = kipc_err (EINVAL); } + + if (!err) { + // Get our bootstrap port + err = task_get_bootstrap_port (mach_task_self (), &boot_port); + } + + if (!err && !in_launch_if_necessary) { + char *lookup_name = NULL; + mach_port_t lookup_port = MACH_PORT_NULL; + + err = kipc_get_lookup_name (&lookup_name, in_service_id); + + if (!err) { + // Use the lookup name because the service name will return + // a valid port even if the server isn't running + err = bootstrap_look_up (boot_port, lookup_name, &lookup_port); + //dprintf ("%s(): bootstrap_look_up('%s'): port is %x (err = %d '%s')", + // __FUNCTION__, lookup_name, lookup_port, err, mach_error_string (err)); + } + + if (lookup_name != NULL ) { kipc_free_string (lookup_name); } + if (lookup_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), lookup_port); } + } + + if (!err) { + err = kipc_get_service_name (&service_name, in_service_id); + } + + if (!err) { + err = bootstrap_look_up (boot_port, service_name, out_service_port); + //dprintf ("%s(): bootstrap_look_up('%s'): port is %x (err = %d '%s')", + // __FUNCTION__, service_name, *out_service_port, err, mach_error_string (err)); + } + + if (service_name != NULL ) { kipc_free_string (service_name); } + if (boot_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), boot_port); } + + if (err == BOOTSTRAP_UNKNOWN_SERVICE) { + return err; // Avoid spewing to the log file + } else { + return kipc_err (err); + } +} diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c new file mode 100644 index 000000000..438650f2a --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c @@ -0,0 +1,93 @@ +/* + * kipc_common.c + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#include +#include + + +// --------------------------------------------------------------------------- + +kipc_err_t __kipc_err (kipc_err_t in_error, const char *in_function, const char *in_file, int in_line) +{ + if (in_error && (ddebuglevel () > 0)) { + dprintf ("%s() got %d ('%s') at %s: %d", + in_function, in_error, mach_error_string (in_error), in_file, in_line); + dprintsession (); + //dprintbootstrap (mach_task_self ()); + } + return in_error; +} +// --------------------------------------------------------------------------- + + +const char *kipc_error_string (kipc_err_t in_error) +{ + return mach_error_string (in_error); +} + +// --------------------------------------------------------------------------- + +kipc_err_t kipc_get_service_name (char **out_service_name, const char *in_service_id) +{ + kipc_err_t err = 0; + + if (out_service_name == NULL) { err = EINVAL; } + if (in_service_id == NULL) { err = EINVAL; } + + if (!err) { + int wrote = asprintf (out_service_name, "%s%s", in_service_id, ".ipcService"); + if (wrote < 0) { err = ENOMEM; } + } + + return kipc_err (err); +} + +// --------------------------------------------------------------------------- + +kipc_err_t kipc_get_lookup_name (char **out_lookup_name, const char *in_service_id) +{ + kipc_err_t err = 0; + + if (out_lookup_name == NULL) { err = EINVAL; } + if (in_service_id == NULL) { err = EINVAL; } + + if (!err) { + int wrote = asprintf (out_lookup_name, "%s%s", in_service_id, ".ipcLookup"); + if (wrote < 0) { err = ENOMEM; } + } + + return kipc_err (err); +} + +// --------------------------------------------------------------------------- + +void kipc_free_string (char *io_string) +{ + free (io_string); +} + diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c new file mode 100644 index 000000000..c7c973bee --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c @@ -0,0 +1,313 @@ +/* + * kipc_server.c + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#include +#include +#include "notifyServer.h" + +// Global variables for servers (used by demux) +static mach_port_t g_service_port = MACH_PORT_NULL; +static kipc_boolean_t g_ready_to_quit = FALSE; +static kipc_demux_proc g_demux_proc = NULL; + +#pragma mark - + +// --------------------------------------------------------------------------- + +mach_port_t +kipc_server_get_service_port () +{ + return g_service_port; +} + +#pragma mark - + +// --------------------------------------------------------------------------- + +kipc_boolean_t +kipc_server_quit (void) +{ + // Do not unregister our port because then we won't get automatically launched again. + dprintf ("mach_server_quit_self(): quitting..."); + g_ready_to_quit = true; + return g_ready_to_quit; +} + +#pragma mark - + +// --------------------------------------------------------------------------- + +static kipc_boolean_t +kipc_server_demux (mach_msg_header_t *request, mach_msg_header_t *reply) +{ + if (mach_notify_server (request, reply) != false) { + return true; + } else { + return g_demux_proc (request, reply); + } + return false; +} + +#pragma mark - + +// --------------------------------------------------------------------------- + +static kipc_err_t +kipc_get_server_id (char **out_server_id) +{ + kern_return_t err = KERN_SUCCESS; + CFBundleRef bundle = NULL; + CFStringRef id_string = NULL; + CFIndex id_length = 0; + char *server_id = NULL; + + if (out_server_id == NULL) { err = kipc_err (EINVAL); } + + if (!err) { + bundle = CFBundleGetMainBundle (); + if (bundle == NULL) { err = ENOENT; } + } + + if (!err) { + id_string = CFBundleGetIdentifier (bundle); + if (id_string == NULL) { err = ENOMEM; } + } + + if (!err) { + id_length = CFStringGetMaximumSizeForEncoding (CFStringGetLength (id_string), + CFStringGetSystemEncoding ()) + 1; + server_id = calloc (id_length, sizeof (char)); + if (server_id == NULL) { err = errno; } + } + + if (!err) { + if (!CFStringGetCString (id_string, server_id, id_length, CFStringGetSystemEncoding ())) { + err = ENOMEM; + } + } + + if (!err) { + *out_server_id = server_id; + server_id = NULL; + } + + if (server_id != NULL) { kipc_free_string (server_id); } + + return kipc_err (err); +} + +// --------------------------------------------------------------------------- + +kipc_err_t +kipc_server_run_server (kipc_demux_proc in_demux_proc) +{ + kern_return_t err = KERN_SUCCESS; + char *server_id = NULL; + char *service_name = NULL; + char *lookup_name = NULL; + mach_port_t boot_port = MACH_PORT_NULL; + mach_port_t lookup_port = MACH_PORT_NULL; + mach_port_t notify_port = MACH_PORT_NULL; + mach_port_t previous_notify_port = MACH_PORT_NULL; + mach_port_t listen_port_set = MACH_PORT_NULL; + + if (in_demux_proc == NULL) { err = kipc_err (EINVAL); } + + // Shed root privileges if any + if (!err && (geteuid () == 0)) { + uid_t new_uid = kipc_session_get_server_uid (); + if (setuid (new_uid) < 0) { + dprintf ("%s(): setuid(%d) failed (euid is %d)", __FUNCTION__, new_uid, geteuid ()); + } + } + + if (!err) { + // Set up the globals so the demux can find them + g_demux_proc = in_demux_proc; + } + + if (!err) { + err = kipc_get_server_id (&server_id); + } + + if (!err) { + err = kipc_get_service_name (&service_name, server_id); + } + + if (!err) { + err = kipc_get_lookup_name (&lookup_name, server_id); + } + + if (!err) { + // Get the bootstrap port + err = task_get_bootstrap_port (mach_task_self (), &boot_port); + dprintf ("%s(): task_get_bootstrap_port(): port is %x (err = %d '%s')", + __FUNCTION__, boot_port, err, mach_error_string (err)); + } + + if (!err) { + // Create the lookup port: + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &lookup_port); + } + + if (!err) { + err = mach_port_insert_right (mach_task_self (), lookup_port, lookup_port, MACH_MSG_TYPE_MAKE_SEND); + } + + if (!err) { + // Register the lookup port so others can tell whether or not we are running + err = bootstrap_register (boot_port, lookup_name, lookup_port); + dprintf ("%s(): bootstrap_register('%s', %x): (err = %d '%s')", + __FUNCTION__, lookup_name, lookup_port, err, mach_error_string (err)); + } + + if (!err) { + // We are an on-demand server so our port already exists. Just ask for it. + err = bootstrap_check_in (boot_port, (char *) service_name, &g_service_port); + dprintf ("%s(): bootstrap_check_in('%s'): port is %d (err = %d '%s')", + __FUNCTION__, service_name, g_service_port, err, mach_error_string (err)); + } + + if (!err) { + // Create the notification port: + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, ¬ify_port); + } + + if (!err) { + // Ask for notification when the server port has no more senders + // A send-once right != a send right so our send-once right will not interfere with the notification + err = mach_port_request_notification (mach_task_self (), g_service_port, MACH_NOTIFY_NO_SENDERS, true, + notify_port, MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous_notify_port); + dprintf ("%s(): requesting notification for no senders of %x returned '%s', err = %d\n", + __FUNCTION__, g_service_port, mach_error_string (err), err); + } + + if (!err) { + // Create the port set that the server will listen on + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, &listen_port_set); + } + + if (!err) { + // Add the service port to the port set + err = mach_port_move_member (mach_task_self (), g_service_port, listen_port_set); + } + + if (!err) { + // Add the notify port to the port set + err = mach_port_move_member (mach_task_self (), notify_port, listen_port_set); + } + + if (!err) { + dprintf ("%s(): \"%s\": starting up. service port = %x, bootstrap port = %x\n", + __FUNCTION__, service_name, g_service_port, boot_port); + } + + while (!err && !g_ready_to_quit) { + // Handle one message at a time so we can check to see if the server wants to quit + err = mach_msg_server_once (kipc_server_demux, kkipc_max_message_size, listen_port_set, MACH_MSG_OPTION_NONE); + } + + // Regardless of whether there was an error, unregister ourselves from no senders notifications + // so we don't get launched again by the notification message when we quit + // A send-once right != a send right so our send-once right will not interfere with the notification + if (g_service_port != MACH_PORT_NULL) { + err = mach_port_request_notification (mach_task_self (), g_service_port, MACH_NOTIFY_NO_SENDERS, + true, MACH_PORT_NULL, MACH_MSG_TYPE_MAKE_SEND_ONCE, + &previous_notify_port); + dprintf ("%s(): removing notification for no senders of %x returned '%s', err = %d\n", + __FUNCTION__, previous_notify_port, mach_error_string (err), err); + } + + // Clean up the ports and strings + if (lookup_port != MACH_PORT_NULL) { + kipc_err_t terr = bootstrap_register (boot_port, lookup_name, MACH_PORT_NULL); + dprintf ("%s(): bootstrap_register('%s', MACH_PORT_NULL): (err = %d '%s')", + __FUNCTION__, lookup_name, terr, mach_error_string (terr)); + mach_port_deallocate (mach_task_self (), lookup_port); + } + if (notify_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), notify_port); } + if (listen_port_set != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), listen_port_set); } + if (boot_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), boot_port); } + if (lookup_name != NULL ) { kipc_free_string (lookup_name); } + if (service_name != NULL ) { kipc_free_string (service_name); } + if (server_id != NULL ) { kipc_free_string (server_id); } + + return kipc_err (err); +} + +#pragma mark - + +// --------------------------------------------------------------------------- + +kern_return_t +do_mach_notify_port_deleted (mach_port_t notify, mach_port_name_t name) +{ + dprintf ("Received MACH_NOTIFY_PORT_DELETED... quitting self"); + kipc_server_quit (); + return KERN_SUCCESS; +} + +// --------------------------------------------------------------------------- + +kern_return_t +do_mach_notify_port_destroyed (mach_port_t notify, mach_port_t rights) +{ + dprintf ("Received MACH_NOTIFY_PORT_DESTROYED... quitting self"); + kipc_server_quit (); + return KERN_SUCCESS; +} + +// --------------------------------------------------------------------------- + +kern_return_t +do_mach_notify_no_senders (mach_port_t notify, mach_port_mscount_t mscount) +{ + dprintf ("Received MACH_NOTIFY_NO_SENDERS... quitting self"); + kipc_server_quit (); + return KERN_SUCCESS; +} + +// --------------------------------------------------------------------------- + +kern_return_t +do_mach_notify_send_once (mach_port_t notify) +{ + dprintf ("Received MACH_NOTIFY_SEND_ONCE"); + return KERN_SUCCESS; +} + +// --------------------------------------------------------------------------- + +kern_return_t +do_mach_notify_dead_name (mach_port_t notify, mach_port_name_t name) +{ + dprintf ("Received MACH_NOTIFY_DEAD_NAME... quitting self"); + kipc_server_quit (); + return KERN_SUCCESS; +} + diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c new file mode 100644 index 000000000..c08e1bc32 --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c @@ -0,0 +1,141 @@ +/* + * kipc_session.c + * + * $Header$ + * + * Copyright 2006 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 M.I.T. 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. + */ + +#include +#include +#include + +// --------------------------------------------------------------------------- + +kipc_boolean_t kipc_session_is_root_session (void) +{ + kipc_err_t err = 0; + kipc_boolean_t is_root_session = TRUE; // safer to assume root session + SessionAttributeBits sattrs = 0L; + + err = SessionGetInfo (callerSecuritySession, NULL, &sattrs); + + if (!err) { + is_root_session = (sattrs & sessionIsRoot); + dprintf ("%s(): running in %s session", + __FUNCTION__, is_root_session ? "the root" : "a user"); + } else { + dprintf ("%s(): SessionGetInfo() failed with %d", __FUNCTION__, err); + } + + return is_root_session; +} + +// --------------------------------------------------------------------------- + +kipc_session_attributes_t kipc_session_get_attributes (void) +{ + kipc_session_attributes_t attributes = 0L; + SessionAttributeBits sattrs = 0L; + int fd_stdin = fileno (stdin); + int fd_stdout = fileno (stdout); + char *fd_stdin_name = ttyname (fd_stdin); + + if ((SessionGetInfo (callerSecuritySession, NULL, &sattrs) == noErr) && (sattrs & sessionHasGraphicAccess)) { + dprintf ("%s(): Session has graphic access.", __FUNCTION__); + attributes |= kkipc_session_has_gui_access; + + // Check for the HIToolbox (Carbon) or AppKit (Cocoa). If either is loaded, we are a GUI app! + CFBundleRef hiToolBoxBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.HIToolbox")); + if (hiToolBoxBundle != NULL && CFBundleIsExecutableLoaded (hiToolBoxBundle)) { + dprintf ("%s(): Carbon Toolbox is loaded.", __FUNCTION__); + attributes |= kkipc_session_caller_uses_gui; + } + + CFBundleRef appKitBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.AppKit")); + if (appKitBundle != NULL && CFBundleIsExecutableLoaded (appKitBundle)) { + dprintf ("%s(): AppKit is loaded.", __FUNCTION__); + attributes |= kkipc_session_caller_uses_gui; + } + } + + // Session info isn't reliable for remote sessions. + // Check manually for terminal access with file descriptors + if (isatty (fd_stdin) && isatty (fd_stdout) && (fd_stdin_name != NULL)) { + dprintf ("%s(): Terminal '%s' of type '%s' exists.", + __FUNCTION__, fd_stdin_name, getenv ("TERM")); + attributes |= kkipc_session_has_cli_access; + } + + dprintf ("%s(): Attributes are %x", __FUNCTION__, attributes); + return attributes; +} + +// --------------------------------------------------------------------------- + +kipc_string kipc_get_session_id_string (void) +{ + // Session ID is a 32 bit quanitity, so the longest string is 0xFFFFFFFF + static char s_session_name[16]; + SecuritySessionId id; + + s_session_name[0] = '\0'; + + if (SessionGetInfo (callerSecuritySession, &id, NULL) == noErr) { + snprintf (s_session_name, sizeof (s_session_name), "0x%lx", id); + } + + return s_session_name; +} + +// --------------------------------------------------------------------------- + +uid_t kipc_session_get_session_uid (void) +{ + // Get the uid of the user that the server will be run and named for. + uid_t uid = geteuid (); + + // Avoid root because the client can later go back to the real uid + if (uid == 0 /* root */) { + dprintf ("%s(): geteuid returned UID %d, trying getuid...\n", __FUNCTION__, uid); + uid = getuid (); + } + + return uid; +} + +// --------------------------------------------------------------------------- + +uid_t kipc_session_get_server_uid (void) +{ + uid_t server_uid = 92; + + struct passwd *pw = getpwnam ("securityagent"); + if (pw != NULL) { + server_uid = pw->pw_uid; + } else { + dprintf ("%s: getpwnam(securityagent) failed, using hardcoded value.", __FUNCTION__); + } + + return server_uid; +} diff --git a/src/lib/ccapi/common/mac/KerberosIPC/notify.defs b/src/lib/ccapi/common/mac/KerberosIPC/notify.defs new file mode 100644 index 000000000..fea03c9d5 --- /dev/null +++ b/src/lib/ccapi/common/mac/KerberosIPC/notify.defs @@ -0,0 +1,36 @@ +/* + * mach_notify.defs + * + * $Header$ + * + * Copyright 2003 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 M.I.T. 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 is totally disgusting. + * Rename the demux function so we don't collide with other libraries using this. + */ + +#define notify_server mach_notify_server + +#include -- cgit From 2ba7d72e94611af27cbf0a552a46a98341f5da94 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 12 Jun 2006 13:56:31 +0000 Subject: remove duplicate header file and obsolete source file git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18106 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/server/main.c | 64 ------- src/lib/ccapi/server/serv_ops.h | 376 ---------------------------------------- 2 files changed, 440 deletions(-) delete mode 100644 src/lib/ccapi/server/main.c delete mode 100644 src/lib/ccapi/server/serv_ops.h (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/server/main.c b/src/lib/ccapi/server/main.c deleted file mode 100644 index dbd447f66..000000000 --- a/src/lib/ccapi/server/main.c +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include "CredentialsCache.h" -#include "msg.h" -#include "rpc_auth.h" - -/* This object module is platform dependent. */ - -int main( int argc, char *argv[] ) -{ - cc_int32 code; - int running = 1; - - /* we need a set of functions we want to support. - * so we can provide an abstract platform independent - * interface. - */ - - code = ccs_serv_initialize(); - if (code) { - /* ok. we failed to initialize the ccs data structures. - * terminate service start. Log the result. - */ - fprintf(stderr, "ccs_serv_initialize failure: %d\n", code); - return -1; - } - - /* initialize the IPC mechanism for this platform */ - - /* implement a message loop that receives in-bound requests - * processes them, and sends back responses. - */ - while ( running ) { - cc_msg_t * req_msg, *resp_msg; - cc_auth_info_t* auth_info; - cc_session_info_t* session_info; - char * data; - int len; - - /* accept IPC request */ - - /* unflatten input stream to msg */ - code = cci_msg_unflatten(data, len, &req_msg); - - /* process request */ - code = ccs_serv_process_msg(req_msg, auth_info, session_info, &resp_msg); - - code = cci_msg_flatten(resp_msg, NULL); - - /* send response (resp_msg->flat, resp_msg->flat_len) */ - - /* cleanup */ - cci_msg_destroy(req_msg); - cci_msg_destroy(resp_msg); - } - - /* de-register IPC mechanism */ - - /* cleanup ccs resources */ - ccs_serv_cleanup(); - - /* exit */ - return 0; -} diff --git a/src/lib/ccapi/server/serv_ops.h b/src/lib/ccapi/server/serv_ops.h deleted file mode 100644 index 1433e0f15..000000000 --- a/src/lib/ccapi/server/serv_ops.h +++ /dev/null @@ -1,376 +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). - * $ - */ - -/* - * Prototypes for serv_ops.c - */ - -#ifndef __SERV_OPS_H__ -#define __SERV_OPS_H__ - -#include "CredentialsCache.h" -#include "rpc_auth.h" -#include "msg.h" -#include "datastore.h" - -struct type_to_op_mapping_t { - cc_int32 (*operations[CC_MSG_MAX_TYPE]) ( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); -}; -typedef struct type_to_op_mapping_t type_to_op_mapping_t; - -cc_int32 ccs_serv_initialize(void); -cc_int32 ccs_serv_cleanup(void); -cc_int32 ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg); -cc_int32 ccs_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** contextp); -cc_int32 ccs_serv_find_ctx_by_handle(cc_handle ctx_handle, cc_auth_info_t *auth, cc_session_info_t* session, cc_server_context_t** contextp); -cc_int32 ccs_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache_handle, cc_server_ccache_t** ccachep) ; -cc_int32 ccs_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodep); -cc_int32 ccs_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodep); -cc_int32 ccs_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); -cc_int32 ccs_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); - -cc_int32 -ccop_INIT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_GET_CHANGE_TIME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_GET_DEFAULT_CCACHE_NAME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_CCACHE_OPEN( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_CCACHE_OPEN_DEFAULT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_CCACHE_CREATE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_NEW_CCACHE_ITERATOR( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_LOCK( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_UNLOCK( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_COMPARE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_DESTROY( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_SET_DEFAULT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_GET_CREDS_VERSION( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_GET_NAME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_GET_PRINCIPAL( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_SET_PRINCIPAL( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_STORE_CREDS( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_REM_CREDS( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_NEW_CREDS_ITERATOR( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_MOVE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_LOCK( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_UNLOCK( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_GET_LAST_DEFAULT_TIME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_GET_CHANGE_TIME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg) ; - -cc_int32 -ccop_CCACHE_COMPARE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_GET_KDC_TIME_OFFSET( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_SET_KDC_TIME_OFFSET( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_CLEAR_KDC_TIME_OFFSET( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_ITERATOR_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_ITERATOR_NEXT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_ITERATOR_CLONE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CREDS_ITERATOR_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CREDS_ITERATOR_NEXT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CREDS_ITERATOR_CLONE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); -#endif /*__SERV_OPS_H__*/ -- cgit From 66b03de7fa804d6b56810c7b986fa1b9f989b3b4 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 22 Jun 2006 16:58:37 +0000 Subject: Fix parameter name in cc_credentials_iterator_t next() git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18194 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/include/CredentialsCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/include/CredentialsCache.h b/src/lib/ccapi/include/CredentialsCache.h index 45b9ac4c4..95c4fe79b 100644 --- a/src/lib/ccapi/include/CredentialsCache.h +++ b/src/lib/ccapi/include/CredentialsCache.h @@ -475,7 +475,7 @@ struct cc_credentials_iterator_f { cc_credentials_iterator_t iter); cc_int32 (*next) ( cc_credentials_iterator_t iter, - cc_credentials_t* ccache); + cc_credentials_t* cred); cc_int32 (*clone) ( cc_credentials_iterator_t iter, cc_credentials_iterator_t* new_iter); -- cgit From 9c3ce006fb55a1e201e088a784be55659399128a Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 22 Jun 2006 16:59:08 +0000 Subject: Add missing header git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18195 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/server/serv_ops.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/server/serv_ops.c b/src/lib/ccapi/server/serv_ops.c index 5409ef97d..52c62f45c 100644 --- a/src/lib/ccapi/server/serv_ops.c +++ b/src/lib/ccapi/server/serv_ops.c @@ -50,6 +50,7 @@ #include "datastore.h" #include "rpc_auth.h" #include "msg_headers.h" +#include "marshall.h" #include #include -- cgit From 90c9fe974de343ffec87efbed89ddcfefd431d9e Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Thu, 22 Jun 2006 18:42:12 +0000 Subject: Revert 18100 before merging onto trunk git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18199 dc483132-0cff-0310-8789-dd5450dbe970 --- .../common/mac/KerberosIPC/Kerberos/kipc_client.h | 47 ---- .../common/mac/KerberosIPC/Kerberos/kipc_common.h | 76 ----- .../common/mac/KerberosIPC/Kerberos/kipc_server.h | 54 ---- .../common/mac/KerberosIPC/Kerberos/kipc_session.h | 59 ---- src/lib/ccapi/common/mac/KerberosIPC/README | 3 - src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c | 86 ------ src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c | 93 ------ src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c | 313 --------------------- .../ccapi/common/mac/KerberosIPC/kipc_session.c | 141 ---------- src/lib/ccapi/common/mac/KerberosIPC/notify.defs | 36 --- 10 files changed, 908 deletions(-) delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/README delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c delete mode 100644 src/lib/ccapi/common/mac/KerberosIPC/notify.defs (limited to 'src/lib/ccapi') diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h deleted file mode 100644 index 89923eb16..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_client.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * kipc_client.h - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#ifndef KIPC_CLIENT_H -#define KIPC_CLIENT_H - -#include - -#if __cplusplus -extern "C" { -#endif - -kipc_err_t -kipc_client_lookup_server (const char *in_service_id, - boolean_t in_launch_if_necessary, - mach_port_t *out_service_port); - -#if __cplusplus -} -#endif - -#endif /* KIPC_CLIENT_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h deleted file mode 100644 index 361f7f576..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_common.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * KerberosIPCCommon.h - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#ifndef KIPC_COMMON_H -#define KIPC_COMMON_H - -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#if __cplusplus -extern "C" { -#endif - -typedef kern_return_t kipc_err_t; -typedef boolean_t kipc_boolean_t; -typedef char *kipc_string; - -#define kkipc_max_message_size 2048 + MAX_TRAILER_SIZE -#define kkipc_timeout 200 - -// Debugging API used by library -kipc_err_t __kipc_err (kipc_err_t inError, const char *function, const char *file, int line); -#define kipc_err(err) __kipc_err(err, __FUNCTION__, __FILE__, __LINE__) - -const char *kipc_error_string (kipc_err_t in_error); - -kipc_err_t kipc_get_lookup_name (char **out_lookup_name, const char *in_service_id); -kipc_err_t kipc_get_service_name (char **out_service_name, const char *in_service_id); - -void kipc_free_string (char *io_string); - -#if __cplusplus -} -#endif - -#endif /* KIPC_COMMON_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h deleted file mode 100644 index 5d9754758..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_server.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * kipc_server.h - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#ifndef KIPC_SERVER_H -#define KIPC_SERVER_H - -#include - -#define kKerberosIPCMaxMsgSize 2048 + MAX_TRAILER_SIZE -#define kKerberosIPCTimeout 200 - -#if __cplusplus -extern "C" { -#endif - -typedef kipc_boolean_t (*kipc_demux_proc) (mach_msg_header_t *, mach_msg_header_t *); - - -kipc_err_t kipc_server_run_server (kipc_demux_proc in_demux_proc); - -mach_port_t kipc_server_get_service_port (); - -kipc_boolean_t kipc_server_quit (void); - -#if __cplusplus -} -#endif - -#endif /* KIPC_SERVER_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h b/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h deleted file mode 100644 index 3f259561e..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/Kerberos/kipc_session.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * kipc_session.h - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#ifndef KIPC_SESSION_H -#define KIPC_SESSION_H - -#include - -#if __cplusplus -extern "C" { -#endif - -#define kkipc_session_has_gui_access 0x00000001 -#define kkipc_session_caller_uses_gui 0x00000002 -#define kkipc_session_has_cli_access 0x00000004 - -typedef u_int32_t kipc_session_attributes_t; - - -kipc_boolean_t kipc_session_is_root_session (void); - -kipc_session_attributes_t kipc_session_get_attributes (void); - -kipc_string kipc_get_session_id_string (void); - -uid_t kipc_session_get_session_uid (void); - -uid_t kipc_session_get_server_uid (void); - -#if __cplusplus -} -#endif - -#endif /* KIPC_SESSION_H */ diff --git a/src/lib/ccapi/common/mac/KerberosIPC/README b/src/lib/ccapi/common/mac/KerberosIPC/README deleted file mode 100644 index 2e2d70d4d..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/README +++ /dev/null @@ -1,3 +0,0 @@ -This is a temporary copy of the KfM KerberosIPC library sources. -Once this gets merged onto the trunk the KfM build will use the -KerberosIPC library instead. diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c deleted file mode 100644 index 2e48c42cd..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/kipc_client.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * kipc_client.c - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#include - -// --------------------------------------------------------------------------- - -kipc_err_t -kipc_client_lookup_server (const char *in_service_id, - boolean_t in_launch_if_necessary, - mach_port_t *out_service_port) -{ - kipc_err_t err = 0; - mach_port_t boot_port = MACH_PORT_NULL; - char *service_name = NULL; - - if (in_service_id == NULL) { err = kipc_err (EINVAL); } - if (out_service_port == NULL) { err = kipc_err (EINVAL); } - - if (!err) { - // Get our bootstrap port - err = task_get_bootstrap_port (mach_task_self (), &boot_port); - } - - if (!err && !in_launch_if_necessary) { - char *lookup_name = NULL; - mach_port_t lookup_port = MACH_PORT_NULL; - - err = kipc_get_lookup_name (&lookup_name, in_service_id); - - if (!err) { - // Use the lookup name because the service name will return - // a valid port even if the server isn't running - err = bootstrap_look_up (boot_port, lookup_name, &lookup_port); - //dprintf ("%s(): bootstrap_look_up('%s'): port is %x (err = %d '%s')", - // __FUNCTION__, lookup_name, lookup_port, err, mach_error_string (err)); - } - - if (lookup_name != NULL ) { kipc_free_string (lookup_name); } - if (lookup_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), lookup_port); } - } - - if (!err) { - err = kipc_get_service_name (&service_name, in_service_id); - } - - if (!err) { - err = bootstrap_look_up (boot_port, service_name, out_service_port); - //dprintf ("%s(): bootstrap_look_up('%s'): port is %x (err = %d '%s')", - // __FUNCTION__, service_name, *out_service_port, err, mach_error_string (err)); - } - - if (service_name != NULL ) { kipc_free_string (service_name); } - if (boot_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), boot_port); } - - if (err == BOOTSTRAP_UNKNOWN_SERVICE) { - return err; // Avoid spewing to the log file - } else { - return kipc_err (err); - } -} diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c deleted file mode 100644 index 438650f2a..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/kipc_common.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * kipc_common.c - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#include -#include - - -// --------------------------------------------------------------------------- - -kipc_err_t __kipc_err (kipc_err_t in_error, const char *in_function, const char *in_file, int in_line) -{ - if (in_error && (ddebuglevel () > 0)) { - dprintf ("%s() got %d ('%s') at %s: %d", - in_function, in_error, mach_error_string (in_error), in_file, in_line); - dprintsession (); - //dprintbootstrap (mach_task_self ()); - } - return in_error; -} -// --------------------------------------------------------------------------- - - -const char *kipc_error_string (kipc_err_t in_error) -{ - return mach_error_string (in_error); -} - -// --------------------------------------------------------------------------- - -kipc_err_t kipc_get_service_name (char **out_service_name, const char *in_service_id) -{ - kipc_err_t err = 0; - - if (out_service_name == NULL) { err = EINVAL; } - if (in_service_id == NULL) { err = EINVAL; } - - if (!err) { - int wrote = asprintf (out_service_name, "%s%s", in_service_id, ".ipcService"); - if (wrote < 0) { err = ENOMEM; } - } - - return kipc_err (err); -} - -// --------------------------------------------------------------------------- - -kipc_err_t kipc_get_lookup_name (char **out_lookup_name, const char *in_service_id) -{ - kipc_err_t err = 0; - - if (out_lookup_name == NULL) { err = EINVAL; } - if (in_service_id == NULL) { err = EINVAL; } - - if (!err) { - int wrote = asprintf (out_lookup_name, "%s%s", in_service_id, ".ipcLookup"); - if (wrote < 0) { err = ENOMEM; } - } - - return kipc_err (err); -} - -// --------------------------------------------------------------------------- - -void kipc_free_string (char *io_string) -{ - free (io_string); -} - diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c deleted file mode 100644 index c7c973bee..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/kipc_server.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - * kipc_server.c - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#include -#include -#include "notifyServer.h" - -// Global variables for servers (used by demux) -static mach_port_t g_service_port = MACH_PORT_NULL; -static kipc_boolean_t g_ready_to_quit = FALSE; -static kipc_demux_proc g_demux_proc = NULL; - -#pragma mark - - -// --------------------------------------------------------------------------- - -mach_port_t -kipc_server_get_service_port () -{ - return g_service_port; -} - -#pragma mark - - -// --------------------------------------------------------------------------- - -kipc_boolean_t -kipc_server_quit (void) -{ - // Do not unregister our port because then we won't get automatically launched again. - dprintf ("mach_server_quit_self(): quitting..."); - g_ready_to_quit = true; - return g_ready_to_quit; -} - -#pragma mark - - -// --------------------------------------------------------------------------- - -static kipc_boolean_t -kipc_server_demux (mach_msg_header_t *request, mach_msg_header_t *reply) -{ - if (mach_notify_server (request, reply) != false) { - return true; - } else { - return g_demux_proc (request, reply); - } - return false; -} - -#pragma mark - - -// --------------------------------------------------------------------------- - -static kipc_err_t -kipc_get_server_id (char **out_server_id) -{ - kern_return_t err = KERN_SUCCESS; - CFBundleRef bundle = NULL; - CFStringRef id_string = NULL; - CFIndex id_length = 0; - char *server_id = NULL; - - if (out_server_id == NULL) { err = kipc_err (EINVAL); } - - if (!err) { - bundle = CFBundleGetMainBundle (); - if (bundle == NULL) { err = ENOENT; } - } - - if (!err) { - id_string = CFBundleGetIdentifier (bundle); - if (id_string == NULL) { err = ENOMEM; } - } - - if (!err) { - id_length = CFStringGetMaximumSizeForEncoding (CFStringGetLength (id_string), - CFStringGetSystemEncoding ()) + 1; - server_id = calloc (id_length, sizeof (char)); - if (server_id == NULL) { err = errno; } - } - - if (!err) { - if (!CFStringGetCString (id_string, server_id, id_length, CFStringGetSystemEncoding ())) { - err = ENOMEM; - } - } - - if (!err) { - *out_server_id = server_id; - server_id = NULL; - } - - if (server_id != NULL) { kipc_free_string (server_id); } - - return kipc_err (err); -} - -// --------------------------------------------------------------------------- - -kipc_err_t -kipc_server_run_server (kipc_demux_proc in_demux_proc) -{ - kern_return_t err = KERN_SUCCESS; - char *server_id = NULL; - char *service_name = NULL; - char *lookup_name = NULL; - mach_port_t boot_port = MACH_PORT_NULL; - mach_port_t lookup_port = MACH_PORT_NULL; - mach_port_t notify_port = MACH_PORT_NULL; - mach_port_t previous_notify_port = MACH_PORT_NULL; - mach_port_t listen_port_set = MACH_PORT_NULL; - - if (in_demux_proc == NULL) { err = kipc_err (EINVAL); } - - // Shed root privileges if any - if (!err && (geteuid () == 0)) { - uid_t new_uid = kipc_session_get_server_uid (); - if (setuid (new_uid) < 0) { - dprintf ("%s(): setuid(%d) failed (euid is %d)", __FUNCTION__, new_uid, geteuid ()); - } - } - - if (!err) { - // Set up the globals so the demux can find them - g_demux_proc = in_demux_proc; - } - - if (!err) { - err = kipc_get_server_id (&server_id); - } - - if (!err) { - err = kipc_get_service_name (&service_name, server_id); - } - - if (!err) { - err = kipc_get_lookup_name (&lookup_name, server_id); - } - - if (!err) { - // Get the bootstrap port - err = task_get_bootstrap_port (mach_task_self (), &boot_port); - dprintf ("%s(): task_get_bootstrap_port(): port is %x (err = %d '%s')", - __FUNCTION__, boot_port, err, mach_error_string (err)); - } - - if (!err) { - // Create the lookup port: - err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &lookup_port); - } - - if (!err) { - err = mach_port_insert_right (mach_task_self (), lookup_port, lookup_port, MACH_MSG_TYPE_MAKE_SEND); - } - - if (!err) { - // Register the lookup port so others can tell whether or not we are running - err = bootstrap_register (boot_port, lookup_name, lookup_port); - dprintf ("%s(): bootstrap_register('%s', %x): (err = %d '%s')", - __FUNCTION__, lookup_name, lookup_port, err, mach_error_string (err)); - } - - if (!err) { - // We are an on-demand server so our port already exists. Just ask for it. - err = bootstrap_check_in (boot_port, (char *) service_name, &g_service_port); - dprintf ("%s(): bootstrap_check_in('%s'): port is %d (err = %d '%s')", - __FUNCTION__, service_name, g_service_port, err, mach_error_string (err)); - } - - if (!err) { - // Create the notification port: - err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, ¬ify_port); - } - - if (!err) { - // Ask for notification when the server port has no more senders - // A send-once right != a send right so our send-once right will not interfere with the notification - err = mach_port_request_notification (mach_task_self (), g_service_port, MACH_NOTIFY_NO_SENDERS, true, - notify_port, MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous_notify_port); - dprintf ("%s(): requesting notification for no senders of %x returned '%s', err = %d\n", - __FUNCTION__, g_service_port, mach_error_string (err), err); - } - - if (!err) { - // Create the port set that the server will listen on - err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, &listen_port_set); - } - - if (!err) { - // Add the service port to the port set - err = mach_port_move_member (mach_task_self (), g_service_port, listen_port_set); - } - - if (!err) { - // Add the notify port to the port set - err = mach_port_move_member (mach_task_self (), notify_port, listen_port_set); - } - - if (!err) { - dprintf ("%s(): \"%s\": starting up. service port = %x, bootstrap port = %x\n", - __FUNCTION__, service_name, g_service_port, boot_port); - } - - while (!err && !g_ready_to_quit) { - // Handle one message at a time so we can check to see if the server wants to quit - err = mach_msg_server_once (kipc_server_demux, kkipc_max_message_size, listen_port_set, MACH_MSG_OPTION_NONE); - } - - // Regardless of whether there was an error, unregister ourselves from no senders notifications - // so we don't get launched again by the notification message when we quit - // A send-once right != a send right so our send-once right will not interfere with the notification - if (g_service_port != MACH_PORT_NULL) { - err = mach_port_request_notification (mach_task_self (), g_service_port, MACH_NOTIFY_NO_SENDERS, - true, MACH_PORT_NULL, MACH_MSG_TYPE_MAKE_SEND_ONCE, - &previous_notify_port); - dprintf ("%s(): removing notification for no senders of %x returned '%s', err = %d\n", - __FUNCTION__, previous_notify_port, mach_error_string (err), err); - } - - // Clean up the ports and strings - if (lookup_port != MACH_PORT_NULL) { - kipc_err_t terr = bootstrap_register (boot_port, lookup_name, MACH_PORT_NULL); - dprintf ("%s(): bootstrap_register('%s', MACH_PORT_NULL): (err = %d '%s')", - __FUNCTION__, lookup_name, terr, mach_error_string (terr)); - mach_port_deallocate (mach_task_self (), lookup_port); - } - if (notify_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), notify_port); } - if (listen_port_set != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), listen_port_set); } - if (boot_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), boot_port); } - if (lookup_name != NULL ) { kipc_free_string (lookup_name); } - if (service_name != NULL ) { kipc_free_string (service_name); } - if (server_id != NULL ) { kipc_free_string (server_id); } - - return kipc_err (err); -} - -#pragma mark - - -// --------------------------------------------------------------------------- - -kern_return_t -do_mach_notify_port_deleted (mach_port_t notify, mach_port_name_t name) -{ - dprintf ("Received MACH_NOTIFY_PORT_DELETED... quitting self"); - kipc_server_quit (); - return KERN_SUCCESS; -} - -// --------------------------------------------------------------------------- - -kern_return_t -do_mach_notify_port_destroyed (mach_port_t notify, mach_port_t rights) -{ - dprintf ("Received MACH_NOTIFY_PORT_DESTROYED... quitting self"); - kipc_server_quit (); - return KERN_SUCCESS; -} - -// --------------------------------------------------------------------------- - -kern_return_t -do_mach_notify_no_senders (mach_port_t notify, mach_port_mscount_t mscount) -{ - dprintf ("Received MACH_NOTIFY_NO_SENDERS... quitting self"); - kipc_server_quit (); - return KERN_SUCCESS; -} - -// --------------------------------------------------------------------------- - -kern_return_t -do_mach_notify_send_once (mach_port_t notify) -{ - dprintf ("Received MACH_NOTIFY_SEND_ONCE"); - return KERN_SUCCESS; -} - -// --------------------------------------------------------------------------- - -kern_return_t -do_mach_notify_dead_name (mach_port_t notify, mach_port_name_t name) -{ - dprintf ("Received MACH_NOTIFY_DEAD_NAME... quitting self"); - kipc_server_quit (); - return KERN_SUCCESS; -} - diff --git a/src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c b/src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c deleted file mode 100644 index c08e1bc32..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/kipc_session.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * kipc_session.c - * - * $Header$ - * - * Copyright 2006 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 M.I.T. 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. - */ - -#include -#include -#include - -// --------------------------------------------------------------------------- - -kipc_boolean_t kipc_session_is_root_session (void) -{ - kipc_err_t err = 0; - kipc_boolean_t is_root_session = TRUE; // safer to assume root session - SessionAttributeBits sattrs = 0L; - - err = SessionGetInfo (callerSecuritySession, NULL, &sattrs); - - if (!err) { - is_root_session = (sattrs & sessionIsRoot); - dprintf ("%s(): running in %s session", - __FUNCTION__, is_root_session ? "the root" : "a user"); - } else { - dprintf ("%s(): SessionGetInfo() failed with %d", __FUNCTION__, err); - } - - return is_root_session; -} - -// --------------------------------------------------------------------------- - -kipc_session_attributes_t kipc_session_get_attributes (void) -{ - kipc_session_attributes_t attributes = 0L; - SessionAttributeBits sattrs = 0L; - int fd_stdin = fileno (stdin); - int fd_stdout = fileno (stdout); - char *fd_stdin_name = ttyname (fd_stdin); - - if ((SessionGetInfo (callerSecuritySession, NULL, &sattrs) == noErr) && (sattrs & sessionHasGraphicAccess)) { - dprintf ("%s(): Session has graphic access.", __FUNCTION__); - attributes |= kkipc_session_has_gui_access; - - // Check for the HIToolbox (Carbon) or AppKit (Cocoa). If either is loaded, we are a GUI app! - CFBundleRef hiToolBoxBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.HIToolbox")); - if (hiToolBoxBundle != NULL && CFBundleIsExecutableLoaded (hiToolBoxBundle)) { - dprintf ("%s(): Carbon Toolbox is loaded.", __FUNCTION__); - attributes |= kkipc_session_caller_uses_gui; - } - - CFBundleRef appKitBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.AppKit")); - if (appKitBundle != NULL && CFBundleIsExecutableLoaded (appKitBundle)) { - dprintf ("%s(): AppKit is loaded.", __FUNCTION__); - attributes |= kkipc_session_caller_uses_gui; - } - } - - // Session info isn't reliable for remote sessions. - // Check manually for terminal access with file descriptors - if (isatty (fd_stdin) && isatty (fd_stdout) && (fd_stdin_name != NULL)) { - dprintf ("%s(): Terminal '%s' of type '%s' exists.", - __FUNCTION__, fd_stdin_name, getenv ("TERM")); - attributes |= kkipc_session_has_cli_access; - } - - dprintf ("%s(): Attributes are %x", __FUNCTION__, attributes); - return attributes; -} - -// --------------------------------------------------------------------------- - -kipc_string kipc_get_session_id_string (void) -{ - // Session ID is a 32 bit quanitity, so the longest string is 0xFFFFFFFF - static char s_session_name[16]; - SecuritySessionId id; - - s_session_name[0] = '\0'; - - if (SessionGetInfo (callerSecuritySession, &id, NULL) == noErr) { - snprintf (s_session_name, sizeof (s_session_name), "0x%lx", id); - } - - return s_session_name; -} - -// --------------------------------------------------------------------------- - -uid_t kipc_session_get_session_uid (void) -{ - // Get the uid of the user that the server will be run and named for. - uid_t uid = geteuid (); - - // Avoid root because the client can later go back to the real uid - if (uid == 0 /* root */) { - dprintf ("%s(): geteuid returned UID %d, trying getuid...\n", __FUNCTION__, uid); - uid = getuid (); - } - - return uid; -} - -// --------------------------------------------------------------------------- - -uid_t kipc_session_get_server_uid (void) -{ - uid_t server_uid = 92; - - struct passwd *pw = getpwnam ("securityagent"); - if (pw != NULL) { - server_uid = pw->pw_uid; - } else { - dprintf ("%s: getpwnam(securityagent) failed, using hardcoded value.", __FUNCTION__); - } - - return server_uid; -} diff --git a/src/lib/ccapi/common/mac/KerberosIPC/notify.defs b/src/lib/ccapi/common/mac/KerberosIPC/notify.defs deleted file mode 100644 index fea03c9d5..000000000 --- a/src/lib/ccapi/common/mac/KerberosIPC/notify.defs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * mach_notify.defs - * - * $Header$ - * - * Copyright 2003 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 M.I.T. 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 is totally disgusting. - * Rename the demux function so we don't collide with other libraries using this. - */ - -#define notify_server mach_notify_server - -#include -- cgit