author | Paul Crowley <paul@lshift.net> |
Wed, 14 Oct 2009 15:36:12 +0100 | |
changeset 128 | b1610de4b6b1 |
parent 127 | 3262c0a53b59 |
child 129 | 4d261ae3ba4f |
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> |
|
119 | 15 |
mercurial-server is software for Debian and Ubuntu systems which gives your |
120 | 16 |
developers remote read/write access to <link |
17 |
xlink:href="http://hg-scm.org/">Mercurial</link> repositories using SSH public |
|
119 | 18 |
key authentication; it provides convenient and fine-grained key management |
19 |
and access control. |
|
20 |
</para> |
|
21 |
<para> |
|
22 |
mercurial-server is the easiest and most secure way for several developers |
|
23 |
to have read/write access to a central repository, but that's not the only |
|
24 |
way for several people to work on the same project using Mercurial; you |
|
120 | 25 |
should be familiar with the <link |
26 |
xlink:href="http://mercurial.selenic.com/wiki/MultipleCommitters">other ways of |
|
27 |
handling multiple commiters</link> before deciding to use this. |
|
119 | 28 |
</para> |
29 |
<para> |
|
30 |
Though mercurial-server is currently targeted at Debian-based systems such |
|
31 |
as Ubuntu, other users have reported success getting it running on other |
|
32 |
Unix-based systems such as Red Hat. Running it on a non-Unix system such as |
|
33 |
Windows is not supported. You will need root privileges to install it. |
|
34 |
</para> |
|
35 |
<section> |
|
36 |
<title>Legalese</title> |
|
37 |
<para> |
|
38 |
This program is free software; you can redistribute it and/or modify it |
|
39 |
under the terms of the GNU General Public License as published by the Free |
|
40 |
Software Foundation; either version 2 of the License, or (at your option) |
|
41 |
any later version. |
|
42 |
</para> |
|
43 |
<para> |
|
44 |
This program is distributed in the hope that it will be useful, but |
|
45 |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
46 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
47 |
more details. |
|
48 |
</para> |
|
49 |
<para> |
|
50 |
You should have received a copy of the GNU General Public License along |
|
51 |
with this program; if not, write to the Free Software Foundation, Inc., 51 |
|
52 |
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
53 |
</para> |
|
54 |
</section> |
|
55 |
</section> |
|
56 |
<section> |
|
57 |
<title>Step by step</title> |
|
58 |
<para> |
|
120 | 59 |
mercurial-server authenticates users not using passwords but using <link |
60 |
xlink:href="http://sial.org/howto/openssh/publickey-auth/">SSH public |
|
61 |
keys</link>; everyone who wants access to a mercurial-server repository |
|
62 |
will need such a key, so you'll need to familiarize yourself with them |
|
63 |
before proceeding. In combination with <command>ssh-agent</command> (or |
|
64 |
equivalents such as the Windows program <link |
|
65 |
xlink:href="http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter9.html#pageant">Pageant</link>), |
|
66 |
this means that users will not need to type in a password to access the |
|
67 |
repository. |
|
119 | 68 |
</para> |
120 | 69 |
<section> |
70 |
<title>Creating a repository host</title> |
|
119 | 71 |
<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
|
72 |
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
|
73 |
class="username">jay</systemitem>, that you usually sit at a machine called |
120 | 74 |
<systemitem class="systemname">my-workstation</systemitem> and you wish to |
75 |
install mercurial-server on <systemitem |
|
76 |
class="systemname">repository-host</systemitem>. First, you'll need to |
|
77 |
create an SSH public key if you haven't already. You should consult your |
|
78 |
system documentation on how to do this, but it should look something like |
|
79 |
this. |
|
119 | 80 |
</para> |
81 |
<screen> |
|
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
|
82 |
<computeroutput>jay@my-workstation:~$ </computeroutput><userinput>ssh-keygen</userinput> |
119 | 83 |
<computeroutput>Generating public/private rsa key pair. |
84 |
Enter passphrase (empty for no passphrase): |
|
85 |
Enter same passphrase again: |
|
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
|
86 |
Your identification has been saved in /home/jay/.ssh/id_rsa. |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
87 |
Your public key has been saved in /home/jay/.ssh/id_rsa.pub. |
119 | 88 |
The key fingerprint is: |
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 |
8b:aa:0a:98:fe:e7:84:48:a3:fe:5f:31:4b:16:e6:0b jay@my-workstation |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
90 |
jay@my-workstation:~$ </computeroutput><userinput>ssh-add</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
|
91 |
<computeroutput>Enter passphrase for /home/jay/.ssh/id_rsa: |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
92 |
Identity added: /home/jay/.ssh/id_rsa (/home/jay/.ssh/id_rsa) |
05b676684c7e
Call the user jay rather than user, and use pat instead of other-user
Paul Crowley <paul@lshift.net>
parents:
121
diff
changeset
|
93 |
jay@my-workstation:~$ </computeroutput></screen> |
119 | 94 |
<para>Now copy the files you're going to need over to your target system, and install mercurial-server</para> |
95 |
<screen> |
|
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
|
96 |
<computeroutput>jay@my-workstation:~$ </computeroutput><userinput>ssh-copy-id repository-host</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
|
97 |
<computeroutput>jay@repository-host's password: |
119 | 98 |
Now try logging into the machine, with "ssh 'repository-host'", and check in: |
99 |
||
100 |
.ssh/authorized_keys |
|
101 |
||
102 |
to make sure we haven't added extra keys that you weren't expecting. |
|
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
|
103 |
jay@my-workstation:~$ </computeroutput><userinput>scp mercurial-server_0.6.1_amd64.deb repository-host:</userinput> |
119 | 104 |
<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
|
105 |
jay@my-workstation:~$ </computeroutput><userinput>ssh -A repository-host</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
|
106 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>sudo dpkg -i ../mercurial-server_0.6.1_amd64.deb</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
|
107 |
<computeroutput>[sudo] password for jay: |
119 | 108 |
Selecting previously deselected package mercurial-server. |
109 |
(Reading database ... 144805 files and directories currently installed.) |
|
110 |
Unpacking mercurial-server (from .../mercurial-server_0.6.1_amd64.deb) ... |
|
111 |
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
|
112 |
jay@repository-host:~$ </computeroutput></screen> |
119 | 113 |
<para> |
120 | 114 |
mercurial-server is now installed on the repository host. Next, we need to give you permission to access its repositories. |
119 | 115 |
</para> |
116 |
<screen> |
|
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
|
117 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>ssh-add -L > my-key</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
|
118 |
<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
|
119 |
<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
|
120 |
<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
|
121 |
<computeroutput>jay@repository-host:~$ </computeroutput><userinput>exit</userinput> |
119 | 122 |
<computeroutput>Connection to shell 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
|
123 |
jay@my-workstation:~$ </computeroutput></screen> |
119 | 124 |
<para> |
120 | 125 |
You can now create repositories on the remote machine and have complete |
126 |
read-write access to all of them; you need never log on to <systemitem |
|
127 |
class="systemname">repository-host</systemitem> again. |
|
119 | 128 |
</para> |
120 | 129 |
</section> |
130 |
<section> |
|
131 |
<title>Creating repositories</title> |
|
119 | 132 |
<screen> |
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
|
133 |
<computeroutput>jay@my-workstation:~$ </computeroutput><userinput>cd my-mercurial-project</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
|
134 |
<computeroutput>jay@my-workstation:~/my-mercurial-project$ </computeroutput><userinput>hg clone . ssh://hg@repository-host/repository/name</userinput> |
119 | 135 |
<computeroutput>searching for changes |
136 |
remote: adding changesets |
|
137 |
remote: adding manifests |
|
138 |
remote: adding file changes |
|
139 |
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
|
140 |
jay@my-workstation:~/my-mercurial-project$ </computeroutput><userinput>hg pull ssh://hg@repository-host/repository/name</userinput> |
119 | 141 |
<computeroutput>pulling from ssh://hg@repository-host/repository/name |
142 |
searching for changes |
|
143 |
no changes found |
|
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
|
144 |
jay@my-workstation:~/my-mercurial-project$ </computeroutput></screen> |
120 | 145 |
</section> |
146 |
<section> |
|
147 |
<title>Adding other users</title> |
|
119 | 148 |
<para> |
120 | 149 |
As things stand, no-one but you has any access to any repositories you |
150 |
create on this system. In order to give anyone else access, you'll need a |
|
151 |
copy of their SSH public key; we'll assume you have that key in |
|
123 | 152 |
<filename>~/sam-key.pub</filename>. You could give them access by |
120 | 153 |
logging into <systemitem class="systemname">repository-host</systemitem>, |
154 |
putting the key in the right place under <filename |
|
155 |
class='directory'>/etc/mercurial-server/keys</filename>, and re-running |
|
156 |
<userinput>sudo -u hg /usr/share/mercurial-server/refresh-auth</userinput>. |
|
157 |
However, there's a more convenient way. |
|
119 | 158 |
</para> |
159 |
<screen> |
|
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
|
160 |
<computeroutput>jay@my-workstation:~/my-mercurial-project$ </computeroutput><userinput>cd ..</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
|
161 |
<computeroutput>jay@my-workstation:~$ </computeroutput><userinput>hg clone ssh://hg@repository-host/hgadmin</userinput> |
119 | 162 |
<computeroutput>destination directory: hgadmin |
163 |
no changes found |
|
164 |
updating working directory |
|
165 |
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
|
166 |
jay@my-workstation:~$ </computeroutput><userinput>cd hgadmin</userinput> |
123 | 167 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>mkdir -p keys/users/sam</userinput> |
168 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>cp ~/other-users-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
|
169 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>hg add</userinput> |
123 | 170 |
<computeroutput>adding keys/users/sam/their-workstation |
171 |
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
|
172 |
<computeroutput>jay@my-workstation:~/hgadmin$ </computeroutput><userinput>hg push</userinput> |
119 | 173 |
<computeroutput>pushing to ssh://hg@repository-host/hgadmin |
174 |
searching for changes |
|
175 |
remote: adding changesets |
|
176 |
remote: adding manifests |
|
177 |
remote: adding file changes |
|
178 |
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
|
179 |
jay@my-workstation:~/hgadmin$ </computeroutput></screen> |
119 | 180 |
<para> |
123 | 181 |
Sam can now read and write to your |
120 | 182 |
<literal>ssh://hg@repository-host/repository/name</literal> repository. |
183 |
Most other changes to access control can be made simply by making and |
|
184 |
pushing changes to <literal>hgadmin</literal>, and you can use Mercurial to |
|
185 |
cooperate with other root users in the normal way. |
|
186 |
</para> |
|
187 |
</section> |
|
188 |
<section> |
|
189 |
<title>Basic access control</title> |
|
190 |
<para> |
|
191 |
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. |
|
192 |
</para> |
|
193 |
<para> |
|
194 |
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. This is only the default configuration; for more advanced configuration read <xref linkend="accesscontrol"/>. |
|
195 |
</para> |
|
196 |
</section> |
|
197 |
</section> |
|
198 |
<section id="accesscontrol"> |
|
199 |
<title>Access control</title> |
|
200 |
<para> |
|
201 |
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 |
|
202 |
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 |
|
203 |
class='directory'>keys/root</filename> or <filename |
|
204 |
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> |
|
205 |
<programlisting> |
|
206 |
write repo=widget user=widget/** |
|
207 |
</programlisting> |
|
208 |
<para> |
|
209 |
Pat will have read and write access as soon as we add, commit, and push these files. |
|
210 |
</para> |
|
211 |
<para> |
|
124 | 212 |
Each line of <filename>access.conf</filename> has the following syntax: |
120 | 213 |
</para> |
214 |
<programlisting> |
|
215 |
<replaceable>rule</replaceable> <replaceable>condition</replaceable> <replaceable>condition...</replaceable> |
|
216 |
</programlisting> |
|
217 |
<para> |
|
218 |
Blank lines and lines that start with <literal>#</literal> are ignored. Rule is one of |
|
219 |
</para> |
|
220 |
<itemizedlist> |
|
221 |
<listitem> |
|
222 |
<literal>init</literal>: allow reads, writes, and the creation of new repositories |
|
223 |
</listitem> |
|
224 |
<listitem> |
|
225 |
<literal>write</literal>: allow reads and writes |
|
226 |
</listitem> |
|
227 |
<listitem> |
|
228 |
<literal>read</literal>: allow only read operations |
|
229 |
</listitem> |
|
230 |
<listitem> |
|
231 |
<literal>deny</literal>: deny all requests |
|
232 |
</listitem> |
|
233 |
</itemizedlist> |
|
234 |
<para> |
|
235 |
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. |
|
236 |
</para> |
|
237 |
<para> |
|
238 |
By default, <filename>/etc/mercurial-server/access.conf</filename> has the following rules: |
|
239 |
</para> |
|
240 |
<programlisting> |
|
241 |
init user=root/** |
|
242 |
deny repo=hgadmin |
|
243 |
write user=users/** |
|
244 |
</programlisting> |
|
245 |
<para> |
|
246 |
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. |
|
247 |
</para> |
|
248 |
<para> |
|
249 |
A condition is a globpattern matched against a relative path. The two most |
|
250 |
important conditions are |
|
251 |
</para> |
|
252 |
<itemizedlist> |
|
253 |
<listitem> |
|
254 |
<code><literal>user=</literal><replaceable>globpattern</replaceable></code>: path to the user's key |
|
255 |
</listitem> |
|
256 |
<listitem> |
|
257 |
<code><literal>repo=</literal><replaceable>globpattern</replaceable></code>: path to the repository |
|
258 |
</listitem> |
|
259 |
</itemizedlist> |
|
260 |
<para> |
|
261 |
"*" only matches one directory level, where "**" matches as many as you |
|
262 |
want. More precisely, "*" matches zero or more characters not including "/" |
|
263 |
while "**" matches zero or more characters including "/". |
|
264 |
</para> |
|
265 |
<section> |
|
125
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
266 |
<title>/etc/mercurial-server and hgadmin</title> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
267 |
<para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
</para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
271 |
<itemizedlist> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
272 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
273 |
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
|
274 |
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
|
275 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
276 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
277 |
<filename |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
278 |
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
|
279 |
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
|
280 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
281 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
282 |
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
|
283 |
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
|
284 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
285 |
<listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
286 |
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
|
287 |
</listitem> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
288 |
</itemizedlist> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
289 |
<para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
290 |
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
|
291 |
</para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
292 |
<para> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
293 |
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
|
294 |
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
|
295 |
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
|
296 |
<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
|
297 |
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
|
298 |
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
|
299 |
turning control entirely over to <literal>hgadmin</literal>. |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
300 |
</para> |
127 | 301 |
<para> |
302 |
<filename>/etc/mercurial-server/remote-hgrc</filename> is in the |
|
303 |
<systemitem>HGRCPATH</systemitem> for all remote access to mercurial-server |
|
304 |
repositories. This file contains the hooks that mercurial-server uses for |
|
305 |
access control and logging. You can add hooks to this file, but obviously |
|
306 |
breaking the existing hooks will disable the relevant functionality and |
|
307 |
isn't advisable. |
|
308 |
</para> |
|
125
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
309 |
</section> |
fc5b8fc1040e
Explain why we configure access twice
Paul Crowley <paul@lshift.net>
parents:
124
diff
changeset
|
310 |
<section> |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
311 |
<title>File and branch conditions</title> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
312 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
313 |
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
|
314 |
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
|
315 |
on. </para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
316 |
<caution> |
128 | 317 |
The way these conditions work is subtle and can be counterintuitive. Unless |
318 |
you need what they provide, ignore this section, stick to user and repo |
|
319 |
conditions, and then things are likely to work the way you would expect. |
|
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
320 |
</caution> |
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 |
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
|
323 |
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
|
324 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
325 |
<itemizedlist> |
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 |
<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
|
328 |
</listitem> |
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 |
<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
|
331 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
332 |
</itemizedlist> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
333 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
334 |
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
|
335 |
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
|
336 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
337 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
338 |
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
|
339 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
340 |
<itemizedlist> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
341 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
342 |
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
|
343 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
344 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
345 |
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
|
346 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
347 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
348 |
Whether to allow a changeset, which is on a some branch |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
349 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
350 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
351 |
Whether to allow a changeset which changes a particular file |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
352 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
353 |
</itemizedlist> |
120 | 354 |
<para> |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
355 |
When the first two of these decisions are being made, nothing is known |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
356 |
about what files might be changed, and so all file and branch conditions |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
357 |
automatically succeed for the purpose of such decisions. This means that |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
358 |
doing tricky things with file conditions can have counterintuitive |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
359 |
consequences: |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
360 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
361 |
<itemizedlist> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
362 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
363 |
<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
|
364 |
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
|
365 |
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
|
366 |
masking a later "write" rule, as in this example:</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
367 |
<programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
368 |
read repo=specialrepo file=dontwritethis |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
369 |
write repo=specialrepo |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
370 |
</programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
371 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
372 |
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
|
373 |
<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
|
374 |
<filename>dontwritethis</filename> will be rejected. |
120 | 375 |
</para> |
121
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
376 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
377 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
378 |
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
|
379 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
380 |
<listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
381 |
<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
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
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
|
386 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
387 |
<programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
388 |
write user=docs/* branch=docs file=docs/* |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
389 |
</programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
390 |
<para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
writing it to "docs" first: |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
394 |
</para> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
395 |
<programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
396 |
write user=docs/* branch=docs |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
397 |
write user=docs/* file=docs/* |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
398 |
read user=docs/* |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
399 |
</programlisting> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
400 |
</listitem> |
62185dc7d0c9
Document file and branch conditions in Docbook
Paul Crowley <paul@lshift.net>
parents:
120
diff
changeset
|
401 |
</itemizedlist> |
120 | 402 |
</section> |
403 |
</section> |
|
404 |
<section> |
|
126
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
405 |
<title>How mercurial-server works</title> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
406 |
<para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
407 |
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
|
408 |
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
|
409 |
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
|
410 |
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
|
411 |
<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
|
412 |
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
|
413 |
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
|
414 |
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
|
415 |
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
|
416 |
</para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
417 |
<para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
418 |
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
|
419 |
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
|
420 |
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
|
421 |
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
|
422 |
</para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
423 |
<para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
424 |
<command>refresh-auth</command> recurses through the <filename |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
425 |
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
|
426 |
class='directory'>keys</filename> directory in the |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
427 |
<literal>hgadmin</literal> repository, creating an entry in |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
428 |
<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
|
429 |
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
|
430 |
</para> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
431 |
</section> |
fd7ebe95d8e5
Move how it works section later
Paul Crowley <paul@lshift.net>
parents:
125
diff
changeset
|
432 |
<section> |
120 | 433 |
<title>Security</title> |
434 |
<para> |
|
435 |
mercurial-server relies entirely on sshd to grant access to remote users. |
|
436 |
As a result, it runs no daemons, installs no setuid programs, and no part |
|
437 |
of it runs as root except the install process: all programs run as the user |
|
438 |
hg. And any attack on mercurial-server can only be started if the Bad Guys |
|
439 |
already have a public key in <filename>~hg/.ssh/authorized_keys</filename>, |
|
440 |
otherwise sshd will bar the way. |
|
441 |
</para> |
|
442 |
<para> |
|
443 |
No matter what command the user tries to run on the remote system via SSH, |
|
444 |
mercurial-server is run. It parses the command line the user asked for, and |
|
445 |
interprets and runs the corresponding hg operation itself if access is |
|
446 |
allowed, so users can only read and add to history within repositories; |
|
447 |
they cannot run any other hg command. In addition, every push and pull is |
|
448 |
logged with a datestamp, changeset ID and the key that performed the |
|
449 |
operation. |
|
450 |
</para> |
|
451 |
<para> |
|
452 |
However, while the first paragraph holds no matter what bugs |
|
453 |
mercurial-server contains, the second depends on the relevant code being |
|
454 |
correct; though the entire codebase is short, mercurial-server is a fairly |
|
455 |
new program and may harbour bugs. Backups are essential! |
|
456 |
</para> |
|
457 |
</section> |
|
458 |
<section> |
|
459 |
<title>Thanks</title> |
|
460 |
<para> |
|
461 |
Thanks for reading this far. If you use mercurial-server, please tell me about |
|
462 |
it. |
|
463 |
</para> |
|
464 |
<para> |
|
465 |
Paul Crowley, <email>paul@lshift.net</email>, 2009 |
|
119 | 466 |
</para> |
467 |
</section> |
|
468 |
</article> |
|
469 |