From: Selva Nair <[email protected]> Initializing before open_management() is required for management interface directives such as pkcs11-id-count to not error out if used during the first management-hold, for example.
Github: fixes OpenVPN/openvpn#1166 Change-Id: Ibd33f20108d3ca8ddc17f145502d21d2f6e6d91a Signed-off-by: Selva Nair <[email protected]> Acked-by: Razvan Cojocaru <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2388 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2388 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru <[email protected]> diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 49fcaf6..d26d759 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -747,20 +747,6 @@ do_link_socket_addr_new(c); -#if defined(ENABLE_PKCS11) - if (c->first_time) - { - int i; - pkcs11_initialize(true, c->options.pkcs11_pin_cache_period); - for (i = 0; i < MAX_PARMS && c->options.pkcs11_providers[i] != NULL; i++) - { - pkcs11_addProvider( - c->options.pkcs11_providers[i], c->options.pkcs11_protected_authentication[i], - c->options.pkcs11_private_mode[i], c->options.pkcs11_cert_private[i]); - } - } -#endif - #if 0 /* test get_user_pass with GET_USER_PASS_NEED_OK flag */ { /* @@ -786,6 +772,26 @@ } void +init_pkcs11(const struct context *c) +{ +#if defined(ENABLE_PKCS11) + if (c->first_time) + { + if (!pkcs11_initialize(true, c->options.pkcs11_pin_cache_period)) + { + msg(M_FATAL, "ERROR: pkcs11-helper initialization failed."); + } + for (int i = 0; i < MAX_PARMS && c->options.pkcs11_providers[i] != NULL; i++) + { + pkcs11_addProvider( + c->options.pkcs11_providers[i], c->options.pkcs11_protected_authentication[i], + c->options.pkcs11_private_mode[i], c->options.pkcs11_cert_private[i]); + } + } +#endif +} + +void context_gc_free(struct context *c) { gc_free(&c->c2.gc); diff --git a/src/openvpn/init.h b/src/openvpn/init.h index d028280..b3ee75b 100644 --- a/src/openvpn/init.h +++ b/src/openvpn/init.h @@ -34,6 +34,7 @@ void context_clear_2(struct context *c); void context_init_1(struct context *c); +void init_pkcs11(const struct context *c); void context_clear_all_except_first_time(struct context *c); diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index d9a7c85..50be82c 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -280,6 +280,8 @@ write_pid_file(c.options.writepid, c.options.chroot_dir); } + init_pkcs11(&c); + #ifdef ENABLE_MANAGEMENT /* open management subsystem */ if (!open_management(&c)) _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
