MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / findGroupsWithPerms

Function findGroupsWithPerms

plugins/plugin_utils/plugin_groups.cpp:25–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25std::vector<std::string> findGroupsWithPerms(const std::vector<std::string> &perms, bool skipLocal) {
26 std::vector<std::string> groupsWithPerms;
27
28 bz_APIStringList* groupList = bz_getGroupList();
29
30 if (groupList) {
31 for (unsigned int i = 0; i < groupList->size(); i++) {
32 std::string groupName = groupList->get(i).c_str();
33
34 if (skipLocal && compare_nocase(groupName, "LOCAL.ADMIN") == 0) {
35 continue;
36 }
37
38 bz_APIStringList* groupPerms = bz_getGroupPerms(groupName.c_str());
39 if (groupPerms) {
40 // see if any of the perms are NOT in this group.
41 bool hasOneWithNoPerm = false;
42 for (size_t p = 0; p < perms.size(); p++) {
43 if (!permInGroup(perms[p], groupPerms)) {
44 hasOneWithNoPerm = true;
45 }
46 }
47 bz_deleteStringList(groupPerms);
48
49 if (!hasOneWithNoPerm) {
50 groupsWithPerms.push_back(groupName);
51 }
52 }
53 }
54 bz_deleteStringList(groupList);
55 }
56
57 return groupsWithPerms;
58}
59
60std::vector<std::string> findGroupsWithPerm(const char* perm, bool skipLocal) {
61 std::string name;

Callers 1

findGroupsWithAdminFunction · 0.85

Calls 7

permInGroupFunction · 0.85
bz_deleteStringListFunction · 0.85
c_strMethod · 0.80
compare_nocaseFunction · 0.70
sizeMethod · 0.45
getMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected