From: Richard Levitte Date: Fri, 11 Oct 2002 18:49:55 +0000 (+0000) Subject: Step 11c of move of engines: Time to make the changes to support X-Git-Tag: OpenSSL_0_9_7-beta4~109^2~33 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=aae329c447025eb87dab294d909f9fbc48f7174c;p=oweals%2Fopenssl.git Step 11c of move of engines: Time to make the changes to support automatic load of dynamic engines. Change the iterator to try to load the requested engine dynamically. The environment variable OPENSSL_ENGINES can be used to override the internal default directory where one can expect to find dynamically loadable engines. Note: The changes in step 11 have all been made by Geoff Thorpe. Credit where credit is due. --- diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index 5018856781..b41e6ba0f7 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -351,6 +351,7 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src) ENGINE *ENGINE_by_id(const char *id) { ENGINE *iterator; + char *load_dir = NULL; if(id == NULL) { ENGINEerr(ENGINE_F_ENGINE_BY_ID, @@ -384,6 +385,7 @@ ENGINE *ENGINE_by_id(const char *id) } } CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE); +#if 0 if(iterator == NULL) { ENGINEerr(ENGINE_F_ENGINE_BY_ID, @@ -391,4 +393,26 @@ ENGINE *ENGINE_by_id(const char *id) ERR_add_error_data(2, "id=", id); } return iterator; +#else + /* EEK! Experimental code starts */ + if(iterator) return iterator; +#ifdef OPENSSL_SYS_VMS + if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = "SSLROOT:[ENGINES]"; +#else + if((load_dir = getenv("OPENSSL_ENGINES")) == 0) load_dir = OPENSSLDIR "/engines"; +#endif + iterator = ENGINE_by_id("dynamic"); + if(!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) || + !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) || + !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD", + load_dir, 0) || + !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0)) + goto notfound; + return iterator; +notfound: + ENGINEerr(ENGINE_F_ENGINE_BY_ID,ENGINE_R_NO_SUCH_ENGINE); + ERR_add_error_data(2, "id=", id); + return NULL; + /* EEK! Experimental code ends */ +#endif }