]> gitweb @ CieloNegro.org - youtube-dl.git/blobdiff - youtube_dl/utils.py
[utils] Fix file permissions in write_json_file (closes #12471) (#25122)
[youtube-dl.git] / 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: