Skip to content

Commit

Permalink
Revert "cleanup: removed deprecated OpenSSL functions from build"
Browse files Browse the repository at this point in the history
This reverts commit f8252e4.
Disabling the callbacks breaks openssl thread-safety on openssl 1.0.
  • Loading branch information
arogge committed Mar 26, 2020
1 parent f5d9ff7 commit eb53d60
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions core/src/lib/crypto_openssl.cc
Expand Up @@ -1568,7 +1568,6 @@ void OpensslPostErrors(JobControlRecord *jcr, int type, const char *errstring)
* Returns: thread ID
*
*/
#if OPENSSL_VERSION_NUMBER < 0x10000000L
static unsigned long GetOpensslThreadId(void)
{
#ifdef HAVE_WIN32
Expand All @@ -1581,14 +1580,12 @@ static unsigned long GetOpensslThreadId(void)
* emulation code, which defines pthread_t as a structure.
*/
return ((unsigned long)pthread_self());
#endif /* not HAVE_WIN32 */
#endif
}
#endif /* #if OPENSSL_VERSION_NUMBER < 0x10000000L */

/*
* Allocate a dynamic OpenSSL mutex
*/
#if OPENSSL_VERSION_NUMBER < 0x10000000L
static struct CRYPTO_dynlock_value *openssl_create_dynamic_mutex (const char *file, int line)
{
struct CRYPTO_dynlock_value *dynlock;
Expand Down Expand Up @@ -1624,12 +1621,10 @@ static void OpensslDestroyDynamicMutex(struct CRYPTO_dynlock_value *dynlock, con

free(dynlock);
}
#endif /* OPENSSL_VERSION_NUMBER < 0x10000000L */

/*
* (Un)Lock a static OpenSSL mutex
*/
#if OPENSSL_VERSION_NUMBER < 0x10000000L
static void openssl_update_static_mutex (int mode, int i, const char *file, int line)
{
if (mode & CRYPTO_LOCK) {
Expand All @@ -1638,7 +1633,6 @@ static void openssl_update_static_mutex (int mode, int i, const char *file, int
V(mutexes[i]);
}
}
#endif /* OPENSSL_VERSION_NUMBER < 0x10000000L */

/*
* Initialize OpenSSL thread support
Expand All @@ -1652,9 +1646,7 @@ int OpensslInitThreads (void)


/* Set thread ID callback */
#if OPENSSL_VERSION_NUMBER < 0x10000000L
CRYPTO_set_id_callback(GetOpensslThreadId);
#endif

/* Initialize static locking */
numlocks = CRYPTO_num_locks();
Expand All @@ -1667,15 +1659,13 @@ int OpensslInitThreads (void)
}
}

#if OPENSSL_VERSION_NUMBER < 0x10000000L
/* Set static locking callback */
CRYPTO_set_locking_callback(openssl_update_static_mutex);

/* Initialize dyanmic locking */
CRYPTO_set_dynlock_create_callback(openssl_create_dynamic_mutex);
CRYPTO_set_dynlock_lock_callback(OpensslUpdateDynamicMutex);
CRYPTO_set_dynlock_destroy_callback(OpensslDestroyDynamicMutex);
#endif

return 0;
}
Expand Down

0 comments on commit eb53d60

Please sign in to comment.