(groups)
| 528 | |
| 529 | |
| 530 | def _setgroups_hack(groups): |
| 531 | # :fun:`setgroups` may have a platform-dependent limit, |
| 532 | # and it's not always possible to know in advance what this limit |
| 533 | # is, so we use this ugly hack stolen from glibc. |
| 534 | groups = groups[:] |
| 535 | |
| 536 | while 1: |
| 537 | try: |
| 538 | return os.setgroups(groups) |
| 539 | except ValueError: # error from Python's check. |
| 540 | if len(groups) <= 1: |
| 541 | raise |
| 542 | groups[:] = groups[:-1] |
| 543 | except OSError as exc: # error from the OS. |
| 544 | if exc.errno != errno.EINVAL or len(groups) <= 1: |
| 545 | raise |
| 546 | groups[:] = groups[:-1] |
| 547 | |
| 548 | |
| 549 | def setgroups(groups): |
no outgoing calls