Ejemplo n.º 1
0
static void
authenticateAuthUserRequestFree(auth_user_request_t * auth_user_request)
{
    dlink_node *link;
    debug(29, 5) ("authenticateAuthUserRequestFree: freeing request %p\n", auth_user_request);
    if (!auth_user_request)
	return;
    assert(auth_user_request->references == 0);
    if (auth_user_request->auth_user) {
	if (auth_user_request->scheme_data != NULL) {
	    /* we MUST know the module */
	    assert((auth_user_request->auth_user->auth_module > 0));
	    /* and the module MUST support requestFree if it has created scheme data */
	    assert(authscheme_list[auth_user_request->auth_user->auth_module - 1].requestFree != NULL);
	    authscheme_list[auth_user_request->auth_user->auth_module - 1].requestFree(auth_user_request);
	}
	/* unlink from the auth_user struct */
	link = auth_user_request->auth_user->requests.head;
	while (link && (link->data != auth_user_request))
	    link = link->next;
	assert(link != NULL);
	dlinkDelete(link, &auth_user_request->auth_user->requests);
	dlinkNodeDelete(link);

	/* unlock the request structure's lock */
	authenticateAuthUserUnlock(auth_user_request->auth_user);
	auth_user_request->auth_user = NULL;
    } else
	assert(auth_user_request->scheme_data == NULL);
    if (auth_user_request->message)
	xfree(auth_user_request->message);
    memPoolFree(auth_user_request_pool, auth_user_request);
}
Ejemplo n.º 2
0
static void
authDigestNonceUserUnlink(digest_nonce_h * nonce)
{
    digest_user_h *digest_user;
    dlink_node *link, *tmplink;
    if (!nonce)
	return;
    if (!nonce->auth_user)
	return;
    digest_user = nonce->auth_user->scheme_data;
    /* unlink from the user list. Yes we're crossing structures but this is the only 
     * time this code is needed
     */
    link = digest_user->nonces.head;
    while (link) {
	tmplink = link;
	link = link->next;
	if (tmplink->data == nonce) {
	    dlinkDelete(tmplink, &digest_user->nonces);
	    authDigestNonceUnlink(tmplink->data);
	    dlinkNodeDelete(tmplink);
	    link = NULL;
	}
    }
    /* this reference to auth_user was not locked because freeeing the auth_user frees
     * the nonce too. 
     */
    nonce->auth_user = NULL;
}
Ejemplo n.º 3
0
void
authenticateFreeProxyAuthUser(void *data)
{
	auth_user_t *u = data;
	auth_user_request_t *auth_user_request;
	dlink_node *link, *tmplink;
	assert(data != NULL);
	debug(29, 5) ("authenticateFreeProxyAuthUser: Freeing auth_user '%p' with refcount '%ld'.\n", u, (long int) u->references);
	assert(u->references == 0);
	/* were they linked in by username ? */
	if (u->usernamehash)
	{
		assert(u->usernamehash->auth_user == u);
		debug(29, 5) ("authenticateFreeProxyAuthUser: removing usernamehash entry '%p'\n", u->usernamehash);
		hash_remove_link(proxy_auth_username_cache,
						 (hash_link *) u->usernamehash);
		/* don't free the key as we use the same user string as the auth_user
		 * structure */
		memFree(u->usernamehash, MEM_AUTH_USER_HASH);
	}
	/* remove any outstanding requests */
	link = u->requests.head;
	while (link)
	{
		debug(29, 5) ("authenticateFreeProxyAuthUser: removing request entry '%p'\n", link->data);
		auth_user_request = link->data;
		tmplink = link;
		link = link->next;
		dlinkDelete(tmplink, &u->requests);
		dlinkNodeDelete(tmplink);
		authenticateAuthUserRequestFree(auth_user_request);
	}
	/* free cached acl results */
	aclCacheMatchFlush(&u->proxy_match_cache);
	/* free seen ip address's */
	authenticateAuthUserClearIp(u);
	if (u->scheme_data && u->auth_module > 0)
		authscheme_list[u->auth_module - 1].FreeUser(u);
	/* prevent accidental reuse */
	u->auth_type = AUTH_UNKNOWN;
	memFree(u, MEM_AUTH_USER_T);
}
Ejemplo n.º 4
0
static void
authenticateDigestUserFree(auth_user_t * auth_user)
{
    digest_user_h *digest_user = auth_user->scheme_data;
    dlink_node *link, *tmplink;
    debug(29, 9) ("authenticateDigestFreeUser: Clearing Digest scheme data\n");
    if (!digest_user)
	return;
    safe_free(digest_user->username);

    link = digest_user->nonces.head;
    while (link) {
	tmplink = link;
	link = link->next;
	dlinkDelete(tmplink, &digest_user->nonces);
	authDigestNoncePurge(tmplink->data);
	authDigestNonceUnlink(tmplink->data);
	dlinkNodeDelete(tmplink);
    }

    memPoolFree(digest_user_pool, auth_user->scheme_data);
    auth_user->scheme_data = NULL;
}