Revert alloc_str changes

This reverts commit fdead26ffe.
This reverts commit 3e2419ebe3.
This reverts commit 17ce69b47a.
This commit is contained in:
Martin Willi
2011-04-21 13:35:31 +02:00
parent fdead26ffe
commit 5b0bcfb1fc
17 changed files with 49 additions and 123 deletions
@@ -550,34 +550,36 @@ openssl_rsa_private_key_t *openssl_rsa_private_key_connect(key_type_t type,
if (!engine_id)
{
engine_id = lib->settings->alloc_str(lib->settings,
engine_id = lib->settings->get_str(lib->settings,
"libstrongswan.plugins.openssl.engine_id", "pkcs11");
}
engine = ENGINE_by_id(engine_id);
if (!engine)
{
DBG2(DBG_LIB, "engine '%s' is not available", engine_id);
goto engine_failed;
return NULL;
}
if (!ENGINE_init(engine))
{
DBG1(DBG_LIB, "failed to initialize engine '%s'", engine_id);
goto engine_failed;
ENGINE_free(engine);
return NULL;
}
if (!login(engine, keyid))
{
DBG1(DBG_LIB, "login to engine '%s' failed", engine_id);
goto engine_failed;
ENGINE_free(engine);
return NULL;
}
key = ENGINE_load_private_key(engine, keyname, NULL, NULL);
if (!key)
{
DBG1(DBG_LIB, "failed to load private key with ID '%s' from "
"engine '%s'", keyname, engine_id);
goto engine_failed;
ENGINE_free(engine);
return NULL;
}
ENGINE_free(engine);
free(engine_id);
this = create_empty();
this->rsa = EVP_PKEY_get1_RSA(key);
@@ -592,12 +594,5 @@ openssl_rsa_private_key_t *openssl_rsa_private_key_connect(key_type_t type,
#else /* OPENSSL_NO_ENGINE */
return NULL;
#endif /* OPENSSL_NO_ENGINE */
engine_failed:
if (engine)
{
ENGINE_free(engine);
}
free(engine_id);
return NULL;
}
@@ -74,8 +74,7 @@ static void lib_entry_destroy(lib_entry_t *entry)
{
entry->job->cancel(entry->job);
}
DESTROY_IF(entry->lib);
free(entry->path);
entry->lib->destroy(entry->lib);
free(entry);
}
@@ -366,12 +365,12 @@ pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb,
.this = this,
);
entry->path = lib->settings->alloc_str(lib->settings,
entry->path = lib->settings->get_str(lib->settings,
"libstrongswan.plugins.pkcs11.modules.%s.path", NULL, module);
if (!entry->path)
{
DBG1(DBG_CFG, "PKCS11 module '%s' lacks library path", module);
lib_entry_destroy(entry);
free(entry);
continue;
}
entry->lib = pkcs11_library_create(module, entry->path,
@@ -380,7 +379,7 @@ pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb,
FALSE, module));
if (!entry->lib)
{
lib_entry_destroy(entry);
free(entry);
continue;
}
this->libs->insert_last(this->libs, entry);