Parse group id. Arguments: gid (str, int): Actual gid, or the name of a group. Returns: int: The actual gid of the group.
(gid)
| 511 | |
| 512 | |
| 513 | def parse_gid(gid): |
| 514 | """Parse group id. |
| 515 | |
| 516 | Arguments: |
| 517 | gid (str, int): Actual gid, or the name of a group. |
| 518 | Returns: |
| 519 | int: The actual gid of the group. |
| 520 | """ |
| 521 | try: |
| 522 | return int(gid) |
| 523 | except ValueError: |
| 524 | try: |
| 525 | return grp.getgrnam(gid).gr_gid |
| 526 | except (AttributeError, KeyError): |
| 527 | raise KeyError(f'Group does not exist: {gid}') |
| 528 | |
| 529 | |
| 530 | def _setgroups_hack(groups): |
no outgoing calls