本文整理汇总了Python中stat.S_IWOTH属性的典型用法代码示例。如果您正苦于以下问题:Python stat.S_IWOTH属性的具体用法?Python stat.S_IWOTH怎么用?Python stat.S_IWOTH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类stat
的用法示例。
在下文中一共展示了stat.S_IWOTH属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _warn_unsafe_extraction_path
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IWOTH [as 别名]
def _warn_unsafe_extraction_path(path):
"""
If the default extraction path is overridden and set to an insecure
location, such as /tmp, it opens up an opportunity for an attacker to
replace an extracted file with an unauthorized payload. Warn the user
if a known insecure location is used.
See Distribute #375 for more details.
"""
if os.name == 'nt' and not path.startswith(os.environ['windir']):
# On Windows, permissions are generally restrictive by default
# and temp directories are not writable by other users, so
# bypass the warning.
return
mode = os.stat(path).st_mode
if mode & stat.S_IWOTH or mode & stat.S_IWGRP:
msg = ("%s is writable by group/others and vulnerable to attack "
"when "
"used with get_resource_filename. Consider a more secure "
"location (set with .set_extraction_path or the "
"PYTHON_EGG_CACHE environment variable)." % path)
warnings.warn(msg, UserWarning)
示例2: chmod
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IWOTH [as 别名]
def chmod(path):
os.chmod(path,
# user
stat.S_IRUSR | # read
stat.S_IWUSR | # write
stat.S_IXUSR | # execute
# group
stat.S_IRGRP | # read
stat.S_IWGRP | # write
stat.S_IXGRP | # execute
# other
stat.S_IROTH | # read
# stat.S_IWOTH | # write
stat.S_IXOTH # execute
)
示例3: _warn_unsafe_extraction_path
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IWOTH [as 别名]
def _warn_unsafe_extraction_path(path):
"""
If the default extraction path is overridden and set to an insecure
location, such as /tmp, it opens up an opportunity for an attacker to
replace an extracted file with an unauthorized payload. Warn the user
if a known insecure location is used.
See Distribute #375 for more details.
"""
if os.name == 'nt' and not path.startswith(os.environ['windir']):
# On Windows, permissions are generally restrictive by default
# and temp directories are not writable by other users, so
# bypass the warning.
return
mode = os.stat(path).st_mode
if mode & stat.S_IWOTH or mode & stat.S_IWGRP:
msg = (
"%s is writable by group/others and vulnerable to attack "
"when "
"used with get_resource_filename. Consider a more secure "
"location (set with .set_extraction_path or the "
"PYTHON_EGG_CACHE environment variable)." % path
)
warnings.warn(msg, UserWarning)