#endif
#include <globus_common.h>
+#include <globus_gsi_callback.h>
#include <gssapi.h>
#include <openssl/err.h>
if (edg_wll_gss_oid_equal(mech, get_oid("GSI"))) {
req_flags = GSS_C_GLOBUS_SSL_COMPATIBLE;
- setenv("GLOBUS_GSSAPI_NAME_COMPATIBILITY", "STRICT_RFC2818", 0);
}
ret = do_connect(&sock, addr, addrtype, port, timeout);
do { /* XXX: the black magic above */
while (!context_established) {
-#ifdef GLITE_LBU_THREADED
- /* XXX: gss_init_sec_context() not thread-safe? */
- pthread_mutex_lock(&init_lock);
-#endif
/* XXX verify ret_flags match what was requested */
maj_stat = gss_init_sec_context(&min_stat, gss_cred, &context,
target, mech,
0, GSS_C_NO_CHANNEL_BINDINGS,
&input_token, NULL, &output_token,
NULL, NULL);
-#ifdef GLITE_LBU_THREADED
- pthread_mutex_unlock(&init_lock);
-#endif
if (input_token.length > 0) {
free(input_token.value);
input_token.length = 0;
edg_wll_gss_initialize(void)
{
int ret = 0;
+ int index;
#ifdef GLITE_LBU_THREADED
pthread_mutex_lock(&init_lock);
#endif
- if (!getenv("GLOBUS_THREAD_MODEL")) {
- putenv("GLOBUS_THREAD_MODEL=pthread");
- }
+ setenv("GLOBUS_THREAD_MODEL", "pthread", 0);
+ setenv("GLOBUS_GSSAPI_NAME_COMPATIBILITY", "STRICT_RFC2818", 0);
#ifndef NO_GLOBUS_GSSAPI
if (globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE) != GLOBUS_SUCCESS) {
if (globus_module_activate(GLOBUS_COMMON_MODULE) == GLOBUS_SUCCESS)
globus_common_activated = 1;
+
+ // some pre-initializations (workarounds thread-safe problem
+ // in gss_init_sec_context)
+ globus_gsi_callback_get_SSL_callback_data_index(&index);
#ifdef GLITE_LBU_THREADED
pthread_mutex_unlock(&init_lock);
#endif
* the server.
* */
+#ifdef GLITE_LBU_THREADED
+ // to protect the environment
+ // XXX: only partial fix, every getenv() can still cause race-condition
+ pthread_mutex_lock(&init_lock);
+#endif
orig_cert = getenv("X509_USER_CERT");
orig_key = getenv("X509_USER_KEY");
setenv("X509_USER_KEY", orig_key, 1);
else
unsetenv("X509_USER_KEY");
+#ifdef GLITE_LBU_THREADED
+ pthread_mutex_unlock(&init_lock);
+#endif
if (GSS_ERROR(maj_stat)) {
if (gss_code) {