Example #1
0
krb5_error_code KRB5_CALLCONV
krb5_c_random_make_octets(krb5_context context, krb5_data *outdata)
{
#ifdef _WIN32
    DWORD pid = GetCurrentProcessId();
#else
    pid_t pid = getpid();
#endif
    unsigned char pidbuf[4];

    k5_mutex_lock(&fortuna_lock);

    if (!have_entropy) {
        k5_mutex_unlock(&fortuna_lock);
        return KRB5_CRYPTO_INTERNAL;
    }

    if (pid != last_pid) {
        /* We forked; make sure child's PRNG stream differs from parent's. */
        store_32_be(pid, pidbuf);
        generator_reseed(&main_state, pidbuf, 4);
        last_pid = pid;
    }

    accumulator_output(&main_state, (unsigned char *)outdata->data,
                       outdata->length);
    k5_mutex_unlock(&fortuna_lock);
    return 0;
}
Example #2
0
void KRB5_CALLCONV
profile_abandon(profile_t profile)
{
    prf_file_t      p, next;
    errcode_t       err;

    if (!profile || profile->magic != PROF_MAGIC_PROFILE)
        return;

    if (profile->vt) {
        if (profile->vt->cleanup)
            profile->vt->cleanup(profile->cbdata);
        if (profile->lib_handle) {
            /* Decrement the refcount on the handle and maybe free it. */
            err = k5_mutex_lock(&profile->lib_handle->lock);
            if (!err && --profile->lib_handle->refcount == 0) {
                krb5int_close_plugin(profile->lib_handle->plugin_handle);
                k5_mutex_unlock(&profile->lib_handle->lock);
                k5_mutex_destroy(&profile->lib_handle->lock);
                free(profile->lib_handle);
            } else if (!err)
                k5_mutex_unlock(&profile->lib_handle->lock);
        }
        free(profile->vt);
    } else {
        for (p = profile->first_file; p; p = next) {
            next = p->next;
            profile_free_file(p);
        }
    }
    profile->magic = 0;
    free(profile);
}
Example #3
0
OM_uint32
krb5_gss_validate_cred_1(OM_uint32 *minor_status, gss_cred_id_t cred_handle,
                         krb5_context context)
{
    krb5_gss_cred_id_t cred;
    krb5_error_code code;
    krb5_principal princ;

    cred = (krb5_gss_cred_id_t) cred_handle;

    code = k5_mutex_lock(&cred->lock);
    if (code) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    if (cred->ccache) {
        if ((code = krb5_cc_get_principal(context, cred->ccache, &princ))) {
            k5_mutex_unlock(&cred->lock);
            *minor_status = code;
            return(GSS_S_DEFECTIVE_CREDENTIAL);
        }
        if (!krb5_principal_compare(context, princ, cred->name->princ)) {
            k5_mutex_unlock(&cred->lock);
            *minor_status = KG_CCACHE_NOMATCH;
            return(GSS_S_DEFECTIVE_CREDENTIAL);
        }
        (void)krb5_free_principal(context, princ);
    }
    *minor_status = 0;
    return GSS_S_COMPLETE;
}
Example #4
0
krb5_error_code KRB5_CALLCONV
krb5_kt_register(krb5_context context, const krb5_kt_ops *ops)
{
    const struct krb5_kt_typelist *t;
    struct krb5_kt_typelist *newt;
    krb5_error_code err;

    err = k5_mutex_lock(&kt_typehead_lock);
    if (err)
	return err;
    for (t = kt_typehead; t && strcmp(t->ops->prefix,ops->prefix);t = t->next)
	;
    if (t) {
	k5_mutex_unlock(&kt_typehead_lock);
	return KRB5_KT_TYPE_EXISTS;
    }
    if (!(newt = (struct krb5_kt_typelist *) malloc(sizeof(*t)))) {
	k5_mutex_unlock(&kt_typehead_lock);
	return ENOMEM;
    }
    newt->next = kt_typehead;
    newt->ops = ops;
    kt_typehead = newt;
    k5_mutex_unlock(&kt_typehead_lock);
    return 0;
}
Example #5
0
/*ARGSUSED*/
krb5_error_code krb5_rc_register_type(krb5_context context,
				      const krb5_rc_ops *ops)
{
 struct krb5_rc_typelist *t;
 krb5_error_code err;

 err = k5_mutex_lock(&rc_typelist_lock);
 if (err)
	return err;

 for (t = typehead;t && strcmp(t->ops->type,ops->type);t = t->next)
   ;
 if (t) {
   k5_mutex_unlock(&rc_typelist_lock);
   return KRB5_RC_TYPE_EXISTS;
 }

 t = (struct krb5_rc_typelist *) malloc(sizeof(struct krb5_rc_typelist));
 if (t == NULL) {
	k5_mutex_unlock(&rc_typelist_lock);
	return KRB5_RC_MALLOC;
 }
 t->next = typehead;
 t->ops = ops;
 typehead = t;

 k5_mutex_unlock(&rc_typelist_lock);
 return 0;
}
/*@-incondefs@*/ /* _et_list is global on unix but not in header annotations */
errcode_t KRB5_CALLCONV
remove_error_table(const struct error_table * et)
/*@modifies _et_list,et_list_dynamic@*/
/*@=incondefs@*/
{
    struct dynamic_et_list **del;
    struct et_list **el;
    int merr;

    if (CALL_INIT_FUNCTION(com_err_initialize))
        return 0;
    merr = k5_mutex_lock(&et_list_lock);
    if (merr)
        return merr;

    /* Remove the entry that matches the error table instance.  Prefer dynamic
       entries, but if there are none, check for a static one too.  */
    for (del = &et_list_dynamic; *del; del = &(*del)->next)
        if ((*del)->table == et) {
            /*@only@*/ struct dynamic_et_list *old = *del;
            *del = old->next;
            free (old);
            return k5_mutex_unlock(&et_list_lock);
        }
    for (el = &_et_list; *el; el = &(*el)->next)
        if ((*el)->table == et) {
            struct et_list *old = *el;
            *el = old->next;
            old->next = NULL;
            old->table = NULL;
            return k5_mutex_unlock(&et_list_lock);
        }
    k5_mutex_unlock(&et_list_lock);
    return ENOENT;
}
Example #7
0
OM_uint32 KRB5_CALLCONV
krb5_gss_release_any_name_mapping(OM_uint32 *minor_status,
                                  gss_name_t name,
                                  gss_buffer_t type_id,
                                  gss_any_t *input)
{
    krb5_context context;
    krb5_error_code code;
    krb5_gss_name_t kname;
    char *kmodule;

    if (minor_status != NULL)
        *minor_status = 0;

    code = krb5_gss_init_context(&context);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    kname = (krb5_gss_name_t)name;

    code = k5_mutex_lock(&kname->lock);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    if (kname->ad_context == NULL) {
        code = krb5_authdata_context_init(context, &kname->ad_context);
        if (code != 0) {
            *minor_status = code;
            k5_mutex_unlock(&kname->lock);
            krb5_free_context(context);
            return GSS_S_UNAVAILABLE;
        }
    }

    kmodule = (char *)type_id->value;
    if (kmodule[type_id->length] != '\0') {
        k5_mutex_unlock(&kname->lock);
        krb5_free_context(context);
        return GSS_S_UNAVAILABLE;
    }

    code = krb5_authdata_free_internal(context,
                                       kname->ad_context,
                                       kmodule,
                                       *input);
    if (code == 0)
        *input = NULL;

    k5_mutex_unlock(&kname->lock);
    krb5_free_context(context);

    return kg_map_name_error(minor_status, code);

}
Example #8
0
File: prof_set.c Project: WeiY/krb5
/*
 * Insert a new relation.  If the new_value argument is NULL, then
 * create a new section instead.
 *
 * Note: if the intermediate sections do not exist, this function will
 * automatically create them.
 *
 * ADL - 2/23/99, rewritten TYT 2/25/99
 */
errcode_t KRB5_CALLCONV
profile_add_relation(profile_t profile, const char **names,
                     const char *new_value)
{
    errcode_t       retval;
    struct profile_node *section;
    const char      **cpp;
    void            *state;

    if (profile->vt) {
        if (!profile->vt->add_relation)
            return PROF_UNSUPPORTED;
        return profile->vt->add_relation(profile->cbdata, names, new_value);
    }

    retval = rw_setup(profile);
    if (retval)
        return retval;

    if (names == 0 || names[0] == 0 || names[1] == 0)
        return PROF_BAD_NAMESET;

    k5_mutex_lock(&profile->first_file->data->lock);
    section = profile->first_file->data->root;
    for (cpp = names; cpp[1]; cpp++) {
        state = 0;
        retval = profile_find_node(section, *cpp, 0, 1,
                                   &state, &section);
        if (retval == PROF_NO_SECTION)
            retval = profile_add_node(section, *cpp, 0, &section);
        if (retval) {
            k5_mutex_unlock(&profile->first_file->data->lock);
            return retval;
        }
    }

    if (new_value == 0) {
        retval = profile_find_node(section, *cpp, 0, 1, &state, 0);
        if (retval == 0) {
            k5_mutex_unlock(&profile->first_file->data->lock);
            return PROF_EXISTS;
        } else if (retval != PROF_NO_SECTION) {
            k5_mutex_unlock(&profile->first_file->data->lock);
            return retval;
        }
    }

    retval = profile_add_node(section, *cpp, new_value, 0);
    if (retval) {
        k5_mutex_unlock(&profile->first_file->data->lock);
        return retval;
    }

    profile->first_file->data->flags |= PROFILE_FILE_DIRTY;
    k5_mutex_unlock(&profile->first_file->data->lock);
    return 0;
}
Example #9
0
OM_uint32 KRB5_CALLCONV
krb5_gss_set_name_attribute(OM_uint32 *minor_status,
                            gss_name_t name,
                            int complete,
                            gss_buffer_t attr,
                            gss_buffer_t value)
{
    krb5_context context;
    krb5_error_code code;
    krb5_gss_name_t kname;
    krb5_data kattr;
    krb5_data kvalue;

    if (minor_status != NULL)
        *minor_status = 0;

    code = krb5_gss_init_context(&context);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    kname = (krb5_gss_name_t)name;

    code = k5_mutex_lock(&kname->lock);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    if (kname->ad_context == NULL) {
        code = krb5_authdata_context_init(context, &kname->ad_context);
        if (code != 0) {
            *minor_status = code;
            k5_mutex_unlock(&kname->lock);
            krb5_free_context(context);
            return GSS_S_UNAVAILABLE;
        }
    }

    kattr.data = (char *)attr->value;
    kattr.length = attr->length;

    kvalue.data = (char *)value->value;
    kvalue.length = value->length;

    code = krb5_authdata_set_attribute(context,
                                       kname->ad_context,
                                       complete,
                                       &kattr,
                                       &kvalue);

    k5_mutex_unlock(&kname->lock);
    krb5_free_context(context);

    return kg_map_name_error(minor_status, code);
}
Example #10
0
OM_uint32
krb5_gss_delete_name_attribute(OM_uint32 *minor_status,
                               gss_name_t name,
                               gss_buffer_t attr)
{
    krb5_context context;
    krb5_error_code code;
    krb5_gss_name_t kname;
    krb5_data kattr;

    if (minor_status != NULL)
        *minor_status = 0;

    code = krb5_gss_init_context(&context);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    if (!kg_validate_name(name)) {
        *minor_status = (OM_uint32)G_VALIDATE_FAILED;
        krb5_free_context(context);
        return GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME;
    }

    kname = (krb5_gss_name_t)name;

    code = k5_mutex_lock(&kname->lock);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    if (kname->ad_context == NULL) {
        code = krb5_authdata_context_init(context, &kname->ad_context);
        if (code != 0) {
            *minor_status = code;
            k5_mutex_unlock(&kname->lock);
            krb5_free_context(context);
            return GSS_S_UNAVAILABLE;
        }
    }

    kattr.data = (char *)attr->value;
    kattr.length = attr->length;

    code = krb5_authdata_delete_attribute(context,
                                          kname->ad_context,
                                          &kattr);

    k5_mutex_unlock(&kname->lock);
    krb5_free_context(context);

    return kg_map_name_error(minor_status, code);
}
Example #11
0
File: prof_set.c Project: WeiY/krb5
/*
 * Delete or update a particular child node
 *
 * ADL - 2/23/99, rewritten TYT 2/25/99
 */
errcode_t KRB5_CALLCONV
profile_update_relation(profile_t profile, const char **names,
                        const char *old_value, const char *new_value)
{
    errcode_t       retval;
    struct profile_node *section, *node;
    void            *state;
    const char      **cpp;

    if (profile->vt) {
        if (!profile->vt->update_relation)
            return PROF_UNSUPPORTED;
        return profile->vt->update_relation(profile->cbdata, names, old_value,
                                            new_value);
    }

    retval = rw_setup(profile);
    if (retval)
        return retval;

    if (names == 0 || names[0] == 0 || names[1] == 0)
        return PROF_BAD_NAMESET;

    if (!old_value || !*old_value)
        return PROF_EINVAL;

    k5_mutex_lock(&profile->first_file->data->lock);
    section = profile->first_file->data->root;
    for (cpp = names; cpp[1]; cpp++) {
        state = 0;
        retval = profile_find_node(section, *cpp, 0, 1,
                                   &state, &section);
        if (retval) {
            k5_mutex_unlock(&profile->first_file->data->lock);
            return retval;
        }
    }

    state = 0;
    retval = profile_find_node(section, *cpp, old_value, 0, &state, &node);
    if (retval == 0) {
        if (new_value)
            retval = profile_set_relation_value(node, new_value);
        else
            retval = profile_remove_node(node);
    }
    if (retval == 0)
        profile->first_file->data->flags |= PROFILE_FILE_DIRTY;
    k5_mutex_unlock(&profile->first_file->data->lock);

    return retval;
}
Example #12
0
cc_int32 cci_context_change_time_update (cci_identifier_t in_identifier,
                                         cc_time_t        in_new_change_time)
{
    cc_int32 err = ccNoError;
    cc_int32 lock_err = err = k5_mutex_lock (&g_change_time_mutex);
    
    if (!err) {
        if (!in_identifier) { err = cci_check_error (err); }
    }
    
    if (!err) {
        if (g_change_time < in_new_change_time) {
            /* Only update if it increases the time.  May be a different server. */
            g_change_time = in_new_change_time;
            cci_debug_printf ("%s: setting change time to %d", 
                              __FUNCTION__, in_new_change_time);
        }
    }
    
    if (!err) {
        err = cci_context_change_time_update_identifier (in_identifier,
                                                         NULL, NULL, NULL);
    }
    
    if (!lock_err) {
        k5_mutex_unlock (&g_change_time_mutex);
    }

    return err;
}
Example #13
0
errcode_t KRB5_CALLCONV
add_error_table(const struct error_table *et)
{
    struct et_list *e;

    if (CALL_INIT_FUNCTION(com_err_initialize))
        return 0;

    e = malloc(sizeof(struct et_list));
    if (e == NULL)
        return ENOMEM;

    e->table = et;

    k5_mutex_lock(&et_list_lock);
    e->next = et_list;
    et_list = e;

    /* If there are two strings at the end of the table, they are a text domain
     * and locale dir, and we are supposed to call bindtextdomain. */
    if (et->msgs[et->n_msgs] != NULL && et->msgs[et->n_msgs + 1] != NULL)
        bindtextdomain(et->msgs[et->n_msgs], et->msgs[et->n_msgs + 1]);

    k5_mutex_unlock(&et_list_lock);
    return 0;
}
Example #14
0
void KRB5_CALLCONV com_err_va(const char *whoami,
			      errcode_t code,
			      const char *fmt,
			      va_list ap)
{
    int err;
    et_old_error_hook_func p;

    err = com_err_finish_init();
    if (err)
	goto best_try;
    err = k5_mutex_lock(&com_err_hook_lock);
    if (err)
	goto best_try;
    p = com_err_hook ? com_err_hook : default_com_err_proc;
    (*p)(whoami, code, fmt, ap);
    k5_mutex_unlock(&com_err_hook_lock);
    return;

best_try:
    /* Yikes.  Our library initialization failed or we couldn't lock
       the lock we want.  We could be in trouble.  Gosh, we should
       probably print an error message.  Oh, wait.  That's what we're
       trying to do.  In fact, if we're losing on initialization here,
       there's a good chance it has to do with failed initialization
       of the caller.  */
    if (!com_err_hook)
	default_com_err_proc(whoami, code, fmt, ap);
    else
	(com_err_hook)(whoami, code, fmt, ap);
    assert(err == 0);
    abort();
}
Example #15
0
File: threads.c Project: WeiY/krb5
static void thread_termination (void *tptr)
{
    int i, pass, none_found;
    struct tsd_block *t = tptr;

    k5_mutex_lock(&key_lock);

    /*
     * Make multiple passes in case, for example, a libkrb5 cleanup
     * function wants to print out an error message, which causes
     * com_err to allocate a thread-specific buffer, after we just
     * freed up the old one.
     *
     * Shouldn't actually happen, if we're careful, but check just in
     * case.
     */

    pass = 0;
    none_found = 0;
    while (pass < 4 && !none_found) {
        none_found = 1;
        for (i = 0; i < K5_KEY_MAX; i++) {
            if (destructors_set[i] && destructors[i] && t->values[i]) {
                void *v = t->values[i];
                t->values[i] = 0;
                (*destructors[i])(v);
                none_found = 0;
            }
        }
    }
    free (t);
    k5_mutex_unlock(&key_lock);

    /* remove thread from global linked list */
}
Example #16
0
/* Run one invocation of the callback, unlocking the mutex and possibly the DB
 * around the invocation. */
static krb5_error_code
curs_run_cb(iter_curs *curs, ctx_iterate_cb func, krb5_pointer func_arg)
{
    krb5_db2_context *dbc = curs->dbc;
    krb5_error_code retval, lockerr;
    krb5_db_entry *entry;
    krb5_context ctx = curs->ctx;
    krb5_data contdata;

    contdata = make_data(curs->data.data, curs->data.size);
    retval = krb5_decode_princ_entry(ctx, &contdata, &entry);
    if (retval)
        return retval;
    /* Save libdb key across possible DB closure. */
    retval = curs_save(curs);
    if (retval)
        return retval;

    if (dbc->unlockiter)
        curs_unlock(curs);

    k5_mutex_unlock(krb5_db2_mutex);
    retval = (*func)(func_arg, entry);
    krb5_db2_free(ctx, entry);
    k5_mutex_lock(krb5_db2_mutex);
    if (dbc->unlockiter) {
        lockerr = curs_lock(curs);
        if (lockerr)
            return lockerr;
    }
    return retval;
}
Example #17
0
static kim_error kim_error_set_message (kim_error  in_error,
                                        kim_string in_message)
{
    int lock_err = 0;
    kim_error err = KIM_NO_ERROR;
    kim_last_error last_error = NULL;

    err = lock_err = k5_mutex_lock (&kim_error_lock);

    if (!err) {
        last_error = k5_getspecific (K5_KEY_KIM_ERROR_MESSAGE);

        if (!last_error) {
            last_error = malloc (sizeof (*last_error));
            if (!last_error) {
                err = KIM_OUT_OF_MEMORY_ERR;
            } else {
                last_error->code = KIM_NO_ERROR;
                err = k5_setspecific (K5_KEY_KIM_ERROR_MESSAGE, last_error);
            }
        }
    }

    if (!err) {
        strncpy (last_error->message, in_message, sizeof (last_error->message));
        last_error->message[sizeof (last_error->message)-1] = '\0';
        last_error->code = in_error;
    }

    if (!lock_err) { k5_mutex_unlock (&kim_error_lock); }

    return err;
}
Example #18
0
krb5_error_code KRB5_CALLCONV
krb5_c_random_add_entropy(krb5_context context, unsigned int randsource,
                          const krb5_data *indata)
{
    krb5_error_code ret;

    ret = krb5int_crypto_init();
    if (ret)
        return ret;
    k5_mutex_lock(&fortuna_lock);
    if (randsource == KRB5_C_RANDSOURCE_OSRAND ||
        randsource == KRB5_C_RANDSOURCE_TRUSTEDPARTY) {
        /* These sources contain enough entropy that we should use them
         * immediately, so that they benefit the next request. */
        generator_reseed(&main_state, (unsigned char *)indata->data,
                         indata->length);
        have_entropy = TRUE;
    } else {
        /* Other sources should just go into the pools and be used according to
         * the accumulator logic. */
        accumulator_add_event(&main_state, (unsigned char *)indata->data,
                              indata->length);
    }
    k5_mutex_unlock(&fortuna_lock);
    return 0;
}
/*@-incondefs@*/ /* _et_list is global on unix but not in header annotations */
errcode_t KRB5_CALLCONV
add_error_table(/*@dependent@*/ const struct error_table * et)
/*@modifies _et_list,et_list_dynamic@*/
/*@=incondefs@*/
{
    struct dynamic_et_list *del;
    int merr;

    if (CALL_INIT_FUNCTION(com_err_initialize))
        return 0;

    del = (struct dynamic_et_list *)malloc(sizeof(struct dynamic_et_list));
    if (del == NULL)
        return ENOMEM;

    del->table = et;

    merr = k5_mutex_lock(&et_list_lock);
    if (merr) {
        free(del);
        return merr;
    }
    del->next = et_list_dynamic;
    et_list_dynamic = del;
    return k5_mutex_unlock(&et_list_lock);
}
Example #20
0
errcode_t profile_flush_file_data(prf_data_t data)
{
    errcode_t       retval = 0;

    if (!data || data->magic != PROF_MAGIC_FILE_DATA)
        return PROF_MAGIC_FILE_DATA;

    k5_mutex_lock(&data->lock);

    if ((data->flags & PROFILE_FILE_DIRTY) == 0) {
        k5_mutex_unlock(&data->lock);
        return 0;
    }

    retval = write_data_to_file(data, data->filespec, 0);
    k5_mutex_unlock(&data->lock);
    return retval;
}
Example #21
0
OM_uint32 KRB5_CALLCONV
krb5_gss_inquire_name(OM_uint32 *minor_status,
                      gss_name_t name,
                      int *name_is_MN,
                      gss_OID *MN_mech,
                      gss_buffer_set_t *attrs)
{
    krb5_context context;
    krb5_error_code code;
    krb5_gss_name_t kname;
    krb5_data *kattrs = NULL;

    if (minor_status != NULL)
        *minor_status = 0;

    if (attrs != NULL)
        *attrs = GSS_C_NO_BUFFER_SET;

    code = krb5_gss_init_context(&context);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    kname = (krb5_gss_name_t)name;

    code = k5_mutex_lock(&kname->lock);
    if (code != 0) {
        *minor_status = code;
        return GSS_S_FAILURE;
    }

    if (kname->ad_context == NULL) {
        code = krb5_authdata_context_init(context, &kname->ad_context);
        if (code != 0)
            goto cleanup;
    }

    code = krb5_authdata_get_attribute_types(context,
                                             kname->ad_context,
                                             &kattrs);
    if (code != 0)
        goto cleanup;

    code = data_list_to_buffer_set(context, kattrs, attrs);
    kattrs = NULL;
    if (code != 0)
        goto cleanup;

cleanup:
    k5_mutex_unlock(&kname->lock);
    krb5int_free_data_list(context, kattrs);

    krb5_free_context(context);

    return kg_map_name_error(minor_status, code);
}
Example #22
0
errcode_t profile_flush_file_data_to_buffer (prf_data_t data, char **bufp)
{
    errcode_t       retval;

    k5_mutex_lock(&data->lock);
    retval = profile_write_tree_to_buffer(data->root, bufp);
    k5_mutex_unlock(&data->lock);
    return retval;
}
Example #23
0
void profile_dereference_data(prf_data_t data)
{
    int err;
    err = k5_mutex_lock(&g_shared_trees_mutex);
    if (err)
	return;
    profile_dereference_data_locked(data);
    (void) k5_mutex_unlock(&g_shared_trees_mutex);
}
Example #24
0
errcode_t profile_update_file_data(prf_data_t data, char **ret_modspec)
{
    errcode_t retval;

    k5_mutex_lock(&data->lock);
    retval = profile_update_file_data_locked(data, ret_modspec);
    k5_mutex_unlock(&data->lock);
    return retval;
}
Example #25
0
krb5_error_code KRB5_CALLCONV
krb5_rc_dfl_expunge(krb5_context context, krb5_rcache id)
{
    krb5_error_code ret;

    k5_mutex_lock(&id->lock);
    ret = krb5_rc_dfl_expunge_locked(context, id);
    k5_mutex_unlock(&id->lock);
    return ret;
}
Example #26
0
krb5_error_code KRB5_CALLCONV
krb5_rc_dfl_close(krb5_context context, krb5_rcache id)
{
    k5_mutex_lock(&id->lock);
    krb5_rc_dfl_close_no_free(context, id);
    k5_mutex_unlock(&id->lock);
    k5_mutex_destroy(&id->lock);
    free(id);
    return 0;
}
Example #27
0
krb5_error_code KRB5_CALLCONV
krb5_rc_dfl_init(krb5_context context, krb5_rcache id, krb5_deltat lifespan)
{
    krb5_error_code retval;

    k5_mutex_lock(&id->lock);
    retval = krb5_rc_dfl_init_locked(context, id, lifespan);
    k5_mutex_unlock(&id->lock);
    return retval;
}
Example #28
0
/*ARGSUSED*/
krb5_error_code krb5_rc_resolve_type(krb5_context context, krb5_rcache *id,
				     char *type)
{
    struct krb5_rc_typelist *t;
    krb5_error_code err;
    err = k5_mutex_lock(&rc_typelist_lock);
    if (err)
	return err;
    for (t = typehead;t && strcmp(t->ops->type,type);t = t->next)
	;
    if (!t) {
	k5_mutex_unlock(&rc_typelist_lock);
	return KRB5_RC_TYPE_NOTFOUND;
    }
    /* allocate *id? nah */
    (*id)->ops = t->ops;
    k5_mutex_unlock(&rc_typelist_lock);
    return k5_mutex_init(&(*id)->lock);
}
Example #29
0
kim_error kim_os_library_unlock_for_bundle_lookup (void)
{
    kim_error err = CALL_INIT_FUNCTION (kim_os_library_thread_init);

    if (!err) {
        err = k5_mutex_unlock (&g_bundle_lookup_mutex);
    }

    return err;
}
Example #30
0
/* 
 * Rename a particular section; if the new_section name is NULL,
 * delete it.
 * 
 * ADL - 2/23/99, rewritten TYT 2/25/99
 */
errcode_t KRB5_CALLCONV
profile_rename_section(profile_t profile, const char **names,
		       const char *new_name)
{	
	errcode_t	retval;
	struct profile_node *section, *node;
	void		*state;
	const char	**cpp;
	
	retval = rw_setup(profile);
	if (retval)
		return retval;
	
	if (names == 0 || names[0] == 0 || names[1] == 0)
		return PROF_BAD_NAMESET;

	retval = k5_mutex_lock(&profile->first_file->data->lock);
	if (retval)
	    return retval;
	section = profile->first_file->data->root;
	for (cpp = names; cpp[1]; cpp++) {
		state = 0;
		retval = profile_find_node(section, *cpp, 0, 1,
					   &state, &section);
		if (retval) {
		    k5_mutex_unlock(&profile->first_file->data->lock);
		    return retval;
		}
	}

	state = 0;
	retval = profile_find_node(section, *cpp, 0, 1, &state, &node);
	if (retval == 0) {
	    if (new_name)
		retval = profile_rename_node(node, new_name);
	    else
		retval = profile_remove_node(node);
	}
	if (retval == 0)
	    profile->first_file->data->flags |= PROFILE_FILE_DIRTY;
	k5_mutex_unlock(&profile->first_file->data->lock);
	return retval;
}