[utils] Fix file permissions in write_json_file (closes #12471) (#25122)
authorRob <ankenyr@gmail.com>
Tue, 19 May 2020 20:21:52 +0000 (13:21 -0700)
committerGitHub <noreply@github.com>
Tue, 19 May 2020 20:21:52 +0000 (03:21 +0700)
youtube_dl/utils.py

index 112279ed7dfc484395d0d8b57b81c03a7a14e9ec..d1eca3760a66e89fbfc1673e70a2d526035776cf 100644 (file)
@@ -1837,6 +1837,12 @@ def write_json_file(obj, fn):
                 os.unlink(fn)
             except OSError:
                 pass
+        try:
+            mask = os.umask(0)
+            os.umask(mask)
+            os.chmod(tf.name, 0o666 & ~mask)
+        except OSError:
+            pass
         os.rename(tf.name, fn)
     except Exception:
         try: