[PATCH] git-receive-pack needs to set umask(2)
From: Michael Richardson <hidden>
Date: 2016-06-15 22:42:27
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
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 <redacted> --- 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
Attachments
- (unnamed) [application/pgp-signature] 482 bytes