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