Skip to content

Commit 5256b00

Browse files
moygitster
authored andcommitted
Use git_mkstemp_mode instead of plain mkstemp to create object files
We used to unnecessarily give the read permission to group and others, regardless of the umask, which isn't serious because the objects are still protected by their containing directory, but isn't necessary either. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1d9740c commit 5256b00

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sha1_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,7 +2206,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
22062206
}
22072207

22082208
out:
2209-
if (set_shared_perm(filename, (S_IFREG|0444)))
2209+
if (adjust_shared_perm(filename))
22102210
return error("unable to set permission to '%s'", filename);
22112211
return 0;
22122212
}
@@ -2262,7 +2262,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
22622262
}
22632263
memcpy(buffer, filename, dirlen);
22642264
strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
2265-
fd = mkstemp(buffer);
2265+
fd = git_mkstemp_mode(buffer, 0444);
22662266
if (fd < 0 && dirlen && errno == ENOENT) {
22672267
/* Make sure the directory exists */
22682268
memcpy(buffer, filename, dirlen);
@@ -2272,7 +2272,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
22722272

22732273
/* Try again */
22742274
strcpy(buffer + dirlen - 1, "/tmp_obj_XXXXXX");
2275-
fd = mkstemp(buffer);
2275+
fd = git_mkstemp_mode(buffer, 0444);
22762276
}
22772277
return fd;
22782278
}

t/t1304-default-acl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test_expect_success 'Setup test repo' '
5454
git commit -m "init"
5555
'
5656

57-
test_expect_failure 'Objects creation does not break ACLs with restrictive umask' '
57+
test_expect_success 'Objects creation does not break ACLs with restrictive umask' '
5858
# SHA1 for empty blob
5959
check_perms_and_acl .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
6060
'

0 commit comments

Comments
 (0)