MCPcopy Index your code
hub / github.com/RustPython/RustPython / check_enableusersite

Function check_enableusersite

Lib/site.py:260–282  ·  view source on GitHub ↗

Check if user site directory is safe for inclusion The function tests for the command line flag (including environment var), process uid/gid equal to effective uid/gid. None: Disabled for security reasons False: Disabled by user (command line option) True: Safe and enabled

()

Source from the content-addressed store, hash-verified

258
259
260def check_enableusersite():
261 """Check if user site directory is safe for inclusion
262
263 The function tests for the command line flag (including environment var),
264 process uid/gid equal to effective uid/gid.
265
266 None: Disabled for security reasons
267 False: Disabled by user (command line option)
268 True: Safe and enabled
269 """
270 if sys.flags.no_user_site:
271 return False
272
273 if hasattr(os, "getuid") and hasattr(os, "geteuid"):
274 # check process uid == effective uid
275 if os.geteuid() != os.getuid():
276 return None
277 if hasattr(os, "getgid") and hasattr(os, "getegid"):
278 # check process gid == effective gid
279 if os.getegid() != os.getgid():
280 return None
281
282 return True
283
284
285# NOTE: sysconfig and it's dependencies are relatively large but site module

Callers 1

mainFunction · 0.85

Calls 1

hasattrFunction · 0.85

Tested by

no test coverage detected