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

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

From
Nicolas Pitre <nico@cam.org>
Date
Apr 22, 2007, 18:34 UTC
Message-ID
<alpine.LFD.0.98.0704221431430.28339@xanadu.home>
In-Reply-To
<7vejmcnu28.fsf@assigned-by-dhcp.cox.net>
On Sun, 22 Apr 2007, Junio C Hamano wrote:
Show 14 quoted lines
> Nicolas Pitre <nico@cam.org> writes:
> 
> > On Sun, 22 Apr 2007, Junio C Hamano wrote:
> >
> >> With recent glibc, mkstemp() creates 0400 file.  Updated
> >> pack-objects uses it in pack/idx writing without fixing this,
> >> hence this problem.
> >
> > Oops.  I guess I'm guilty for this.  I didn't bother looking at the 
> > permission on the pack for git-pack-objects since git-repack seemed to 
> > take care of that.  But it only _remove_ write permissions.
> 
> Ok, then probably we can change the 0444 in my "quickfix" patch
> to 0644.  That should also let the 5300 test pass.

Well, actually there is no point making pack files writable. If they're modified, they get corrupted.

Here's the fix I wanted to propose:
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index c72e07a..85c6e6e 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1786,11 +1786,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		if (rename(pack_tmp_name, tmpname))
 			die("unable to rename temporary pack file: %s",
 			    strerror(errno));
+		chmod(tmpname, 0444);
 		snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
 			 base_name, sha1_to_hex(object_list_sha1));
 		if (rename(idx_tmp_name, tmpname))
 			die("unable to rename temporary index file: %s",
 			    strerror(errno));
+		chmod(tmpname, 0444);
 		puts(sha1_to_hex(object_list_sha1));
 	}
 	if (progress)


Nicolas
Previous: Junio C HamanoNext: Nicolas Pitre
Message 8 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.