Construct an outline of a sample platform specific main.c
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 21 May 2006 03:48:39 +0000 (03:48 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 21 May 2006 03:48:39 +0000 (03:48 +0000)
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
src/lib/ccapi/server/rpc_auth.c
src/lib/ccapi/server/rpc_auth.h
src/lib/ccapi/server/serv_ops.c
src/lib/ccapi/server/serv_ops.h

index cf69af312aa487e05d93da318e04581549018552..dbd447f66dbf69716e9082c025af1d0dbd360232 100644 (file)
@@ -1,12 +1,64 @@
 #include <stdarg.h>\r
 #include <stdio.h>\r
+#include "CredentialsCache.h"\r
+#include "msg.h"\r
+#include "rpc_auth.h"\r
+\r
+/* This object module is platform dependent. */\r
 \r
 int main( int argc, char *argv[] )\r
 {\r
+    cc_int32 code;\r
+    int      running = 1;\r
+\r
     /* we need a set of functions we want to support.\r
      * so we can provide an abstract platform independent\r
      * interface.\r
      */\r
 \r
+    code = ccs_serv_initialize();\r
+    if (code) {\r
+       /* ok.  we failed to initialize the ccs data structures.\r
+        * terminate service start.  Log the result.  \r
+        */\r
+       fprintf(stderr, "ccs_serv_initialize failure: %d\n", code);\r
+       return -1;\r
+    }\r
+\r
+    /* initialize the IPC mechanism for this platform */\r
+\r
+    /* implement a message loop that receives in-bound requests\r
+     * processes them, and sends back responses.\r
+     */\r
+    while ( running ) {\r
+       cc_msg_t * req_msg, *resp_msg;\r
+       cc_auth_info_t* auth_info;\r
+       cc_session_info_t* session_info;\r
+       char * data;\r
+       int    len;\r
+\r
+       /* accept IPC request */\r
+\r
+       /* unflatten input stream to msg */\r
+       code = cci_msg_unflatten(data, len, &req_msg);\r
+\r
+       /* process request */\r
+       code = ccs_serv_process_msg(req_msg, auth_info, session_info, &resp_msg);\r
+\r
+       code = cci_msg_flatten(resp_msg, NULL); \r
+\r
+       /* send response (resp_msg->flat, resp_msg->flat_len) */\r
+\r
+       /* cleanup */\r
+       cci_msg_destroy(req_msg);\r
+       cci_msg_destroy(resp_msg);\r
+    }\r
+\r
+    /* de-register IPC mechanism */\r
+\r
+    /* cleanup ccs resources */\r
+    ccs_serv_cleanup();\r
+\r
+    /* exit */\r
     return 0;\r
 }\r
index dd338e010cbc126e887c97c518bc0b521bdf0b8a..66bc6aee9c0836d3c664946312faf55c8b95d327 100644 (file)
 #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;
index 21d7db501cfd66fdae646d9df0518b6a9efb64d6..010a1e2a510b0d6c861b6c134a187c8c9eeb6af9 100644 (file)
@@ -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__*/
index 360536a928a0db99e7ff4dadb55444d6ea53be2f..fb279e6948bb7cbad3217f3374b691e0d714ac68 100644 (file)
@@ -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;
index 152188636b79c4cf4f5ec5a9d7e64727b8c9818a..1433e0f1523280d6457095113a4dff0fa2a9af71 100644 (file)
@@ -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);