From 78a78db37a81fbf0d710db2b602a2b007ab75207 Mon Sep 17 00:00:00 2001 From: minfrin Date: Sat, 3 Jan 2009 17:30:06 +0000 Subject: 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 --- CHANGES | 3 +++ crypto/apr_crypto.c | 4 +++- crypto/apr_crypto_nss.c | 7 +++++-- crypto/apr_crypto_openssl.c | 2 +- include/private/apr_crypto_internal.h | 2 +- 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, -- cgit v1.2.1