15

1 年以上、GIT とディレクトリ/ファイルのアクセス許可に問題がありました。複数の開発者が ssh (ssh://example/git/repository として設定されたオリジン) を使用してコードをプッシュする中央リポジトリがあります。次のようにリポジトリを設定しました。

1) 中央リポジトリの構成ファイル: [core] repositoryformatversion = 0 filemode = true ベア = true sharedrepository = 0660

2) すべてのリポジトリ ディレクトリのパーミッションが 770 に設定されている (rwxrwx---) 3) ./objects/XX および ./objects/info 内のすべてのファイルが 440 に設定されている (r--r-----) 4) すべてその他のファイルは 660 に設定されます (rw-rw----) 5) 所有権は root:group_name に設定されます

(これは、このスレッドのトップの応答で推奨されたセットアップからのものであることに注意してください: Making git push reject permissions? )

アクセスしているすべてのユーザーは、グループ「group_name」のメンバーです。

問題は、user1 がリポジトリにプッシュすると、一部のファイルのファイル所有権が user1:user1 に設定されることです。これは、グループが変更されることを意味します。これが発生すると、リポジトリ内の必要なファイルからの読み取り、書き込み、または実行の権限がなくなるため、他のユーザーはリポジトリからプッシュ (またはプル) できなくなります。

Stack Overflow およびネット上の他のほとんどすべての場所に関する問題に関して見つけられるすべてのスレッドを読みましたが、この同じ問題に遭遇し続けています。

問題は、この問題が GIT の問題なのか UNIX の問題なのかわかりません。また、修正方法もわかりません。ユーザーがリポジトリにプッシュしたときにグループが変更されないようにするにはどうすればよいですか?

4

1 に答える 1

17

権限を正しく設定する必要があるgit config core.sharedRepository 0660を使用するのではなく、リポジトリを初期化した後にに変更したようです。git init --shared=0660これは、sgid ビットが git リポジトリのディレクトリに正しく設定されないことを意味します。次のような方法でこれを手動で修正する必要があります (GNU find と xargs を想定):

find . -print0 | xargs -0 chgrp group_name

find . -type d -print0 | xargs -0 chmod g+s

vs. vs.git init --helpについて混乱している人のための抜粋:grouptrue0660

   --shared[=(false|true|umask|group|all|world|everybody|0xxx)]
       Specify that the Git repository is to be shared amongst several users.
       This allows users belonging to the same group to push into that
       repository. When specified, the config variable
       "core.sharedRepository" is set so that files and directories under
       $GIT_DIR are created with the requested permissions. When not
       specified, Git will use permissions reported by umask(2).

       The option can have the following values, defaulting to group if no
       value is given:

       umask (or false)
           Use permissions reported by umask(2). The default, when --shared
           is not specified.

       group (or true)
           Make the repository group-writable, (and g+sx, since the git group
           may be not the primary group of all users). This is used to loosen
           the permissions of an otherwise safe umask(2) value. Note that the
           umask still applies to the other permission bits (e.g. if umask is
           0022, using group will not remove read privileges from other
           (non-group) users). See 0xxx for how to exactly specify the
           repository permissions.

       all (or world or everybody)
           Same as group, but make the repository readable by all users.

       0xxx
           0xxx is an octal number and each file will have mode 0xxx.  0xxx
           will override users' umask(2) value (and not only loosen
           permissions as group and all does).  0640 will create a repository
           which is group-readable, but not group-writable or accessible to
           others.  0660 will create a repo that is readable and writable to
           the current user and group, but inaccessible to others.
于 2013-04-24T08:06:11.280 に答える