MCPcopy
hub / github.com/celery/celery / initgroups

Function initgroups

celery/platforms.py:502–515  ·  view source on GitHub ↗

Init process group permissions. Compat version of :func:`os.initgroups` that was first added to Python 2.7.

(uid, gid)

Source from the content-addressed store, hash-verified

500
501
502def initgroups(uid, gid):
503 """Init process group permissions.
504
505 Compat version of :func:`os.initgroups` that was first
506 added to Python 2.7.
507 """
508 if not pwd: # pragma: no cover
509 return
510 username = pwd.getpwuid(uid)[0]
511 if hasattr(os, 'initgroups'): # Python 2.7+
512 return os.initgroups(username, gid)
513 groups = [gr.gr_gid for gr in grp.getgrall()
514 if username in gr.gr_mem]
515 setgroups(groups)
516
517
518def setgid(gid):

Callers 3

test_with_initgroupsMethod · 0.90
_setuidFunction · 0.85

Calls 1

setgroupsFunction · 0.85

Tested by 2

test_with_initgroupsMethod · 0.72