summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminfrin <minfrin@13f79535-47bb-0310-9956-ffa450edef68>2009-01-03 17:30:06 +0000
committerminfrin <minfrin@13f79535-47bb-0310-9956-ffa450edef68>2009-01-03 17:30:06 +0000
commit78a78db37a81fbf0d710db2b602a2b007ab75207 (patch)
tree18756390a78552f29b8eb44332f2e8d7785838cb
parent99ce8e90edb1fa72d39c38d7f4ef68a826937c58 (diff)
downloadlibapr-util-78a78db37a81fbf0d710db2b602a2b007ab75207.tar.gz
Make sure that the underlying result code during driver initialisation
is exposed to the caller. git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@731033 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES3
-rw-r--r--crypto/apr_crypto.c4
-rw-r--r--crypto/apr_crypto_nss.c7
-rw-r--r--crypto/apr_crypto_openssl.c2
-rw-r--r--include/private/apr_crypto_internal.h2
5 files changed, 13 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 0cea4401..3a5eabc4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with APR-util 1.4.0
+ *) Make sure that the underlying result code during driver initialisation
+ is exposed to the caller. [Graham Leggett]
+
*) Provide a mechanism to provide the recommended crypto driver to
calling application. [Graham Leggett]
diff --git a/crypto/apr_crypto.c b/crypto/apr_crypto.c
index 7e794caa..ef843102 100644
--- a/crypto/apr_crypto.c
+++ b/crypto/apr_crypto.c
@@ -111,6 +111,7 @@ APU_DECLARE(apr_status_t) apr_crypto_get_driver(apr_pool_t *pool, const char *na
apr_dso_handle_sym_t symbol;
#endif
apr_status_t rv;
+ int rc = 0;
#if APU_DSO_BUILD
rv = apu_dso_mutex_lock();
@@ -151,7 +152,7 @@ APU_DECLARE(apr_status_t) apr_crypto_get_driver(apr_pool_t *pool, const char *na
}
*driver = symbol;
if ((*driver)->init) {
- (*driver)->init(pool, params);
+ rv = (*driver)->init(pool, params, &rc);
}
name = apr_pstrdup(pool, name);
apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
@@ -165,6 +166,7 @@ APU_DECLARE(apr_status_t) apr_crypto_get_driver(apr_pool_t *pool, const char *na
apr_dso_error(dso, buffer, ERROR_SIZE - 1);
err->msg = buffer;
err->reason = modname;
+ err->rc = rc;
*result = err;
}
}
diff --git a/crypto/apr_crypto_nss.c b/crypto/apr_crypto_nss.c
index bab01880..88355ca4 100644
--- a/crypto/apr_crypto_nss.c
+++ b/crypto/apr_crypto_nss.c
@@ -78,7 +78,7 @@ static apr_status_t crypto_shutdown_helper(void *data)
/**
* Initialise the crypto library and perform one time initialisation.
*/
-static apr_status_t crypto_init(apr_pool_t *pool, const apr_array_header_t *params)
+static apr_status_t crypto_init(apr_pool_t *pool, const apr_array_header_t *params, int *rc)
{
SECStatus s;
const char *dir = NULL;
@@ -127,6 +127,9 @@ static apr_status_t crypto_init(apr_pool_t *pool, const apr_array_header_t *para
s = NSS_NoDB_Init(NULL);
}
if (s != SECSuccess) {
+ if (rc) {
+ *rc = PR_GetError();
+ }
return APR_ECRYPT;
}
@@ -386,7 +389,7 @@ static apr_status_t crypto_passphrase(apr_pool_t *p,
key->ivSize = PK11_GetIVLength(key->cipherMech);
if (ivSize) {
- *ivSize = key->ivSize;
+ *ivSize = key->ivSize;
}
return rv;
diff --git a/crypto/apr_crypto_openssl.c b/crypto/apr_crypto_openssl.c
index cc37e470..a9dda907 100644
--- a/crypto/apr_crypto_openssl.c
+++ b/crypto/apr_crypto_openssl.c
@@ -77,7 +77,7 @@ static apr_status_t crypto_shutdown_helper(void *data) {
* Initialise the crypto library and perform one time initialisation.
*/
static apr_status_t crypto_init(apr_pool_t *pool,
- const apr_array_header_t *params) {
+ const apr_array_header_t *params, int *rc) {
CRYPTO_malloc_init();
ERR_load_crypto_strings();
/* SSL_load_error_strings(); */
diff --git a/include/private/apr_crypto_internal.h b/include/private/apr_crypto_internal.h
index c70e4550..de109de5 100644
--- a/include/private/apr_crypto_internal.h
+++ b/include/private/apr_crypto_internal.h
@@ -38,7 +38,7 @@ struct apr_crypto_driver_t {
* @param pool The pool to register the cleanup in.
* @param params An array of optional init parameters.
*/
- apr_status_t (*init)(apr_pool_t *pool, const apr_array_header_t *params);
+ apr_status_t (*init)(apr_pool_t *pool, const apr_array_header_t *params, int *rc);
/**
* @brief Create a context for supporting encryption. Keys, certificates,