def checkFixPermissionsForPath(pth):
mode = os.stat(pth).st_mode
groupReadable = stat.S_IRGRP & mode == stat.S_IRGRP
otherReadable = stat.S_IROTH & mode == stat.S_IROTH
msg = ''
if not groupReadable:
msg += ' not group readable'
mode |= stat.S_IRGRP
if not otherReadable:
msg += ' not other readable'
mode |= stat.S_IROTH
if len(msg.strip())>0:
print("%s, fixing permissions for %s" % (msg, pth))
os.chmod(pth, mode)
评论列表
文章目录