Initial import from FreeBSD RELENG_4:
[games.git] / usr.sbin / ctm / ctm_rmail / ctm_rmail.1
1 .\" NOTICE: This is free documentation.  I hope you get some use from these
2 .\" words.  In return you should think about all the nice people who sweat
3 .\" blood to document their free software.  Maybe you should write some
4 .\" documentation and give it away.  Maybe with a free program attached!
5 .\"
6 .\" Author: Stephen McKay
7 .\"
8 .\" $FreeBSD: src/usr.sbin/ctm/ctm_rmail/ctm_rmail.1,v 1.19.2.7 2003/03/12 22:08:14 trhodes Exp $
9 .\"
10 .Dd January 24, 1995
11 .Dt CTM_MAIL 1
12 .Os
13 .Sh NAME
14 .Nm ctm_smail ,
15 .Nm ctm_dequeue ,
16 .Nm ctm_rmail
17 .Nd send and receive
18 .Xr ctm 1
19 deltas via mail
20 .Sh SYNOPSIS
21 .Nm ctm_smail
22 .Op Fl l Ar log
23 .Op Fl m Ar maxmsgsize
24 .Op Fl c Ar maxctmsize
25 .Op Fl q Ar queue-dir
26 .Ar ctm-delta
27 .Ar mail-alias
28 .Nm ctm_dequeue
29 .Op Fl l Ar log
30 .Op Fl n Ar numchunks
31 .Ar queue-dir
32 .Nm ctm_rmail
33 .Op Fl Dfuv
34 .Op Fl l Ar log
35 .Op Fl p Ar piecedir
36 .Op Fl d Ar deltadir
37 .Op Fl b Ar basedir
38 .Op Ar
39 .Sh DESCRIPTION
40 In conjunction with the
41 .Xr ctm 1
42 command,
43 .Nm ctm_smail ,
44 .Nm ctm_dequeue
45 and
46 .Nm ctm_rmail
47 are used to distribute changes to a source tree via email.
48 The
49 .Nm ctm_smail
50 utility is given a compressed
51 .Xr ctm
52 delta, and a mailing list to send it to.  It splits the delta into manageable
53 pieces, encodes them as mail messages and sends them to the mailing list
54 (optionally queued to spread the mail load).
55 Each recipient uses
56 .Nm ctm_rmail
57 (either manually or automatically) to decode and reassemble the delta, and
58 optionally call
59 .Xr ctm
60 to apply it to the source tree.
61 At the moment,
62 several source trees are distributed, and by several sites.  These include
63 the
64 .Fx Ns -current
65 source and CVS trees, distributed by
66 .Li freefall.FreeBSD.org .
67 .Pp
68 Command line arguments for
69 .Nm ctm_smail :
70 .Bl -tag -width indent
71 .It Fl l Ar log
72 Instead of appearing on
73 .Em stderr ,
74 error diagnostics and informational messages (other than command line errors)
75 are time stamped and written to the file
76 .Em log .
77 .It Fl m Ar maxmsgsize
78 Limit the maximum size mail message that
79 .Nm ctm_smail
80 is allowed to send.  It is approximate since mail headers and other niceties
81 are not counted in this limit.  If not specified, it will default to 64000
82 bytes, leaving room for 1535 bytes of headers before the rumoured 64k mail
83 limit.
84 .It Fl c Ar maxctmsize
85 Limit the maximum size delta that will be sent.  Deltas bigger that this
86 limit will cause an apology mail message to be sent to the mailing list.
87 This is to prevent massive changes overwhelming users' mail boxes.  Note that
88 this is the size before encoding.  Encoding causes a 4/3 size increase before
89 mail headers are added.  If not specified, there is no limit.
90 .It Fl q Ar queue-dir
91 Instead of mailing the delta pieces now, store them in the given directory
92 to be mailed later using
93 .Nm ctm_dequeue .
94 This feature allows the mailing of large deltas to be spread out over
95 hours or even days to limit the impact on recipients with limited network
96 bandwidth or small mail spool areas.
97 .El
98 .Pp
99 .Ar ctm-delta
100 is the delta to be sent, and
101 .Ar mail-alias
102 is the mailing list to send the delta to.
103 The mail messages are sent using
104 .Xr sendmail 8 .
105 .Pp
106 Command line arguments for
107 .Nm ctm_dequeue :
108 .Bl -tag -width indent
109 .It Fl l Ar log
110 Instead of appearing on
111 .Em stderr ,
112 error diagnostics and informational messages (other than command line errors)
113 are time stamped and written to the file
114 .Em log .
115 .It Fl n Ar numchunks
116 Limit the number of mail messages that
117 .Nm ctm_dequeue
118 will send per run.  By default,
119 .Nm ctm_dequeue
120 will send one mail message per run.
121 .El
122 .Pp
123 .Ar queuedir
124 is the directory containing the mail messages stored by
125 .Nm ctm_smail .
126 Up to
127 .Ar numchunks
128 mail messages will be sent in each run.  The recipient mailing list is already
129 encoded in the queued files.
130 .Pp
131 It is safe to run
132 .Nm ctm_dequeue
133 while
134 .Nm ctm_smail
135 is adding entries to the queue, or even to run
136 .Nm ctm_smail
137 multiple times concurrently, but a separate queue directory should be used
138 for each tree being distributed.  This is because entries are served in
139 alphabetical order, and one tree will be unfairly serviced before any others,
140 based on the delta names, not delta creation times.
141 .Pp
142 Command line arguments for
143 .Nm ctm_rmail :
144 .Bl -tag -width indent
145 .It Fl l Ar log
146 Instead of appearing on
147 .Em stderr ,
148 error diagnostics and informational messages (other than command line errors)
149 are time stamped and written to the file
150 .Em log .
151 .It Fl p Ar piecedir
152 Collect pieces of deltas in this directory.  Each piece corresponds to a
153 single mail message.  Pieces are removed when complete deltas are built.
154 If this flag is not given, no input files will be read, but completed
155 deltas may still be applied with
156 .Xr ctm
157 if the
158 .Fl b
159 flag is given.
160 .It Fl d Ar deltadir
161 Collect completed deltas in this directory.  Deltas are built from one or
162 more pieces when all pieces are present.
163 .It Fl b Ar basedir
164 Apply any completed deltas to this source tree.  If this flag is not given,
165 deltas will be stored, but not applied.  The user may then apply the deltas
166 manually, or by using
167 .Nm ctm_rmail
168 without the
169 .Fl p
170 flag.
171 Deltas will not be applied if they do not match the
172 .Li .ctm_status
173 file in
174 .Ar basedir
175 (or if
176 .Li .ctm_status
177 does not exist).
178 .It Fl D
179 Delete deltas after successful application by
180 .Xr ctm .
181 It is probably a good idea to avoid this flag (and keep all the deltas) as
182 .Xr ctm
183 has the ability to recover small groups of files from a full set of deltas.
184 .It Fl f
185 Fork and execute in the background while applying deltas with
186 .Xr ctm .
187 This is useful when automatically invoking
188 .Nm ctm_rmail
189 from
190 .Xr sendmail
191 because
192 .Xr ctm
193 can take a very long time to complete, causing other people's mail to
194 be delayed, and can in theory cause spurious
195 mail retransmission due to the remote
196 .Xr sendmail
197 timing out, or even termination of
198 .Nm ctm_rmail
199 by mail filters such as
200 .Xr "MH's"
201 .Xr slocal .
202 Don't worry about zillions of background
203 .Xr ctm
204 processes loading your machine, since locking is used to prevent more than one
205 .Xr ctm
206 invocation at a time.
207 .It Fl u
208 Pass the
209 .Fl u
210 flag to the
211 .Xr ctm
212 command when applying the complete deltas, causing it to set the modification
213 time of created and modified files to the CTM delta creation time.
214 .It Fl v
215 Pass the
216 .Fl v
217 flag to the
218 .Xr ctm
219 command when applying the complete deltas, causing a more informative
220 output.  All
221 .Xr ctm
222 output appears in the
223 .Nm ctm_rmail
224 log file.
225 .El
226 .Pp
227 The file arguments (or
228 .Em stdin ,
229 if there are none) are scanned for delta pieces.  Multiple delta pieces
230 can be read from a single file, so an entire maildrop can be scanned
231 and processed with a single command.
232 .Pp
233 It is safe to invoke
234 .Nm ctm_rmail
235 multiple times concurrently (with different input files),
236 as might happen when
237 .Xr sendmail
238 is delivering mail asynchronously.  This is because locking is used to
239 keep things orderly.
240 .Sh FILE FORMAT
241 Following are the important parts of an actual (very small) delta piece:
242 .Bd -literal
243 From: owner-src-cur
244 To: src-cur
245 Subject: ctm-mail src-cur.0003.gz 1/4
246
247 CTM_MAIL BEGIN src-cur.0003.gz 1 4
248 H4sIAAAAAAACA3VU72/bNhD9bP0VByQoEiyRSZEUSQP9kKTeYCR2gDTdsGFAwB/HRogtG5K8NCj6
249 v4+UZSdtUQh6Rz0eee/xaF/dzx8up3/MFlDkBNrGnbttAwyo1pxoRgoiBNX/QJ5d3c9/X8DcPGGo
250 lggkPiXngE4W1gUjKPJCYyk5MZRbIqmNW/ASglIFcdwIzTUxaAqhnCPcBqloKEkJVNDMF0Azk+Bo
251 dDzzk0Ods/+A5gXv9YyJHjMCtJwQNeESNma7hOmXDRxn
252 CTM_MAIL END 61065
253 .Ed
254 .Pp
255 The subject of the message always begins with
256 .Dq ctm-mail
257 followed by the name of the delta, which piece this is, and how many total
258 pieces there are.  The data are bracketed by
259 .Dq CTM_MAIL BEGIN
260 and
261 .Dq CTM_MAIL END
262 lines, duplicating the information in the subject line, plus a simple checksum.
263 .Pp
264 If the delta exceeds
265 .Ar maxctmsize ,
266 then a message like this will be received instead:
267 .Bd -literal
268 From: owner-src-cur
269 To: src-cur
270 Subject: ctm-notice src-cur.0999.gz
271
272 src-cur.0999.gz is 792843 bytes.  The limit is 300000 bytes.
273
274 You can retrieve this delta via ftpmail, or your good mate at the university.
275 .Ed
276 .Pp
277 You are then on your own!
278 .Sh EXAMPLES
279 To send delta 32 of
280 .Em src-cur
281 to a group of wonderful code hackers known to
282 .Xr sendmail
283 as
284 .Em src-guys ,
285 limiting the mail size to roughly 60000 bytes, you could use:
286 .Bd -literal -offset indent
287 ctm_smail -m 60000 /wherever/it/is/src-cur.0032.gz src-guys
288 .Ed
289 .Pp
290 To decode every
291 .Nm ctm-mail
292 message in your mailbox, assemble them into complete deltas, then apply
293 any deltas built or lying around, you could use:
294 .Bd -literal -offset indent
295 ctm_rmail -p ~/pieces -d ~/deltas -b /usr/ctm-src-cur $MAIL
296 .Ed
297 .Pp
298 (Note that no messages are deleted by
299 .Nm ctm_rmail .
300 Any mail reader could be used for that purpose.)
301 .Pp
302 To create a mail alias called
303 .Em receiver-dude
304 that will automatically decode and assemble deltas, but not apply them,
305 you could put the following lines in your
306 .Pa /etc/mail/aliases
307 file (assuming the
308 .Pa /ctm/tmp
309 and
310 .Pa /ctm/deltas
311 directories and
312 .Pa /ctm/log
313 file are writable by user
314 .Em daemon
315 or group
316 .Em wheel ) :
317 .Bd -literal -offset indent
318 receiver-dude: "|ctm_rmail -p /ctm/tmp -d /ctm/deltas -l /ctm/log"
319 owner-receiver-dude: real_dude@wherever.you.like
320 .Ed
321 .Pp
322 The second line will catch failures and drop them into your regular mailbox,
323 or wherever else you like.
324 .Pp
325 To apply all the deltas collected, and delete those applied, you could use:
326 .Bd -literal -offset indent
327 ctm_rmail -D -d /ctm/deltas -b /ctm/src-cur -l /ctm/apply.log
328 .Ed
329 .Pp
330 For maximum flexibility, consider this excerpt from a
331 .Xr procmail
332 script:
333 .Bd -literal -offset indent
334 PATH=$HOME/bin:$PATH
335
336 :0 w
337 * ^Subject: ctm-mail cvs-cur
338 | ctm_incoming
339 .Ed
340 .Pp
341 together with the
342 shell script
343 .Pa ~/bin/ctm_incoming :
344 .Bd -literal -offset indent
345 #! /bin/sh
346 PATH="$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
347 export PATH
348
349 cd $HOME/ctm && ctm_rmail -f -p pieces -d deltas -l log -b /ctm
350 .Ed
351 .Pp
352 which will deposit all
353 .Xr ctm
354 deltas in
355 .Pa ~/ctm/deltas ,
356 apply them to the tree in
357 .Pa /ctm ,
358 and drop any failures into your regular mail box.
359 Note the
360 .Ev PATH
361 manipulation in
362 .Pa ctm_incoming
363 which allows
364 .Nm ctm_rmail
365 to execute
366 .Xr ctm 1
367 on the
368 .Pq non- Ns Fx
369 machine that this example was taken from.
370 .Sh SECURITY
371 On its own, CTM is an insecure protocol
372 - there is no authentication performed that the
373 changes applied to the source code were sent by a
374 trusted party, and so care should be taken if the
375 CTM deltas are obtained via an unauthenticated
376 medium such as regular email.
377 It is a relatively simple matter for an attacker
378 to forge a CTM delta to replace or precede the
379 legitimate one and insert malicious code into your
380 source tree.
381 If the legitimate delta is somehow prevented from
382 arriving, this will go unnoticed until a later
383 delta attempts to touch the same file, at which
384 point the MD5 checksum will fail.
385 .Pp
386 To remedy this insecurity, CTM delta pieces generated by
387 FreeBSD.org are cryptographically signed in a
388 format compatible with the GNU Privacy Guard
389 utility, available in /usr/ports/security/gpg, and
390 the Pretty Good Privacy v5 utility,
391 /usr/ports/security/pgp5.
392 The relevant public key can be obtained by
393 fingering ctm@FreeBSD.org.
394 .Pp
395 CTM deltas which are thus signed cannot be
396 undetectably altered by an attacker.
397 Therefore it is recommended that you make use of
398 GPG or PGP5 to verify the signatures if you
399 receive your CTM deltas via email.
400 .\" This next request is for sections 1, 6, 7 & 8 only
401 .Sh ENVIRONMENT
402 If deltas are to be applied then
403 .Xr ctm 1
404 and
405 .Xr gunzip 1
406 must be in your
407 .Ev PATH .
408 .Sh FILES
409 .Bl -tag -width indent
410 .It Pa QUEUEDIR/*
411 Pieces of deltas encoded as mail messages waiting to be sent to the
412 mailing list.
413 .It Pa PIECEDIR/*
414 Pieces of deltas waiting for the rest to arrive.
415 .It Pa DELTADIR/*
416 Completed deltas.
417 .It Pa BASEDIR/.ctm_status
418 File containing the name and number of the next delta to be applied to this
419 source tree.
420 .El
421 .Sh DIAGNOSTICS
422 The
423 .Nm ctm_smail ,
424 .Nm ctm_dequeue
425 and
426 .Nm ctm_rmail
427 utilities return exit status 0 for success, and 1 for various failures.
428 The
429 .Nm ctm_rmail
430 utility is expected to be called from a mail transfer program, and thus signals
431 failure only when the input mail message should be bounced (preferably into
432 your regular maildrop, not back to the sender).  In short, failure to
433 apply a completed delta with
434 .Xr ctm
435 is not considered an error important enough to bounce the mail, and
436 .Nm ctm_rmail
437 returns an exit status of 0.
438 .Pp
439 In normal operation,
440 .Nm ctm_smail
441 will report messages like:
442 .Bd -literal -offset indent
443 ctm_smail: src-cur.0250.gz 1/2 sent to src-guys
444 .Ed
445 .Pp
446 or, if queueing,
447 .Bd -literal -offset indent
448 ctm_smail: src-cur.0250.gz 1/2 queued for src-guys
449 .Ed
450 .Pp
451 The
452 .Nm ctm_dequeue
453 utility will report messages like:
454 .Bd -literal -offset indent
455 ctm_dequeue: src-cur.0250.gz 1/2 sent
456 .Ed
457 .Pp
458 The
459 .Nm ctm_rmail
460 utility will report messages like:
461 .Bd -literal -offset indent
462 ctm_rmail: src-cur.0250.gz 1/2 stored
463 ctm_rmail: src-cur.0250.gz 2/2 stored
464 ctm_rmail: src-cur.0250.gz complete
465 .Ed
466 .Pp
467 If any of the input files do not contain a valid delta piece,
468 .Nm ctm_rmail
469 will report:
470 .Bd -literal -offset indent
471 ctm_rmail: message contains no delta
472 .Ed
473 .Pp
474 and return an exit status of 1.  You can use this to redirect wayward messages
475 back into your real mailbox if your mail filter goes wonky.
476 .Pp
477 These messages go to
478 .Em stderr
479 or to the log file.  Messages from
480 .Xr ctm 1
481 turn up here too.  Error messages should be self explanatory.
482 .Sh SEE ALSO
483 .Xr ctm 1 ,
484 .Xr ctm 5
485 .\" .Sh HISTORY
486 .Sh AUTHORS
487 .An Stephen McKay Aq mckay@FreeBSD.org