summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctm/ctm_rmail/ctm_rmail.1
blob: 8cca1325e5b850f2cf37f47199bc2c5ba5cdf982 (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
.\" NOTICE: This is free documentation.  I hope you get some use from these
.\" words.  In return you should think about all the nice people who sweat
.\" blood to document their free software.  Maybe you should write some
.\" documentation and give it away.  Maybe with a free program attached!
.\"
.\" Author: Stephen McKay
.\"
.Dd January 15, 1995
.Os
.Dt CTM_MAIL 1
.Sh NAME
.Nm ctm_smail, ctm_rmail
.Nd send and receive
.Nm ctm
deltas via mail
.Sh SYNOPSIS
.Nm ctm_smail
.Op Fl l Ar log
.Op Fl m Ar maxmsgsize
.Op Fl c Ar maxctmsize
.Ar ctm-delta
.Ar mail-alias
.Nm ctm_rmail
.Op Fl D
.Op Fl l Ar log
.Op Fl p Ar piecedir
.Op Fl d Ar deltadir
.Op Fl b Ar basedir
.Op Ar
.Sh DESCRIPTION
In conjuction with the
.Xr ctm 1
command,
.Nm ctm_smail
and
.Nm ctm_rmail
are used to distribute changes to a source tree via email.
.Nm ctm_smail
is given a compressed
.Nm ctm
delta, and a mailing list to send it to.  It splits the delta into manageable
pieces, encodes them as mail messages and sends them to the mailing list.
Each recipient uses
.Nm ctm_rmail
(either manually or automatically) to decode and reassemble the delta, and
optionally call
.Xr ctm 1
to apply it to the source tree.
At the moment,
only two source trees are distributed, and both by the same site.  These are
the FreeBSD-current source and CVS trees, distributed by
.Li ref.tfs.com .
.Pp
Command line arguments for
.Nm ctm_smail :
.Bl -tag -width indent
.It Fl l Ar log
Instead of appearing on
.Em stderr ,
error diagnostics and informational messages (other than command line errors)
are time stamped and written to the file
.Em log .
.It Fl m Ar maxmsgsize
Limit the maximum size mail message that
.Nm ctm_smail
is allowed to send.  It is approximate since mail headers and other niceties
are not counted in this limit.  If not specified, it will default to 64000
bytes, leaving room for 1535 bytes of headers before the rumoured 64k mail
limit.
.It Fl c Ar maxctmsize
Limit the maximum size delta that will be sent.  Deltas bigger that this
limit will cause an apology mail message to be sent to the mailing list.
This is to prevent massive changes overwhelming users' mail boxes.  Note that
this is the size before encoding.  Encoding causes a 4/3 size increase before
mail headers are added.  If not specified, there is no limit.
.El
.Pp
.Ar ctm-delta
is the delta to be sent, and
.Ar mail-alias
is the mailing list to send the delta to.
The mail messages are sent using
.Xr sendmail 8 .
.Pp
Command line arguments for
.Nm ctm_rmail :
.Bl -tag -width indent
.It Fl l Ar log
Instead of appearing on
.Em stderr ,
error diagnostics and informational messages (other than command line errors)
are time stamped and written to the file
.Em log .
.It Fl p Ar piecedir
Collect pieces of deltas in this directory.  Each piece corresponds to a
single mail message.  Pieces are removed when complete deltas are built.
If this flag is not given, no input files will be read, but completed
deltas may still be applied with
.Xr ctm 1
if the
.Fl b
flag is given.
.It Fl d Ar deltadir
Collect completed deltas in this directory.  Deltas are built from one or
more pieces when all pieces are present.
.It Fl b Ar basedir
Apply any completed deltas to this source tree.  If this flag is not given,
deltas will be stored, but not applied.  The user may then apply the deltas
manually, or by using
.Nm ctm_rmail
without the
.Fl p
flag.
Deltas will not be applied if they do not match the
.Li .ctm_status
file in
.Ar basedir
(or if
.Li .ctm_status
does not exist).
.It Fl D
Delete deltas after successful application by
.Xr ctm 1 .
It is probably a good idea to avoid this flag (and keep all the deltas)
as one of the possible future enhancements to
.Xr ctm 1
is the ability to recover small groups of files from a full set of deltas.
.El
.Pp
The file arguments (or
.Em stdin ,
if there are none) are scanned for delta pieces.  Multiple delta pieces
can be read from a single file, so an entire maildrop can be scanned
and processed with a single command.
.Sh FILE FORMAT
Following are the important parts of an actual (very small) delta piece:
.Bd -literal
From: src-cur-owner
To: src-cur
Subject: ctm-mail src-cur.0003.gz 1/4

CTM_MAIL BEGIN src-cur.0003.gz 1 4
H4sIAAAAAAACA3VU72/bNhD9bP0VByQoEiyRSZEUSQP9kKTeYCR2gDTdsGFAwB/HRogtG5K8NCj6
v4+UZSdtUQh6Rz0eee/xaF/dzx8up3/MFlDkBNrGnbttAwyo1pxoRgoiBNX/QJ5d3c9/X8DcPGGo
lggkPiXngE4W1gUjKPJCYyk5MZRbIqmNW/ASglIFcdwIzTUxaAqhnCPcBqloKEkJVNDMF0Azk+Bo
dDzzk0Ods/+A5gXv9YyJHjMCtJwQNeESNma7hOmXDRxn
CTM_MAIL END 61065
.Ed
.Pp
The subject of the message always begins with
.Dq ctm-mail
followed by the name of the delta, which piece this is, and how many total
pieces there are.  The data is bracketed by
.Dq CTM_MAIL BEGIN
and
.Dq CTM_MAIL END
lines, duplicating the information in the subject line, plus a simple checksum.
.Pp
If the delta exceeds
.Ar maxctmsize ,
then a message like this will be received instead:
.Bd -literal
From: src-cur-owner
To: src-cur
Subject: ctm-notice src-cur.0999.gz

src-cur.0999.gz is 792843 bytes.  The limit is 300000 bytes.

You can retrieve this delta via ftpmail, or your good mate at the university.
.Ed
.Pp
You are then on your own!
.Sh EXAMPLES
To send delta 32 of
.Em src-cur
to a group of wonderful code hackers known to
.Xr sendmail 8
as
.Em src-guys ,
limiting the mail size to roughly 60000 bytes, you could use:
.Bd -literal -offset indent
ctm_smail -m 60000 /wherever/it/is/src-cur.0032.gz src-guys
.Ed
.Pp
To decode every
.Nm ctm-mail
message in your mailbox, assemble them into complete deltas, then apply
any deltas built or lying around, you could use:
.Bd -literal -offset indent
ctm_rmail -p ~/pieces -d ~/deltas -b /usr/ctm-src-cur $MAIL
.Ed
.Pp
(Note that no messages are deleted by
.Nm ctm_rmail .
Any mail reader could be used for that purpose.)
.Pp
To create a mail alias called
.Em receiver-dude
that will automatically decode and assemble deltas, but not apply them,
you could put the following lines in your
.Pa /etc/aliases
file (assuming the
.Pa /ctm/tmp
and
.Pa /ctm/deltas
directories and
.Pa /ctm/log
file are writable by user
.Em daemon
or group
.Em wheel ) :
.Bd -literal -offset indent
receiver-dude: "|ctm_rmail -p /ctm/tmp -d /ctm/deltas -l /ctm/log"
owner-receiver-dude: real_dude@wherever.you.like
.Ed
.Pp
The second line will catch failures and drop them into your regular mailbox,
or wherever else you like.
.Pp
To apply all the deltas collected, and delete those applied, you could use:
.Bd -literal -offset indent
ctm_rmail -D -d /ctm/deltas -b /ctm/src-cur -l /ctm/apply.log
.Ed
.Sh SECURITY
If you automatically take your mail and pass it to a file tree patcher, you
might think you are handing the keys to your system to the hackers!  Happily,
the window for mischief is quite small.
.Nm ctm_rmail
is careful to write only to the directories given to it (by not believing any
.Dq /
characters in the delta name), and the latest
.Nm ctm
disallows absolute pathnames in files it manipulates, so the worst you
could lose are a few source tree files (recoverable from your deltas).
Since
.Nm ctm
requires that a
.Nm md5
checksum match before it touches a file, only fellow
source recipients would be able to generate a fake delta, and they're such
nice folk that they wouldn't even think of it! :-)
.Pp
Even this possibility could be removed by using cryptographic signatures.
A possible future enhancement would be to use
.Nm PGP
to provide a secure wrapper.
.\" This next request is for sections 1, 6, 7 & 8 only
.Sh ENVIRONMENT
If deltas are to be applied then
.Xr ctm 1
and
.Xr gunzip 1
must be in your
.Ev PATH .
.Sh FILES
.Bl -tag -width indent
.It Pa PIECEDIR/*
Pieces of deltas waiting for the rest.
.It Pa DELTADIR/*
Completed deltas.
.It Pa BASEDIR/.ctm_status
File containing name and number of the next delta to be applied to this
source tree.
.\" This next request is for sections 1, 6, 7 & 8 only
.\"     (command return values (to shell) and fprintf/stderr type diagnostics)
.Sh DIAGNOSTICS
.Nm ctm_smail
and
.Nm ctm_rmail
return exit status 0 for success, and 1 for various failures.
.Nm ctm_rmail
is expected to be called from a mail transfer program, and thus signals
failure only when the input mail message should be bounced (preferably into
your regular maildrop, not back to the sender).  In short, failure to
apply a completed delta with
.Nm ctm
is not considered an error important enough to bounce the mail, and
.Nm ctm_rmail
returns an exit status of 0.
.Pp
In normal operation,
.Nm ctm_smail
will report messages like:
.Bd -literal -offset indent
ctm_smail: src-cur.0250.gz 1/2 sent to src-guys
.Ed
.Pp
.Nm ctm_rmail
will report messages like:
.Bd -literal -offset indent
ctm_rmail: src-cur.0250.gz 1/2 stored
ctm_rmail: src-cur.0250.gz 2/2 stored
ctm_rmail: src-cur.0250.gz complete
.Ed
.Pp
These messages go to
.Em stderr
or to the log file.  Messages from
.Nm ctm
turn up here too.  Error messages should be self explanatory.
.\" The next request is for sections 2 and 3 error and signal handling only.
.\" .Sh ERRORS
.Sh SEE ALSO
.Xr ctm 1
(coming soon)
.\" .Sh STANDARDS
.\" .Sh HISTORY
.Sh AUTHOR
Stephen McKay <syssgm@devetir.qld.gov.au>
.\" .Sh BUGS
OpenPOWER on IntegriCloud