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