diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-07-30 14:29:23 +0200 |
---|---|---|
committer | Stef Walter <stefw@redhat.com> | 2014-09-25 09:46:53 +0200 |
commit | 85e5d09e80c14c618d1d8826284f827f720ea20e (patch) | |
tree | cf11f9f83de2ef32b994f0d800c795f5c25b80a6 | |
parent | 5cc0a71cbacedfb1c8ba6c3ba4642b9bc2679f02 (diff) | |
download | p11-kit-85e5d09e80c14c618d1d8826284f827f720ea20e.tar.gz |
remote: server will overwrite the library manufacturer
That would allow objects within a PKCS #11 module to remain
unique if both the remote and the normal module are in use,
as well when many remote modules exist.
-rw-r--r-- | p11-kit/remote.c | 7 | ||||
-rw-r--r-- | p11-kit/rpc-server.c | 27 | ||||
-rw-r--r-- | p11-kit/rpc.h | 3 | ||||
-rw-r--r-- | p11-kit/test-rpc.c | 2 |
4 files changed, 31 insertions, 8 deletions
diff --git a/p11-kit/remote.c b/p11-kit/remote.c index a9f03c6..c5502c9 100644 --- a/p11-kit/remote.c +++ b/p11-kit/remote.c @@ -85,7 +85,8 @@ SIGHANDLER_T ocsignal(int signum, SIGHANDLER_T handler) } static int -serve_module (CK_FUNCTION_LIST *module, +serve_module (const char *name, + CK_FUNCTION_LIST *module, p11_buffer *options, p11_buffer *buffer, p11_virtual *virt, int fd) @@ -153,7 +154,7 @@ serve_module (CK_FUNCTION_LIST *module, goto out; } - if (!p11_rpc_server_handle (&virt->funcs, buffer, buffer)) { + if (!p11_rpc_server_handle (name, &virt->funcs, buffer, buffer)) { p11_message ("unexpected error handling rpc message"); goto out; } @@ -339,7 +340,7 @@ p11_kit_remote_serve_module (CK_FUNCTION_LIST *module, case 0: /* child */ sigprocmask(SIG_UNBLOCK, &blockset, NULL); - serve_module (module, &options, &buffer, &virt, cfd); + serve_module (socket_file, module, &options, &buffer, &virt, cfd); _exit(0); default: children_avail++; diff --git a/p11-kit/rpc-server.c b/p11-kit/rpc-server.c index b8288c9..f074fd0 100644 --- a/p11-kit/rpc-server.c +++ b/p11-kit/rpc-server.c @@ -48,6 +48,7 @@ #include <sys/param.h> #include <assert.h> #include <errno.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -707,14 +708,29 @@ rpc_C_Finalize (CK_X_FUNCTION_LIST *self, END_CALL; } +static void fix_info(const char *id, CK_INFO *info) +{ + unsigned len; + unsigned i; + + /* replace description */ + snprintf((char*)info->manufacturerID, sizeof(info->manufacturerID), "V:%s", id); + len = strlen((char*)info->manufacturerID); + + for (i=len;i<sizeof(info->manufacturerID);i++) + info->manufacturerID[i] = ' '; +} + static CK_RV -rpc_C_GetInfo (CK_X_FUNCTION_LIST *self, +rpc_C_GetInfo (const char *id, + CK_X_FUNCTION_LIST *self, p11_rpc_message *msg) { CK_INFO info; BEGIN_CALL (GetInfo); PROCESS_CALL ((self, &info)); + fix_info (id, &info); OUT_INFO (info); END_CALL; } @@ -1763,7 +1779,8 @@ rpc_C_GenerateRandom (CK_X_FUNCTION_LIST *self, } bool -p11_rpc_server_handle (CK_X_FUNCTION_LIST *self, +p11_rpc_server_handle (const char *name, + CK_X_FUNCTION_LIST *self, p11_buffer *request, p11_buffer *response) { @@ -1795,9 +1812,13 @@ p11_rpc_server_handle (CK_X_FUNCTION_LIST *self, case P11_RPC_CALL_##name: \ ret = rpc_##name (self, &msg); \ break; + #define CASE_CALL_ID(id, name) \ + case P11_RPC_CALL_##name: \ + ret = rpc_##name (id, self, &msg); \ + break; CASE_CALL (C_Initialize) CASE_CALL (C_Finalize) - CASE_CALL (C_GetInfo) + CASE_CALL_ID (name, C_GetInfo) CASE_CALL (C_GetSlotList) CASE_CALL (C_GetSlotInfo) CASE_CALL (C_GetTokenInfo) diff --git a/p11-kit/rpc.h b/p11-kit/rpc.h index b129e61..4b169dc 100644 --- a/p11-kit/rpc.h +++ b/p11-kit/rpc.h @@ -59,7 +59,8 @@ struct _p11_rpc_client_vtable { bool p11_rpc_client_init (p11_virtual *virt, p11_rpc_client_vtable *vtable); -bool p11_rpc_server_handle (CK_X_FUNCTION_LIST *funcs, +bool p11_rpc_server_handle (const char *name, + CK_X_FUNCTION_LIST *funcs, p11_buffer *request, p11_buffer *response); diff --git a/p11-kit/test-rpc.c b/p11-kit/test-rpc.c index 8c20a40..db14500 100644 --- a/p11-kit/test-rpc.c +++ b/p11-kit/test-rpc.c @@ -400,7 +400,7 @@ rpc_transport (p11_rpc_client_vtable *vtable, assert_str_eq (vtable->data, "vtable-data"); /* Just pass directly to the server code */ - ret = p11_rpc_server_handle (&base.funcs, request, response); + ret = p11_rpc_server_handle ("virtual", &base.funcs, request, response); assert (ret == true); return CKR_OK; |