Skip to content

Commit

Permalink
Set default "tar" umask to 002 and owner.group to root.root
Browse files Browse the repository at this point in the history
In order to make the generated tar files more friendly to users who
extract them as root using GNU tar and its implied -p option, change
the default umask to 002 and change the owner name and group name to
root.  This ensures that a) the extracted files and directories are
not world-writable and b) that they belong to user and group root.

Before they would have been assigned to a user and/or group named
git if it existed.  This also answers the question in the removed
comment: uid=0, gid=0, uname=root, gname=root is exactly what we
want.

Normal users who let tar apply their umask while extracting are
only affected if their umask allowed the world to change their
files (e.g. a umask of zero).  This case is so unlikely and strange
that we don't need to support it.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Jan 6, 2007
1 parent 21afc41 commit f08b3b0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static char block[BLOCKSIZE];
static unsigned long offset;

static time_t archive_time;
static int tar_umask;
static int tar_umask = 002;
static int verbose;

/* writes out the whole block, but only if it is full */
Expand Down Expand Up @@ -210,11 +210,10 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
sprintf(header.size, "%011lo", S_ISREG(mode) ? size : 0);
sprintf(header.mtime, "%011lo", archive_time);

/* XXX: should we provide more meaningful info here? */
sprintf(header.uid, "%07o", 0);
sprintf(header.gid, "%07o", 0);
strlcpy(header.uname, "git", sizeof(header.uname));
strlcpy(header.gname, "git", sizeof(header.gname));
strlcpy(header.uname, "root", sizeof(header.uname));
strlcpy(header.gname, "root", sizeof(header.gname));
sprintf(header.devmajor, "%07o", 0);
sprintf(header.devminor, "%07o", 0);

Expand Down

0 comments on commit f08b3b0

Please sign in to comment.