Skip to content

Commit d3a0037

Browse files
committed
Fixed critical issues with incorrect permissions set on files the db has written - it was only rw-- for the user that wrote them, but should be readable by everyone by default
1 parent 09275ad commit d3a0037

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

db/loose.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
to_hex_sha,
2929
hex_to_bin,
3030
exists,
31+
chmod,
3132
isdir,
3233
mkdir,
3334
rename,
@@ -199,6 +200,10 @@ def store(self, istream):
199200
mkdir(obj_dir)
200201
# END handle destination directory
201202
rename(tmp_path, obj_path)
203+
204+
# make sure its readable for all ! It started out as rw-- tmp file
205+
# but needs to be rrr
206+
chmod(obj_path, 0444)
202207
# END handle dry_run
203208

204209
istream.sha = hexsha

util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def unpack_from(fmt, data, offset=0):
5454
# os shortcuts
5555
exists = os.path.exists
5656
mkdir = os.mkdir
57+
chmod = os.chmod
5758
isdir = os.path.isdir
5859
rename = os.rename
5960
dirname = os.path.dirname
@@ -291,6 +292,9 @@ def _end_writing(self, successful=True):
291292
# END remove if exists
292293
# END win32 special handling
293294
os.rename(lockfile, self._filepath)
295+
296+
# assure others can at least read the file - the tmpfile left it at rw--
297+
chmod(self._filepath, 0444)
294298
else:
295299
# just delete the file so far, we failed
296300
os.remove(lockfile)

0 commit comments

Comments
 (0)