void cPlayer::AddToGroup( const AString & a_GroupName ) { cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName ); m_Groups.push_back( Group ); LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); ResolvePermissions(); }
void cPlayer::RemoveFromGroup( const AString & a_GroupName ) { bool bRemoved = false; for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr ) { if( (*itr)->GetName().compare(a_GroupName ) == 0 ) { m_Groups.erase( itr ); bRemoved = true; break; } } if( bRemoved ) { LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); ResolvePermissions(); } else { LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str() ); } }
static DWORD QueryMemberOf( VOID ) { DWORD dwError = 0; HANDLE hLsa = NULL; DWORD dwIndex = 0; PLSA_SECURITY_OBJECT* ppObjects = NULL; PSTR pszSid = NULL; PSTR* ppszSids = NULL; DWORD dwSidCount = 0; DWORD dwGroupSidCount = 0; PSTR* ppszGroupSids = NULL; dwError = LsaOpenServer(&hLsa); BAIL_ON_LSA_ERROR(dwError); dwError = LwAllocateMemory(sizeof(*ppszSids) * gState.dwCount, OUT_PPVOID(&ppszSids)); BAIL_ON_LSA_ERROR(dwError); for (dwIndex = 0; dwIndex < gState.dwCount; dwIndex++) { dwError = ResolveSid(hLsa, gState.QueryType, gState.QueryList, dwIndex, &pszSid); BAIL_ON_LSA_ERROR(dwError); if (!pszSid) { switch(gState.QueryType) { case LSA_QUERY_TYPE_BY_UNIX_ID: printf("Not found: %lu\n\n", (unsigned long) gState.QueryList.pdwIds[dwIndex]); if (gState.dwCount == 1) { dwError = LW_ERROR_NO_SUCH_OBJECT; BAIL_ON_LSA_ERROR(dwError); } break; default: printf("Not found: %s\n\n", gState.QueryList.ppszStrings[dwIndex]); if (gState.dwCount == 1) { dwError = LW_ERROR_NO_SUCH_OBJECT; BAIL_ON_LSA_ERROR(dwError); } break; } } else { ppszSids[dwSidCount++] = pszSid; pszSid = NULL; } } dwError = LsaQueryMemberOf( hLsa, gState.pszTargetProvider, gState.FindFlags, dwSidCount, ppszSids, &dwGroupSidCount, &ppszGroupSids); BAIL_ON_LSA_ERROR(dwError); dwError = ResolveGroups(hLsa, dwGroupSidCount, ppszGroupSids, &ppObjects); BAIL_ON_LSA_ERROR(dwError); for (dwIndex = 0; dwIndex < dwGroupSidCount; dwIndex++) { if (ppObjects[dwIndex]) { PrintSecurityObject(ppObjects[dwIndex], dwIndex, dwGroupSidCount, gState.bPBOutputMode); if (!gState.bPBOutputMode) { printf("\n"); } } else { printf("Unresolvable SID [%u of %u] (%s)\n\n", dwIndex + 1, dwGroupSidCount, ppszGroupSids[dwIndex]); } } cleanup: LW_SAFE_FREE_MEMORY(pszSid); if (ppszGroupSids) { LsaFreeSidList(dwGroupSidCount, ppszGroupSids); } if (ppszSids) { LsaFreeSidList(dwSidCount, ppszSids); } if (hLsa) { LsaCloseServer(hLsa); } if (ppObjects) { LsaFreeSecurityObjectList(dwGroupSidCount, ppObjects); } return dwError; error: goto cleanup; }