Example #1
0
static struct mg_thread_ctx *
_gss_mechglue_thread(void)
{
    struct mg_thread_ctx *ctx;
    int ret = 0;

    HEIMDAL_MUTEX_lock(&context_mutex);

    if (!created_key) {
	HEIMDAL_key_create(&context_key, destroy_context, ret);
	if (ret) {
	    HEIMDAL_MUTEX_unlock(&context_mutex);
	    return NULL;
	}
	created_key = 1;
    }
    HEIMDAL_MUTEX_unlock(&context_mutex);

    ctx = HEIMDAL_getspecific(context_key);
    if (ctx == NULL) {

	ctx = calloc(1, sizeof(*ctx));
	if (ctx == NULL)
	    return NULL;
	HEIMDAL_setspecific(context_key, ctx, ret);
	if (ret) {
	    free(ctx);
	    return NULL;
	}
    }
    return ctx;
}
Example #2
0
File: init.c Project: gojdic/samba
krb5_error_code
_gsskrb5_init (krb5_context *context)
{
    krb5_error_code ret = 0;

    HEIMDAL_MUTEX_lock(&context_mutex);

    if (!created_key) {
	HEIMDAL_key_create(&context_key, destroy_context, ret);
	if (ret) {
	    HEIMDAL_MUTEX_unlock(&context_mutex);
	    return ret;
	}
	created_key = 1;
    }
    HEIMDAL_MUTEX_unlock(&context_mutex);

    *context = HEIMDAL_getspecific(context_key);
    if (*context == NULL) {

	ret = krb5_init_context(context);
	if (ret == 0) {
	    HEIMDAL_setspecific(context_key, *context, ret);
	    if (ret) {
		krb5_free_context(*context);
		*context = NULL;
	    }
	}
    }

    return ret;
}
static void
once_func(void *ctx)
{
    int ret;

    _gsskrb5_kGSSICPassword = heim_string_create("kGSSICPassword");
    _gsskrb5_kGSSICCertificate = heim_string_create("kGSSICCertificate");
    _gsskrb5_kGSSICKerberosCacheName = heim_string_create("kGSSICKerberosCacheName");
    _gsskrb5_kGSSICLKDCHostname = heim_string_create("kGSSICLKDCHostname");
    _gsskrb5_kGSSICAppIdentifierACL = heim_string_create("kGSSICAppIdentifierACL");
    
    HEIMDAL_key_create(&context_key, destroy_context, ret);
}
Example #4
0
krb5_error_code
_gsskrb5_init (void)
{
    krb5_error_code ret = 0;

    HEIMDAL_MUTEX_lock(&_gsskrb5_context_mutex);

    if(_gsskrb5_context == NULL)
	ret = krb5_init_context (&_gsskrb5_context);
    if (ret == 0 && !created_key) {
	HEIMDAL_key_create(&gssapi_context_key, 
			   gssapi_destroy_thread_context,
			   ret);
	if (ret) {
	    krb5_free_context(_gsskrb5_context);
	    _gsskrb5_context = NULL;
	} else
	    created_key = 1;
    }

    HEIMDAL_MUTEX_unlock(&_gsskrb5_context_mutex);

    return ret;
}