{"thread":{"id":"2911","subject":"[PATCH] Introduce core.sharedrepository","startedAt":"2005-12-22T22:13:56Z","lastAt":"2005-12-23T11:07:18Z","messageCount":7,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13962","messageId":"Pine.LNX.4.63.0512222313070.12044@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2911","inReplyTo":null,"subject":"[PATCH] Introduce core.sharedrepository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-12-22T22:13:56Z","receivedAt":"2005-12-22T22:13:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThis is the second attempt, after Junio convinced me that my simple approach\nto set umask was misguided.\n\nIf the config variable 'core.sharedrepository' is set, the directories\n\n\t$GIT_DIR/objects/\n\t$GIT_DIR/objects/??\n\t$GIT_DIR/objects/pack\n\t$GIT_DIR/refs\n\t$GIT_DIR/refs/heads\n\t$GIT_DIR/refs/heads/tags\n\nare set group writable (and g+s, since the git group may be not the primary\ngroup of all users).\n\nSince all files are written as lock files first,\nand then moved to their destination, they do not have to be group writable.\nIndeed, if this leads to problems you found a bug.\n\nNote that -- as in my first attempt -- the config variable is set in the\nfunction which checks the repository format. If this were done in\ngit_default_config instead, a lot of programs would need to be modified\nto call git_config(git_default_config) first.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n cache.h     |    1 +\n setup.c     |    4 ++++\n sha1_file.c |   21 +++++++++++++++++++++\n 3 files changed, 26 insertions(+), 0 deletions(-)\n\n1a164f16e90378ba66e70e6082266645d3b45c57\ndiff --git a/cache.h b/cache.h\nindex cb87bec..0f875dd 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -159,6 +159,7 @@ extern void rollback_index_file(struct c\n extern int trust_executable_bit;\n extern int only_use_symrefs;\n extern int diff_rename_limit_default;\n+extern int shared_repository;\n \n #define GIT_REPO_VERSION 0\n extern int repository_format_version;\ndiff --git a/setup.c b/setup.c\nindex d3556ed..3de372e 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -1,5 +1,7 @@\n #include \"cache.h\"\n \n+int shared_repository = 0;\n+\n const char *prefix_path(const char *prefix, int len, const char *path)\n {\n \tconst char *orig = path;\n@@ -180,6 +182,8 @@ 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        return 0;\n }\n \ndiff --git a/sha1_file.c b/sha1_file.c\nindex d451a94..e109a07 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -48,6 +48,21 @@ int get_sha1_hex(const char *hex, unsign\n \treturn 0;\n }\n \n+static int make_group_writable(const char *path)\n+{\n+\tstruct stat st;\n+\n+\tif (lstat(path, &st) < 0)\n+\t\treturn -1;\n+\tif (st.st_mode & S_IWUSR)\n+\t\tst.st_mode |= S_IWGRP;\n+\tif (S_ISDIR(st.st_mode))\n+\t\tst.st_mode |= S_ISGID;\n+\tif (chmod(path, st.st_mode) < 0)\n+\t\treturn -2;\n+\treturn 0;\n+}\n+\n int safe_create_leading_directories(char *path)\n {\n \tchar *pos = path;\n@@ -64,6 +79,10 @@ int safe_create_leading_directories(char\n \t\t\t\t*pos = '/';\n \t\t\t\treturn -1;\n \t\t\t}\n+\t\tif (shared_repository && make_group_writable(path)) {\n+\t\t\t*pos = '/';\n+\t\t\treturn -2;\n+\t\t}\n \t\t*pos++ = '/';\n \t}\n \treturn 0;\n@@ -1241,6 +1260,8 @@ static int link_temp_to_file(const char \n \t\tif (dir) {\n \t\t\t*dir = 0;\n \t\t\tmkdir(filename, 0777);\n+\t\t\tif (shared_repository && make_group_writable(filename))\n+\t\t\t\treturn -2;\n \t\t\t*dir = '/';\n \t\t\tif (!link(tmpfile, filename))\n \t\t\t\treturn 0;\n-- \n1.0.GIT\n"},{"id":"13966","messageId":"7vaceshi18.fsf@assigned-by-dhcp.cox.net","threadId":"2911","inReplyTo":"Pine.LNX.4.63.0512222313070.12044@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Introduce core.sharedrepository","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-22T22:40:51Z","receivedAt":"2005-12-22T22:40:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> +static int make_group_writable(const char *path)\n> +{\n> +\tstruct stat st;\n> +\n> +\tif (lstat(path, &st) < 0)\n> +\t\treturn -1;\n> +\tif (st.st_mode & S_IWUSR)\n> +\t\tst.st_mode |= S_IWGRP;\n> +\tif (S_ISDIR(st.st_mode))\n> +\t\tst.st_mode |= S_ISGID;\n> +\tif (chmod(path, st.st_mode) < 0)\n> +\t\treturn -2;\n> +\treturn 0;\n> +}\n\nPerhaps g+sx not just g+s on directories.\n\n> +\n>  int safe_create_leading_directories(char *path)\n>  {\n>  \tchar *pos = path;\n> @@ -64,6 +79,10 @@ int safe_create_leading_directories(char\n>  \t\t\t\t*pos = '/';\n>  \t\t\t\treturn -1;\n>  \t\t\t}\n> +\t\tif (shared_repository && make_group_writable(path)) {\n> +\t\t\t*pos = '/';\n> +\t\t\treturn -2;\n> +\t\t}\n\nWouldn't this safe_create_leading_directories(\"/pub/git.git/objects\")\ntry chmod \"/pub\" and fail?\n"},{"id":"13967","messageId":"Pine.LNX.4.63.0512222356540.12681@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2911","inReplyTo":"7vaceshi18.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Introduce core.sharedrepository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-12-22T22:59:47Z","receivedAt":"2005-12-22T22:59:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 22 Dec 2005, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > +static int make_group_writable(const char *path)\n> > +{\n> > +\tstruct stat st;\n> > +\n> > +\tif (lstat(path, &st) < 0)\n> > +\t\treturn -1;\n> > +\tif (st.st_mode & S_IWUSR)\n> > +\t\tst.st_mode |= S_IWGRP;\n> > +\tif (S_ISDIR(st.st_mode))\n> > +\t\tst.st_mode |= S_ISGID;\n> > +\tif (chmod(path, st.st_mode) < 0)\n> > +\t\treturn -2;\n> > +\treturn 0;\n> > +}\n> \n> Perhaps g+sx not just g+s on directories.\n\nOkay:\n\n        if (S_ISDIR(st.st_mode))\n                st.st_mode |= S_ISGID | S_IXGRP;\n\n> > +\n> >  int safe_create_leading_directories(char *path)\n> >  {\n> >  \tchar *pos = path;\n> > @@ -64,6 +79,10 @@ int safe_create_leading_directories(char\n> >  \t\t\t\t*pos = '/';\n> >  \t\t\t\treturn -1;\n> >  \t\t\t}\n> > +\t\tif (shared_repository && make_group_writable(path)) {\n> > +\t\t\t*pos = '/';\n> > +\t\t\treturn -2;\n> > +\t\t}\n> \n> Wouldn't this safe_create_leading_directories(\"/pub/git.git/objects\")\n> try chmod \"/pub\" and fail?\n\nYes.\n\nHow about an \"else\" in front of the \"if\"? Like so:\n\n                if (mkdir(path, 0777) < 0)\n                        if (errno != EEXIST) {\n                                *pos = '/';\n                                return -1;\n                        }\n                else if (shared_repository && make_group_writable(path)) {\n                        *pos = '/';\n                        return -2;\n                }\n\nYou want me to resend the patch?\n\nCiao,\nDscho\n"},{"id":"13968","messageId":"Pine.LNX.4.63.0512230003560.12795@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2911","inReplyTo":"Pine.LNX.4.63.0512222356540.12681@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Introduce core.sharedrepository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-12-22T23:04:40Z","receivedAt":"2005-12-22T23:04:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 22 Dec 2005, Johannes Schindelin wrote:\n\n>                 if (mkdir(path, 0777) < 0)\n>                         if (errno != EEXIST) {\n>                                 *pos = '/';\n>                                 return -1;\n>                         }\n>                 else if (shared_repository && make_group_writable(path)) {\n>                         *pos = '/';\n>                         return -2;\n>                 }\n\nD'oh! Time to head to bed now:\n\n                if (mkdir(path, 0777) < 0) {\n                        if (errno != EEXIST) {\n                                *pos = '/';\n                                return -1;\n                        }\n                } else if (shared_repository && make_group_writable(path)) {\n                        *pos = '/';\n                        return -2;\n                }\n\nCiao,\nDscho\n"},{"id":"13977","messageId":"7vbqz89o0y.fsf@assigned-by-dhcp.cox.net","threadId":"2911","inReplyTo":"Pine.LNX.4.63.0512230003560.12795@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Introduce core.sharedrepository","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-23T09:10:53Z","receivedAt":"2005-12-23T09:10:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> D'oh! Time to head to bed now:\n\nLikewise.\n\nI've merged up your patches yesterday after some churning and\nthey are in the pu branch.  I hope I did not break them too much\n;-).\n"},{"id":"13978","messageId":"Pine.LNX.4.63.0512231141410.28090@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2911","inReplyTo":"7vbqz89o0y.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Introduce core.sharedrepository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-12-23T10:42:05Z","receivedAt":"2005-12-23T10:42:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 23 Dec 2005, Junio C Hamano wrote:\n\n> I've merged up your patches yesterday after some churning and\n> they are in the pu branch.  I hope I did not break them too much\n> ;-).\n\nLooks good. Will test.\n\nCiao,\nDscho\n"},{"id":"13979","messageId":"Pine.LNX.4.63.0512231206590.18905@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2911","inReplyTo":"Pine.LNX.4.63.0512231141410.28090@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Introduce core.sharedrepository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-12-23T11:07:18Z","receivedAt":"2005-12-23T11:07:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 23 Dec 2005, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Fri, 23 Dec 2005, Junio C Hamano wrote:\n> \n> > I've merged up your patches yesterday after some churning and\n> > they are in the pu branch.  I hope I did not break them too much\n> > ;-).\n> \n> Looks good. Will test.\n\nTested. Looks even better.\n\nCiao,\nDscho\n"}]}