浏览代码

Don't trust modes if they can't be modified after a file has been created. Fixes: #719

Jelmer Vernooij 5 年之前
父节点
当前提交
fc00072f84
共有 2 个文件被更改,包括 7 次插入1 次删除
  1. 3 0
      NEWS
  2. 4 1
      dulwich/repo.py

+ 3 - 0
NEWS

@@ -18,6 +18,9 @@
  * Implement ``RefsContainer.__iter__``
    (Jelmer Vernooij, #717)
 
+ * Don't trust modes if they can't be modified after a file has been created.
+   (Jelmer Vernooij, #719)
+
 0.19.11	2019-02-07
 
  IMPROVEMENTS

+ 4 - 1
dulwich/repo.py

@@ -994,7 +994,10 @@ class Repo(BaseRepo):
             f.write('')
 
         st1 = os.lstat(fname)
-        os.chmod(fname, st1.st_mode ^ stat.S_IXUSR)
+        try:
+            os.chmod(fname, st1.st_mode ^ stat.S_IXUSR)
+        except PermissionError:
+            return False
         st2 = os.lstat(fname)
 
         os.unlink(fname)