* Check if gid is a member of the group set. */
| 1270 | * Check if gid is a member of the group set. |
| 1271 | */ |
| 1272 | int |
| 1273 | groupmember(gid_t gid, struct ucred *cred) |
| 1274 | { |
| 1275 | int l; |
| 1276 | int h; |
| 1277 | int m; |
| 1278 | |
| 1279 | if (cred->cr_groups[0] == gid) |
| 1280 | return(1); |
| 1281 | |
| 1282 | /* |
| 1283 | * If gid was not our primary group, perform a binary search |
| 1284 | * of the supplemental groups. This is possible because we |
| 1285 | * sort the groups in crsetgroups(). |
| 1286 | */ |
| 1287 | l = 1; |
| 1288 | h = cred->cr_ngroups; |
| 1289 | while (l < h) { |
| 1290 | m = l + ((h - l) / 2); |
| 1291 | if (cred->cr_groups[m] < gid) |
| 1292 | l = m + 1; |
| 1293 | else |
| 1294 | h = m; |
| 1295 | } |
| 1296 | if ((l < cred->cr_ngroups) && (cred->cr_groups[l] == gid)) |
| 1297 | return (1); |
| 1298 | |
| 1299 | return (0); |
| 1300 | } |
| 1301 | |
| 1302 | /* |
| 1303 | * Test the active securelevel against a given level. securelevel_gt() |
no outgoing calls
no test coverage detected