如何设置权限以便两个用户可以在同一个 hg 存储库上工作?

发布于 2024-09-01 14:21:37 字数 642 浏览 5 评论 0原文

Ubuntu: Jaunty  
Mercurial: 1.3.1  
Access: ssh  (users john and bob)  
File permission:   -rw-rw----  1 john john  129276 May 17 13:28 dirstate  
User: bob  
Command: 'hg st'  
Response:  

**abort: Permission denied: /our/respository/.hg/dirstate**

显然mercurial不能让bob看到状态,因为它需要读取的文件属于我。

因此,我更改了权限以允许鲍勃读取该文件,一切都很好,直到我下次尝试做某事,情况就相反了。现在他拥有该文件,而我无法读取它。

因此,我建立了一个“提交者”组,约翰和鲍勃都属于该组,但每当一个或另一个提交时,仍然反复无常地摆弄所有权和权限。

此外,每当我们中的一个或另一个人将文件添加到存储库时,该文件就由提交者独占拥有。这对我来说很好,因为我对 chmod 足够熟悉,但是当我忽略授予他许可时,这给鲍勃带来了一个主要问题。我想我们只需要一个提交后挂钩;但只是为了包含此症状...

我们如何配置它,以便同一组中的两个不同登录可以通过 ssh 提交到同一个存储库?

Ubuntu: Jaunty  
Mercurial: 1.3.1  
Access: ssh  (users john and bob)  
File permission:   -rw-rw----  1 john john  129276 May 17 13:28 dirstate  
User: bob  
Command: 'hg st'  
Response:  

**abort: Permission denied: /our/respository/.hg/dirstate**

Obviously mercurial can't let bob see the state because the file it needs to read belongs to me.

So I change the permissions to allow bob to read the file and everything is fine, up until I next try to do something, whence the situations are reversed. Now he owns the file and I can't read it.

So I set up a "committers" group and both john and bob belong to the group, but still mercurial fiddles with the ownership and permissions whenever one or other commits.

Furthermore whenever one or other of us adds a file to the repository the file is owned exclusively by the committer. That's fine by me since I'm familiar enough with chmod but it presents a major problem to bob when I neglect to grant him permission. I guess we just need a post-commit hook for that; but just to include this symptom...

How do we configure it so two different logins in the same group can commit to the same repository over ssh?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

莫多说 2024-09-08 14:21:37

您需要在所有相关目录上设置“组粘滞位”。该权限位表示在这些目录中创建的任何文件或目录都应具有父目录组的组所有权,而不是创建用户的主要组的组所有权。

您可以通过转到整个存储库的顶层 (hg root) 并运行以下命令来进行正确设置:

chgrp -R committers .
chmod -R ug+=rwX .
find . -type d -print0 | xargs -0 chmod 2775   # or 2770 if other can't read

第一个命令将所有文件的组所有权返回给提交者和目录。第二个命令确保所有者和组成员可以读取和写入所有文件和目录,并且可以下行所有目录。第三个命令仅列出目录(省略文件),然后在它们上设置粘组位。完成后,目录的权限将如下所示: rwxrwsr-x

您只需执行一次此操作,如果您在创建存储库之前执行此操作,则根本不需要使用 find因为粘性组位将被所有目录继承。过去的 CVS 和 svn 也是以同样的方式完成的。

You need to set the "group sticky bit" on all the relevant directories. That permissions bit says that any file or directory created in those directories should have group ownership of the parent directory's group, not of the creating user's primary group.

You can set things right by going to the top level of your whole repo (hg root) and running these commands:

chgrp -R committers .
chmod -R ug+=rwX .
find . -type d -print0 | xargs -0 chmod 2775   # or 2770 if other can't read

That first command gives group ownership back to committers for all files and directories. The second command makes sure owners and group members can read and write all files and directories and that they can descend all directories. The third command lists only the directories (omitting files) and then sets the stick group bit on them. After you're done the permissions for directories will look like: rwxrwsr-x

You only have to do this once, and if you do it before creating the repo you don't need to use find at all since the sticky group bit will be inherited by all directories. It was done the same way for CVS and svn back in the olden days.

层林尽染 2024-09-08 14:21:37

使用 unix 组:请参阅此处的文件系统方法。

using unix groups: see the filesystem method here.

失而复得 2024-09-08 14:21:37

从长远来看,粘性位解决方案也不起作用。

有效的方法是将 chmod/chgrp 命令放入 bash 脚本中并教设计人员如何运行它。

#!/bin/bash
chgrp -R foo /foo/development/templates
chgrp -R foo /foo/development/media
chgrp -R foo /foo/development/static

chmod -R g+w /foo/development/templates
chmod -R g+w /foo/development/media
chmod -R g+w /foo/development/static

Long term the sticky bit solution didn't work either.

What has worked is putting the chmod/chgrp commands into a bash script and teaching the designer how to run it.

#!/bin/bash
chgrp -R foo /foo/development/templates
chgrp -R foo /foo/development/media
chgrp -R foo /foo/development/static

chmod -R g+w /foo/development/templates
chmod -R g+w /foo/development/media
chmod -R g+w /foo/development/static
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文