git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Today's 'master' leaves .idx/.pack in 0400

From
Junio C Hamano <junkio@cox.net>
Date
Apr 22, 2007, 19:20 UTC
Message-ID
<7vd51wmd1a.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vy7kkmdtg.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 8 quoted lines
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>
>> So I think that if the user has a umask that says "nobody else can read", 
>> then we should *not* make it world readable (unless the 
>> "shared_repository" thing is set to override it, of course).
>
> I obviously agree, but as a tentative measure, I'll push out
> 0644 version anyway.

How about this as a replacement (hot off the press -- still running the tests).

-- >8 -- pack-objects: adjust the permission bits of created files.

The updated pack-objects let mkstemp() to create new pack/idx pair, without fixing the permission bits on them.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 builtin-pack-objects.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index c72e07a..34350bf 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1612,6 +1612,13 @@ static void get_object_list(int ac, const char **av)
 	traverse_commit_list(&revs, show_commit, show_object);
 }
 
+static int adjust_perm(const char *path, mode_t mode)
+{
+	if (chmod(path, mode))
+		return -1;
+	return adjust_shared_perm(path);
+}
+
 int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 {
 	int depth = 10;
@@ -1780,14 +1787,25 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	last_obj_offset = write_pack_file();
 	if (!pack_to_stdout) {
 		unsigned char object_list_sha1[20];
+		mode_t mode = umask(0);
+
+		umask(mode);
+		mode = 0666 & ~mode;
+
 		write_index_file(last_obj_offset, object_list_sha1);
 		snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
 			 base_name, sha1_to_hex(object_list_sha1));
+		if (adjust_perm(pack_tmp_name, mode))
+			die("unable to make temporary pack file readable: %s",
+			    strerror(errno));
 		if (rename(pack_tmp_name, tmpname))
 			die("unable to rename temporary pack file: %s",
 			    strerror(errno));
 		snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
 			 base_name, sha1_to_hex(object_list_sha1));
+		if (adjust_perm(idx_tmp_name, mode))
+			die("unable to make temporary index file readable: %s",
+			    strerror(errno));
 		if (rename(idx_tmp_name, tmpname))
 			die("unable to rename temporary index file: %s",
 			    strerror(errno));
Previous: Junio C HamanoNext: Linus Torvalds
Message 13 of 15 in “[ANNOUNCE] GIT 1.5.1.1”
  1. Junio C HamanoApr 12, 2007
  2. [ANNOUNCE] GIT 1.5.1.2Junio C Hamano, Apr 22, 2007
  3. Linus TorvaldsApr 22, 2007
  4. Junio C HamanoApr 22, 2007
  5. Today's 'master' leaves .idx/.pack in 0400Junio C Hamano, Apr 22, 2007
  6. Nicolas PitreApr 22, 2007
  7. Junio C HamanoApr 22, 2007
  8. Nicolas PitreApr 22, 2007
  9. Nicolas PitreApr 22, 2007
  10. Junio C HamanoApr 22, 2007
  11. Linus TorvaldsApr 22, 2007
  12. Junio C HamanoApr 22, 2007
  13. Junio C HamanoApr 22, 2007
  14. Linus TorvaldsApr 22, 2007
  15. Junio C HamanoApr 22, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.