From 4c918f965c1e0ca4a9dd62a52fed4b5160e6e397 Mon Sep 17 00:00:00 2001
From: Leif Johansson <leifj@sunet.se>
Date: Tue, 4 Sep 2012 12:22:36 +0200
Subject: [PATCH] forgot to initialize p11 library in inetd-mode

---
 gck-rpc-daemon-standalone.c | 2 +-
 gck-rpc-dispatch.c          | 6 ++++--
 gck-rpc-layer.h             | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gck-rpc-daemon-standalone.c b/gck-rpc-daemon-standalone.c
index a0039f2..5f30514 100644
--- a/gck-rpc-daemon-standalone.c
+++ b/gck-rpc-daemon-standalone.c
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
 	   path = SOCKET_PATH;
 
         if (strcmp(path,"-") == 0) {
-           gck_rpc_layer_inetd();
+           gck_rpc_layer_inetd(funcs);
         } else {
 	   sock = gck_rpc_layer_initialize(path, funcs);
 	   if (sock == -1)
diff --git a/gck-rpc-dispatch.c b/gck-rpc-dispatch.c
index de6f558..6b0687d 100644
--- a/gck-rpc-dispatch.c
+++ b/gck-rpc-dispatch.c
@@ -101,7 +101,7 @@ void gck_rpc_log(const char *msg, ...)
 	va_list ap;
 
 	va_start(ap, msg);
-	vfprintf(stdout, msg, ap);
+	vfprintf(stderr, msg, ap);
 	printf("\n");
 	va_end(ap);
 }
@@ -2240,7 +2240,7 @@ void gck_rpc_layer_accept(void)
 	pthread_mutex_unlock(&pkcs11_dispatchers_mutex);
 }
 
-void gck_rpc_layer_inetd(void)
+void gck_rpc_layer_inetd(CK_FUNCTION_LIST_PTR module)
 {
    CallState cs;
 
@@ -2249,6 +2249,8 @@ void gck_rpc_layer_inetd(void)
    cs.read = &read;
    cs.write = &write;
 
+   pkcs11_module = module;
+
    run_dispatch_thread(&cs);
 }
 
diff --git a/gck-rpc-layer.h b/gck-rpc-layer.h
index be6cdeb..5d2766c 100644
--- a/gck-rpc-layer.h
+++ b/gck-rpc-layer.h
@@ -17,6 +17,6 @@ void gck_rpc_layer_uninitialize(void);
 void gck_rpc_layer_accept(void);
 
 /* Run a single connection off of STDIN - call from inetd or stunnel */
-void gck_rpc_layer_inetd(void);
+void gck_rpc_layer_inetd(CK_FUNCTION_LIST_PTR funcs);
 
 #endif /* GCKRPC_LAYER_H_ */
-- 
GitLab