| 23 | } |
| 24 | |
| 25 | std::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 | |
| 60 | std::vector<std::string> findGroupsWithPerm(const char* perm, bool skipLocal) { |
| 61 | std::string name; |
no test coverage detected