Re: git ls-files -o under .git/ prints all repository files
- From
Junio C Hamano <junkio@cox.net>
- Date
- Jan 19, 2007, 06:47 UTC
- Message-ID
- <7vwt3jjywc.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <87r6trsu7n.wl@mail2.atmark-techno.com>
Yasushi SHOJI <yashi@atmark-techno.com> writes:
Show 6 quoted lines
> ls-files -o prints all files under .git if you are in the .git > directory. this is pretty dangerous since we now have git clean to > delete files marked others. > > sure in UNIX env., you can easily shoot yourself in the foot. but it'd > might be nice to help newbies.
It's amusing to see that people can find obscure ways to shoot themselves in the foot.
Amusing problems deserve an equally amusing solution.
-- >8 -- [PATCH] Make sure .git/ is not readable by anybody.
Normal git operation continues to work after doing "chmod a-r .git". This makes a newly created git repository unreadable (but searchable) so that people cannot do "cd .git && git clean" to shoot themselves.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/builtin-init-db.c b/builtin-init-db.c index 8e7540b..4310a05 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -18,7 +18,10 @@ static void safe_create_dir(const char *dir, int share) { - if (mkdir(dir, 0777) < 0) { + mode_t mode; + + mode = share ? 0777 : 0333; + if (mkdir(dir, mode) < 0) { if (errno != EEXIST) { perror(dir); exit(1);