(groups)
| 464 | |
| 465 | |
| 466 | def _setgroups_hack(groups): |
| 467 | # :fun:`setgroups` may have a platform-dependent limit, |
| 468 | # and it's not always possible to know in advance what this limit |
| 469 | # is, so we use this ugly hack stolen from glibc. |
| 470 | groups = groups[:] |
| 471 | |
| 472 | while 1: |
| 473 | try: |
| 474 | return os.setgroups(groups) |
| 475 | except ValueError: # error from Python's check. |
| 476 | if len(groups) <= 1: |
| 477 | raise |
| 478 | groups[:] = groups[:-1] |
| 479 | except OSError as exc: # error from the OS. |
| 480 | if exc.errno != errno.EINVAL or len(groups) <= 1: |
| 481 | raise |
| 482 | groups[:] = groups[:-1] |
| 483 | |
| 484 | |
| 485 | def setgroups(groups): |
no outgoing calls