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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Nicolas Pitre <nico@...>, <git@...>, <linux-kernel@...>
Date: Sunday, April 22, 2007 - 3:20 pm

Junio C Hamano <junkio@cox.net> writes:


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 message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[ANNOUNCE] GIT 1.5.1.1, Junio C Hamano, (Wed Apr 11, 10:09 pm)
[ANNOUNCE] GIT 1.5.1.2, Junio C Hamano, (Sun Apr 22, 2:16 am)
Re: [ANNOUNCE] GIT 1.5.1.2, Linus Torvalds, (Sun Apr 22, 1:22 pm)
Re: [ANNOUNCE] GIT 1.5.1.2, Junio C Hamano, (Sun Apr 22, 2:47 pm)
Re: [ANNOUNCE] GIT 1.5.1.2, Junio C Hamano, (Sun Apr 22, 1:58 pm)
Today's 'master' leaves .idx/.pack in 0400, Junio C Hamano, (Sun Apr 22, 2:06 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Nicolas Pitre, (Sun Apr 22, 2:25 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Junio C Hamano, (Sun Apr 22, 2:27 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Nicolas Pitre, (Sun Apr 22, 2:34 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Linus Torvalds, (Sun Apr 22, 2:54 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Junio C Hamano, (Sun Apr 22, 3:03 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Junio C Hamano, (Sun Apr 22, 3:20 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Linus Torvalds, (Sun Apr 22, 3:29 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Nicolas Pitre, (Sun Apr 22, 2:47 pm)
Re: Today's 'master' leaves .idx/.pack in 0400, Junio C Hamano, (Sun Apr 22, 2:52 pm)