Changed initializing logic for nss lib/openssl lib/s3fs own.

This commit is contained in:
Takeshi Nakatani 2014-06-01 03:54:02 +00:00
parent edad91186f
commit 160196798b
3 changed files with 26 additions and 0 deletions

View File

@ -54,6 +54,7 @@ const char* s3fs_crypt_lib_name(void)
//------------------------------------------------------------------- //-------------------------------------------------------------------
bool s3fs_init_global_ssl(void) bool s3fs_init_global_ssl(void)
{ {
NSS_Init(NULL);
NSS_NoDB_Init(NULL); NSS_NoDB_Init(NULL);
return true; return true;
} }

View File

@ -33,6 +33,7 @@
#include <openssl/hmac.h> #include <openssl/hmac.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/err.h>
#include <string> #include <string>
#include <map> #include <map>
@ -56,11 +57,16 @@ const char* s3fs_crypt_lib_name(void)
//------------------------------------------------------------------- //-------------------------------------------------------------------
bool s3fs_init_global_ssl(void) bool s3fs_init_global_ssl(void)
{ {
ERR_load_crypto_strings();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
return true; return true;
} }
bool s3fs_destroy_global_ssl(void) bool s3fs_destroy_global_ssl(void)
{ {
EVP_cleanup();
ERR_free_strings();
return true; return true;
} }

View File

@ -2597,6 +2597,12 @@ static void* s3fs_init(struct fuse_conn_info* conn)
FPRN("init"); FPRN("init");
LOWSYSLOGPRINT(LOG_ERR, "init v%s (%s)", VERSION, s3fs_crypt_lib_name()); LOWSYSLOGPRINT(LOG_ERR, "init v%s (%s)", VERSION, s3fs_crypt_lib_name());
// ssl init
if(!s3fs_init_global_ssl()){
fprintf(stderr, "%s: could not initialize for ssl libraries.\n", program_name.c_str());
exit(EXIT_FAILURE);
}
// init curl // init curl
if(!S3fsCurl::InitS3fsCurl("/etc/mime.types")){ if(!S3fsCurl::InitS3fsCurl("/etc/mime.types")){
fprintf(stderr, "%s: Could not initiate curl library.\n", program_name.c_str()); fprintf(stderr, "%s: Could not initiate curl library.\n", program_name.c_str());
@ -2637,6 +2643,8 @@ static void s3fs_destroy(void*)
if(is_remove_cache && !FdManager::DeleteCacheDirectory()){ if(is_remove_cache && !FdManager::DeleteCacheDirectory()){
DPRN("Could not remove cache directory."); DPRN("Could not remove cache directory.");
} }
// ssl
s3fs_destroy_global_ssl();
} }
static int s3fs_access(const char* path, int mask) static int s3fs_access(const char* path, int mask)
@ -2840,10 +2848,17 @@ static int s3fs_utility_mode(void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// ssl init
if(!s3fs_init_global_ssl()){
fprintf(stderr, "%s: could not initialize for ssl libraries.\n", program_name.c_str());
return EXIT_FAILURE;
}
// init curl // init curl
if(!S3fsCurl::InitS3fsCurl("/etc/mime.types")){ if(!S3fsCurl::InitS3fsCurl("/etc/mime.types")){
fprintf(stderr, "%s: Could not initiate curl library.\n", program_name.c_str()); fprintf(stderr, "%s: Could not initiate curl library.\n", program_name.c_str());
LOWSYSLOGPRINT(LOG_ERR, "Could not initiate curl library."); LOWSYSLOGPRINT(LOG_ERR, "Could not initiate curl library.");
s3fs_destroy_global_ssl();
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -2888,6 +2903,10 @@ static int s3fs_utility_mode(void)
if(!S3fsCurl::DestroyS3fsCurl()){ if(!S3fsCurl::DestroyS3fsCurl()){
DPRN("Could not release curl library."); DPRN("Could not release curl library.");
} }
// ssl
s3fs_destroy_global_ssl();
return result; return result;
} }