aboutsummaryrefslogtreecommitdiff
path: root/README
blob: ddeb41c3bf858775bfaff772feef43719e07e45e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325

        So, you want to run an anoncvs server.

        A summary of the steps you'll need to do is:

1) Find enough disk space to hold the anoncvs tree, and mount it in an
   appropriate place.

2) Compile and install anoncvssh, the shell used for the anoncvs user.
   Install the cvsync client using 'pkg_add cvsync' command.
   ( If you aren't using OpenBSD you'll probably need to compile a cvsync
     client as well. The easier path is to use OpenBSD ;).

3) Add the anoncvs user to the password file, with no password, and
   anoncvssh as it's shell. Decide on a user that will run cvsync to maintain
   the archive (this is a different user, NOT the anoncvs user).

4) Make a home directory for the anoncvs user. The anoncvs user's
   home directory is a chroot jail in which the anoncvssh processes
   run when servicing anoncvs requests. The jail must contain the
   cvs binary as well as whatever shared libraries and support files
   are needed to run them unless you compile and link everything
   statically. This example shows what is needed for OpenBSD. If you
   use another platform you'll need to be familiar with what needs
   to go in a chroot jail for your platform.

5) Get permission to use cvsync to obtain the cvs tree from a server.

6) Set up cvsync to retrieve the cvs tree from an appropriate place.

7) Run cvsync to retrieve the distribution from the server.

8) Once you get the distribution in, set up a cron job to run cvsync
   periodically to keep your server up to date.

**********************************************************************
STEP 1) find enough disk space.
    You need roughly 2GB.
    Mount it on /open, make sure it doesn't have nosuid and nodev flags.
    If you are not able to mount it as /open, substitute it's location
    throughout the rest of this description.

**********************************************************************
STEP 2) compile the anoncvssh binary.
    In the Makefile, change the variable CVSROOT.
    Install the binary setuid-root in /open/anoncvssh.

**********************************************************************
STEP 3) Create the anoncvs account and decide who will run "cvsync"
    to maintain the archive. The anoncvs account should *NOT* be the one
    running cvsync to maintain the archive.

create an account similar to:

    anoncvs::32766:32766::0:0:Anonymous CVS User:/open/anoncvs:/open/anoncvssh

Yes, that is right - the account has no password. Be sure that the
uid and gid are unique for your system, if the ones above aren't,
pick different values.

Decide who will run cvsync to maintain the archive. Call that user
$CVSYNCUSER.  Oh, and in case it hasn't been previously mentioned,
$CVSYNCUSER should *NOT* be the anoncvs user :).

Add the following to the end of your /etc/ssh/sshd_config and restart
your sshd daemon:

Match User anoncvs
        PermitEmptyPasswords yes
        AllowTcpForwarding no
        AllowAgentForwarding no
        X11Forwarding no

**********************************************************************
STEP 4) Build the anoncvs user's home directory chroot jail. This
    example assumes that you're using OpenBSD. If you're not you
    may need different files in the chroot.

mkdir /open/anoncvs
mkdir /open/anoncvs/cvs
chown -R $CVSYNCUSER /open/anoncvs/cvs /open/anoncvs

Start filling the account up with nice stuff. You are building a chroot
jail for anoncvs in /open/anoncvs.

    cd /open/anoncvs
    touch .hushlogin
    touch .profile

Put a message like the following in .plan:
    To use anonymous CVS install the latest version of CVS on your local
    machine.
    Then set your CVSROOT environment variable to the following value:
            anoncvs@anoncvs.openbsd.org:/cvs

    mkdir bin dev tmp usr var etc
    cp /bin/{cat,pwd,rm,sh} bin/

Using mknod, make a dev/null that has the same major/minor numbers as
    your /dev/null, and make it mode 666.

Some shared library systems require a dev/zero created in the same way.

Fill etc space for the account
    cp /etc/{group,hosts,passwd,protocols} etc/
    cp /etc/{pwd.db,resolv.conf,services,ttys} etc/
    modify these files to suit your idea of system security

anoncvssh (by setting the environment variable CVSREADONLYFS) uses
a tiny extension provided in the openbsd cvs server code which
permits the use of read-only cvs repositories, therefore you MUST
compile the openbsd version of cvs.  Luckily this is not a problem
on a non-openbsd machine, since the cvs sources are imported verbatim
into the openbsd tree.  They are in gnu/usr.bin/cvs.  The sources
are integrated in such way that Makefile.bsd-wrapper knows how to build
the sources on an OpenBSD machine, using obj directories.

Create tmp space for the account
    # (cd var && ln -s ../tmp tmp)
    # chmod a+rwx tmp

    # mkdir usr/{bin,lib}
    # cp /usr/bin/cvs usr/bin/

If your system has ld.so in /usr/libexec,
    # mkdir usr/libexec
    # cp /usr/libexec/ld.so usr/libexec/

If using shared libraries, use ldd to find out which shared libs you need:
    # ldd /usr/bin/cvs
        /usr/bin/cvs:
                Start    End      Type Open Ref GrpRef Name
                1c000000 3c01f000 exe  1    0   0      /usr/bin/cvs
                0f802000 2f80a000 rlib 0    1   0      /usr/lib/libz.so.4.1
                020f3000 220f8000 rlib 0    1   0      /usr/lib/libgssapi.so.5.0
                0530c000 2531c000 rlib 0    1   0      /usr/lib/libkrb5.so.17.0
                03801000 23841000 rlib 0    1   0      /usr/lib/libcrypto.so.18.0
                0a8fb000 2a900000 rlib 0    1   0      /usr/lib/libdes.so.9.0
                094d2000 2950b000 rlib 0    1   0      /usr/lib/libc.so.51.0
                094ca000 094ca000 rtld 0    1   0      /usr/libexec/ld.so

    and then copy the required libraries to usr/lib/

As a final pass, make sure that all the files you have just created are
not world writable (except dev/null).

For :pserver: support (optional)
  - Create an entry in /etc/services
     cvspserver 2401/tcp    # CVS client/server operations
  - Create an entry in /etc/inetd.conf
     cvspserver stream tcp nowait anoncvs /open/anoncvssh anoncvssh pserver
  - Create a file /open/anoncvs/cvs/CVSROOT/passwd with the following entry
        anoncvs:AHDysQkJIubEc
    which would be a password of "anoncvs" (as per anoncvs.html)
  - Create a file /open/anoncvs/cvs/CVSROOT/readers with a single entry:
        anoncvs
    which tells cvs that user "anoncvs" is allowed readonly access.
  - Create a zero-length file /open/anoncvs/cvs/CVSROOT/writers since you don't
    want anyone to be able to write to the mirror.
        % cp /dev/null /open/anoncvs/cvs/CVSROOT/writers

See the example layout below for full details.

**********************************************************************
STEP 5): Get cvsync permission.
send mail to sup@openbsd.org
1) to have cvsync permissions granted on an appropriate machine for you
   to cvsync from. We will need to know your host's real hostname and
   IP address.
2) to have an anoncvsN.COUNTRY.openbsd.org alias created.
3) to have your site mentioned in the http://www.openbsd.org/anoncvs.html page.

**********************************************************************
STEP 6): Configure cvsync.

You have to install cvsync package.

The file /etc/cvsync.conf contains the configuration of cvsync. It will
normally contain:

config {
        base-prefix /open/anoncvs/
        hostname anoncvs.ca.openbsd.org
        collection {
                name openbsd-cvsroot release rcs
                prefix cvs
        }
        collection {
                name openbsd-src release rcs
                prefix cvs
        }
        collection {
                name openbsd-ports release rcs
                prefix cvs
        }
        collection {
                name openbsd-www release rcs
                prefix cvs
        }
        collection {
                name openbsd-xenocara release rcs
                prefix cvs
        }
}

**********************************************************************
STEP 7): Run cvsync to retrieve the tree for the first time.

Log in as or become the $CVSYNCUSER, and run

cvsync > /tmp/cvsynclog &; tail -f /tmp/cvsynclog

If you have cvsync permission, and have specified the correct host and
prefix in /etc/cvsync.conf you should see a list of files start
coming in after a short while. Don't panic if nothing happens
immediately.  Watch for errors (cvsync can timeout or die). If you can't
access files contact the cvsync server maintainer. If you get a timeout
or if cvsync dies you can restart and it should continue where it left off.

It can take a good while (and a couple of restarts) to obtain the
whole tree for the first time.

**********************************************************************
STEP 8): Set up cron to keep the tree up to date.

You run cvsync periodically from the cron by setting up the crontab file
of the $CVSYNCUSER.

For example, to update every two hours:

15 */2 * * * /usr/local/bin/cvsync > /dev/null

**********************************************************************

EXAMPLE LAYOUT

Example layout for OpenBSD. In this example "deraadt" is the $CVSYNCUSER.

$ cd /open
$ ls -alF
total 64
drwxr-xr-x   5 root    wheel     512 Jun 18 22:29 ./
drwxr-xr-x  13 root    wheel     512 Jun  4 05:14 ../
drwxr-xr-x   9 deraadt wheel     512 Jun  3 02:15 anoncvs/
---s--x--x   1 root    wheel   14302 Jun 18 22:29 anoncvssh*
drwxr-xr-x   4 root    wheel    5120 Jun 10 14:34 ftp/

$ cd anoncvs
$ ls -alF
total 68
drwxr-xr-x   9 root    wheel    512 Jun  3 02:15 ./
drwxr-xr-x   5 root    wheel    512 Jun 10 14:32 ../
-rw-r--r--   1 root    wheel      0 Jun  3 01:50 .hushlogin
-rw-r--r--   1 root    wheel     84 Jun  3 01:50 .plan
-rw-r--r--   1 root    wheel      0 Jun  3 01:50 .profile
drwxr-xr-x   2 root    wheel    512 Jun  3 01:40 bin/
drwxr-xr-x   7 deraadt wheel    512 Jun 18 22:19 cvs/
drwxr-xr-x   2 root    wheel    512 Jun  3 01:51 dev/
drwxr-xr-x   2 root    wheel    512 Jun  3 01:53 etc/
drwxrwxrwx  10 root    wheel    512 Jun 18 17:38 tmp/
drwxr-xr-x   5 root    wheel    512 Jun  3 01:54 usr/
drwxr-xr-x   2 root    wheel    512 Jun  3 01:54 var/
$ ls -alFR bin usr tmp etc dev
bin:
total 1984
drwxr-xr-x  2 root  wheel     512 Jun  3 01:40 ./
drwxr-xr-x  9 root  wheel     512 Jun  3 02:15 ../
-r-xr-xr-x  1 root  wheel  132368 Jun  3 01:40 cat*
-r-xr-xr-x  1 root  wheel  124176 Jun  3 01:40 pwd*
-r-xr-xr-x  1 root  wheel  238864 Jun  3 01:40 rm*
-r-xr-xr-x  1 root  wheel  460048 Jun  3 01:40 sh*
  
dev:
total 8
drwxr-xr-x  2 root  wheel       512 Jun  3 01:51 ./
drwxr-xr-x  9 root  wheel       512 Jun  3 02:15 ../
crw-rw-rw-  1 root  wheel    3,   2 Jun  3 01:51 null
crw-rw-rw-  1 root  wheel    3,  12 Jun  3 01:51 zero
  
etc:
total 188
drwxr-xr-x  2 root  wheel    512 Jun  3 01:53 ./
drwxr-xr-x  9 root  wheel    512 Jun  3 02:15 ../
-r--r--r--  1 root  wheel     64 Jun  3 01:52 group*
-r--r--r--  1 root  wheel    576 Jun  3 01:52 hosts*
-r--r--r--  1 root  wheel    291 Jun  3 01:53 passwd*
-r--r--r--  1 root  wheel   5625 Jun  3 01:52 protocols*
-r--r--r--  1 root  wheel  40960 Jun  3 01:52 pwd.db*
-r--r--r--  1 root  wheel     93 Jun  3 01:52 resolv.conf*
-r--r--r--  1 root  wheel   9875 Jun  3 01:52 services*
-r--r--r--  1 root  wheel  26428 Jun  3 01:52 ttys*

usr:
total 20
drwxr-xr-x  5 root  wheel  512 Jun  3 01:54 ./
drwxr-xr-x  9 root  wheel  512 Jun  3 02:15 ../
drwxr-xr-x  2 root  wheel  512 Jun  3 01:57 bin/
drwxr-xr-x  2 root  wheel  512 Jun  3 01:56 lib/
drwxr-xr-x  2 root  wheel  512 Jun  3 01:55 libexec/

usr/bin:
total 3016
drwxr-xr-x  2 root  wheel     512 Jun  3 01:57 ./
drwxr-xr-x  5 root  wheel     512 Jun  3 01:54 ../
-r-xr-xr-x  1 root  wheel  643728 Jun  3 01:54 cvs*

usr/lib:
total 42344
drwxr-xr-x  2 root  wheel      512 Jun  3 01:56 ./
drwxr-xr-x  5 root  wheel      512 Jun  3 01:54 ../
-r--r--r--  1 root  wheel  4605409 Jun  3 01:56 libc.so.50.1
-r--r--r--  1 root  wheel  9659802 Jun  3 01:56 libcrypto.so.18.0
-r--r--r--  1 root  wheel   190814 Jun  3 01:56 libdes.so.9.0
-r--r--r--  1 root  wheel  1593303 Jun  3 01:55 libgssapi.so.5.0
-r--r--r--  1 root  wheel  5337583 Jun  3 01:56 libkrb5.so.16.0
-r--r--r--  1 root  wheel   182556 Jun  3 01:55 libz.so.4.1

usr/libexec:
total 120
drwxr-xr-x  2 root  wheel    512 Jun  3 01:55 ./
drwxr-xr-x  5 root  wheel    512 Jun  3 01:54 ../
-r-xr-xr-x  1 root  wheel  55683 Jun  3 01:55 ld.so*
$ ls cvs
CVSROOT  ports    src      www      xenocara