summaryrefslogtreecommitdiff
path: root/git-fat
diff options
context:
space:
mode:
authorJed Brown <jed@59A2.org>2013-07-25 16:50:19 -0500
committerJed Brown <jed@59A2.org>2013-07-26 09:42:20 -0500
commit4664f2dc2eee13b86d2e426780fd1130e0086e9f (patch)
treec8cacf87bbefa04fc7a1f410314d71a917de8014 /git-fat
parent58db90461a596da50c3973da29c07ecc56aa5e24 (diff)
downloadgit-fat-4664f2dc2eee13b86d2e426780fd1130e0086e9f.tar.gz
Set permissions for object store using current umask
tempfile.mkstemp() creates a file with mode 0600 by default, which after pushing, prevents others from accessing the shared object store. Instead, use 0444 (as with git-native objects) and respect umask so that pushed objects will be readable with default configuration. Noticed-by: Ashok Argent-Katwala <ashok@freshbooks.com> Comments-by: Owen Jacobson <owen.jacobson@grimoire.ca>
Diffstat (limited to 'git-fat')
-rwxr-xr-xgit-fat8
1 files changed, 8 insertions, 0 deletions
diff --git a/git-fat b/git-fat
index 5bc8156..f654fab 100755
--- a/git-fat
+++ b/git-fat
@@ -30,6 +30,12 @@ def mkdir_p(path):
pass
else: raise
+def umask():
+ """Get umask without changing it."""
+ old = os.umask(0)
+ os.umask(old)
+ return old
+
def readblocks(stream):
bytes = 0
while True:
@@ -204,6 +210,8 @@ class GitFat(object):
self.verbose('git-fat filter-clean: cache already exists %s' % objfile)
os.remove(tmpname)
else:
+ # Set permissions for the new file using the current umask
+ os.chmod(tmpname, int('444', 8) & ~umask())
os.rename(tmpname, objfile)
self.verbose('git-fat filter-clean: caching to %s' % objfile)
cached = True