All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git-receive-pack needs to set umask(2)
@ 2006-05-28 21:31 Michael Richardson
  2006-05-28 22:00 ` Jakub Narebski
  2006-05-28 22:06 ` Petr Baudis
  0 siblings, 2 replies; 11+ messages in thread
From: Michael Richardson @ 2006-05-28 21:31 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 3351 bytes --]


If there is another way to solve this, please let me know.
Wrapping git-receive-pack with a shell script to call umask seemed like too
global a change.
(also http://git.openswan.org/git#umask_hack)

When working with a common git repository, not all users are always clueful
enough to set their umask properly --- nor should the default for the user
always be so permissive.

This change adds $GIT_DIR/umask to contain a single line, an integer
which will be fed to umask(). This should also work for the git daemon,
which I personally do not use, so this may be inappropriate.

Signed-off-by: Michael Richardson <mcr@xelerance.com>

---

8698daf8fedc8618593ec44574df1efb9f31db84
 Documentation/git-receive-pack.txt |    3 +++
 cache.h                            |    1 +
 path.c                             |    2 ++
 setup.c                            |   19 +++++++++++++++++++
 4 files changed, 25 insertions(+), 0 deletions(-)

8698daf8fedc8618593ec44574df1efb9f31db84
diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt
index 60debca..d3a8c11 100644
--- a/Documentation/git-receive-pack.txt
+++ b/Documentation/git-receive-pack.txt
@@ -74,6 +74,9 @@ packed and is served via a dumb transpor
 There are other real-world examples of using update and
 post-update hooks found in the Documentation/howto directory.
 
+The file $GIT_DIR/umask, if it exists will be opened, and the integer found
+in it will be used to initialize the umask(2) for subsequent file creation
+operations. 
 
 OPTIONS
 -------
diff --git a/cache.h b/cache.h
index 3a46fb9..65d5124 100644
--- a/cache.h
+++ b/cache.h
@@ -355,6 +355,7 @@ extern int git_config_bool(const char *,
 extern int git_config_set(const char *, const char *);
 extern int git_config_set_multivar(const char *, const char *, const char *, int);
 extern int check_repository_format_version(const char *var, const char *value);
+extern void setup_umask();
 
 #define MAX_GITNAME (1000)
 extern char git_default_email[MAX_GITNAME];
diff --git a/path.c b/path.c
index 334b2bd..571ff01 100644
--- a/path.c
+++ b/path.c
@@ -244,6 +244,8 @@ char *enter_repo(char *path, int strict)
 	if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
 	    validate_symref("HEAD") == 0) {
 		putenv("GIT_DIR=.");
+
+		setup_umask();
 		check_repository_format();
 		return path;
 	}
diff --git a/setup.c b/setup.c
index fe7f884..2129125 100644
--- a/setup.c
+++ b/setup.c
@@ -228,6 +228,25 @@ int check_repository_format_version(cons
        return 0;
 }
 
+void setup_umask(void)
+{
+	FILE *f;
+
+	f = fopen(git_path("umask"), "r");
+	if(f != NULL) {
+		char maskstr[32];
+		if(fgets(maskstr, sizeof(maskstr), f) != NULL) {
+			char *foo;
+			unsigned int mask = strtoul(maskstr, &foo, 0);
+			
+			if(foo != maskstr) {
+				umask(mask);
+			}
+		}
+		fclose(f);
+	}
+}
+
 int check_repository_format(void)
 {
 	git_config(check_repository_format_version);
-- 
1.3.GIT





-- 
]       ON HUMILITY: to err is human. To moo, bovine.           |  firewalls  [
]   Michael Richardson,    Xelerance Corporation, Ottawa, ON    |net architect[
] mcr@xelerance.com      http://www.sandelman.ottawa.on.ca/mcr/ |device driver[
] panic("Just another Debian GNU/Linux using, kernel hacking, security guy"); [

    "The Microsoft _Get the Facts CD_ does not work on Linux." - orospakr


[-- Attachment #2: Type: application/pgp-signature, Size: 482 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* RE: [PATCH] git-receive-pack needs to set umask(2)
@ 2006-05-29 12:07 Zakirov, Salikh
  0 siblings, 0 replies; 11+ messages in thread
From: Zakirov, Salikh @ 2006-05-29 12:07 UTC (permalink / raw)
  To: spearce; +Cc: git

Thanks a lot, that works!

Shawn wrote:
>
> > Could you please elaborate on what does it mean "make it shared"?
> 
> Try setting 'core.sharedRepository' to true:
> 
> 
> 	git repo-config core.sharedRepository true
> 
> and running your chmod script one last time.  See
> Documentation/config.txt for some details on this switch.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-05-29 21:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-28 21:31 [PATCH] git-receive-pack needs to set umask(2) Michael Richardson
2006-05-28 22:00 ` Jakub Narebski
2006-05-29  7:13   ` Johannes Schindelin
2006-05-29 11:28     ` Salikh Zakirov
2006-05-29 11:33       ` Shawn Pearce
2006-05-29 17:00       ` Linus Torvalds
2006-05-29 21:28         ` Alex Riesen
2006-05-29 21:50           ` Johannes Schindelin
2006-05-28 22:06 ` Petr Baudis
2006-05-29 16:03   ` Michael Richardson
  -- strict thread matches above, loose matches on Subject: below --
2006-05-29 12:07 Zakirov, Salikh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.