Commit 0c40f00c authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

call chmod() for directory too and ignore symlinks.

parent 1e67d300
...@@ -2080,20 +2080,23 @@ def _final_version(parsed_version): ...@@ -2080,20 +2080,23 @@ def _final_version(parsed_version):
return False return False
return True return True
def chmod(filepath): def chmod(path):
if os.path.islink(path):
return
# give the same permission but write as owner to group and other. # give the same permission but write as owner to group and other.
current_perm = os.stat(filepath).st_mode & \ current_perm = os.stat(path).st_mode & \
(stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO) (stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO)
owner_perm = current_perm & stat.S_IRWXU owner_perm = current_perm & stat.S_IRWXU
new_perm = (owner_perm + owner_perm / 0o010 + owner_perm / 0o100) & \ new_perm = (owner_perm + owner_perm / 0o010 + owner_perm / 0o100) & \
(~ 0o022) (~ 0o022)
if new_perm != current_perm: if new_perm != current_perm:
os.chmod(filepath, new_perm) os.chmod(path, new_perm)
def redo_pyc(egg): def redo_pyc(egg):
if not os.path.isdir(egg): if not os.path.isdir(egg):
return return
for dirpath, dirnames, filenames in os.walk(egg): for dirpath, dirnames, filenames in os.walk(egg):
chmod(dirpath)
for filename in filenames: for filename in filenames:
filepath = os.path.join(dirpath, filename) filepath = os.path.join(dirpath, filename)
chmod(filepath) chmod(filepath)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment