{"thread":{"id":"4451","subject":"RE: Git-daemon messing up permissions for gitweb","startedAt":"2006-06-09T20:52:22Z","lastAt":"2006-06-10T22:30:53Z","messageCount":14,"participants":["Post, Mark K","Junio C Hamano","Linus Torvalds","Jakub Narebski","Rene Scharfe","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"21497","messageId":"5A14AF34CFF8AD44A44891F7C9FF410507957896@usahm236.amer.corp.eds.com","threadId":"4451","inReplyTo":null,"subject":"RE: Git-daemon messing up permissions for gitweb","fromName":"Post, Mark K","fromEmail":"mark.post@eds.com","sentAt":"2006-06-09T20:52:22Z","receivedAt":"2006-06-09T20:52:22Z","isPatch":false,"sender":{"key":"mark.post@eds.com","avatar":null},"body":"Since umask isn't an environment variable, per se, I'm not sure how this\nwill change anything.\n\nOne other thing I noticed is that init-db.c spells core.sharedRepository\nwith a capital R, but setup.c spells it \"core.sharedrepository\" with no\nupper case letters.  Would this make any difference to anything I'm\nseeing? \n\n\nMark Post\n\n-----Original Message-----\nFrom: Linus Torvalds [mailto:torvalds@osdl.org] \nSent: Friday, June 09, 2006 4:44 PM\nTo: Junio C Hamano\nCc: git@vger.kernel.org; Post, Mark K\nSubject: Re: Git-daemon messing up permissions for gitweb\n\n\n\nOn Fri, 9 Jun 2006, Junio C Hamano wrote:\n>\n> But that should be tweakable by configuring what sshd does for\n> the user, shouldn't it?  The \"LOGIN PROCESS\" section from man\n> sshd(8) seems to talk about $HOME/.ssh/environment, for example.\n\nYeah. That's probably the right place to set things up.\n\n\t\tLinus\n"},{"id":"21502","messageId":"7virnam435.fsf@assigned-by-dhcp.cox.net","threadId":"4451","inReplyTo":"5A14AF34CFF8AD44A44891F7C9FF410507957896@usahm236.amer.corp.eds.com","subject":"Re: Git-daemon messing up permissions for gitweb","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-09T21:06:22Z","receivedAt":"2006-06-09T21:06:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Post, Mark K\" <mark.post@eds.com> writes:\n\n> Since umask isn't an environment variable, per se, I'm not sure how this\n> will change anything.\n\nI do not configure my sshd, so you may need a bit more reading\non it yourself; $HOME/.ssh/environment does not seem to be it,\nas you said.\n\n> One other thing I noticed is that init-db.c spells core.sharedRepository\n> with a capital R, but setup.c spells it \"core.sharedrepository\" with no\n> upper case letters.  Would this make any difference to anything I'm\n> seeing? \n\nThe distinction should not matter since the code downcases\n(git_config_set_multivar() in config.c) it, but to avoid future\nconfusion we might want to downcase the one in init-db.c\n"},{"id":"21514","messageId":"7v3bedn8ym.fsf_-_@assigned-by-dhcp.cox.net","threadId":"4451","inReplyTo":"7virnam435.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH/RFC] Retire SIMPLE_*** stuff.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-10T00:35:45Z","receivedAt":"2006-06-10T00:35:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It used to be a good idea to keep simple stuff without linking with git\nlibrary, but more and more programs are using the config mechanism, and\nyet more things are becoming internal.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n Makefile |   24 +++++-------------------\n 1 files changed, 5 insertions(+), 19 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 5226fa1..d65fc71 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -142,12 +142,7 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)\n \t  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \\\n \t  git-cherry-pick git-status\n \n-# The ones that do not have to link with lcrypto, lz nor xdiff.\n-SIMPLE_PROGRAMS = \\\n-\tgit-get-tar-commit-id$X git-mailsplit$X \\\n-\tgit-stripspace$X git-daemon$X\n-\n-# ... and all the rest that could be moved out of bindir to gitexecdir\n+# Programs could be moved out of bindir to gitexecdir\n PROGRAMS = \\\n \tgit-checkout-index$X git-clone-pack$X \\\n \tgit-convert-objects$X git-fetch-pack$X git-fsck-objects$X \\\n@@ -162,7 +157,9 @@ PROGRAMS = \\\n \tgit-upload-pack$X git-verify-pack$X git-write-tree$X \\\n \tgit-update-ref$X git-symbolic-ref$X \\\n \tgit-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \\\n-\tgit-describe$X git-merge-tree$X git-blame$X git-imap-send$X\n+\tgit-describe$X git-merge-tree$X git-blame$X git-imap-send$X \\\n+\tgit-get-tar-commit-id$X git-mailsplit$X \\\n+\tgit-stripspace$X git-daemon$X\n \n BUILT_INS = git-log$X git-whatchanged$X git-show$X \\\n \tgit-count-objects$X git-diff$X git-push$X \\\n@@ -175,7 +172,7 @@ BUILT_INS = git-log$X git-whatchanged$X \n \tgit-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X\n \n # what 'all' will build and 'install' will install, in gitexecdir\n-ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)\n+ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)\n \n # Backward compatibility -- to be removed after 1.0\n PROGRAMS += git-ssh-pull$X git-ssh-push$X\n@@ -386,11 +383,9 @@ else\n endif\n ifdef NEEDS_SOCKET\n \tLIBS += -lsocket\n-\tSIMPLE_LIB += -lsocket\n endif\n ifdef NEEDS_NSL\n \tLIBS += -lnsl\n-\tSIMPLE_LIB += -lnsl\n endif\n ifdef NO_D_TYPE_IN_DIRENT\n \tALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT\n@@ -428,6 +428,8 @@ endif\n \n ifdef NO_ICONV\n \tALL_CFLAGS += -DNO_ICONV\n+else\n+\tLIBS += $(LIB_4_ICONV)\n endif\n \n ifdef PPC_SHA1\n\n@@ -559,15 +554,6 @@ endif\n git-%$X: %.o $(GITLIBS)\n \t$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n \n-$(SIMPLE_PROGRAMS) : $(LIB_FILE)\n-$(SIMPLE_PROGRAMS) : git-%$X : %.o\n-\t$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n-\t\t$(LIB_FILE) $(SIMPLE_LIB)\n-\n-git-mailinfo$X: mailinfo.o $(LIB_FILE)\n-\t$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n-\t\t$(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)\n-\n git-local-fetch$X: fetch.o\n git-ssh-fetch$X: rsh.o fetch.o\n git-ssh-upload$X: rsh.o\n-- \n1.4.0.rc2.g55be\n"},{"id":"21515","messageId":"7vver9lu8g.fsf_-_@assigned-by-dhcp.cox.net","threadId":"4451","inReplyTo":"7virnam435.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] shared repository settings enhancement.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-10T00:39:11Z","receivedAt":"2006-06-10T00:39:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This lets you say:\n\n\t[core]\n\t\tsharedrepository = 075\n\nto allow permission bits on files under $GIT_DIR for OTHER users\n(not just GROUP users) to be copied from the permission bits of\nthe owner of the file.  This is useful for publishing a shared\nrepository over gitweb, when gitweb does not run as a member of\nthe project group and some members have umask too strict for\nothers to read what is created by default.  The historical\nboolean sharedrepository maps to 070 (i.e. if the owner can read\nor write or execute it, group members can, too).\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * This patch is meant for discussion, not application, as you\n   can see there is one big \"NEEDSWORK\" in builtin-init-db.c.\n\n   Regardless of this enhancement to deal with S_I[RWX]OTH, I\n   spotted a couple of places that lack permission adjustment in\n   the existing code, which might be worth fixing first.\n\n builtin-init-db.c |   21 ++++++++++++++++++---\n config.c          |    2 +-\n lockfile.c        |   15 ++++++++++-----\n refs.c            |    5 +++++\n setup.c           |   25 +++++++++++++++++++++++--\n sha1_file.c       |    9 ++++++---\n 6 files changed, 63 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 88b39a4..4826c08 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -198,6 +198,11 @@ static void create_default_files(const c\n \n \tgit_config(git_default_config);\n \n+\t/* NEEDSWORK: we would have created the above under user's\n+\t * umask -- under shared-repository settings, we would need\n+\t * to fix them up by scanning under $GIT_DIR here.\n+\t */\n+\n \t/*\n \t * Create the default symlink from \".git/HEAD\" to the \"master\"\n \t * branch, if it does not exist yet.\n@@ -248,7 +253,14 @@ int cmd_init_db(int argc, const char **a\n \t\tif (!strncmp(arg, \"--template=\", 11))\n \t\t\ttemplate_dir = arg+11;\n \t\telse if (!strcmp(arg, \"--shared\"))\n-\t\t\tshared_repository = 1;\n+\t\t\tshared_repository = 070; /* might want 075 */\n+\t\telse if (!strncmp(arg, \"--shared=\", 9)) {\n+\t\t\tchar *end;\n+\t\t\tlong val = strtol(arg+9, &end, 8);\n+\t\t\tif (*end || 077 < val)\n+\t\t\t\tdie(\"bad option for --shared=\");\n+\t\t\tshared_repository = val;\n+\t\t}\n \t\telse\n \t\t\tdie(init_db_usage);\n \t}\n@@ -286,8 +298,11 @@ int cmd_init_db(int argc, const char **a\n \tstrcpy(path+len, \"/info\");\n \tsafe_create_dir(path, 1);\n \n-\tif (shared_repository)\n-\t\tgit_config_set(\"core.sharedrepository\", \"true\");\n+\tif (shared_repository) {\n+\t\tchar buf[6];\n+\t\tsprintf(buf, \"%o\", shared_repository);\n+\t\tgit_config_set(\"core.sharedrepository\", buf);\n+\t}\n \n \treturn 0;\n }\ndiff --git a/config.c b/config.c\nindex 2ae6153..c474970 100644\n--- a/config.c\n+++ b/config.c\n@@ -536,7 +536,7 @@ int git_config_set_multivar(const char* \n \t * contents of .git/config will be written into it.\n \t */\n \tfd = open(lock_file, O_WRONLY | O_CREAT | O_EXCL, 0666);\n-\tif (fd < 0) {\n+\tif (fd < 0 || adjust_shared_perm(lock_file)) {\n \t\tfprintf(stderr, \"could not lock config file\\n\");\n \t\tfree(store.key);\n \t\tret = -1;\ndiff --git a/lockfile.c b/lockfile.c\nindex 9bc6083..2346e0e 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -27,11 +27,16 @@ int hold_lock_file_for_update(struct loc\n \tint fd;\n \tsprintf(lk->filename, \"%s.lock\", path);\n \tfd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);\n-\tif (fd >=0 && !lk->next) {\n-\t\tlk->next = lock_file_list;\n-\t\tlock_file_list = lk;\n-\t\tsignal(SIGINT, remove_lock_file_on_signal);\n-\t\tatexit(remove_lock_file);\n+\tif (0 <= fd) {\n+\t\tif (!lk->next) {\n+\t\t\tlk->next = lock_file_list;\n+\t\t\tlock_file_list = lk;\n+\t\t\tsignal(SIGINT, remove_lock_file_on_signal);\n+\t\t\tatexit(remove_lock_file);\n+\t\t}\n+\t\tif (adjust_shared_perm(lk->filename))\n+\t\t\treturn error(\"cannot fix permission bits on %s\",\n+\t\t\t\t     lk->filename);\n \t}\n \treturn fd;\n }\ndiff --git a/refs.c b/refs.c\nindex f91b771..713ca46 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -104,6 +104,11 @@ #endif\n \t\terror(\"Unable to create %s\", git_HEAD);\n \t\treturn -3;\n \t}\n+\tif (adjust_shared_perm(git_HEAD)) {\n+\t\tunlink(lockpath);\n+\t\terror(\"Unable to fix permissions on %s\", lockpath);\n+\t\treturn -4;\n+\t}\n \treturn 0;\n }\n \ndiff --git a/setup.c b/setup.c\nindex fe7f884..213c596 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -223,8 +223,29 @@ int check_repository_format_version(cons\n {\n        if (strcmp(var, \"core.repositoryformatversion\") == 0)\n                repository_format_version = git_config_int(var, value);\n-\telse if (strcmp(var, \"core.sharedrepository\") == 0)\n-\t\tshared_repository = git_config_bool(var, value);\n+       else if (strcmp(var, \"core.sharedrepository\") == 0) {\n+\t       /* This is unfortunate, but historically this\n+\t\t* variable was bool, and it now takes the umask\n+\t\t* to say if we want to keep the same access bits for\n+\t\t* the user to group members and others.\n+\t\t*/\n+\t       if (!value)\n+\t\t       shared_repository = 070; /* \"true\" - perhaps 075? */\n+\t       else if (!*value)\n+\t\t       ; /* bool \"false\" */\n+\t       else if (!strcasecmp(value, \"true\"))\n+\t\t       shared_repository = 070; /* \"true\" - perhaps 075? */\n+\t       else if (!strcasecmp(value, \"false\"))\n+\t\t       ; /* bool \"false\" */\n+\t       else if (strchr(\"01234567\", *value)) {\n+\t\t       char *end;\n+\t\t       long val = strtol(value, &end, 8);\n+\t\t       if (*end || 077 < val)\n+\t\t\t       die(\"bad config value '%s' for '%s'\",\n+\t\t\t\t   value, var);\n+\t\t       shared_repository = val;\n+\t       }\n+       }\n        return 0;\n }\n \ndiff --git a/sha1_file.c b/sha1_file.c\nindex aea0f40..fa19835 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -61,11 +61,14 @@ int adjust_shared_perm(const char *path)\n \t\treturn -1;\n \tmode = st.st_mode;\n \tif (mode & S_IRUSR)\n-\t\tmode |= S_IRGRP;\n+\t\tmode |= ( ((shared_repository & 040) ? S_IRGRP : 0) |\n+\t\t\t  ((shared_repository & 004) ? S_IROTH : 0) );\n \tif (mode & S_IWUSR)\n-\t\tmode |= S_IWGRP;\n+\t\tmode |= ( ((shared_repository & 020) ? S_IWGRP : 0) |\n+\t\t\t  ((shared_repository & 002) ? S_IWOTH : 0) );\n \tif (mode & S_IXUSR)\n-\t\tmode |= S_IXGRP;\n+\t\tmode |= ( ((shared_repository & 010) ? S_IXGRP : 0) |\n+\t\t\t  ((shared_repository & 001) ? S_IXOTH : 0) );\n \tif (S_ISDIR(mode))\n \t\tmode |= S_ISGID;\n \tif (chmod(path, mode) < 0)\n-- \n1.4.0.rc2.g55be\n"},{"id":"21517","messageId":"Pine.LNX.4.64.0606091743410.5498@g5.osdl.org","threadId":"4451","inReplyTo":"7vver9lu8g.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] shared repository settings enhancement.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-06-10T00:46:04Z","receivedAt":"2006-06-10T00:46:04Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 9 Jun 2006, Junio C Hamano wrote:\n>\n> This lets you say:\n> \n> \t[core]\n> \t\tsharedrepository = 075\n\nI really think it's better to express this as some more traditional \nnumber.\n\nI had to think about what 075 meant, while saying\n\n\t[core]\n\t\tsharedrepository = 0644\n\njust makes sense more or less automatically (and yes, for directories, the \nread bit should obviously be expanded as an execute bit).\n\nThe difference is just that the latter is how you _usually_ express \npermissions, so people are used to it. \n\nAnd \"being used to it\" is what \"ease of use\" really all boils down to.\n\n\t\tLinus\n"},{"id":"21521","messageId":"e6d7qk$64r$1@sea.gmane.org","threadId":"4451","inReplyTo":"Pine.LNX.4.64.0606091743410.5498@g5.osdl.org","subject":"Re: [PATCH] shared repository settings enhancement.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-06-10T01:38:38Z","receivedAt":"2006-06-10T01:38:38Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Linus Torvalds wrote:\n\n> \n> \n> On Fri, 9 Jun 2006, Junio C Hamano wrote:\n>>\n>> This lets you say:\n>> \n>>      [core]\n>>              sharedrepository = 075\n> \n> I really think it's better to express this as some more traditional \n> number.\n> \n> I had to think about what 075 meant, while saying\n> \n>       [core]\n>               sharedrepository = 0644\n\nYet another solution would be to actually set umask.\n\n-- \nJakub Narebski\nWarsaw, Poland\n"},{"id":"21532","messageId":"7v8xo5lleo.fsf@assigned-by-dhcp.cox.net","threadId":"4451","inReplyTo":"Pine.LNX.4.64.0606091743410.5498@g5.osdl.org","subject":"Re: [PATCH] shared repository settings enhancement.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-10T03:49:51Z","receivedAt":"2006-06-10T03:49:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> On Fri, 9 Jun 2006, Junio C Hamano wrote:\n>>\n>> This lets you say:\n>> \n>> \t[core]\n>> \t\tsharedrepository = 075\n>\n> I really think it's better to express this as some more traditional \n> number.\n>\n> I had to think about what 075 meant, while saying\n>\n> \t[core]\n> \t\tsharedrepository = 0644\n>\n> just makes sense more or less automatically (and yes, for directories, the \n> read bit should obviously be expanded as an execute bit).\n\nOr probably use the umask notation, 007 for traditional shared\nrepositories and 002 for gitweb exported ones.  With your\nnotation, people would start wondering what the distinction\nbetween 0755, 0644, and even 0254 is (there isn't any).\n\nHaving said that, I do not think the distinction is that\nimportant; I would rather make the core.sharedrepository = true\nto mean an equivalent of \"chmod go+rX\" (it does \"chmod g+rX\"\ncurrently).\n"},{"id":"21535","messageId":"Pine.LNX.4.64.0606092103170.5498@g5.osdl.org","threadId":"4451","inReplyTo":"7v8xo5lleo.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] shared repository settings enhancement.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-06-10T04:08:30Z","receivedAt":"2006-06-10T04:08:30Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 9 Jun 2006, Junio C Hamano wrote:\n> \n> Having said that, I do not think the distinction is that\n> important; I would rather make the core.sharedrepository = true\n> to mean an equivalent of \"chmod go+rX\" (it does \"chmod g+rX\"\n> currently).\n\nHow about making it be\n\n\t[core]\n\t\tsharedrepository = {umask | user | group | everybody}\n\nand allow the old boolean expression syntax to mean \"0/false means umask, \n1/true means group\".\n\nSo you'd have:\n\n - umask/0/false means \"use 0777 permissions with default umask\"\n - user means \"use 0500 permissions\"\n - group means \"use 0550 permissions\"\n - everybody means \"use 0555 permissions\"\n\n(where \"5\" is r-x, and only for directories, and obviously degenerates to \njust \"4\" aka r-- for regular files).\n\nThat sounds really pretty self-explanatory and obvious, wouldn't you say?\n\n\t\t\tLinus\n"},{"id":"21537","messageId":"7vver9k5gg.fsf@assigned-by-dhcp.cox.net","threadId":"4451","inReplyTo":"Pine.LNX.4.64.0606092103170.5498@g5.osdl.org","subject":"Re: [PATCH] shared repository settings enhancement.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-10T04:19:43Z","receivedAt":"2006-06-10T04:19:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> How about making it be\n>\n> \t[core]\n> \t\tsharedrepository = {umask | user | group | everybody}\n>\n> and allow the old boolean expression syntax to mean \"0/false means umask, \n> 1/true means group\".\n>\n> So you'd have:\n>\n>  - umask/0/false means \"use 0777 permissions with default umask\"\n>  - user means \"use 0500 permissions\"\n>  - group means \"use 0550 permissions\"\n>  - everybody means \"use 0555 permissions\"\n>\n> (where \"5\" is r-x, and only for directories, and obviously degenerates to \n> just \"4\" aka r-- for regular files).\n>\n> That sounds really pretty self-explanatory and obvious, wouldn't you say?\n\nYes, the user can mistype \"gruop\", people would start making\nnoises about having \"world\" as a synonym for \"everybody\", and\nthe parsing becomes somewhat cumbersome, and all that trouble,\nbut on the other hand that is probably the easiest to explain.\n"},{"id":"21538","messageId":"Pine.LNX.4.64.0606092131150.5498@g5.osdl.org","threadId":"4451","inReplyTo":"7vver9k5gg.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] shared repository settings enhancement.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-06-10T04:39:45Z","receivedAt":"2006-06-10T04:39:45Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 9 Jun 2006, Junio C Hamano wrote:\n> \n> Yes, the user can mistype \"gruop\", people would start making\n> noises about having \"world\" as a synonym for \"everybody\", and\n> the parsing becomes somewhat cumbersome, and all that trouble,\n> but on the other hand that is probably the easiest to explain.\n\nActually, it's quite easy to parse using the git config file parsers.\n\nLet's say that 0 means umask, 1 means group, 2 means user and 3 means \neverybody. That leaves \"0/1\" with the old false/true behaviour, and leaves \numask as the default.\n\nSo we'd have\n\n\tenum sharedrepo {\n\t\tPERM_UMASK = 0,\n\t\tPERM_GROUP,\n\t\tPERM_USER,\n\t\tPERM_EVERYBODY\n\t};\n\n\tint git_config_perm(const char *var, const char *value)\n\t{\n\t\tif (!strncmp(value, \"umask\"))\n\t\t\treturn PERM_UMASK;\n\t\tif (!strncmp(value, \"group\"))\n\t\t\treturn PERM_GROUP;\n\t\tif (!strncmp(value, \"user\"))\n\t\t\treturn PERM_USER;\n\t\tif (!strncmp(value, \"world\") || !strncmp(value, \"everybody\"))\n\t\t\treturn PERM_EVERYBODY;\n\t\treturn git_config_bool(var, value);\n\t}\n\nand then in check_repository_format_version() you just have\n\n\t..\n\telse if (strcmp(var, \"core.sharedrepository\") == 0)\n\t\tshared_repository = git_config_perm(var, value);\n\t..\n\ninstead of git_config_bool() there, and you're done. That's not so bad, is \nit?\n\n\t\tLinus\n"},{"id":"21547","messageId":"20060610141341.GA5787@lsrfire.ath.cx","threadId":"4451","inReplyTo":"7v3bedn8ym.fsf_-_@assigned-by-dhcp.cox.net","subject":"[PATCH] Built-in git-get-tar-commit-id (was: [PATCH/RFC] Retire SIMPLE_*** stuff.)","fromName":"Rene Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2006-06-10T14:13:41Z","receivedAt":"2006-06-10T14:13:41Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"By being an internal command git-get-commit-id can make use of\nstruct ustar_header and other stuff and stops wasting precious\ndisk space.\n\nNote: I recycled one of the two \"tar-tree\" entries instead of\nsplitting that cleanup into a separate patch.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n\ndiff --git a/Makefile b/Makefile\nindex 5226fa1..2a1e639 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -142,11 +142,11 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)\n \t  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \\\n \t  git-cherry-pick git-status\n \n # The ones that do not have to link with lcrypto, lz nor xdiff.\n SIMPLE_PROGRAMS = \\\n-\tgit-get-tar-commit-id$X git-mailsplit$X \\\n+\tgit-mailsplit$X \\\n \tgit-stripspace$X git-daemon$X\n \n # ... and all the rest that could be moved out of bindir to gitexecdir\n PROGRAMS = \\\n \tgit-checkout-index$X git-clone-pack$X \\\n@@ -167,11 +167,11 @@ PROGRAMS = \\\n BUILT_INS = git-log$X git-whatchanged$X git-show$X \\\n \tgit-count-objects$X git-diff$X git-push$X \\\n \tgit-grep$X git-add$X git-rm$X git-rev-list$X \\\n \tgit-check-ref-format$X git-rev-parse$X \\\n \tgit-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \\\n-\tgit-ls-files$X git-ls-tree$X \\\n+\tgit-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \\\n \tgit-read-tree$X git-commit-tree$X \\\n \tgit-apply$X git-show-branch$X git-diff-files$X \\\n \tgit-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X\n \n # what 'all' will build and 'install' will install, in gitexecdir\ndiff --git a/builtin-tar-tree.c b/builtin-tar-tree.c\nindex 7663b9b..58a8ccd 100644\n--- a/builtin-tar-tree.c\n+++ b/builtin-tar-tree.c\n@@ -400,5 +400,30 @@ int cmd_tar_tree(int argc, const char **\n \t\tusage(tar_tree_usage);\n \tif (!strncmp(\"--remote=\", argv[1], 9))\n \t\treturn remote_tar(argc, argv);\n \treturn generate_tar(argc, argv, envp);\n }\n+\n+/* ustar header + extended global header content */\n+#define HEADERSIZE (2 * RECORDSIZE)\n+\n+int cmd_get_tar_commit_id(int argc, const char **argv, char **envp)\n+{\n+\tchar buffer[HEADERSIZE];\n+\tstruct ustar_header *header = (struct ustar_header *)buffer;\n+\tchar *content = buffer + RECORDSIZE;\n+\tssize_t n;\n+\n+\tn = xread(0, buffer, HEADERSIZE);\n+\tif (n < HEADERSIZE)\n+\t\tdie(\"git-get-tar-commit-id: read error\");\n+\tif (header->typeflag[0] != 'g')\n+\t\treturn 1;\n+\tif (memcmp(content, \"52 comment=\", 11))\n+\t\treturn 1;\n+\n+\tn = xwrite(1, content + 11, 41);\n+\tif (n < 41)\n+\t\tdie(\"git-get-tar-commit-id: write error\");\n+\n+\treturn 0;\n+}\ndiff --git a/builtin.h b/builtin.h\nindex ffa9340..b9f36be 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -30,10 +30,11 @@ extern int cmd_add(int argc, const char \n extern int cmd_rev_list(int argc, const char **argv, char **envp);\n extern int cmd_check_ref_format(int argc, const char **argv, char **envp);\n extern int cmd_init_db(int argc, const char **argv, char **envp);\n extern int cmd_tar_tree(int argc, const char **argv, char **envp);\n extern int cmd_upload_tar(int argc, const char **argv, char **envp);\n+extern int cmd_get_tar_commit_id(int argc, const char **argv, char **envp);\n extern int cmd_ls_files(int argc, const char **argv, char **envp);\n extern int cmd_ls_tree(int argc, const char **argv, char **envp);\n extern int cmd_read_tree(int argc, const char **argv, char **envp);\n extern int cmd_commit_tree(int argc, const char **argv, char **envp);\n extern int cmd_apply(int argc, const char **argv, char **envp);\ndiff --git a/get-tar-commit-id.c b/get-tar-commit-id.c\ndeleted file mode 100644\nindex 4166290..0000000\n--- a/get-tar-commit-id.c\n+++ /dev/null\n@@ -1,30 +0,0 @@\n-/*\n- * Copyright (C) 2005 Rene Scharfe\n- */\n-#include <stdio.h>\n-#include <string.h>\n-#include <unistd.h>\n-\n-#define HEADERSIZE\t1024\n-\n-int main(int argc, char **argv)\n-{\n-\tchar buffer[HEADERSIZE];\n-\tssize_t n;\n-\n-\tn = read(0, buffer, HEADERSIZE);\n-\tif (n < HEADERSIZE) {\n-\t\tfprintf(stderr, \"read error\\n\");\n-\t\treturn 3;\n-\t}\n-\tif (buffer[156] != 'g')\n-\t\treturn 1;\n-\tif (memcmp(&buffer[512], \"52 comment=\", 11))\n-\t\treturn 1;\n-\tn = write(1, &buffer[523], 41);\n-\tif (n < 41) {\n-\t\tfprintf(stderr, \"write error\\n\");\n-\t\treturn 2;\n-\t}\n-\treturn 0;\n-}\ndiff --git a/git.c b/git.c\nindex 6db8f2b..9469d44 100644\n--- a/git.c\n+++ b/git.c\n@@ -161,11 +161,11 @@ static void handle_internal_command(int \n \t\t{ \"grep\", cmd_grep },\n \t\t{ \"rm\", cmd_rm },\n \t\t{ \"add\", cmd_add },\n \t\t{ \"rev-list\", cmd_rev_list },\n \t\t{ \"init-db\", cmd_init_db },\n-\t\t{ \"tar-tree\", cmd_tar_tree },\n+\t\t{ \"get-tar-commit-id\", cmd_get_tar_commit_id },\n \t\t{ \"upload-tar\", cmd_upload_tar },\n \t\t{ \"check-ref-format\", cmd_check_ref_format },\n \t\t{ \"ls-files\", cmd_ls_files },\n \t\t{ \"ls-tree\", cmd_ls_tree },\n \t\t{ \"tar-tree\", cmd_tar_tree },\n"},{"id":"21562","messageId":"20060610213051.GB5825@steel.home","threadId":"4451","inReplyTo":"5A14AF34CFF8AD44A44891F7C9FF410507957896@usahm236.amer.corp.eds.com","subject":"Re: Git-daemon messing up permissions for gitweb","fromName":"Alex Riesen","fromEmail":"fork0@t-online.de","sentAt":"2006-06-10T21:30:51Z","receivedAt":"2006-06-10T21:30:51Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Post, Mark K, Fri, Jun 09, 2006 22:52:22 +0200:\n> Since umask isn't an environment variable, per se, I'm not sure how this\n> will change anything.\n\n$ ssh -V\nOpenSSH_4.2p1, OpenSSL 0.9.7i 14 Oct 2005\n\n$ man sshd\n     ~/.ssh/rc\n             If this file exists, it is run with /bin/sh after reading the\n             environment files but before starting the user's shell or com-\n             mand.  It must not produce any output on stdout; stderr must be\n             used instead.  If X11 forwarding is in use, it will receive the\n             \"proto cookie\" pair in its standard input (and DISPLAY in its\n             environment).  The script must call xauth(1) because sshd will\n             not run xauth automatically to add X11 cookies.\n\nAFAIK, it was always there.\n"},{"id":"21563","messageId":"Pine.LNX.4.64.0606101439530.5498@g5.osdl.org","threadId":"4451","inReplyTo":"20060610213051.GB5825@steel.home","subject":"Re: Git-daemon messing up permissions for gitweb","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-06-10T21:41:52Z","receivedAt":"2006-06-10T21:41:52Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 10 Jun 2006, Alex Riesen wrote:\n>\n>      ~/.ssh/rc\n> \n> AFAIK, it was always there.\n\nNote that since umask is a per-process flag, and only inherited from \nparents to children, not the other way around, if the rc file is run as a \nseparate shell script (and I assume it is) instead of \"sourced\" from the \nthe shell that actually executes the programs you run, then this won't \nhelp at all.\n\nTry:\n\n\tsh -c \"umask 0777 ; umask\" ; umask\n\nto see in more graphic (\"textual\") detail what I mean.\n\n\t\tLinus\n"},{"id":"21565","messageId":"20060610223053.GC5825@steel.home","threadId":"4451","inReplyTo":"Pine.LNX.4.64.0606101439530.5498@g5.osdl.org","subject":"Re: Git-daemon messing up permissions for gitweb","fromName":"Alex Riesen","fromEmail":"fork0@t-online.de","sentAt":"2006-06-10T22:30:53Z","receivedAt":"2006-06-10T22:30:53Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Linus Torvalds, Sat, Jun 10, 2006 23:41:52 +0200:\n> >\n> >      ~/.ssh/rc\n> > \n> > AFAIK, it was always there.\n> \n> Note that since umask is a per-process flag, and only inherited from \n> parents to children, not the other way around, if the rc file is run as a \n> separate shell script (and I assume it is) instead of \"sourced\" from the \n> the shell that actually executes the programs you run, then this won't \n> help at all.\n\nRight, it doesn't. I should have tried ~/.ssh/rc with umask, really.\nBecause of this it can't be used for environment too (that's why they\nhave ~/.ssh/environment).\n"}]}