src/server/security-server-cookie.c
/* Search existing cookie from the cookie list for matching cookie and privilege */
/* If privilege is 0, just search cookie exists or not */
Search existing cookie from the cookie list for matching cookie and privilege
If privilege is 0, just search cookie exists or not
Search existing cookie from the cookie list for matching cookie and privilege If privilege is 0 just search cookie exists or not
cookie_list *search_cookie(const cookie_list *c_list, const unsigned char *cookie, int privilege)
{
	cookie_list *current = (cookie_list *)c_list, *retval = NULL;
	int i;
	while(current != NULL)
	{
		current = garbage_collection(current);
		if(current == NULL)
			break;
		if(memcmp(current->cookie, cookie, SECURITY_SERVER_COOKIE_LEN) == 0)
		{
			SEC_SVR_DBG("%s", "cookie has been found");
			if(current->pid == 0 || privilege == 0)
			{
				retval = current;
				goto finish;
			}
			else
			{
				for(i=0 ; i < current->permission_len ; i++)
				{
					if(privilege == current->permissions[i])
					{
						SEC_SVR_DBG("Found privilege %d", privilege);
						retval = current;
						goto finish;
					}
				}
			}
		}
		current = current->next;
	}
finish:
	return retval;
}
cookie_list * search_cookie ( const cookie_list * c_list , const unsigned char * cookie , int privilege ) { cookie_list * current = ( cookie_list * ) c_list , * retval = NULL ; int i ; while ( current != NULL ) { current = garbage_collection ( current ) ; if ( current == NULL ) break ; if ( memcmp ( current -> cookie , cookie , SECURITY_SERVER_COOKIE_LEN ) == 0 ) { SEC_SVR_DBG ( " " , " " ) ; if ( current -> pid == 0 || privilege == 0 ) { retval = current ; goto finish ; } else { for ( i = 0 ; i < current -> permission_len ; i ++ ) { if ( privilege == current -> permissions [ i ] ) { SEC_SVR_DBG ( " " , privilege ) ; retval = current ; goto finish ; } } } } current = current -> next ; } finish : return retval ; }
Search existing cookie from the cookie list for matching cookie and privilege
If privilege is 0, just search cookie exists or not
Search existing cookie from the cookie list for matching cookie and privilege If privilege is 0 just search cookie exists or not
/* Search from the list */ /* print_cookie(current);*/ /* PID must be same */ /* default cookie is for root process which is pid is set to 0 */