Пример #1
0
status_t
NameToUID(void* buffer)
{
	char* userName = reinterpret_cast<char*>(buffer);

	struct passwd* userInfo = NULL;

	if (MatchDomain(userName) == B_OK)
		userInfo = getpwnam(userName);

	if (userInfo == NULL)
		return write_port(gReplyPort, MsgReply, &gNobodyId, sizeof(gNobodyId));

	return write_port(gReplyPort, MsgReply, &userInfo->pw_uid, sizeof(uid_t));
}
Пример #2
0
BOOL GfwList_Match(const char *Domain, int *HashValue)
{
	BOOL Result;

	if( MainContainer == NULL )
	{
		return FALSE;
	}

	RWLock_RdLock(GFWListLock);

	Result = MatchDomain(&(MainContainer -> GFWList), Domain, HashValue);

	RWLock_UnRLock(GFWListLock);

	return Result;
}
Пример #3
0
status_t
NameToGID(void* buffer)
{
	char* groupName = reinterpret_cast<char*>(buffer);
	
	struct group* groupInfo = NULL;

	if (MatchDomain(groupName) == B_OK)
		groupInfo = getgrnam(groupName);

	if (groupInfo == NULL) {
		return write_port(gReplyPort, MsgReply, &gNogroupId,
			sizeof(gNogroupId));
	}

	return write_port(gReplyPort, MsgReply, &groupInfo->gr_gid, sizeof(gid_t));
}
Пример #4
0
static BOOL ParseGfwListItem(char *Item, GFWListContainer *Container)
{
	char *Itr = NULL;

	if( strchr(Item, '/') != NULL || *Item == '@' || strchr(Item, '?') != NULL || *Item == '!' || strchr(Item, '.') == NULL || *Item == '[' )
	{
		return FALSE;
	}

	if( strchr(Item, '*') != NULL )
	{
		if( strstr("wikipedia.org", Item) == 0 )
		{
			Itr = strchr(Item + 13, '*');
			if( Itr != NULL )
			{
				*Itr = '\0';
			}
		} else {
			return FALSE;
		}
	}

	if( *Item == '|' )
	{
		for(++Item; *Item == '|'; ++Item);
	}

	if( *Item == '.' )
	{
		++Item;
	}

	if( strncmp("http://", Item, 7) == 0 )
	{
		Item += 7;
	}

	if( strncmp("https://", Item, 8) == 0 )
	{
		Item += 8;
	}

	Itr = strchr(Item, '/');
	if( Itr != NULL )
	{
		*Itr = '\0';
	}

	if( strchr(Item, '%') != NULL )
	{
		return FALSE;
	}

	if( MatchDomain(&(Container -> GFWList), Item, NULL) == FALSE )
	{
		StringChunk_Add(&(Container -> GFWList), Item, NULL, 0);
		return TRUE;
	} else {
		return FALSE;
	}

}