From: Jeffrey Altman Date: Sun, 21 May 2006 03:48:39 +0000 (+0000) Subject: Construct an outline of a sample platform specific main.c X-Git-Tag: krb5-1.6-alpha1~274^2~20 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d68adb389e9c1926f4f8c9a0e6132e6dd97ed32b;p=krb5.git 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 --- 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);