如何设置权限,以便两个用户可以在同一个hg存储库上工作? [英] How to set permissions so two users can work on the same hg repository?

查看:66
本文介绍了如何设置权限,以便两个用户可以在同一个hg存储库上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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**

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

因此,我更改了权限,以允许bob读取文件,一切正常,直到下一次尝试做某事为止,然后情况发生了逆转.现在他拥有该文件了,我看不懂.

因此,我成立了一个"committers"组,并且john和bob都属于该组,但是无论何时提交一个或其他提交,其所有权和权限仍然是摆弄.

此外,只要我们中的一个人或其他人将文件添加到存储库中,该文件便由提交者专有.对我而言,这很好,因为我对chmod足够熟悉,但是当我忽略授予他许可时,这会带来一个重大问题.我想我们只需要一个提交后的钩子即可;只是为了包含这种症状...

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

解决方案

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

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

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

第一个命令将所有文件和目录的组所有权归还给committers.第二个命令确保所有者和组成员可以读取和写入所有文件和目录,并确保它们可以属于所有目录.第三个命令仅列出目录(省略文件),然后在其上设置摇杆组位.完成后,目录的权限将如下所示:rwxrwsr-x

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

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?

解决方案

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.

这篇关于如何设置权限,以便两个用户可以在同一个hg存储库上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆