author | Paul Crowley <paul@lshift.net> |
Thu, 15 Oct 2009 10:30:05 +0100 | |
changeset 144 | 2dbaddde1fd5 |
parent 143 | afb1d57ca9f7 |
child 145 | bc2b93fa662d |
permissions | -rw-r--r-- |
119 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
120 | 2 |
<article xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en" |
3 |
xmlns:xlink="http://www.w3.org/1999/xlink"> |
|
119 | 4 |
<info> |
5 |
<title>Sharing Mercurial repositories with mercurial-server</title> |
|
6 |
<author><firstname>Paul</firstname><surname>Crowley</surname></author> |
|
120 | 7 |
<copyright><year>2009</year><holder>Paul Crowley, LShift Ltd</holder></copyright> |
119 | 8 |
</info> |
9 |
<section> |
|
10 |
<title>About mercurial-server</title> |
|
11 |
<para> |
|
120 | 12 |
Home page: <link xlink:href="http://www.lshift.net/mercurial-server.html"/> |
13 |
</para> |
|
14 |
<para> |
|
133
a99ab5be891a
Let next para do the work of discussing what OS it runs on
Paul Crowley <paul@lshift.net>
parents:
132
diff
changeset
|
15 |
mercurial-server gives your developers remote read/write access to |
a99ab5be891a
Let next para do the work of discussing what OS it runs on
Paul Crowley <paul@lshift.net>
parents:
132
diff
changeset
|
16 |
centralized <link xlink:href="http://hg-scm.org/">Mercurial</link> |
a99ab5be891a
Let next para do the work of discussing what OS it runs on
Paul Crowley <paul@lshift.net>
parents:
132
diff
changeset
|
17 |
repositories using SSH public key authentication; it provides convenient |
a99ab5be891a
Let next para do the work of discussing what OS it runs on
Paul Crowley <paul@lshift.net>
parents:
132
diff
changeset
|
18 |
and fine-grained key management and access control. |
119 | 19 |
</para> |
20 |
<para> |
|
21 |
Though mercurial-server is currently targeted at Debian-based systems such |
|
22 |
as Ubuntu, other users have reported success getting it running on other |
|
23 |
Unix-based systems such as Red Hat. Running it on a non-Unix system such as |
|
24 |
Windows is not supported. You will need root privileges to install it. |
|
25 |
</para> |
|
26 |
</section> |
|
27 |
<section> |
|
28 |
<title>Step by step</title> |
|
29 |
<para> |
|
134
525976d2827c
Change the way we link to SSH tutorial
Paul Crowley <paul@lshift.net>
parents:
133
diff
changeset
|
30 |
mercurial-server authenticates users not using passwords but using SSH |
525976d2827c
Change the way we link to SSH tutorial
Paul Crowley <paul@lshift.net>
parents:
133
diff
changeset
|
31 |
public keys; everyone who wants access to a mercurial-server repository |
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
32 |
will need such a key. In combination with <command>ssh-agent</command> (or |
120 | 33 |
equivalents such as the Windows program <link |
34 |
xlink:href="http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter9.html#pageant">Pageant</link>), |
|
35 |
this means that users will not need to type in a password to access the |
|
134
525976d2827c
Change the way we link to SSH tutorial
Paul Crowley <paul@lshift.net>
parents:
133
diff
changeset
|
36 |
repository. If you're not familiar with SSH public keys, the <link |
525976d2827c
Change the way we link to SSH tutorial
Paul Crowley <paul@lshift.net>
parents:
133
diff
changeset
|
37 |
xlink:href="http://sial.org/howto/openssh/publickey-auth/">OpenSSH Public |
525976d2827c
Change the way we link to SSH tutorial
Paul Crowley <paul@lshift.net>
parents:
133
diff
changeset
|
38 |
Key Authentication tutorial</link> may be helpful. |
119 | 39 |
</para> |
120 | 40 |
<section> |
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
41 |
<title>Installing mercurial-server</title> |
119 | 42 |
<para> |
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
43 |
In what follows, we assume that your username is <systemitem |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
44 |
class="username">jay</systemitem>, that you usually sit at a machine called |
120 | 45 |
<systemitem class="systemname">my-workstation</systemitem> and you wish to |
46 |
install mercurial-server on <systemitem |
|
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
47 |
class="systemname">repository-host</systemitem>. We assume that you have created your SSH public key, set up your SSH agent with this key, and that this key gives you access to <systemitem |
134
525976d2827c
Change the way we link to SSH tutorial
Paul Crowley <paul@lshift.net>
parents:
133
diff
changeset
|
48 |
class="systemname">repository-host</systemitem>. |
119 | 49 |
</para> |
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
50 |
<para>First install mercurial-server on <systemitem |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
51 |
class="systemname">repository-host</systemitem>:</para> |
142
fb64f9ac44c5
Remove blank lines before screen output
Paul Crowley <paul@lshift.net>
parents:
141
diff
changeset
|
52 |
<screen><computeroutput>jay@my-workstation:~$ </computeroutput><userinput>scp mercurial-server_0.6.1_amd64.deb repository-host:</userinput> |
119 | 53 |
<computeroutput>mercurial-server_0.6.1_amd64.deb 100% |
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
54 |
jay@my-workstation:~$ </computeroutput><userinput>ssh -A repository-host</userinput> |
138
44ee9dc3bba9
Remove cut/paste error in commands
Paul Crowley <paul@lshift.net>
parents:
137
diff
changeset
|
55 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>sudo dpkg -i mercurial-server_0.6.1_amd64.deb</userinput> |
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
56 |
<computeroutput>[sudo] password for jay: |
119 | 57 |
Selecting previously deselected package mercurial-server. |
58 |
(Reading database ... 144805 files and directories currently installed.) |
|
59 |
Unpacking mercurial-server (from .../mercurial-server_0.6.1_amd64.deb) ... |
|
60 |
Setting up mercurial-server (0.6.1) ... |
|
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
61 |
jay@repository-host:~$ </computeroutput></screen> |
119 | 62 |
<para> |
120 | 63 |
mercurial-server is now installed on the repository host. Next, we need to give you permission to access its repositories. |
119 | 64 |
</para> |
142
fb64f9ac44c5
Remove blank lines before screen output
Paul Crowley <paul@lshift.net>
parents:
141
diff
changeset
|
65 |
<screen><computeroutput>jay@repository-host:~$ </computeroutput><userinput>ssh-add -L > my-key</userinput> |
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
66 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>sudo mkdir -p /etc/mercurial-server/keys/root/jay</userinput> |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
67 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>sudo cp my-key /etc/mercurial-server/keys/root/jay/my-workstation</userinput> |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
68 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>sudo -u hg /usr/share/mercurial-server/refresh-auth</userinput> |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
69 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>exit</userinput> |
141
e326e29b48ab
fix output that should read "repository-host"
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
70 |
<computeroutput>Connection to repository-host closed. |
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
71 |
jay@my-workstation:~$ </computeroutput></screen> |
119 | 72 |
<para> |
120 | 73 |
You can now create repositories on the remote machine and have complete |
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
74 |
read-write access to all of them. |
119 | 75 |
</para> |
120 | 76 |
</section> |
77 |
<section> |
|
78 |
<title>Creating repositories</title> |
|
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
79 |
<para> |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
80 |
To store a repository on the server, clone it over. |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
81 |
</para> |
142
fb64f9ac44c5
Remove blank lines before screen output
Paul Crowley <paul@lshift.net>
parents:
141
diff
changeset
|
82 |
<screen><computeroutput>jay@my-workstation:~$ </computeroutput><userinput>cd my-mercurial-project</userinput> |
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
83 |
<computeroutput>jay@my-workstation:~/my-mercurial-project$ </computeroutput><userinput>hg clone . ssh://hg@repository-host/repository/name</userinput> |
119 | 84 |
<computeroutput>searching for changes |
85 |
remote: adding changesets |
|
86 |
remote: adding manifests |
|
87 |
remote: adding file changes |
|
88 |
remote: added 119 changesets with 284 changes to 61 files |
|
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
89 |
jay@my-workstation:~/my-mercurial-project$ </computeroutput><userinput>hg pull ssh://hg@repository-host/repository/name</userinput> |
119 | 90 |
<computeroutput>pulling from ssh://hg@repository-host/repository/name |
91 |
searching for changes |
|
92 |
no changes found |
|
136 | 93 |
<computeroutput>jay@my-workstation:~/my-mercurial-project$ </computeroutput><userinput>cd ..</userinput> |
94 |
jay@my-workstation:~$ </computeroutput></screen> |
|
120 | 95 |
</section> |
96 |
<section> |
|
97 |
<title>Adding other users</title> |
|
119 | 98 |
<para> |
120 | 99 |
As things stand, no-one but you has any access to any repositories you |
100 |
create on this system. In order to give anyone else access, you'll need a |
|
101 |
copy of their SSH public key; we'll assume you have that key in |
|
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
102 |
<filename>~/sam-key.pub</filename>. To manage access, you make changes to the special <literal>hgadmin</literal> repository. |
119 | 103 |
</para> |
142
fb64f9ac44c5
Remove blank lines before screen output
Paul Crowley <paul@lshift.net>
parents:
141
diff
changeset
|
104 |
<screen><computeroutput>jay@my-workstation:~$ </computeroutput><userinput>hg clone ssh://hg@repository-host/hgadmin</userinput> |
119 | 105 |
<computeroutput>destination directory: hgadmin |
106 |
no changes found |
|
107 |
updating working directory |
|
108 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
109 |
jay@my-workstation:~$ </computeroutput><userinput>cd hgadmin</userinput> |
123 | 110 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>mkdir -p keys/users/sam</userinput> |
135
298c6ea6295c
Missed something in change to sam
Paul Crowley <paul@lshift.net>
parents:
134
diff
changeset
|
111 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>cp ~/sam-key.pub keys/users/sam/their-workstation</userinput> |
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
112 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>hg add</userinput> |
123 | 113 |
<computeroutput>adding keys/users/sam/their-workstation |
114 |
jay@my-workstation:~/hgadmin$ </computeroutput><userinput>hg commit -m "Add Sam's key'"</userinput> |
|
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
115 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>hg push</userinput> |
119 | 116 |
<computeroutput>pushing to ssh://hg@repository-host/hgadmin |
117 |
searching for changes |
|
118 |
remote: adding changesets |
|
119 |
remote: adding manifests |
|
120 |
remote: adding file changes |
|
121 |
remote: added 1 changesets with 1 changes to 1 files |
|
122
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
122 |
jay@my-workstation:~/hgadmin$ </computeroutput></screen> |
119 | 123 |
<para> |
123 | 124 |
Sam can now read and write to your |
120 | 125 |
<literal>ssh://hg@repository-host/repository/name</literal> repository. |
126 |
Most other changes to access control can be made simply by making and |
|
127 |
pushing changes to <literal>hgadmin</literal>, and you can use Mercurial to |
|
128 |
cooperate with other root users in the normal way. |
|
129 |
</para> |
|
131
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
130 |
<para> |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
131 |
If you prefer, you could give them access by |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
132 |
logging into <systemitem class="systemname">repository-host</systemitem>, |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
133 |
putting the key in the right place under <filename |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
134 |
class='directory'>/etc/mercurial-server/keys</filename>, and re-running |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
135 |
<userinput>sudo -u hg /usr/share/mercurial-server/refresh-auth</userinput>. |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
136 |
However, using <literal>hgadmin</literal> is usually more convenient if you need to make more than a very few changes; it also makes it easier to share administration with others and provides a log of all changes. |
e8bf13d06582
Assume they have SSH set up; talk about hgadmin first
Paul Crowley <paul@lshift.net>
parents:
130
diff
changeset
|
137 |
</para> |
120 | 138 |
</section> |
132
a5850a63390f
Move basic access control to the start of access control
Paul Crowley <paul@lshift.net>
parents:
131
diff
changeset
|
139 |
</section> |
120 | 140 |
<section> |
132
a5850a63390f
Move basic access control to the start of access control
Paul Crowley <paul@lshift.net>
parents:
131
diff
changeset
|
141 |
<title>Access control</title> |
120 | 142 |
<para> |
143 |
Out of the box, mercurial-server supports two kinds of users: "root" users and normal users. If you followed the steps above, you are a "root" user because your key is under <filename class='directory'>keys/root</filename>, while the other user you gave access to is a normal user since their key is under <filename class='directory'>keys/users</filename>. Keys that are not in either of these directories will by default have no access to anything. |
|
144 |
</para> |
|
145 |
<para> |
|
132
a5850a63390f
Move basic access control to the start of access control
Paul Crowley <paul@lshift.net>
parents:
131
diff
changeset
|
146 |
Root users can edit <literal>hgadmin</literal>, create new repositories and read and write to existing ones. Normal users cannot access <literal>hgadmin</literal> or create new repositories, but they can read and write to any other repository. |
120 | 147 |
</para> |
132
a5850a63390f
Move basic access control to the start of access control
Paul Crowley <paul@lshift.net>
parents:
131
diff
changeset
|
148 |
<section> |
a5850a63390f
Move basic access control to the start of access control
Paul Crowley <paul@lshift.net>
parents:
131
diff
changeset
|
149 |
<title>Using access.conf</title> |
120 | 150 |
<para> |
151 |
mercurial-server offers much more fine-grained access control than this division into two classes of users. Let's suppose you wish to give Pat access to the <literal>widget</literal> repository, but no other. We first copy Pat's SSH public key into the <filename |
|
152 |
class='directory'>keys/widget/pat</filename> directory in <literal>hgadmin</literal>. Now mercurial-server knows about Pat's key, but will give Pat no access to anything because the key is not under either <filename |
|
153 |
class='directory'>keys/root</filename> or <filename |
|
154 |
class='directory'>keys/users</filename>. To grant this key access, we must give mercurial-server a new access rule, so we create a file in <literal>hgadmin</literal> called <filename>access.conf</filename>, with the following contents:</para> |
|
144
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
155 |
<programlisting>write repo=widget user=widget/** |
120 | 156 |
</programlisting> |
157 |
<para> |
|
158 |
Pat will have read and write access as soon as we add, commit, and push these files. |
|
159 |
</para> |
|
160 |
<para> |
|
124 | 161 |
Each line of <filename>access.conf</filename> has the following syntax: |
120 | 162 |
</para> |
144
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
163 |
<programlisting><replaceable>rule</replaceable> <replaceable>condition</replaceable> <replaceable>condition...</replaceable> |
120 | 164 |
</programlisting> |
165 |
<para> |
|
166 |
Blank lines and lines that start with <literal>#</literal> are ignored. Rule is one of |
|
167 |
</para> |
|
168 |
<itemizedlist> |
|
169 |
<listitem> |
|
170 |
<literal>init</literal>: allow reads, writes, and the creation of new repositories |
|
171 |
</listitem> |
|
172 |
<listitem> |
|
173 |
<literal>write</literal>: allow reads and writes |
|
174 |
</listitem> |
|
175 |
<listitem> |
|
176 |
<literal>read</literal>: allow only read operations |
|
177 |
</listitem> |
|
178 |
<listitem> |
|
179 |
<literal>deny</literal>: deny all requests |
|
180 |
</listitem> |
|
181 |
</itemizedlist> |
|
182 |
<para> |
|
183 |
When considering a request, mercurial-server steps through all the rules in <filename>/etc/mercurial-server/access.conf</filename> and then all the rules in <filename>access.conf</filename> in <literal>hgadmin</literal> looking for a rule which matches on every condition. If it does not find such a rule, it denies the request; otherwise it checks whether the rule grants sufficient privilege to allow it. |
|
184 |
</para> |
|
185 |
<para> |
|
186 |
By default, <filename>/etc/mercurial-server/access.conf</filename> has the following rules: |
|
187 |
</para> |
|
144
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
188 |
<programlisting>init user=root/** |
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
189 |
deny repo=hgadmin |
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
190 |
write user=users/** |
120 | 191 |
</programlisting> |
192 |
<para> |
|
193 |
These rules ensure that root users can do any operation on any repository, that no other users can access the <literal>hgadmin</literal> repository, and that those with keys in <filename class='directory'>keys/users</filename> can read or write to any repository but not create repositories. |
|
194 |
</para> |
|
195 |
<para> |
|
196 |
A condition is a globpattern matched against a relative path. The two most |
|
197 |
important conditions are |
|
198 |
</para> |
|
199 |
<itemizedlist> |
|
200 |
<listitem> |
|
201 |
<code><literal>user=</literal><replaceable>globpattern</replaceable></code>: path to the user's key |
|
202 |
</listitem> |
|
203 |
<listitem> |
|
204 |
<code><literal>repo=</literal><replaceable>globpattern</replaceable></code>: path to the repository |
|
205 |
</listitem> |
|
206 |
</itemizedlist> |
|
207 |
<para> |
|
208 |
"*" only matches one directory level, where "**" matches as many as you |
|
209 |
want. More precisely, "*" matches zero or more characters not including "/" |
|
210 |
while "**" matches zero or more characters including "/". |
|
211 |
</para> |
|
132
a5850a63390f
Move basic access control to the start of access control
Paul Crowley <paul@lshift.net>
parents:
131
diff
changeset
|
212 |
</section> |
120 | 213 |
<section> |
125
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
214 |
<title>/etc/mercurial-server and hgadmin</title> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
215 |
<para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
216 |
mercurial-server consults two distinct locations to collect information about what to allow: <filename |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
217 |
class='directory'>/etc/mercurial-server</filename> and its own <literal>hgadmin</literal> repository. This is useful for several reasons: |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
218 |
</para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
219 |
<itemizedlist> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
220 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
221 |
Users may not need the sophistication of access control via mercurial; for these users updating <filename |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
222 |
class='directory'>/etc/mercurial-server</filename> may offer a simpler route. |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
223 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
224 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
225 |
<filename |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
226 |
class='directory'>/etc/mercurial-server</filename> is suitable for management by some other route, such as with <link |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
227 |
xlink:href="http://reductivelabs.com/products/puppet">Puppet</link> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
228 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
229 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
230 |
If a change to <literal>hgadmin</literal> leaves you "locked out", <filename |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
231 |
class='directory'>/etc/mercurial-server</filename> allows you a way back in. |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
232 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
233 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
234 |
At install time, all users are "locked out", and so some mechanism to allow some users in is needed. |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
235 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
236 |
</itemizedlist> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
237 |
<para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
238 |
Rules in <filename>/etc/mercurial-server/access.conf</filename> take precedence over those in <literal>hgadmin</literal>, and obviously keys in <filename class='directory'>/etc/mercurial-server/keys</filename> cannot be affected by changes to <literal>hgadmin</literal>. |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
239 |
</para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
240 |
<para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
241 |
We anticipate that once mercurial-server is successfully installed and |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
242 |
working most users will want to use <literal>hgadmin</literal> for most |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
243 |
access control tasks. Once you have the right keys and |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
244 |
<filename>access.conf</filename> set up in <literal>hgadmin</literal>, you |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
245 |
can delete <filename>/etc/mercurial-server/access.conf</filename> and all |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
246 |
of <filename class='directory'>/etc/mercurial-server/keys</filename>, |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
247 |
turning control entirely over to <literal>hgadmin</literal>. |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
248 |
</para> |
127 | 249 |
<para> |
250 |
<filename>/etc/mercurial-server/remote-hgrc</filename> is in the |
|
251 |
<systemitem>HGRCPATH</systemitem> for all remote access to mercurial-server |
|
252 |
repositories. This file contains the hooks that mercurial-server uses for |
|
253 |
access control and logging. You can add hooks to this file, but obviously |
|
254 |
breaking the existing hooks will disable the relevant functionality and |
|
255 |
isn't advisable. |
|
256 |
</para> |
|
125
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
257 |
</section> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
258 |
<section> |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
259 |
<title>File and branch conditions</title> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
260 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
261 |
mercurial-server supports file and branch conditions, which restrict an |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
262 |
operation depending on what files it modifies and what branch the work is |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
263 |
on. </para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
264 |
<caution> |
128 | 265 |
The way these conditions work is subtle and can be counterintuitive. Unless |
266 |
you need what they provide, ignore this section, stick to user and repo |
|
140 | 267 |
conditions, and then things are likely to work the way you would expect. If |
268 |
you do need what they provide, read what follows very carefully. |
|
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
269 |
</caution> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
270 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
271 |
File and branch conditions are added to the conditions against which a rule |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
272 |
matches, just like user and repo conditions; they have this form: |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
273 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
274 |
<itemizedlist> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
275 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
276 |
<code><literal>file=</literal><replaceable>globpattern</replaceable></code>: file within the repo |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
277 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
278 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
279 |
<code><literal>branch=</literal><replaceable>globpattern</replaceable></code>: Mercurial branch name |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
280 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
281 |
</itemizedlist> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
282 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
283 |
However, in order to understand what effect adding these conditions will |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
284 |
have, it helps to understand how and when these rules are applied. |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
285 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
286 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
287 |
The rules file is used to make three decisions: |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
288 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
289 |
<itemizedlist> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
290 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
291 |
Whether to allow a repository to be created |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
292 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
293 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
294 |
Whether to allow any access to a repository |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
295 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
296 |
<listitem> |
139
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
297 |
Whether to allow a changeset |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
298 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
299 |
</itemizedlist> |
120 | 300 |
<para> |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
301 |
When the first two of these decisions are being made, nothing is known |
139
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
302 |
about any changsets that might be pushed, and so all file and branch |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
303 |
conditions automatically succeed for the purpose of such decisions. For the |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
304 |
third condition, every file changed in the changeset must be allowed by a |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
305 |
<literal>write</literal> or <literal>init</literal> rule for the changeset |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
306 |
to be allowed. |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
307 |
</para> |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
308 |
<para> |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
309 |
This means that doing tricky things with file conditions can have |
b7e78f9705e6
There are only three decisions, honest
Paul Crowley <paul@lshift.net>
parents:
138
diff
changeset
|
310 |
counterintuitive consequences: |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
311 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
312 |
<itemizedlist> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
313 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
314 |
<para>You cannot limit read access to a subset of a repository with a "read" |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
315 |
rule and a file condition: any user who has access to a repository can read |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
316 |
all of it and its full history. Such a rule can only have the effect of |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
317 |
masking a later "write" rule, as in this example:</para> |
144
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
318 |
<programlisting>read repo=specialrepo file=dontwritethis |
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
319 |
write repo=specialrepo |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
320 |
</programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
321 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
322 |
allows all users to read specialrepo, and to write to all files |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
323 |
<emphasis>except</emphasis> that any changeset which writes to |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
324 |
<filename>dontwritethis</filename> will be rejected. |
120 | 325 |
</para> |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
326 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
327 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
328 |
For similar reasons, don't give <literal>init</literal> rules file conditions. |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
329 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
330 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
331 |
<para>Don't try to deny write access to a particular file on a particular |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
332 |
branch - a developer can write to the file on another branch and then merge |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
333 |
it in. Either deny all writes to the branch from that user, or allow them |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
334 |
to write to all the files they can write to on any branch. In other words, |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
335 |
something like this will have the intended effect: |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
336 |
</para> |
144
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
337 |
<programlisting>write user=docs/* branch=docs file=docs/* |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
338 |
</programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
339 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
340 |
But something like this will not have the intended effect; it will |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
341 |
effectively allow these users to write to any file on any branch, by |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
342 |
writing it to "docs" first: |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
343 |
</para> |
144
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
344 |
<programlisting>write user=docs/* branch=docs |
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
345 |
write user=docs/* file=docs/* |
2dbaddde1fd5
programlisting also needs no initial blank lines
Paul Crowley <paul@lshift.net>
parents:
143
diff
changeset
|
346 |
read user=docs/* |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
347 |
</programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
348 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
349 |
</itemizedlist> |
120 | 350 |
</section> |
351 |
</section> |
|
352 |
<section> |
|
126
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
353 |
<title>How mercurial-server works</title> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
354 |
<para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
355 |
All of the repositories controlled by mercurial-server are owned by a |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
356 |
single user, the <literal>hg</literal> user, which is why all URLs for |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
357 |
mercurial-server repositories start with <literal>ssh://hg@...</literal>. |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
358 |
Each SSH key that has access to the repository has an entry in |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
359 |
<filename>~hg/.ssh/authorized_keys</filename>; this is how the SSH daemon |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
360 |
knows to give that key access. When the user connects over SSH, their |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
361 |
commands are run in a specially crafted restricted shell; this shell knows |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
362 |
which key was used to connect, determines what the user is trying to do, |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
363 |
and checks the access rules to decide whether to allow it. |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
364 |
</para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
365 |
<para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
366 |
This restricted shell also ensures that certain Mercurial extensions are |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
367 |
loaded when the user acts on a repository; these extensions check the |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
368 |
access control rules for any changeset that the user tries to commit, and |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
369 |
log all pushes and pulls into a per-repository access log. |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
370 |
</para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
371 |
<para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
372 |
<command>refresh-auth</command> recurses through the <filename |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
373 |
class='directory'>/etc/mercurial-server/keys</filename> and the <filename |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
374 |
class='directory'>keys</filename> directory in the |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
375 |
<literal>hgadmin</literal> repository, creating an entry in |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
376 |
<filename>~hg/.ssh/authorized_keys</filename> for each one. This is redone |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
377 |
automatically whenever a change is pushed to <literal>hgadmin</literal>. |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
378 |
</para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
379 |
</section> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
380 |
<section> |
120 | 381 |
<title>Security</title> |
382 |
<para> |
|
383 |
mercurial-server relies entirely on sshd to grant access to remote users. |
|
384 |
As a result, it runs no daemons, installs no setuid programs, and no part |
|
385 |
of it runs as root except the install process: all programs run as the user |
|
137 | 386 |
hg. Any attack on mercurial-server can only be started if the attacker |
387 |
already has a public key in <filename>~hg/.ssh/authorized_keys</filename>, |
|
120 | 388 |
otherwise sshd will bar the way. |
389 |
</para> |
|
390 |
<para> |
|
391 |
No matter what command the user tries to run on the remote system via SSH, |
|
392 |
mercurial-server is run. It parses the command line the user asked for, and |
|
393 |
interprets and runs the corresponding hg operation itself if access is |
|
394 |
allowed, so users can only read and add to history within repositories; |
|
395 |
they cannot run any other hg command. In addition, every push and pull is |
|
396 |
logged with a datestamp, changeset ID and the key that performed the |
|
397 |
operation. |
|
398 |
</para> |
|
399 |
<para> |
|
400 |
However, while the first paragraph holds no matter what bugs |
|
401 |
mercurial-server contains, the second depends on the relevant code being |
|
402 |
correct; though the entire codebase is short, mercurial-server is a fairly |
|
403 |
new program and may harbour bugs. Backups are essential! |
|
404 |
</para> |
|
405 |
</section> |
|
406 |
<section> |
|
129 | 407 |
<title>Legalese</title> |
408 |
<para> |
|
409 |
This program is free software; you can redistribute it and/or modify it |
|
410 |
under the terms of the GNU General Public License as published by the Free |
|
411 |
Software Foundation; either version 2 of the License, or (at your option) |
|
412 |
any later version. |
|
413 |
</para> |
|
414 |
<para> |
|
415 |
This program is distributed in the hope that it will be useful, but |
|
416 |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
417 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
418 |
more details. |
|
419 |
</para> |
|
420 |
<para> |
|
421 |
You should have received a copy of the GNU General Public License along |
|
422 |
with this program; if not, write to the Free Software Foundation, Inc., 51 |
|
423 |
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
424 |
</para> |
|
425 |
</section> |
|
426 |
<section> |
|
120 | 427 |
<title>Thanks</title> |
428 |
<para> |
|
429 |
Thanks for reading this far. If you use mercurial-server, please tell me about |
|
430 |
it. |
|
431 |
</para> |
|
432 |
<para> |
|
433 |
Paul Crowley, <email>paul@lshift.net</email>, 2009 |
|
119 | 434 |
</para> |
435 |
</section> |
|
436 |
</article> |
|
437 |