栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何禁用环境的“ site.ENABLE_USER_SITE”?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何禁用环境的“ site.ENABLE_USER_SITE”?

该变量的值完全由Python代码确定:

def check_enableusersite():    """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    """    if sys.flags.no_user_site:        return False    if hasattr(os, "getuid") and hasattr(os, "geteuid"):        # check process uid == effective uid        if os.geteuid() != os.getuid(): return None    if hasattr(os, "getgid") and hasattr(os, "getegid"):        # check process gid == effective gid        if os.getegid() != os.getgid(): return None    return True

第一个测试只是针对已使用的

-s
开关或
PYTHONNOUSERSITE
环境变量。

None
如果有效用户标识或组标识不同于进程用户标识或组标识,则剩下的测试将返回。

管理员可以设置有效用户ID或组ID位,然后将可执行文件的有效用户更改为可执行文件的所有者或组,而不是执行Python的用户,此时将返回上述函数

None

除此之外,

sitecustomize.py
软件包还可以将值设置为
None
,并再次从路径中显式删除用户目录。如果是这样,则将
usercustomize.py
跳过导入步骤。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/646773.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号