threads / discuss / 4451

RE: Git-daemon messing up permissions for gitweb

Subject: RE: Git-daemon messing up permissions for gitweb

## tl;dr

14 messages between Jun 9, 2006 and Jun 10, 2006.

replies: 13people: 6as markdown or json

Post, Mark K· Jun 9, 2006, 20:52 UTC · lore

Since umask isn't an environment variable, per se, I'm not sure how this will change anything.

One other thing I noticed is that init-db.c spells core.sharedRepository with a capital R, but setup.c spells it "core.sharedrepository" with no upper case letters. Would this make any difference to anything I'm seeing?

Mark Post
-----Original Message-----
From: Linus Torvalds [mailto:torvalds@osdl.org] 
Sent: Friday, June 09, 2006 4:44 PM
To: Junio C Hamano
Cc: git@vger.kernel.org; Post, Mark K
Subject: Re: Git-daemon messing up permissions for gitweb
On Fri, 9 Jun 2006, Junio C Hamano wrote:
>
> But that should be tweakable by configuring what sshd does for
> the user, shouldn't it?  The "LOGIN PROCESS" section from man
> sshd(8) seems to talk about $HOME/.ssh/environment, for example.
Yeah. That's probably the right place to set things up.
		Linus
Junio C Hamano· Jun 9, 2006, 21:06 UTC · re: Post, Mark K · lore

Re: Git-daemon messing up permissions for gitweb

"Post, Mark K" <mark.post@eds.com> writes:
> Since umask isn't an environment variable, per se, I'm not sure how this
> will change anything.

I do not configure my sshd, so you may need a bit more reading on it yourself; $HOME/.ssh/environment does not seem to be it, as you said.

> One other thing I noticed is that init-db.c spells core.sharedRepository
> with a capital R, but setup.c spells it "core.sharedrepository" with no
> upper case letters.  Would this make any difference to anything I'm
> seeing? 

The distinction should not matter since the code downcases (git_config_set_multivar() in config.c) it, but to avoid future confusion we might want to downcase the one in init-db.c

Junio C Hamano· Jun 10, 2006, 00:35 UTC · re: Junio C Hamano · lore

[PATCH/RFC] Retire SIMPLE_*** stuff.

It used to be a good idea to keep simple stuff without linking with git library, but more and more programs are using the config mechanism, and yet more things are becoming internal.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 Makefile |   24 +++++-------------------
 1 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index 5226fa1..d65fc71 100644
--- a/Makefile
+++ b/Makefile
@@ -142,12 +142,7 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)
 	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 	  git-cherry-pick git-status
 
-# The ones that do not have to link with lcrypto, lz nor xdiff.
-SIMPLE_PROGRAMS = \
-	git-get-tar-commit-id$X git-mailsplit$X \
-	git-stripspace$X git-daemon$X
-
-# ... and all the rest that could be moved out of bindir to gitexecdir
+# Programs could be moved out of bindir to gitexecdir
 PROGRAMS = \
 	git-checkout-index$X git-clone-pack$X \
 	git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
@@ -162,7 +157,9 @@ PROGRAMS = \
 	git-upload-pack$X git-verify-pack$X git-write-tree$X \
 	git-update-ref$X git-symbolic-ref$X \
 	git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
-	git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
+	git-describe$X git-merge-tree$X git-blame$X git-imap-send$X \
+	git-get-tar-commit-id$X git-mailsplit$X \
+	git-stripspace$X git-daemon$X
 
 BUILT_INS = git-log$X git-whatchanged$X git-show$X \
 	git-count-objects$X git-diff$X git-push$X \
@@ -175,7 +172,7 @@ BUILT_INS = git-log$X git-whatchanged$X 
 	git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X
 
 # what 'all' will build and 'install' will install, in gitexecdir
-ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
+ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 
 # Backward compatibility -- to be removed after 1.0
 PROGRAMS += git-ssh-pull$X git-ssh-push$X
@@ -386,11 +383,9 @@ else
 endif
 ifdef NEEDS_SOCKET
 	LIBS += -lsocket
-	SIMPLE_LIB += -lsocket
 endif
 ifdef NEEDS_NSL
 	LIBS += -lnsl
-	SIMPLE_LIB += -lnsl
 endif
 ifdef NO_D_TYPE_IN_DIRENT
 	ALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT
@@ -428,6 +428,8 @@ endif
 
 ifdef NO_ICONV
 	ALL_CFLAGS += -DNO_ICONV
+else
+	LIBS += $(LIB_4_ICONV)
 endif
 
 ifdef PPC_SHA1

@@ -559,15 +554,6 @@ endif
 git-%$X: %.o $(GITLIBS)
 	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
-$(SIMPLE_PROGRAMS) : $(LIB_FILE)
-$(SIMPLE_PROGRAMS) : git-%$X : %.o
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
-		$(LIB_FILE) $(SIMPLE_LIB)
-
-git-mailinfo$X: mailinfo.o $(LIB_FILE)
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
-		$(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)
-
 git-local-fetch$X: fetch.o
 git-ssh-fetch$X: rsh.o fetch.o
 git-ssh-upload$X: rsh.o
-- 
1.4.0.rc2.g55be
Rene Scharfe· Jun 10, 2006, 14:13 UTC · re: Junio C Hamano · lore

[PATCH] Built-in git-get-tar-commit-id (was: [PATCH/RFC] Retire SIMPLE_*** stuff.)

By being an internal command git-get-commit-id can make use of struct ustar_header and other stuff and stops wasting precious disk space.

Note: I recycled one of the two "tar-tree" entries instead of
splitting that cleanup into a separate patch.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
diff --git a/Makefile b/Makefile
index 5226fa1..2a1e639 100644
--- a/Makefile
+++ b/Makefile
@@ -142,11 +142,11 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)
 	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 	  git-cherry-pick git-status
 
 # The ones that do not have to link with lcrypto, lz nor xdiff.
 SIMPLE_PROGRAMS = \
-	git-get-tar-commit-id$X git-mailsplit$X \
+	git-mailsplit$X \
 	git-stripspace$X git-daemon$X
 
 # ... and all the rest that could be moved out of bindir to gitexecdir
 PROGRAMS = \
 	git-checkout-index$X git-clone-pack$X \
@@ -167,11 +167,11 @@ PROGRAMS = \
 BUILT_INS = git-log$X git-whatchanged$X git-show$X \
 	git-count-objects$X git-diff$X git-push$X \
 	git-grep$X git-add$X git-rm$X git-rev-list$X \
 	git-check-ref-format$X git-rev-parse$X \
 	git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
-	git-ls-files$X git-ls-tree$X \
+	git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \
 	git-read-tree$X git-commit-tree$X \
 	git-apply$X git-show-branch$X git-diff-files$X \
 	git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X
 
 # what 'all' will build and 'install' will install, in gitexecdir
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 7663b9b..58a8ccd 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -400,5 +400,30 @@ int cmd_tar_tree(int argc, const char **
 		usage(tar_tree_usage);
 	if (!strncmp("--remote=", argv[1], 9))
 		return remote_tar(argc, argv);
 	return generate_tar(argc, argv, envp);
 }
+
+/* ustar header + extended global header content */
+#define HEADERSIZE (2 * RECORDSIZE)
+
+int cmd_get_tar_commit_id(int argc, const char **argv, char **envp)
+{
+	char buffer[HEADERSIZE];
+	struct ustar_header *header = (struct ustar_header *)buffer;
+	char *content = buffer + RECORDSIZE;
+	ssize_t n;
+
+	n = xread(0, buffer, HEADERSIZE);
+	if (n < HEADERSIZE)
+		die("git-get-tar-commit-id: read error");
+	if (header->typeflag[0] != 'g')
+		return 1;
+	if (memcmp(content, "52 comment=", 11))
+		return 1;
+
+	n = xwrite(1, content + 11, 41);
+	if (n < 41)
+		die("git-get-tar-commit-id: write error");
+
+	return 0;
+}
diff --git a/builtin.h b/builtin.h
index ffa9340..b9f36be 100644
--- a/builtin.h
+++ b/builtin.h
@@ -30,10 +30,11 @@ extern int cmd_add(int argc, const char 
 extern int cmd_rev_list(int argc, const char **argv, char **envp);
 extern int cmd_check_ref_format(int argc, const char **argv, char **envp);
 extern int cmd_init_db(int argc, const char **argv, char **envp);
 extern int cmd_tar_tree(int argc, const char **argv, char **envp);
 extern int cmd_upload_tar(int argc, const char **argv, char **envp);
+extern int cmd_get_tar_commit_id(int argc, const char **argv, char **envp);
 extern int cmd_ls_files(int argc, const char **argv, char **envp);
 extern int cmd_ls_tree(int argc, const char **argv, char **envp);
 extern int cmd_read_tree(int argc, const char **argv, char **envp);
 extern int cmd_commit_tree(int argc, const char **argv, char **envp);
 extern int cmd_apply(int argc, const char **argv, char **envp);
diff --git a/get-tar-commit-id.c b/get-tar-commit-id.c
deleted file mode 100644
index 4166290..0000000
--- a/get-tar-commit-id.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2005 Rene Scharfe
- */
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#define HEADERSIZE	1024
-
-int main(int argc, char **argv)
-{
-	char buffer[HEADERSIZE];
-	ssize_t n;
-
-	n = read(0, buffer, HEADERSIZE);
-	if (n < HEADERSIZE) {
-		fprintf(stderr, "read error\n");
-		return 3;
-	}
-	if (buffer[156] != 'g')
-		return 1;
-	if (memcmp(&buffer[512], "52 comment=", 11))
-		return 1;
-	n = write(1, &buffer[523], 41);
-	if (n < 41) {
-		fprintf(stderr, "write error\n");
-		return 2;
-	}
-	return 0;
-}
diff --git a/git.c b/git.c
index 6db8f2b..9469d44 100644
--- a/git.c
+++ b/git.c
@@ -161,11 +161,11 @@ static void handle_internal_command(int 
 		{ "grep", cmd_grep },
 		{ "rm", cmd_rm },
 		{ "add", cmd_add },
 		{ "rev-list", cmd_rev_list },
 		{ "init-db", cmd_init_db },
-		{ "tar-tree", cmd_tar_tree },
+		{ "get-tar-commit-id", cmd_get_tar_commit_id },
 		{ "upload-tar", cmd_upload_tar },
 		{ "check-ref-format", cmd_check_ref_format },
 		{ "ls-files", cmd_ls_files },
 		{ "ls-tree", cmd_ls_tree },
 		{ "tar-tree", cmd_tar_tree },
Junio C Hamano· Jun 10, 2006, 00:39 UTC · re: Junio C Hamano · lore

[PATCH] shared repository settings enhancement.

This lets you say:
	[core]
		sharedrepository = 075

to allow permission bits on files under $GIT_DIR for OTHER users (not just GROUP users) to be copied from the permission bits of the owner of the file. This is useful for publishing a shared repository over gitweb, when gitweb does not run as a member of the project group and some members have umask too strict for others to read what is created by default. The historical boolean sharedrepository maps to 070 (i.e. if the owner can read or write or execute it, group members can, too).

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * This patch is meant for discussion, not application, as you
   can see there is one big "NEEDSWORK" in builtin-init-db.c.
   Regardless of this enhancement to deal with S_I[RWX]OTH, I
   spotted a couple of places that lack permission adjustment in
   the existing code, which might be worth fixing first.
 builtin-init-db.c |   21 ++++++++++++++++++---
 config.c          |    2 +-
 lockfile.c        |   15 ++++++++++-----
 refs.c            |    5 +++++
 setup.c           |   25 +++++++++++++++++++++++--
 sha1_file.c       |    9 ++++++---
 6 files changed, 63 insertions(+), 14 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 88b39a4..4826c08 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -198,6 +198,11 @@ static void create_default_files(const c
 
 	git_config(git_default_config);
 
+	/* NEEDSWORK: we would have created the above under user's
+	 * umask -- under shared-repository settings, we would need
+	 * to fix them up by scanning under $GIT_DIR here.
+	 */
+
 	/*
 	 * Create the default symlink from ".git/HEAD" to the "master"
 	 * branch, if it does not exist yet.
@@ -248,7 +253,14 @@ int cmd_init_db(int argc, const char **a
 		if (!strncmp(arg, "--template=", 11))
 			template_dir = arg+11;
 		else if (!strcmp(arg, "--shared"))
-			shared_repository = 1;
+			shared_repository = 070; /* might want 075 */
+		else if (!strncmp(arg, "--shared=", 9)) {
+			char *end;
+			long val = strtol(arg+9, &end, 8);
+			if (*end || 077 < val)
+				die("bad option for --shared=");
+			shared_repository = val;
+		}
 		else
 			die(init_db_usage);
 	}
@@ -286,8 +298,11 @@ int cmd_init_db(int argc, const char **a
 	strcpy(path+len, "/info");
 	safe_create_dir(path, 1);
 
-	if (shared_repository)
-		git_config_set("core.sharedrepository", "true");
+	if (shared_repository) {
+		char buf[6];
+		sprintf(buf, "%o", shared_repository);
+		git_config_set("core.sharedrepository", buf);
+	}
 
 	return 0;
 }
diff --git a/config.c b/config.c
index 2ae6153..c474970 100644
--- a/config.c
+++ b/config.c
@@ -536,7 +536,7 @@ int git_config_set_multivar(const char* 
 	 * contents of .git/config will be written into it.
 	 */
 	fd = open(lock_file, O_WRONLY | O_CREAT | O_EXCL, 0666);
-	if (fd < 0) {
+	if (fd < 0 || adjust_shared_perm(lock_file)) {
 		fprintf(stderr, "could not lock config file\n");
 		free(store.key);
 		ret = -1;
diff --git a/lockfile.c b/lockfile.c
index 9bc6083..2346e0e 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -27,11 +27,16 @@ int hold_lock_file_for_update(struct loc
 	int fd;
 	sprintf(lk->filename, "%s.lock", path);
 	fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
-	if (fd >=0 && !lk->next) {
-		lk->next = lock_file_list;
-		lock_file_list = lk;
-		signal(SIGINT, remove_lock_file_on_signal);
-		atexit(remove_lock_file);
+	if (0 <= fd) {
+		if (!lk->next) {
+			lk->next = lock_file_list;
+			lock_file_list = lk;
+			signal(SIGINT, remove_lock_file_on_signal);
+			atexit(remove_lock_file);
+		}
+		if (adjust_shared_perm(lk->filename))
+			return error("cannot fix permission bits on %s",
+				     lk->filename);
 	}
 	return fd;
 }
diff --git a/refs.c b/refs.c
index f91b771..713ca46 100644
--- a/refs.c
+++ b/refs.c
@@ -104,6 +104,11 @@ #endif
 		error("Unable to create %s", git_HEAD);
 		return -3;
 	}
+	if (adjust_shared_perm(git_HEAD)) {
+		unlink(lockpath);
+		error("Unable to fix permissions on %s", lockpath);
+		return -4;
+	}
 	return 0;
 }
 
diff --git a/setup.c b/setup.c
index fe7f884..213c596 100644
--- a/setup.c
+++ b/setup.c
@@ -223,8 +223,29 @@ int check_repository_format_version(cons
 {
        if (strcmp(var, "core.repositoryformatversion") == 0)
                repository_format_version = git_config_int(var, value);
-	else if (strcmp(var, "core.sharedrepository") == 0)
-		shared_repository = git_config_bool(var, value);
+       else if (strcmp(var, "core.sharedrepository") == 0) {
+	       /* This is unfortunate, but historically this
+		* variable was bool, and it now takes the umask
+		* to say if we want to keep the same access bits for
+		* the user to group members and others.
+		*/
+	       if (!value)
+		       shared_repository = 070; /* "true" - perhaps 075? */
+	       else if (!*value)
+		       ; /* bool "false" */
+	       else if (!strcasecmp(value, "true"))
+		       shared_repository = 070; /* "true" - perhaps 075? */
+	       else if (!strcasecmp(value, "false"))
+		       ; /* bool "false" */
+	       else if (strchr("01234567", *value)) {
+		       char *end;
+		       long val = strtol(value, &end, 8);
+		       if (*end || 077 < val)
+			       die("bad config value '%s' for '%s'",
+				   value, var);
+		       shared_repository = val;
+	       }
+       }
        return 0;
 }
 
diff --git a/sha1_file.c b/sha1_file.c
index aea0f40..fa19835 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -61,11 +61,14 @@ int adjust_shared_perm(const char *path)
 		return -1;
 	mode = st.st_mode;
 	if (mode & S_IRUSR)
-		mode |= S_IRGRP;
+		mode |= ( ((shared_repository & 040) ? S_IRGRP : 0) |
+			  ((shared_repository & 004) ? S_IROTH : 0) );
 	if (mode & S_IWUSR)
-		mode |= S_IWGRP;
+		mode |= ( ((shared_repository & 020) ? S_IWGRP : 0) |
+			  ((shared_repository & 002) ? S_IWOTH : 0) );
 	if (mode & S_IXUSR)
-		mode |= S_IXGRP;
+		mode |= ( ((shared_repository & 010) ? S_IXGRP : 0) |
+			  ((shared_repository & 001) ? S_IXOTH : 0) );
 	if (S_ISDIR(mode))
 		mode |= S_ISGID;
 	if (chmod(path, mode) < 0)
-- 
1.4.0.rc2.g55be
Linus Torvalds· Jun 10, 2006, 00:46 UTC · re: Junio C Hamano · lore

Re: [PATCH] shared repository settings enhancement.

On Fri, 9 Jun 2006, Junio C Hamano wrote:
Show 5 quoted lines
>
> This lets you say:
> 
> 	[core]
> 		sharedrepository = 075

I really think it's better to express this as some more traditional number.

I had to think about what 075 meant, while saying
	[core]
		sharedrepository = 0644

just makes sense more or less automatically (and yes, for directories, the read bit should obviously be expanded as an execute bit).

The difference is just that the latter is how you _usually_ express permissions, so people are used to it.

And "being used to it" is what "ease of use" really all boils down to.
		Linus
Jakub Narebski· Jun 10, 2006, 01:38 UTC · re: Linus Torvalds · lore

Re: [PATCH] shared repository settings enhancement.

Linus Torvalds wrote:
Show 16 quoted lines
> 
> 
> On Fri, 9 Jun 2006, Junio C Hamano wrote:
>>
>> This lets you say:
>> 
>>      [core]
>>              sharedrepository = 075
> 
> I really think it's better to express this as some more traditional 
> number.
> 
> I had to think about what 075 meant, while saying
> 
>       [core]
>               sharedrepository = 0644
Yet another solution would be to actually set umask.
-- 
Jakub Narebski
Warsaw, Poland
Junio C Hamano· Jun 10, 2006, 03:49 UTC · re: Linus Torvalds · lore

Re: [PATCH] shared repository settings enhancement.

Linus Torvalds <torvalds@osdl.org> writes:
Show 17 quoted lines
> On Fri, 9 Jun 2006, Junio C Hamano wrote:
>>
>> This lets you say:
>> 
>> 	[core]
>> 		sharedrepository = 075
>
> I really think it's better to express this as some more traditional 
> number.
>
> I had to think about what 075 meant, while saying
>
> 	[core]
> 		sharedrepository = 0644
>
> just makes sense more or less automatically (and yes, for directories, the 
> read bit should obviously be expanded as an execute bit).

Or probably use the umask notation, 007 for traditional shared repositories and 002 for gitweb exported ones. With your notation, people would start wondering what the distinction between 0755, 0644, and even 0254 is (there isn't any).

Having said that, I do not think the distinction is that important; I would rather make the core.sharedrepository = true to mean an equivalent of "chmod go+rX" (it does "chmod g+rX" currently).

Linus Torvalds· Jun 10, 2006, 04:08 UTC · re: Junio C Hamano · lore

Re: [PATCH] shared repository settings enhancement.

On Fri, 9 Jun 2006, Junio C Hamano wrote:
Show 5 quoted lines
> 
> Having said that, I do not think the distinction is that
> important; I would rather make the core.sharedrepository = true
> to mean an equivalent of "chmod go+rX" (it does "chmod g+rX"
> currently).
How about making it be
	[core]
		sharedrepository = {umask | user | group | everybody}

and allow the old boolean expression syntax to mean "0/false means umask, 1/true means group".

So you'd have:
 - umask/0/false means "use 0777 permissions with default umask"
 - user means "use 0500 permissions"
 - group means "use 0550 permissions"
 - everybody means "use 0555 permissions"

(where "5" is r-x, and only for directories, and obviously degenerates to just "4" aka r-- for regular files).

That sounds really pretty self-explanatory and obvious, wouldn't you say?
			Linus
Junio C Hamano· Jun 10, 2006, 04:19 UTC · re: Linus Torvalds · lore

Re: [PATCH] shared repository settings enhancement.

Linus Torvalds <torvalds@osdl.org> writes:
Show 19 quoted lines
> How about making it be
>
> 	[core]
> 		sharedrepository = {umask | user | group | everybody}
>
> and allow the old boolean expression syntax to mean "0/false means umask, 
> 1/true means group".
>
> So you'd have:
>
>  - umask/0/false means "use 0777 permissions with default umask"
>  - user means "use 0500 permissions"
>  - group means "use 0550 permissions"
>  - everybody means "use 0555 permissions"
>
> (where "5" is r-x, and only for directories, and obviously degenerates to 
> just "4" aka r-- for regular files).
>
> That sounds really pretty self-explanatory and obvious, wouldn't you say?

Yes, the user can mistype "gruop", people would start making noises about having "world" as a synonym for "everybody", and the parsing becomes somewhat cumbersome, and all that trouble, but on the other hand that is probably the easiest to explain.

Linus Torvalds· Jun 10, 2006, 04:39 UTC · re: Junio C Hamano · lore

Re: [PATCH] shared repository settings enhancement.

On Fri, 9 Jun 2006, Junio C Hamano wrote:
Show 5 quoted lines
> 
> Yes, the user can mistype "gruop", people would start making
> noises about having "world" as a synonym for "everybody", and
> the parsing becomes somewhat cumbersome, and all that trouble,
> but on the other hand that is probably the easiest to explain.
Actually, it's quite easy to parse using the git config file parsers.

Let's say that 0 means umask, 1 means group, 2 means user and 3 means everybody. That leaves "0/1" with the old false/true behaviour, and leaves umask as the default.

So we'd have
	enum sharedrepo {
		PERM_UMASK = 0,
		PERM_GROUP,
		PERM_USER,
		PERM_EVERYBODY
	};
	int git_config_perm(const char *var, const char *value)
	{
		if (!strncmp(value, "umask"))
			return PERM_UMASK;
		if (!strncmp(value, "group"))
			return PERM_GROUP;
		if (!strncmp(value, "user"))
			return PERM_USER;
		if (!strncmp(value, "world") || !strncmp(value, "everybody"))
			return PERM_EVERYBODY;
		return git_config_bool(var, value);
	}
and then in check_repository_format_version() you just have
	..
	else if (strcmp(var, "core.sharedrepository") == 0)
		shared_repository = git_config_perm(var, value);
	..

instead of git_config_bool() there, and you're done. That's not so bad, is it?

		Linus
Alex Riesen· Jun 10, 2006, 21:30 UTC · re: Post, Mark K · lore

Re: Git-daemon messing up permissions for gitweb

Post, Mark K, Fri, Jun 09, 2006 22:52:22 +0200:
> Since umask isn't an environment variable, per se, I'm not sure how this
> will change anything.

$ ssh -V OpenSSH_4.2p1, OpenSSL 0.9.7i 14 Oct 2005

$ man sshd
     ~/.ssh/rc
             If this file exists, it is run with /bin/sh after reading the
             environment files but before starting the user's shell or com-
             mand.  It must not produce any output on stdout; stderr must be
             used instead.  If X11 forwarding is in use, it will receive the
             "proto cookie" pair in its standard input (and DISPLAY in its
             environment).  The script must call xauth(1) because sshd will
             not run xauth automatically to add X11 cookies.
AFAIK, it was always there.
Linus Torvalds· Jun 10, 2006, 21:41 UTC · re: Alex Riesen · lore

Re: Git-daemon messing up permissions for gitweb

On Sat, 10 Jun 2006, Alex Riesen wrote:
>
>      ~/.ssh/rc
> 
> AFAIK, it was always there.

Note that since umask is a per-process flag, and only inherited from parents to children, not the other way around, if the rc file is run as a separate shell script (and I assume it is) instead of "sourced" from the the shell that actually executes the programs you run, then this won't help at all.

Try:
	sh -c "umask 0777 ; umask" ; umask
to see in more graphic ("textual") detail what I mean.
		Linus
Alex Riesen· Jun 10, 2006, 22:30 UTC · re: Linus Torvalds · lore

Re: Git-daemon messing up permissions for gitweb

Linus Torvalds, Sat, Jun 10, 2006 23:41:52 +0200:
Show 10 quoted lines
> >
> >      ~/.ssh/rc
> > 
> > AFAIK, it was always there.
> 
> Note that since umask is a per-process flag, and only inherited from 
> parents to children, not the other way around, if the rc file is run as a 
> separate shell script (and I assume it is) instead of "sourced" from the 
> the shell that actually executes the programs you run, then this won't 
> help at all.

Right, it doesn't. I should have tried ~/.ssh/rc with umask, really. Because of this it can't be used for environment too (that's why they have ~/.ssh/environment).

← back to recent threads