diff --git a/common/ecdh.c b/common/ecdh.c index a64b65106..f094b0a3a 100644 --- a/common/ecdh.c +++ b/common/ecdh.c @@ -111,7 +111,7 @@ void mserror(const char *str, int err) { } } -int ecdh_load_module(const char *module) { +int ecdh_load_module(const char *module, FILE *out) { UNUSED(module); return 0; } @@ -1570,7 +1570,7 @@ static void trimright(unsigned char *buf, size_t len) { *p = 0; } -int ecdh_load_module(const char *module) { +int ecdh_load_module(const char *module, FILE *out) { if (module_handle) { p11->C_Finalize(0); @@ -1582,14 +1582,14 @@ int ecdh_load_module(const char *module) { if (strcmp(module, "-")) { module_handle = dlopen(module, RTLD_NOW | RTLD_GLOBAL); if (module_handle == 0) { - puts("Can't open shared library"); + fprintf(out, "Can't open shared library '%s'\n", module); return CKR_ARGUMENTS_BAD; } CK_C_GetFunctionList fn = 0; *(void **) (&fn) = dlsym(module_handle, "C_GetFunctionList"); if (fn == 0) { - puts("Can't find symbol"); + fprintf(out, "Can't find symbol 'C_GetFunctionList' in '%s'\n", module); dlclose(module_handle); module_handle = 0; return CKR_GENERAL_ERROR; @@ -1597,7 +1597,7 @@ int ecdh_load_module(const char *module) { CK_RV rv = fn(&p11); if (rv != CKR_OK) { - puts("Can't get function list"); + fprintf(out, "Can't get function list from '%s', rv=%lu\n", module, rv); dlclose(module_handle); module_handle = 0; p11 = &function_list; @@ -1606,7 +1606,7 @@ int ecdh_load_module(const char *module) { rv = p11->C_Initialize(0); if (rv != CKR_OK) { - puts("Can't initialize module"); + fprintf(out, "Can't initialize module '%s', rv = %lu\n", module, rv); dlclose(module_handle); module_handle = 0; p11 = &function_list; diff --git a/common/ecdh.h b/common/ecdh.h index c388c2013..f1cff25a9 100644 --- a/common/ecdh.h +++ b/common/ecdh.h @@ -41,7 +41,7 @@ int YH_INTERNAL ecdh_curve_p256(void); int YH_INTERNAL ecdh_curve_p384(void); int YH_INTERNAL ecdh_curve_p521(void); -int YH_INTERNAL ecdh_load_module(const char *module); +int YH_INTERNAL ecdh_load_module(const char *module, FILE *out); int YH_INTERNAL ecdh_list_providers(void *ctx, int (*callback)(void *ctx, diff --git a/lib/yubihsm.c b/lib/yubihsm.c index 720fe8a4a..a69b4e1fb 100644 --- a/lib/yubihsm.c +++ b/lib/yubihsm.c @@ -1301,9 +1301,9 @@ static int name_listing(void *ctx, const char *name) { return 0; } -yh_rc yh_util_load_client_auth_module(const char *module) { +yh_rc yh_util_load_client_auth_module(const char *module, FILE *out) { - ecdh_load_module(module); + ecdh_load_module(module, out); return YHR_SUCCESS; } diff --git a/lib/yubihsm.h b/lib/yubihsm.h index 0190a9302..f0d90b5dc 100644 --- a/lib/yubihsm.h +++ b/lib/yubihsm.h @@ -937,7 +937,7 @@ yh_rc yh_create_session(yh_connector *connector, uint16_t authkey_id, const uint8_t *key_mac, size_t key_mac_len, bool recreate_session, yh_session **session); -yh_rc yh_util_load_client_auth_module(const char *module); +yh_rc yh_util_load_client_auth_module(const char *module, FILE *out); yh_rc yh_util_list_client_auth_providers(FILE *out); diff --git a/src/commands.c b/src/commands.c index 4d67be53b..5c7aa7578 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1527,7 +1527,7 @@ int yh_com_load_client_auth_module(yubihsm_context *ctx, Argument *argv, UNUSED(in_fmt); UNUSED(fmt); - yh_util_load_client_auth_module(argv[0].s); + yh_util_load_client_auth_module(argv[0].s, ctx->out); return 0; }