[6ff0105] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[6732c094] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[6ff0105] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="svnserver" xreflabel="Running a Subversion Server">
|
---|
[eae0107f] | 9 | <?dbhtml filename="svnserver.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info>
|
---|
| 12 | <othername>$LastChangedBy$</othername>
|
---|
| 13 | <date>$Date$</date>
|
---|
| 14 | </sect1info>
|
---|
| 15 |
|
---|
| 16 | <title>Running a Subversion Server</title>
|
---|
| 17 |
|
---|
| 18 | <sect2 role="package">
|
---|
| 19 | <title>Running a Subversion Server</title>
|
---|
| 20 |
|
---|
| 21 | <para>This section will describe how to set up, administer and secure
|
---|
| 22 | a <application>Subversion</application> server.</para>
|
---|
| 23 |
|
---|
[84f9b731] | 24 | <!-- <note>
|
---|
[cf5c43f3] | 25 | <para>The default build instructions for
|
---|
| 26 | <application>Subversion</application> disabled the
|
---|
| 27 | <application>Berkeley DB</application> repository back-end due to the
|
---|
| 28 | errors encountered in the test suite while building the
|
---|
| 29 | <xref linkend="subversion"/> package. This should not present a
|
---|
| 30 | functionality issue as the FSFS repository back-end is now the default,
|
---|
| 31 | and recommended by the <application>Subversion</application> development
|
---|
| 32 | team.</para>
|
---|
| 33 |
|
---|
| 34 | <para>If you have existing repositories based on a
|
---|
| 35 | <application>Berkeley DB</application> back-end and you followed the
|
---|
| 36 | BLFS instructions for building <application>Subversion</application>,
|
---|
| 37 | you'll need to dump the databases, create new repositories using the
|
---|
| 38 | FSFS back-end, then then reload the data into the new repositories.
|
---|
| 39 | Instructions for performing these operations can be found at <ulink
|
---|
| 40 | url="http://svnbook.red-bean.com/en/1.1/ch05s03.html#svn-ch-5-sect-3.5"/>.
|
---|
| 41 | </para>
|
---|
[84f9b731] | 42 | </note> -->
|
---|
[cf5c43f3] | 43 |
|
---|
[eae0107f] | 44 | <bridgehead renderas="sect3">Subversion Server Dependencies</bridgehead>
|
---|
| 45 |
|
---|
| 46 | <bridgehead renderas="sect4">Required</bridgehead>
|
---|
| 47 | <para><xref linkend="subversion"/> and
|
---|
| 48 | <xref linkend="openssh"/></para>
|
---|
| 49 |
|
---|
| 50 | </sect2>
|
---|
| 51 |
|
---|
| 52 | <sect2 role="configuration">
|
---|
| 53 | <title>Setting up a Subversion Server.</title>
|
---|
| 54 |
|
---|
| 55 | <para>The following instructions will install a
|
---|
| 56 | <application>Subversion</application> server, which will be set up
|
---|
| 57 | to use <application>OpenSSH</application> as the secure remote access
|
---|
| 58 | method, with <command>svnserve</command> available for anonymous
|
---|
| 59 | access.</para>
|
---|
| 60 |
|
---|
| 61 | <para>Configuration of the <application>Subversion</application> server
|
---|
| 62 | consists of the following steps:</para>
|
---|
| 63 |
|
---|
| 64 | <sect3>
|
---|
| 65 | <title>1. Setup Users, Groups, and Permissions</title>
|
---|
| 66 |
|
---|
[823b1a3] | 67 | <para>You'll need to be user
|
---|
| 68 | <systemitem class='username'>root</systemitem> for the initial portion of
|
---|
[eae0107f] | 69 | configuration. Create the <systemitem class="username">svn</systemitem>
|
---|
| 70 | user and group with the following commands:</para>
|
---|
| 71 |
|
---|
[b785ab29] | 72 | <screen role="root"><userinput>groupadd -g 56 svn &&
|
---|
| 73 | useradd -c "SVN Owner" -d /home/svn -m -g svn -s /bin/false -u 56 svn</userinput></screen>
|
---|
[eae0107f] | 74 |
|
---|
| 75 | <para>If you plan to have multiple repositories, you should have a
|
---|
| 76 | group dedicated to each repository for ease of administration. Create
|
---|
| 77 | the <systemitem class="groupname">svntest</systemitem> group for the test
|
---|
| 78 | repository and add the <systemitem class="username">svn</systemitem>
|
---|
| 79 | user to that group with the following commands:</para>
|
---|
| 80 |
|
---|
[b785ab29] | 81 | <screen role="root"><userinput>groupadd -g 57 svntest &&
|
---|
[3a79861] | 82 | usermod -G svntest -a svn</userinput></screen>
|
---|
[eae0107f] | 83 |
|
---|
| 84 | </sect3>
|
---|
| 85 |
|
---|
| 86 | <sect3>
|
---|
| 87 | <title>2. Create a Subversion repository.</title>
|
---|
| 88 |
|
---|
| 89 | <para>With subversion-1.1.0 and greater, a new type of repository
|
---|
| 90 | data-store is available, FSFS. There is a tradeoff for speed with
|
---|
| 91 | the new backend, however, the repository can now be placed on a
|
---|
| 92 | network mount, and any corruption does not require an admin to
|
---|
| 93 | recover the repository. For more information and comparison between
|
---|
[bfb7882] | 94 | FSFS and BDB, see <ulink
|
---|
[eae0107f] | 95 | url="http://svnbook.red-bean.com/svnbook-1.1/ch05.html#svn-ch-5-sect-1.2.A"/>.
|
---|
[cf5c43f3] | 96 | </para>
|
---|
[eae0107f] | 97 |
|
---|
| 98 | <para>Create a new <application>Subversion</application> repository with
|
---|
| 99 | the following commands:</para>
|
---|
| 100 |
|
---|
[975fb37e] | 101 | <screen role="root"><userinput>install -v -m 0755 -d /srv/svn &&
|
---|
[cf5c43f3] | 102 | install -v -m 0755 -o svn -g svn -d /srv/svn/repositories &&
|
---|
[eae0107f] | 103 | svnadmin create --fs-type fsfs /srv/svn/repositories/svntest</userinput></screen>
|
---|
[42c74de] | 104 |
|
---|
[cf5c43f3] | 105 | <para>Now that the repository is created, it should be populated with
|
---|
[eae0107f] | 106 | with something useful. You'll need to have a predefined directory
|
---|
[cf5c43f3] | 107 | layout set up exactly as you want your repository to look. For
|
---|
[eae0107f] | 108 | example, here is a sample BLFS layout setup with a root of
|
---|
| 109 | <filename>svntest/</filename>. You'll need to setup a directory
|
---|
| 110 | tree similar to the following:</para>
|
---|
[42c74de] | 111 |
|
---|
[efd03f7] | 112 | <screen><literal>svntest/ # The name of the repository
|
---|
| 113 | trunk/ # Contains the existing source tree
|
---|
| 114 | BOOK/
|
---|
| 115 | bootscripts/
|
---|
| 116 | edguide/
|
---|
| 117 | patches/
|
---|
| 118 | scripts/
|
---|
| 119 | branches/ # Needed for additional branches
|
---|
| 120 | tags/ # Needed for tagging release points</literal></screen>
|
---|
[42c74de] | 121 |
|
---|
[eae0107f] | 122 | <para>Once you've created your directory layout as shown above, you
|
---|
| 123 | are ready to do the initial import:</para>
|
---|
[42c74de] | 124 |
|
---|
[eae0107f] | 125 | <screen role="root"><userinput>svn import -m "Initial import." \
|
---|
[efd03f7] | 126 | <replaceable></path/to/source/tree></replaceable> \
|
---|
[eae0107f] | 127 | file:///srv/svn/repositories/svntest</userinput></screen>
|
---|
[42c74de] | 128 |
|
---|
[cf5c43f3] | 129 | <para>Now change owner and group information on the
|
---|
[e615d9b] | 130 | repository, and add an unprivileged user to the
|
---|
[eae0107f] | 131 | <systemitem class="groupname">svn</systemitem> and
|
---|
| 132 | <systemitem class="groupname">svntest</systemitem> groups:</para>
|
---|
[42c74de] | 133 |
|
---|
[efd03f7] | 134 | <screen role="root"><userinput>chown -R svn:svntest /srv/svn/repositories/svntest &&
|
---|
| 135 | chmod -R g+w /srv/svn/repositories/svntest &&
|
---|
| 136 | chmod g+s /srv/svn/repositories/svntest/db &&
|
---|
[3a79861] | 137 | usermod -G svn,svntest -a <replaceable><username></replaceable></userinput></screen>
|
---|
[eae0107f] | 138 |
|
---|
| 139 | <para><systemitem class="groupname">svntest</systemitem> is the group
|
---|
| 140 | assigned to the svntest repository. As mentioned earlier, this eases
|
---|
| 141 | administration of multiple repositories when using
|
---|
| 142 | <application>OpenSSH</application> for authentication. Going forward,
|
---|
[4c288b0] | 143 | you'll need to add your unprivileged user, and any additional users that
|
---|
[eae0107f] | 144 | you wish to have write access to the repository, to the
|
---|
| 145 | <systemitem class="groupname">svn</systemitem> and
|
---|
| 146 | <systemitem class="groupname">svntest</systemitem> groups.</para>
|
---|
| 147 |
|
---|
| 148 | <para>In addition, you'll notice that the new repository's
|
---|
| 149 | <filename>db</filename> directory is set-groupID. If the reasoning is
|
---|
| 150 | not immediately obvious, when using any external authentication method
|
---|
| 151 | (such as <command>ssh</command>), the sticky bit is set so that all
|
---|
| 152 | new files will be owned by the user, but group of
|
---|
| 153 | <systemitem class="groupname">svntest</systemitem>. Anyone in the
|
---|
| 154 | <systemitem class="groupname">svntest</systemitem> group can create
|
---|
| 155 | files, but still give the entire group write access to those
|
---|
| 156 | files. This avoids locking out other users from the repository.</para>
|
---|
| 157 |
|
---|
[cf5c43f3] | 158 | <para>Now, return to an unprivileged user account, and take a
|
---|
| 159 | look at the new repository using <command>svnlook</command>:</para>
|
---|
[eae0107f] | 160 |
|
---|
| 161 | <screen><userinput>svnlook tree /srv/svn/repositories/svntest/</userinput></screen>
|
---|
| 162 |
|
---|
| 163 | <note>
|
---|
| 164 | <para>You may need to log out and back in again to refresh your group
|
---|
[3cb0c57] | 165 | memberships. '<command>su <replaceable><username></replaceable></command>'
|
---|
[c5923846] | 166 | should work as well.</para>
|
---|
[eae0107f] | 167 | </note>
|
---|
| 168 |
|
---|
| 169 | </sect3>
|
---|
| 170 |
|
---|
| 171 | <sect3>
|
---|
| 172 | <title>3. Configure the Server</title>
|
---|
| 173 |
|
---|
| 174 | <para>As mentioned previously, these instructions will configure the
|
---|
| 175 | server to use only <command>ssh</command> for write access to the
|
---|
| 176 | repository and to provide anonymous access using
|
---|
| 177 | <command>svnserve</command>. There are several other ways to provide
|
---|
| 178 | access to the repository. These additional configurations are best
|
---|
| 179 | explained at <ulink url="http://svnbook.red-bean.com/"/>.</para>
|
---|
| 180 |
|
---|
| 181 | <para>Access configuration needs to be done for each repository.
|
---|
| 182 | Create the <filename>svnserve.conf</filename> file for the svntest
|
---|
| 183 | repository using the following commands:</para>
|
---|
| 184 |
|
---|
| 185 | <screen role="root"><userinput>cp /srv/svn/repositories/svntest/conf/svnserve.conf \
|
---|
[efd03f7] | 186 | /srv/svn/repositories/svntest/conf/svnserve.conf.default &&
|
---|
| 187 |
|
---|
[eae0107f] | 188 | cat > /srv/svn/repositories/svntest/conf/svnserve.conf << "EOF"
|
---|
| 189 | <literal>[general]
|
---|
| 190 | anon-access = read
|
---|
| 191 | auth-access = write</literal>
|
---|
| 192 | EOF</userinput></screen>
|
---|
[42c74de] | 193 |
|
---|
[eae0107f] | 194 | <para>There is not a lot to the configuration file at all. You'll
|
---|
| 195 | notice that only the general section is required. Take a look at the
|
---|
| 196 | <filename>svnserve.conf.default</filename> file for information on using
|
---|
| 197 | <command>svnserve</command>'s built-in authentication method.</para>
|
---|
[42c74de] | 198 |
|
---|
[eae0107f] | 199 | </sect3>
|
---|
[42c74de] | 200 |
|
---|
[eae0107f] | 201 | <sect3 id="svnserver-init">
|
---|
| 202 | <title>4. Starting the Server</title>
|
---|
[efd03f7] | 203 | <!--
|
---|
[eae0107f] | 204 | <para>There are a couple of ways to start <command>svnserve</command>.
|
---|
| 205 | The most common way is to start it as an <command>inetd</command> or
|
---|
| 206 | <command>xinetd</command> process. Alternately, you can use a
|
---|
| 207 | bootscript to start the service at startup.</para>
|
---|
[42c74de] | 208 |
|
---|
[eae0107f] | 209 | <note>
|
---|
| 210 | <para>If you do not wish to provide anonymous access to your svn
|
---|
| 211 | repositories or use <command>svnserve</command>'s built-in
|
---|
| 212 | authentication, you do not need to run
|
---|
| 213 | <command>svnserve</command>.</para>
|
---|
| 214 | </note>
|
---|
[42c74de] | 215 |
|
---|
[eae0107f] | 216 | <para>If you use <command>inetd</command>, add a line to
|
---|
| 217 | <filename>/etc/inetd.conf</filename> using the following
|
---|
| 218 | commands:</para>
|
---|
[42c74de] | 219 |
|
---|
[eae0107f] | 220 | <indexterm zone="svnserver svnserver-init">
|
---|
| 221 | <primary sortas="e-etc-inetd.conf">/etc/inetd.conf</primary>
|
---|
| 222 | </indexterm>
|
---|
[42c74de] | 223 |
|
---|
[eae0107f] | 224 | <screen role="root"><userinput>cat >> /etc/inetd.conf << "EOF"
|
---|
| 225 | <literal>svn stream tcp nowait svn /usr/bin/svnserve svnserve -i</literal>
|
---|
| 226 | EOF</userinput></screen>
|
---|
[7afc6e2] | 227 |
|
---|
[eae0107f] | 228 | <para>If you use <command>xinetd</command>, the following command will
|
---|
| 229 | create the <application>Subversion</application> server file as
|
---|
| 230 | <filename>/etc/xinetd.d/svn</filename>:</para>
|
---|
[42c74de] | 231 |
|
---|
[eae0107f] | 232 | <indexterm zone="svnserver svnserver-init ">
|
---|
| 233 | <primary sortas="e-etc-xinetd.d-svn">/etc/xinetd.d/svn</primary>
|
---|
| 234 | </indexterm>
|
---|
[42c74de] | 235 |
|
---|
[eae0107f] | 236 | <screen role="root"><userinput>cat >> /etc/xinetd.d/svn << "EOF"
|
---|
| 237 | <literal># Begin /etc/xinetd.d/svn
|
---|
[42c74de] | 238 |
|
---|
| 239 | service svn
|
---|
| 240 | {
|
---|
| 241 | port = 3690
|
---|
| 242 | socket_type = stream
|
---|
| 243 | protocol = tcp
|
---|
| 244 | wait = no
|
---|
| 245 | user = svn
|
---|
| 246 | server = /usr/bin/svnserve
|
---|
| 247 | server_args = -i -r /srv/svn/repositories
|
---|
| 248 | }
|
---|
[1f672c1] | 249 |
|
---|
[eae0107f] | 250 | # End /etc/xinetd.d/svn</literal>
|
---|
[efd03f7] | 251 | EOF</userinput></screen> -->
|
---|
[42c74de] | 252 |
|
---|
[ab4735a7] | 253 | <para>
|
---|
| 254 | To start the <command>svnserve</command> daemon at boot,
|
---|
| 255 | install the systemd unit from the <xref linkend="bootscripts"/>
|
---|
| 256 | package by running the following command as the
|
---|
| 257 | <systemitem class="username">root</systemitem> user:
|
---|
| 258 | </para>
|
---|
[42c74de] | 259 |
|
---|
[eae0107f] | 260 | <indexterm zone="svnserver svnserver-init">
|
---|
[ab4735a7] | 261 | <primary sortas="f-svnserve">svnserve</primary>
|
---|
[eae0107f] | 262 | </indexterm>
|
---|
[42c74de] | 263 |
|
---|
[ab4735a7] | 264 | <screen role="root"><userinput>make install-svnserve</userinput></screen>
|
---|
| 265 |
|
---|
| 266 | <para>Additionally, the instructions above require that svn server
|
---|
| 267 | uses <command>umask 002</command> so that all new files will
|
---|
| 268 | be writable by owner and group. This can be achieved by creating
|
---|
| 269 | a systemd unit override file by running the following command:</para>
|
---|
| 270 |
|
---|
| 271 | <screen role="root"><userinput>mkdir -p /etc/systemd/system/svnserve.service.d
|
---|
| 272 | echo "UMask=0002" > /etc/systemd/system/svnserve.service.d/99-user.conf</userinput></screen>
|
---|
| 273 |
|
---|
| 274 | <para>Options which are passed to <command>svnserve</command> daemon
|
---|
| 275 | can be changed in <filename>/etc/default/svnserve</filename>.</para>
|
---|
[6ff0105] | 276 |
|
---|
[eae0107f] | 277 | </sect3>
|
---|
[6ff0105] | 278 |
|
---|
[eae0107f] | 279 | </sect2>
|
---|
[6ff0105] | 280 |
|
---|
[eae0107f] | 281 | </sect1>
|
---|