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

Default "tar" umask..

From
Linus Torvalds <torvalds@osdl.org>
Date
Dec 30, 2006, 18:45 UTC
Message-ID
<Pine.LNX.4.64.0612301037570.4473@woody.osdl.org>

We just had a posting on the kernel security list where a person was upset that the 2.6.19.1 and .2 tar-files were apparently group and world-writable.

Now, the default kernel releases don't do that (at least any more), because I've got

	[tar]
		umask=022
in my git config file these days, but the stable team apparently doesn't.

Looking at some of the tar-files I have lying around, they all seem to have used that 022 umask, and maybe we should just change the git default to that?

Anybody who wants to, can get the zero umask by just using the config file, but maybe the default should be the common case, and the case that isn't as likely to be a security issue if you untar it.

GNU tar has a "--no-same-permissions" flag to use the user umask at untar time, but I think that's a GNU-tar specific feature (at least I can't see any short flag to do the same), and I have to admit that I've _never_ used it even though I've used "tar" a long time, so at least going by my personal experience, I'd say it's very uncommon for people to use it.

The trivial untested patch below should do it.
		Linus
---
diff --git a/archive-tar.c b/archive-tar.c
index af47fdc..d4a2fa4 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -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 = 022;
 static int verbose;
 
 /* writes out the whole block, but only if it is full */
Next: Junio C Hamano
Message 1 of 10 in “Default "tar" umask..”
  1. Linus TorvaldsDec 30, 2006
  2. Junio C HamanoDec 30, 2006
  3. René ScharfeJan 5, 2007
  4. Junio C HamanoJan 5, 2007
  5. Linus TorvaldsJan 5, 2007
  6. Junio C HamanoJan 5, 2007
  7. Krzysztof HalasaJan 7, 2007
  8. Junio C HamanoJan 7, 2007
  9. René ScharfeJan 5, 2007
  10. Junio C HamanoJan 5, 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.