本文整理匯總了Python中stat.S_IWGRP屬性的典型用法代碼示例。如果您正苦於以下問題:Python stat.S_IWGRP屬性的具體用法?Python stat.S_IWGRP怎麽用?Python stat.S_IWGRP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類stat
的用法示例。
在下文中一共展示了stat.S_IWGRP屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _warn_unsafe_extraction_path
# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IWGRP [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_IWGRP [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_IWGRP [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)