Re: git ls-files -o under .git/ prints all repository files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yasushi SHOJI <yashi@xxxxxxxxxxxxxxxxx> writes:

> 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@xxxxxxx>

---
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);



-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]