Dash:
[t2-trunk.git] / package / mail / metamail / 30_mm-2.7-ohnonotagain.patch
blobfb1a2f9481100360c494b485fd9ba5b825624878
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../metamail/30_mm-2.7-ohnonotagain.patch
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This patch file is dual-licensed. It is available under the license the
11 # patched project is licensed under, as long as it is an OpenSource license
12 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
13 # of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 diff -d -r -u -P mm2.7.orig/src/bin/audiocompose mm2.7/src/bin/audiocompose
19 --- mm2.7.orig/src/bin/audiocompose Mon Jun 15 00:30:47 1998
20 +++ mm2.7/src/bin/audiocompose Sat Jun 20 14:41:16 1998
21 @@ -28,8 +28,8 @@
22 set dev=/dev/audio
23 endif
25 -set audiofile=$1
26 -if (-e $audiofile && ! -z $audiofile) goto whatnext
27 +set audiofile="$1"
28 +if (-e "$audiofile" && ! -z "$audiofile") goto whatnext
30 record:
31 echo -n "Press RETURN when you are ready to start recording: "
32 @@ -38,13 +38,22 @@
33 # THIS IS UNBELIEVABLY GRUBBY
34 onintr cleanup
35 if (! $?RECORD_AUDIO) then
36 - (/bin/cat < $dev > $audiofile) &
37 + (/bin/cat < $dev > "$audiofile") &
38 else
39 - ($RECORD_AUDIO > $audiofile) &
40 + ($RECORD_AUDIO > "$audiofile") &
41 endif
42 -jobs -l > ${METAMAIL_TMPDIR}/AUDCAT.$$
43 -set foo=`/bin/cat ${METAMAIL_TMPDIR}/AUDCAT.$$`
44 -/bin/rm ${METAMAIL_TMPDIR}/AUDCAT.$$
45 +# Generate temporary file name:
46 +if ( -x /bin/mktemp ) then
47 + set TmpAudCat=`/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
48 +else if ( -x /usr/bin/mktemp ) then
49 + set TmpAudCat=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
50 +else
51 + set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
52 + rm -rf $TmpAudCat
53 +endif
54 +jobs -l > $TmpAudCat
55 +set foo=`/bin/cat $TmpAudCat`
56 +/bin/rm $TmpAudCat
57 set PID=$foo[2]
58 echo -n "press RETURN when you are done recording: "
59 set foo=$<
60 @@ -63,7 +72,7 @@
61 set which = $<
62 switch ("$which")
63 case 1:
64 - cat $audiofile > $dev
65 + cat "$audiofile" > $dev
66 breaksw
67 case 2:
68 goto record
69 diff -d -r -u -P mm2.7.orig/src/bin/audiosend mm2.7/src/bin/audiosend
70 --- mm2.7.orig/src/bin/audiosend Mon Jun 15 00:30:47 1998
71 +++ mm2.7/src/bin/audiosend Sat Jun 20 14:42:48 1998
72 @@ -29,7 +29,7 @@
73 endif
75 if ( $#argv == 1 ) then
76 - set to = $1
77 + set to = "$1"
78 else
79 echo -n "To: "
80 set to = $<
81 @@ -43,8 +43,23 @@
82 echo -n "Press RETURN when you are ready to start recording: "
83 set foo = $<
85 -set fname = ${METAMAIL_TMPDIR}/audio-out.$$
86 -set fnameraw = ${METAMAIL_TMPDIR}/audio-raw.$$
87 +# Generate work file names:
88 +if ( -x /bin/mktemp ) then
89 + set fname=`/bin/mktemp ${METAMAIL_TMPDIR}/audio-out.XXXXXXX` || exit 1
90 +else if ( -x /usr/bin/mktemp ) then
91 + set fname=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/audio-out.XXXXXXX` || exit 1
92 +else
93 + set fname = ${METAMAIL_TMPDIR}/audio-out.$$
94 + rm -rf $fname
95 +endif
96 +if ( -x /bin/mktemp ) then
97 + set fnameraw=`/bin/mktemp ${METAMAIL_TMPDIR}/audio-raw.XXXXXXX` || exit 1
98 +else if ( -x /usr/bin/mktemp ) then
99 + set fnameraw=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/audio-raw.XXXXXXX` || exit 1
100 +else
101 + set fnameraw = ${METAMAIL_TMPDIR}/audio-raw.$$
102 + rm -rf $fnameraw
103 +endif
105 echo "To: " "$to" > $fname
106 echo "Subject: " "$subject" >> $fname
107 @@ -60,9 +75,18 @@
108 else
109 ($RECORD_AUDIO > $fnameraw) &
110 endif
111 -jobs -l > ${METAMAIL_TMPDIR}/AUDCAT.$$
112 -set foo=`/bin/cat ${METAMAIL_TMPDIR}/AUDCAT.$$`
113 -/bin/rm ${METAMAIL_TMPDIR}/AUDCAT.$$
114 +# Generate temporary file name:
115 +if ( -x /bin/mktemp ) then
116 + set TmpAudCat=`/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
117 +else if ( -x /usr/bin/mktemp ) then
118 + set TmpAudCat=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
119 +else
120 + set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
121 + rm -rf $TmpAudCat
122 +endif
123 +jobs -l > $TmpAudCat
124 +set foo=`/bin/cat $TmpAudCat`
125 +/bin/rm $TmpAudCat
126 set PID=$foo[2]
127 echo -n "press RETURN when you are done recording: "
128 set foo=$<
129 @@ -86,7 +110,7 @@
130 switch ("$which")
131 case 1:
132 echo -n "Sending mail, please wait... "
133 - /usr/lib/sendmail $to $cc < $fname
134 + /usr/lib/sendmail "$to" "$cc" < $fname
135 if (! $status) then
136 echo "Done."
137 rm $fname
138 diff -d -r -u -P mm2.7.orig/src/bin/extcompose mm2.7/src/bin/extcompose
139 --- mm2.7.orig/src/bin/extcompose Mon Jun 15 00:30:47 1998
140 +++ mm2.7/src/bin/extcompose Sat Jun 20 14:47:19 1998
141 @@ -6,7 +6,7 @@
142 echo "Usage: extcompose output-file-name"
143 exit 1
144 endif
145 -set OUTFNAME=$1
146 +set OUTFNAME="$1"
148 chooseaccesstype:
149 echo ""
150 @@ -19,21 +19,21 @@
151 echo ""
152 echo -n "Please enter a number from 1 to 5: "
153 set ans=$<
154 -if ($ans == 1) then
155 +if ("$ans" == 1) then
156 set accesstype=local-file
157 -else if ($ans == 2) then
158 +else if ("$ans" == 2) then
159 set accesstype=afs
160 -else if ($ans == 3) then
161 +else if ("$ans" == 3) then
162 set accesstype=anon-ftp
163 -else if ($ans == 4) then
164 +else if ("$ans" == 4) then
165 set accesstype=ftp
166 -else if ($ans == 5) then
167 +else if ("$ans" == 5) then
168 set accesstype=mail-server
169 else
170 echo "That is NOT one of your choices."
171 goto chooseaccesstype
172 endif
173 -if ($accesstype == "ftp" || $accesstype == "anon-ftp") then
174 +if ("$accesstype" == "ftp" || "$accesstype" == "anon-ftp") then
175 echo -n "Enter the full Internet domain name of the FTP site: "
176 set site=$<
177 echo -n "Enter the name of the directory containing the file (RETURN for top-level): "
178 @@ -42,27 +42,27 @@
179 set name = $<
180 echo -n "Enter the transfer mode (type 'image' for binary data, RETURN otherwise): "
181 set mode = $<
182 - if ($mode == "") set mode=ascii
183 - echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"\; > $OUTFNAME
184 - echo -n " site="\"$site\" >> $OUTFNAME
185 - if ($directory != "") echo -n "; directory="\"$directory\">> $OUTFNAME
186 - if ($mode != "") echo -n "; mode="\"$mode\">> $OUTFNAME
187 - echo "">> $OUTFNAME
188 -else if ($accesstype == "local-file" || $accesstype == "afs") then
189 + if ("$mode" == "") set mode=ascii
190 + echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"\; > "$OUTFNAME"
191 + echo -n " site="\"$site\" >> "$OUTFNAME"
192 + if ("$directory" != "") echo -n "; directory="\"$directory\">> "$OUTFNAME"
193 + if ("$mode" != "") echo -n "; mode="\"$mode\">> "$OUTFNAME"
194 + echo "">> "$OUTFNAME"
195 +else if ("$accesstype" == "local-file" || "$accesstype" == "afs") then
196 fname:
197 echo -n "Enter the full path name for the file: "
198 set name = $<
199 - if (! -e $name) then
200 + if (! -e "$name") then
201 echo "The file $name does not seem to exist."
202 goto fname
203 endif
204 - echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"> $OUTFNAME
205 -else if ($accesstype == "mail-server") then
206 + echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"> "$OUTFNAME"
207 +else if ("$accesstype" == "mail-server") then
208 echo -n "Enter the full email address for the mailserver: "
209 set server=$<
210 - echo "Content-type: message/external-body; access-type=$accesstype; server="\"$server\"> $OUTFNAME
211 + echo "Content-type: message/external-body; access-type=$accesstype; server="\"$server\"> "$OUTFNAME"
212 else
213 - echo accesstype $accesstype not yet implemented
214 + echo accesstype "$accesstype" not yet implemented
215 goto chooseaccesstype
216 endif
218 @@ -92,12 +92,12 @@
219 echo "That is not one of your choices."
220 goto getcenc
221 endsw
222 -echo "" >> $OUTFNAME
223 -echo "Content-type: " $ctype >> $OUTFNAME
224 -if ($cenc != "") echo "Content-transfer-encoding: " $cenc >> $OUTFNAME
225 -echo "" >> $OUTFNAME
226 -if ($accesstype == "mail-server") then
227 +echo "" >> "$OUTFNAME"
228 +echo "Content-type: " "$ctype" >> "$OUTFNAME"
229 +if ("$cenc" != "") echo "Content-transfer-encoding: " "$cenc" >> "$OUTFNAME"
230 +echo "" >> "$OUTFNAME"
231 +if ("$accesstype" == "mail-server") then
232 echo "Please enter all the data to be sent to the mailserver in the message body, "
233 echo "ending with ^D or your usual end-of-data character:"
234 - cat >> $OUTFNAME
235 + cat >> "$OUTFNAME"
236 endif
237 diff -d -r -u -P mm2.7.orig/src/bin/getfilename mm2.7/src/bin/getfilename
238 --- mm2.7.orig/src/bin/getfilename Mon Jun 15 00:30:47 1998
239 +++ mm2.7/src/bin/getfilename Sat Jun 20 14:47:43 1998
240 @@ -8,9 +8,9 @@
241 echo Aborted
242 exit -1
243 endif
244 -if (! -r $fnam) then
245 +if (! -r "$fnam") then
246 echo No such file
247 exit -1
248 endif
249 -cp $fnam $2
250 +cp "$fnam" "$2"
251 exit 0
252 diff -d -r -u -P mm2.7.orig/src/bin/mailserver mm2.7/src/bin/mailserver
253 --- mm2.7.orig/src/bin/mailserver Mon Jun 15 00:30:47 1998
254 +++ mm2.7/src/bin/mailserver Sat Jun 20 23:01:33 1998
255 @@ -28,20 +28,28 @@
256 rehash
257 set FromName=""
258 set Subject=""
259 -set TmpFile=/tmp/ms.$$
260 +# Generate temporary file name:
261 +if ( -x /bin/mktemp ) then
262 + set TmpFile=`/bin/mktemp /tmp/ms.XXXXXXX` || exit 1
263 +else if ( -x /usr/bin/mktemp ) then
264 + set TmpFile=`/usr/bin/mktemp /tmp/ms.XXXXXXX` || exit 1
265 +else
266 + set TmpFile=/tmp/ms.$$
267 + rm -rf $TmpFile
268 +endif
269 set FOORAW=$<
270 while ("$FOORAW" != "")
271 set FOO=(` echo "$FOORAW" | tr "[" "x"`)
272 set BAR=($FOO)
273 -set BARLC=(`echo $FOO | tr A-Z a-z`)
274 -if ($BARLC[1] == "from:") then
275 +set BARLC=(`echo "$FOO" | tr A-Z a-z`)
276 +if ("$BARLC[1]" == "from:") then
277 if ("$FromName" == "") then
278 - set FromName = ($BAR[2-])
279 + set FromName = ("$BAR[2-]")
280 endif
281 else if ($BARLC[1] == "reply-to:") then
282 - set FromName = ($BAR[2-])
283 + set FromName = ("$BAR[2-]")
284 else if ($BARLC[1] == "subject:") then
285 - set Subject = ($BAR[2-])
286 + set Subject = ("$BAR[2-]")
287 endif
288 set FOORAW=$<
290 @@ -52,10 +60,10 @@
291 endif
293 if ("$FromName" == "") then
294 - cat > $TmpFile <<!
295 -From: $LOCALADDR@`hostname`
296 -To: $MAINTAINER
297 -Subject: $Subject
298 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
299 + echo To: "$MAINTAINER" >> $TmpFile
300 + echo Subject: "$Subject" >> $TmpFile
301 + cat >> $TmpFile <<!
303 The metamail mailserver script, installed locally as $LOCALADDR, has received a request without any reply address.
305 @@ -68,18 +76,18 @@
306 probably run in some circumstance other than mail delivery.
307 --------------------
309 - cat $TmpFile - | /usr/lib/sendmail $MAINTAINER
310 + cat $TmpFile - | /usr/lib/sendmail "$MAINTAINER"
311 # Takes the rest of the message from standard input
312 rm $TmpFile
313 exit 0
314 endif
316 -set danger=`echo $Subject | fgrep ..`
317 -if ($danger != "") then
318 - cat > $TmpFile <<!
319 -From: $LOCALADDR@`hostname`
320 -To: $FromName
321 -Subject: Re: $Subject
322 +set danger=`echo "$Subject" | fgrep ..`
323 +if ("$danger" != "") then
324 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
325 + echo To: "$FromName" >> $TmpFile
326 + echo Subject: Re: "$Subject" >> $TmpFile
327 + cat >> $TmpFile <<!
329 For security reasons, this mailserver automatically rejects all requests
330 that contain ".." in the path name.
331 @@ -93,60 +101,64 @@
333 cd $ROOTDIR
334 if (! -e "$Subject") then
335 - cat > $TmpFile <<!
336 -From: $LOCALADDR@`hostname`
337 -To: $FromName
338 -Subject: Re: $Subject
340 -You recently sent mail to this mail-server requesting the file:
341 - $Subject
343 -That file does not exist, so your request could not be met.
345 -Here is a list of the currently available files:
346 ---------------------------------
348 + # We use a bunch of echo statements rather than a here-document
349 + # so that we can be sure to quote all of our variables properly.
350 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
351 + echo To: "$FromName" >> $TmpFile
352 + echo Subject: Re: "$Subject" >> $TmpFile
353 + echo "" >> $TmpFile
354 + echo "You recently sent mail to this mail-server requesting the file:" >> $TmpFile
355 + echo " $Subject" >> $TmpFile
356 + echo "" >> $TmpFile
357 + echo "That file does not exist, so your request could not be met." >> $TmpFile
358 + echo "" >> $TmpFile
359 + echo "Here is a list of the currently available files:" >> $TmpFile
360 + echo "--------------------------------" >> $TmpFile
361 ls -R >> $TmpFile
362 + echo "" >> $TmpFile
363 /usr/lib/sendmail -t < $TmpFile
364 rm $TmpFile
365 exit 0
366 endif
368 -if (-e ${Subject}.ct) then
369 - set ct=`cat ${Subject}.ct`
370 +if (-e "${Subject}.ct") then
371 + set ct=`cat "${Subject}.ct"`
372 else
373 set ct="application/octet-stream"
374 endif
376 metasend -b -t "$FromName" -f "$Subject" -m "$ct" -s "Re: $Subject"
377 if ($status != 0) then
378 - cat > $TmpFile <<!
379 -From: $LOCALADDR@`hostname`
380 -To: $FromName
381 -Subject: Re: $Subject
383 -You recently sent mail to this mail-server requestion the file:
384 - $Subject
386 -An unanticipated error apparently precluded delivery of the file.
387 -Please accept our apologies.
389 -Command failed:
390 - metasend -b -t "$FromName" -f "$Subject" -m "$ct" -s "Re: $Subject"
393 + # We use a bunch of echo statements rather than a here-document
394 + # so that we can be sure to quote all of our variables properly.
395 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
396 + echo To: "$FromName" >> $TmpFile
397 + echo Subject: Re: "$Subject" >> $TmpFile
398 + echo "" >> $TmpFile
399 + echo "You recently sent mail to this mail-server requestion the file:" >> $TmpFile
400 + echo " $Subject" >> $TmpFile
401 + echo "" >> $TmpFile
402 + echo "An unanticipated error apparently precluded delivery of the file." >> $TmpFile
403 + echo "Please accept our apologies." >> $TmpFile
404 + echo "" >> $TmpFile
405 + echo "Command failed:" >> $TmpFile
406 + echo " metasend -b -t $FromName -f $Subject -m $ct -s Re: $Subject" >> $TmpFile
407 + echo "" >> $TmpFile
408 /usr/lib/sendmail -t < $TmpFile
409 rm $TmpFile
410 exit 0
411 endif
413 if ("$LOGADDR" != "") then
414 - /usr/lib/sendmail -t <<!
415 -From: ${LOCALADDR}@`hostname`
416 -To: $LOGADDR
417 -Subject: Autosend delivery report
418 + echo From: "${LOCALADDR}"@`hostname` > $TmpFile
419 + echo To: "$LOGADDR" >> $TmpFile
420 + echo Subject: Autosend delivery report >> $TmpFile
421 + echo "" >> $TmpFile
422 + echo The file: "$Subject" >> $TmpFile
423 + echo was sent to: "$FromName" >> $TmpFile
424 + echo "" >> $TmpFile
425 + /usr/lib/sendmail -t < $TmpFile
426 +endif
428 -The file: $Subject
429 -was sent to: $FromName
431 +rm -f $TmpFile
432 exit 0
433 diff -d -r -u -P mm2.7.orig/src/bin/metasend mm2.7/src/bin/metasend
434 --- mm2.7.orig/src/bin/metasend Mon Jun 15 00:30:47 1998
435 +++ mm2.7/src/bin/metasend Sat Jun 20 14:59:30 1998
436 @@ -45,7 +45,7 @@
437 echo "-S requires a following argument, the SPLIT threshhold"
438 exit -1
439 endif
440 - set splitsize=$1
441 + set splitsize="$1"
442 shift
443 breaksw
444 case "-b":
445 @@ -68,7 +68,7 @@
446 echo "-i requires a following argument, the Content-ID value"
447 exit -1
448 endif
449 - set cid=$1
450 + set cid="$1"
451 shift
452 breaksw
453 case "-I":
454 @@ -77,7 +77,7 @@
455 echo "-I requires a following argument, the multipart Content-ID value"
456 exit -1
457 endif
458 - set multicid=$1
459 + set multicid="$1"
460 shift
461 breaksw
462 case "-s":
463 @@ -122,12 +122,12 @@
464 echo "-e requires a following argument, the ENCODING value"
465 exit -1
466 endif
467 - set encode=$1
468 - if ($encode == "base64") then
469 + set encode="$1"
470 + if ("$encode" == "base64") then
471 set encodingprog = "mimencode -b"
472 - else if ($encode == "x-uue") then
473 + else if ("$encode" == "x-uue") then
474 set encodingprog = "uuencode mail-body"
475 - else if ($encode == "7bit") then
476 + else if ("$encode" == "7bit") then
477 set encodingprog = cat
478 else
479 set encodingprog = "mimencode -q"
480 @@ -141,9 +141,9 @@
481 echo "-f requires a following argument, the DATA FILE"
482 exit -1
483 endif
484 - set datafile=$1
485 - if (! -e $datafile) then
486 - echo The file $datafile does not exist.
487 + set datafile="$1"
488 + if (! -e "$datafile") then
489 + echo The file "$datafile" does not exist.
490 exit -1
491 endif
492 shift
493 @@ -154,10 +154,10 @@
494 echo "-m requires a following argument, the MIME CONTENT-TYPE"
495 exit -1
496 endif
497 -# set ctyperaw = $1
498 -# set ctype=`echo $ctyperaw | tr \" \'`
499 +# set ctyperaw = "$1"
500 +# set ctype=`echo "$ctyperaw" | tr \" \'`
501 set ctype = "$1"
502 - if (`echo $ctype | grep /` == "") then
503 + if (`echo "$ctype" | grep /` == "") then
504 echo "Invalid content-type specified"
505 exit -1
506 endif
507 @@ -228,11 +228,11 @@
508 endif
509 endif
510 set ctype${multipart} = "$ctype"
511 - set datafile${multipart} = $datafile
512 - set encode${multipart} = $encode
513 + set datafile${multipart} = "$datafile"
514 + set encode${multipart} = "$encode"
515 set cdescrip${multipart} = "$cdescrip"
516 set cid${multipart} = "$cid"
517 - set isentity${multipart} = $isentity
518 + set isentity${multipart} = "$isentity"
519 set encodingprog${multipart} = "$encodingprog"
520 unset ctype
521 unset datafile
522 @@ -247,11 +247,11 @@
523 shift
524 breaksw
525 default:
526 - echo UNRECOGNIZED METASEND OPTION: $1
527 + echo UNRECOGNIZED METASEND OPTION: "$1"
528 exit -1
529 endsw
531 -if ($batchmode == 0) then
532 +if ("$batchmode" == 0) then
533 if (! $?to) then
534 echo -n "To: "
535 set to = $<
536 @@ -271,18 +271,18 @@
537 # set ctype=`echo $ctyperaw | tr \" \'`
538 set ctype = "$<"
539 endif
540 - if (`echo $ctype | grep /` == "") then
541 + if (`echo "$ctype" | grep /` == "") then
542 echo "Invalid content-type specified"
543 unset ctype
544 goto anotherpart
545 endif
546 -# if ($ctype != $ctyperaw) echo Double quotes not allowed, using $ctype
547 +# if ("$ctype" != "$ctyperaw") echo Double quotes not allowed, using "$ctype"
548 if (! $?datafile) then
549 getfile:
550 echo -n "Name of file containing $ctype data: "
551 set datafile = $<
552 - if (! -e $datafile) then
553 - echo The file $datafile does not exist.
554 + if (! -e "$datafile") then
555 + echo The file "$datafile" does not exist.
556 goto getfile
557 endif
558 endif
559 @@ -320,12 +320,12 @@
560 set ans=$<
561 if ("$ans" =~ y*) then
562 set ctype${multipart} = "$ctype"
563 - set datafile${multipart} = $datafile
564 - set encode${multipart} = $encode
565 + set datafile${multipart} = "$datafile"
566 + set encode${multipart} = "$encode"
567 set encodingprog${multipart} = "$encodingprog"
568 set cdescrip${multipart} = "$cdescrip"
569 set cid${multipart} = "$cid"
570 - set isentity${multipart} = $isentity
571 + set isentity${multipart} = "$isentity"
572 set cdescrip = "An object packed by metasend"
573 set isentity=0
574 unset ctype
575 @@ -339,7 +339,7 @@
576 goto anotherpart
577 endif
578 else
579 - if ($outputfile == "") then
580 + if ("$outputfile" == "") then
581 if (! $?to || ! $?subject || ! $?ctype || ! $?datafile) then
582 echo metasend: in batch mode, if output is not directed to a file,-t, -s, -f, and -m are all required
583 exit -1
584 @@ -359,12 +359,12 @@
585 exit -1
586 endif
587 endif
588 - if (! -e $datafile) then
589 - echo metasend: The file $datafile does not exist
590 + if (! -e "$datafile") then
591 + echo metasend: The file "$datafile" does not exist
592 exit -1
593 endif
594 # if (! $?cc) set cc=""
595 -# if ($ctype != $ctyperaw) echo Double quotes not allowed, using $ctype
596 +# if ("$ctype" != "$ctyperaw") echo Double quotes not allowed, using "$ctype"
597 if (! $?encode) then
598 if ("$ctype" =~ text*) then
599 set encodingprog = "mimencode -q"
600 @@ -373,11 +373,11 @@
601 set encodingprog = "mimencode -b"
602 set encode = base64
603 endif
604 - else if ($encode == "base64") then
605 + else if ("$encode" == "base64") then
606 set encodingprog = "mimencode -b"
607 - else if ($encode == "x-uue") then
608 + else if ("$encode" == "x-uue") then
609 set encodingprog = "uuencode mail-body"
610 - else if ($encode == "7bit") then
611 + else if ("$encode" == "7bit") then
612 set encodingprog = cat
613 else
614 set encodingprog = "mimencode -q"
615 @@ -395,14 +395,22 @@
616 endif
617 endif
618 set ctype${multipart} = "$ctype"
619 -set datafile${multipart} = $datafile
620 -set encode${multipart} = $encode
621 +set datafile${multipart} = "$datafile"
622 +set encode${multipart} = "$encode"
623 set cdescrip${multipart} = "$cdescrip"
624 set cid${multipart} = "$cid"
625 -set isentity${multipart} = $isentity
626 +set isentity${multipart} = "$isentity"
627 set encodingprog${multipart} = "$encodingprog"
629 -set fname = ${METAMAIL_TMPDIR}/metasend.$$
630 +# Generate file name:
631 +if ( -x /bin/mktemp ) then
632 + set fname=`/bin/mktemp ${METAMAIL_TMPDIR}/metasend.XXXXXXX` || exit 1
633 +else if ( -x /usr/bin/mktemp ) then
634 + set fname=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/metasend.XXXXXXX` || exit 1
635 +else
636 + set fname=${METAMAIL_TMPDIR}/metasend.$$
637 + rm -rf $fname
638 +endif
639 echo "MIME-Version: 1.0" > $fname
640 if ($?to) then
641 echo "To: " "$to" >> $fname
642 @@ -429,17 +437,26 @@
643 echo " boundary="\"$boundary\" >> $fname
644 echo "" >> $fname
645 if ($?preamblefile) then
646 - cat $preamblefile >> $fname
647 + cat "$preamblefile" >> $fname
648 else
649 echo "This is a multimedia message in MIME format. If you are reading this" >> $fname
650 echo "prefix, your mail reader does not understand MIME. You may wish" >> $fname
651 echo "to look into upgrading to a newer version of your mail reader." >> $fname
652 endif
653 set i=1
654 - set junkfile=${METAMAIL_TMPDIR}/mmjunk.$$
655 - while ($multipart >= $i)
657 + # Generate temporary file name:
658 + if ( -x /bin/mktemp ) then
659 + set junkfile=`/bin/mktemp ${METAMAIL_TMPDIR}/mmjunk.XXXXXXX` || exit 1
660 + else if ( -x /usr/bin/mktemp ) then
661 + set junkfile=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/mmjunk.XXXXXXX` || exit 1
662 + else
663 + set junkfile=${METAMAIL_TMPDIR}/mmjunk.$$
664 + rm -rf $junkfile
665 + endif
666 + while ("$multipart" >= $i)
667 echo "" >> $fname
668 - echo --$boundary >> $fname
669 + echo --"$boundary" >> $fname
670 echo set isentity=\$isentity$i > $junkfile
671 source $junkfile
672 if (! $isentity) then
673 @@ -463,27 +480,27 @@
675 rm $junkfile
676 echo "" >> $fname
677 - echo --${boundary}-- >> $fname
678 + echo --"${boundary}"-- >> $fname
679 echo "" >> $fname
680 else
681 if (! $isentity) then
682 echo "Content-ID: $cid" >> $fname
683 - echo "Content-type: " $ctype >> $fname
684 - echo "Content-Description: " $cdescrip >> $fname
685 - echo "Content-Transfer-Encoding: " $encode >> $fname
686 + echo "Content-type: " "$ctype" >> $fname
687 + echo "Content-Description: " "$cdescrip" >> $fname
688 + echo "Content-Transfer-Encoding: " "$encode" >> $fname
689 endif
690 echo "" >> $fname
691 - $encodingprog < $datafile >> $fname
692 + $encodingprog < "$datafile" >> $fname
693 # Ensure last line has trailing carriage return
694 echo "" >> $fname
695 endif
696 -if ($outputfile == "") then
697 - if ($batchmode == 0) echo -n "Delivering mail, please wait... "
698 - splitmail -s $splitsize -d $fname
699 +if ("$outputfile" == "") then
700 + if ("$batchmode" == 0) echo -n "Delivering mail, please wait... "
701 + splitmail -s "$splitsize" -d "$fname"
702 if (! $status) then
703 - if ($batchmode == 0) echo "Mail delivery apparently succeeded."
704 + if ("$batchmode" == 0) echo "Mail delivery apparently succeeded."
705 rm $fname
706 - else if ($MustDelete == 1) then
707 + else if ("$MustDelete" == 1) then
708 echo Mail delivery failed
709 rm $fname
710 exit -1
711 @@ -492,7 +509,7 @@
712 exit -1
713 endif
714 else
715 - mv $fname $outputfile
716 + mv $fname "$outputfile"
717 if ($status) exit -1
718 endif
719 exit 0
720 diff -d -r -u -P mm2.7.orig/src/bin/patch-metamail mm2.7/src/bin/patch-metamail
721 --- mm2.7.orig/src/bin/patch-metamail Mon Jun 15 00:30:47 1998
722 +++ mm2.7/src/bin/patch-metamail Sat Jun 20 23:18:20 1998
723 @@ -5,40 +5,53 @@
724 set DIRNAME=pub/nsb
725 set PREFIX="mm.patch."
727 +if (! $?METAMAIL_TMPDIR) then
728 + set METAMAIL_TMPDIR=/tmp
729 +endif
731 if ($#argv < 2 || $#argv > 5) then
732 echo Usage: patch-metamail source-tree-root patch-number [hostname [dirname [prefix]]]
733 exit -1
734 endif
736 -set TREEROOT=$1
737 -set PATCHNUMBER=$2
738 -if ($#argv > 2) set HOSTNAME=$3
739 -if ($#argv > 3) set DIRNAME=$4
740 -if ($#argv > 4) set PREFIX=$5
741 +set TREEROOT="$1"
742 +set PATCHNUMBER="$2"
743 +if ($#argv > 2) set HOSTNAME="$3"
744 +if ($#argv > 3) set DIRNAME="$4"
745 +if ($#argv > 4) set PREFIX="$5"
747 echo WARNING: This program, if allowed to do so, will attempt to
748 echo install a PATCH file for your metamail sources which are rooted
749 -echo in the directory $TREEROOT.
750 +echo in the directory "$TREEROOT".
751 echo ""
752 echo It will use a patch file that it retrieves via anonymous ftp
753 -echo from the host $HOSTNAME, in the directory $DIRNAME,
754 -echo with filenames starting with ${PREFIX}.
755 +echo from the host "$HOSTNAME", in the directory "$DIRNAME",
756 +echo with filenames starting with "${PREFIX}".
757 echo ""
758 echo -n "Do you want to install the patch in directory $TREEROOT [y/n] ? "
759 set ans=$<
760 -if ($ans == "y" || $ans == "Y") then
761 - cd $TREEROOT
762 +if ("$ans" == "y" || "$ans" == "Y") then
763 + cd "$TREEROOT"
764 set ident=`whoami`@`hostname`
765 - echo Using anonymous ftp with password $ident
766 - ftp -n <<!
767 -open $HOSTNAME
768 -user anonymous $ident
769 -cd $DIRNAME
770 -binary
771 -get ${PREFIX}${PATCHNUMBER}
772 -quit
774 - patch -p < ${PREFIX}${PATCHNUMBER}
775 + # Generate temporary file name:
776 + if ( -x /bin/mktemp ) then
777 + set TmpFtp=`/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
778 + else if ( -x /usr/bin/mktemp ) then
779 + set TmpFtp=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
780 + else
781 + set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
782 + rm -rf $TmpFtp
783 + endif
784 + echo open "$HOSTNAME" > $TmpFtp
785 + echo user anonymous "$ident" >> $TmpFtp
786 + echo cd "$DIRNAME" >> $TmpFtp
787 + echo binary >> $TmpFtp
788 + echo get "${PREFIX}${PATCHNUMBER}" >> $TmpFtp
789 + echo quit >> $TmpFtp
790 + echo Using anonymous ftp with password "$ident"
791 + ftp -n < $TmpFtp
792 + rm -f $TmpFtp
793 + patch -p < "${PREFIX}${PATCHNUMBER}"
794 else
795 echo Patch not installed
796 endif
797 diff -d -r -u -P mm2.7.orig/src/bin/rcvAppleSingle mm2.7/src/bin/rcvAppleSingle
798 --- mm2.7.orig/src/bin/rcvAppleSingle Mon Jun 15 00:30:47 1998
799 +++ mm2.7/src/bin/rcvAppleSingle Sat Jun 20 14:08:30 1998
800 @@ -13,7 +13,7 @@
801 # Written by Patrik Faltstrom, paf@nada.kth.se, may 1993
804 -FILENAME=$1
805 +FILENAME="$1"
808 # If $AFPDIR environment variable is set, all Macintosh filenames
809 @@ -31,12 +31,12 @@
810 exit 1
813 -echo $NAME | grep '^/' > /dev/null
814 +echo "$NAME" | grep '^/' > /dev/null
815 if [ $? = 1 ]; then
816 - NAME=$AFPDIR/$NAME
817 + NAME="$AFPDIR/$NAME"
820 -cvt2cap $FILENAME $NAME
821 +cvt2cap "$FILENAME" "$NAME"
822 echo "Saved AppleMacintosh file as $NAME"
823 exit 0
825 diff -d -r -u -P mm2.7.orig/src/bin/showaudio mm2.7/src/bin/showaudio
826 --- mm2.7.orig/src/bin/showaudio Mon Jun 15 00:30:47 1998
827 +++ mm2.7/src/bin/showaudio Sat Jun 20 15:01:55 1998
828 @@ -33,7 +33,7 @@
829 set ORG="Bellcore"
830 set STDINPUT=0
831 if ("$1" == "-p") then
832 - set AUDIOPHONE=$2
833 + set AUDIOPHONE="$2"
834 shift
835 shift
836 endif
837 @@ -73,13 +73,13 @@
838 echo ""
839 echo -n "Which do you prefer (1 or 2)? "
840 set ans=$<
841 - if ($ans == 2) then
842 + if ("$ans" == 2) then
843 echo "OK, we'll use the telephone..."
844 set AUDIOPHONEFORCE=1
845 echo "In the future, you can avoid this question by setting the environment variable"
846 echo "AUDIOPHONEFORCE to 1"
847 goto playphone
848 - else if ($ans == 1) then
849 + else if ("$ans" == 1) then
850 echo "OK, Attempting to play the audio using your computer's speaker.."
851 set AUDIOSPEAKERFORCE=1
852 echo "In the future, you can avoid this question by setting the environment variable"
853 @@ -93,8 +93,8 @@
854 set audiohost=$thishost
855 if ($?DISPLAY) then
856 set audiohost=`echo $DISPLAY | sed -e 's/:.*//'`
857 - if ($audiohost == "unix") set audiohost=$thishost
858 - if ($audiohost == "") set audiohost=$thishost
859 + if ("$audiohost" == "unix") set audiohost=$thishost
860 + if ("$audiohost" == "") set audiohost=$thishost
861 endif
862 if ($?AUDIOHOST) then
863 set audiohost=$AUDIOHOST
864 @@ -127,9 +127,18 @@
865 if ($#argv >= 1) then
866 exec /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $*
867 else
868 - cat > ${METAMAIL_TMPDIR}/audio.$$
869 - /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end ${METAMAIL_TMPDIR}/audio.$$
870 - rm ${METAMAIL_TMPDIR}/audio.$$
871 + # Generate temporary file name:
872 + if ( -x /bin/mktemp ) then
873 + set TmpAudio=`/bin/mktemp ${METAMAIL_TMPDIR}/audio.XXXXXXX` || exit 1
874 + else if ( -x /usr/bin/mktemp ) then
875 + set TmpAudio=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/audio.XXXXXXX` || exit 1
876 + else
877 + set TmpAudio=${METAMAIL_TMPDIR}/audio.$$
878 + rm -rf $TmpAudio
879 + endif
880 + cat > $TmpAudio
881 + /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $TmpAudio
882 + rm $TmpAudio
883 exit 0
884 endif
885 else if (-d /usr/sony) then
886 @@ -198,7 +207,15 @@
887 echo ""
888 if (! $?MM_NOTTTY) set MM_NOTTTY=0
889 if ($MM_NOTTTY == 1) then
890 - set fname=/tmp/mm.aud.$$
891 + # Generate unique file name:
892 + if ( -x /bin/mktemp ) then
893 + set fname=`/bin/mktemp /tmp/mm.aud.XXXXXXX` || exit 1
894 + else if ( -x /usr/bin/mktemp ) then
895 + set fname=`/usr/bin/mktemp /tmp/mm.aud.XXXXXXX` || exit 1
896 + else
897 + set fname=/tmp/mm.aud.$$
898 + rm -rf $fname
899 + endif
900 else
901 echo -n "Do you want to write the audio out to a file [y] ? "
902 set ANS=$<
903 @@ -206,7 +223,7 @@
904 echo -n "File name:"
905 set fname=$<
906 endif
907 -cp $1 $fname
908 -if ($status == 0) echo Wrote raw audio file: $fname
909 +cp "$1" "$fname"
910 +if ($status == 0) echo Wrote raw audio file: "$fname"
911 exit 0
913 diff -d -r -u -P mm2.7.orig/src/bin/showexternal mm2.7/src/bin/showexternal
914 --- mm2.7.orig/src/bin/showexternal Mon Jun 15 00:30:47 1998
915 +++ mm2.7/src/bin/showexternal Sat Jun 20 23:20:49 1998
916 @@ -40,14 +40,14 @@
917 endsw
918 set bodyfile="$1"
919 set atype=`echo $2 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
920 -set name=$3
921 +set name="$3"
922 if ($#argv > 3) then
923 set site="$4"
924 else
925 set site=""
926 endif
927 if ($#argv > 4) then
928 - set dir=$5
929 + set dir="$5"
930 else
931 set dir=""
932 endif
933 @@ -62,10 +62,10 @@
934 set server=""
935 endif
937 -if ("$server" == "" && $atype == "mail-server") then
938 +if ("$server" == "" && "$atype" == "mail-server") then
939 # Backward compatibility with some broken stuff
940 - set server=${name}@${site}
941 - echo WARNING -- old style mailserver syntax, using server $server
942 + set server="${name}@${site}"
943 + echo WARNING -- old style mailserver syntax, using server "$server"
944 endif
946 set ctype="`grep -i content-type: $bodyfile | sed -e 's/............: //'`"
947 @@ -75,6 +75,10 @@
948 set pass=""
949 set TMPDIR=${METAMAIL_TMPDIR}/XXXternal.$$
950 mkdir $TMPDIR
951 +if ( $status != 0 ) then
952 + echo Error creating temporary directory
953 + exit 1
954 +endif
955 pushd $TMPDIR
956 set NEWNAME="mm.ext.$$"
957 set NEEDSCONFIRMATION=1
958 @@ -90,7 +94,16 @@
959 echo automatically using the FTP protocol to a site on the network.
960 breaksw
961 case mail-server:
962 - cat > ${METAMAIL_TMPDIR}/ext.junk.$$ <<!
963 + # Generate temporary file name:
964 + if ( -x /bin/mktemp ) then
965 + set TmpExtJunk=`/bin/mktemp ${METAMAIL_TMPDIR}/ext.junk.XXXXXXX` || exit 1
966 + else if ( -x /usr/bin/mktemp ) then
967 + set TmpExtJunk=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/ext.junk.XXXXXXX` || exit 1
968 + else
969 + set TmpExtJunk=${METAMAIL_TMPDIR}/ext.junk.$$
970 + rm -rf $TmpExtJunk
971 + endif
972 + cat > $TmpExtJunk <<!
973 This mail message contains a POINTER (reference) to data that is
974 not included in the message itself. Rather, the data can be retrieved
975 by sending a special mail message to a mail server on the network.
976 @@ -102,13 +115,13 @@
977 This is the message that will be sent if you choose to go ahead and
978 retreive the external data:
980 -Subject: Automated Mail Server Request
981 -To: ${server}
984 - sed -e 1,/^\$/d < $bodyfile >> ${METAMAIL_TMPDIR}/ext.junk.$$
985 - ${METAMAIL_PAGER} ${METAMAIL_TMPDIR}/ext.junk.$$
986 - rm ${METAMAIL_TMPDIR}/ext.junk.$$
987 + echo Subject: Automated Mail Server Request >> $TmpExtJunk
988 + echo To: "$server" >> $TmpExtJunk
989 + echo "" >> $TmpExtJunk
990 + sed -e 1,/^\$/d < $bodyfile >> $TmpExtJunk
991 + ${METAMAIL_PAGER} $TmpExtJunk
992 + rm $TmpExtJunk
993 breaksw
994 default:
995 # IGNORE ALL THE OTHERS -- AUTOMATIC FOR LOCAL-FILE, AFS.
996 @@ -157,17 +170,26 @@
997 else
998 set MODECMD="type $mode"
999 endif
1000 + # Generate temporary file name:
1001 + if ( -x /bin/mktemp ) then
1002 + set TmpFtp=`/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
1003 + else if ( -x /usr/bin/mktemp ) then
1004 + set TmpFtp=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
1005 + else
1006 + set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
1007 + rm -rf $TmpFtp
1008 + endif
1009 + echo open "$site" > $TmpFtp
1010 + echo user "$username" "$pass" >> $TmpFtp
1011 + echo "$DIRCMD" >> $TmpFtp
1012 + echo "$MODECMD" >> $TmpFtp
1013 + echo get "$name" "$NEWNAME" >> $TmpFtp
1014 + echo quit >> $TmpFtp
1015 echo OBTAINING MESSAGE BODY USING FTP
1016 - echo SITE: $site USER $username
1017 - $FTP -n <<!
1018 -open $site
1019 -user $username $pass
1020 -$DIRCMD
1021 -$MODECMD
1022 -get $name $NEWNAME
1023 -quit
1025 - if (! -e $NEWNAME) then
1026 + echo SITE: "$site" USER "$username"
1027 + $FTP -n < $TmpFtp
1028 + rm -f $TmpFtp
1029 + if (! -e "$NEWNAME") then
1030 echo FTP failed.
1031 cd ${METAMAIL_TMPDIR}
1032 rm -rf $TMPDIR
1033 @@ -176,14 +198,14 @@
1034 breaksw
1035 case afs:
1036 case local-file:
1037 - if (! -e $name) then
1038 + if (! -e "$name") then
1039 echo local file not found
1040 cd ${METAMAIL_TMPDIR}
1041 rm -rf $TMPDIR
1042 exit -1
1043 endif
1044 - set NEWNAME=$name
1045 - echo GETTING BODY FROM FILE NAMED: $NEWNAME
1046 + set NEWNAME="$name" # Note that this is not trusted data...
1047 + echo GETTING BODY FROM FILE NAMED: "$NEWNAME"
1048 breaksw
1049 case mail-server: # A very special case
1050 if ("$bodyfile" == "") then
1051 @@ -192,12 +214,12 @@
1052 rm -rf $TMPDIR
1053 exit -1
1054 endif
1055 - echo Subject: Automated Mail Server Request > $NEWNAME
1056 - echo To: ${server} >> $NEWNAME
1057 - echo "" >> $NEWNAME
1058 - sed -e 1,/^\$/d < $bodyfile >> $NEWNAME
1059 - echo "" >> $NEWNAME
1060 - /usr/lib/sendmail -t < $NEWNAME
1061 + echo Subject: Automated Mail Server Request > "$NEWNAME"
1062 + echo To: ${server} >> "$NEWNAME"
1063 + echo "" >> "$NEWNAME"
1064 + sed -e 1,/^\$/d < $bodyfile >> "$NEWNAME"
1065 + echo "" >> "$NEWNAME"
1066 + /usr/lib/sendmail -t < "$NEWNAME"
1067 if ($status) then
1068 echo sendmail failed
1069 cd ${METAMAIL_TMPDIR}
1070 @@ -206,7 +228,7 @@
1071 endif
1072 cd ${METAMAIL_TMPDIR}
1073 rm -rf $TMPDIR
1074 - echo Your $ctype data has been requested from a mail server.
1075 + echo Your "$ctype" data has been requested from a mail server.
1076 exit 0
1077 default:
1078 echo UNRECOGNIZED ACCESS-TYPE
1079 @@ -214,19 +236,19 @@
1080 rm -rf $TMPDIR
1081 exit -1
1082 endsw
1083 -if ($cenc == base64) then
1084 - mimencode -u -b < $NEWNAME > OUT
1085 - mv OUT $NEWNAME
1086 -else if ($cenc == quoted-printable) then
1087 - mimencode -u -q < $NEWNAME > OUT
1088 - mv OUT $NEWNAME
1089 +if ("$cenc" == base64) then
1090 + mimencode -u -b < "$NEWNAME" > OUT
1091 + mv OUT "$NEWNAME"
1092 +else if ("$cenc" == quoted-printable) then
1093 + mimencode -u -q < "$NEWNAME" > OUT
1094 + mv OUT "$NEWNAME"
1095 endif
1097 popd
1098 -if ($atype == "local-file") then
1099 - metamail -p -b -c "$ctype" $NEWNAME
1100 +if ("$atype" == "local-file") then
1101 + metamail -p -b -c "$ctype" "$NEWNAME"
1102 else
1103 - metamail -p -b -c "$ctype" $TMPDIR/$NEWNAME
1104 + metamail -p -b -c "$ctype" "$TMPDIR/$NEWNAME"
1105 endif
1107 if ($status) then
1108 @@ -236,14 +258,14 @@
1109 exit -1
1110 endif
1112 -if ($NEWNAME != $name) then
1113 +if ("$NEWNAME" != "$name") then
1114 echo ""
1115 - echo The data just displayed is stored in the file $TMPDIR/$NEWNAME
1116 + echo The data just displayed is stored in the file "$TMPDIR/$NEWNAME"
1117 echo "Do you want to delete it?"
1118 - rm -i $TMPDIR/$NEWNAME
1119 + rm -i "$TMPDIR/$NEWNAME"
1120 endif
1122 -if (! -e ${TMPDIR}/${NEWNAME}) then
1123 +if (! -e "${TMPDIR}/${NEWNAME}") then
1124 cd ${METAMAIL_TMPDIR}
1125 rmdir $TMPDIR
1126 endif
1127 diff -d -r -u -P mm2.7.orig/src/bin/showpartial mm2.7/src/bin/showpartial
1128 --- mm2.7.orig/src/bin/showpartial Mon Jun 15 00:30:47 1998
1129 +++ mm2.7/src/bin/showpartial Sat Jun 20 14:25:55 1998
1130 @@ -14,78 +14,84 @@
1131 set file="$1"
1132 # This next line is because message-id can contain weird chars
1133 set id=`echo $2 | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\`
1134 -@ partnum = $3
1135 -if ($#argv == 3 || $4 == "") then
1136 +@ partnum = "$3"
1137 +if ($#argv == 3 || "$4" == "") then
1138 set totalnum=-1
1139 else
1140 @ totalnum = "$4"
1141 endif
1143 -if (! -d $TREEROOT) then
1144 +if ( -d $TREEROOT) then
1145 + if (! -o $TREEROOT) then
1146 + echo Error: You do not own $TREEROOT
1147 + exit -1
1148 + endif
1149 +else
1150 mkdir $TREEROOT
1151 if ($status) then
1152 echo mkdir $TREEROOT failed
1153 exit -1
1154 endif
1155 endif
1156 -if (! -d ${TREEROOT}/$id) then
1157 - mkdir ${TREEROOT}/$id
1158 +if (! -d "${TREEROOT}/$id") then
1159 + mkdir "${TREEROOT}/$id"
1160 if ($status) then
1161 - echo mkdir ${TREEROOT}/$id failed
1162 + echo mkdir "${TREEROOT}/$id" failed
1163 exit -1
1164 endif
1165 endif
1166 -cp $file ${TREEROOT}/$id/$partnum
1167 +cp "$file" "${TREEROOT}/$id/$partnum"
1168 if ($status) then
1169 - echo cp $file ${TREEROOT}/$id/$partnum failed
1170 + echo cp "$file" "${TREEROOT}/$id/$partnum" failed
1171 exit -1
1172 endif
1173 -if ($totalnum == -1) then
1174 - if (-e ${TREEROOT}/$id/CT) then
1175 - set totalnum=`cat ${TREEROOT}/$id/CT`
1176 +if ("$totalnum" == -1) then
1177 + if (-e "${TREEROOT}/$id/CT") then
1178 + set totalnum=`cat "${TREEROOT}/$id/CT"`
1179 else
1180 set totalnum=-1 #GROSS HACK
1181 endif
1182 else
1183 - echo $totalnum >! ${TREEROOT}/$id/CT
1184 + echo "$totalnum" >! "${TREEROOT}/$id/CT"
1185 endif
1186 # Slightly bogus here -- the shell messes up the newlines in the headers
1187 # If you put $MM_HEADERS in quotes, it doesn't help.
1188 -# if ($partnum == 1) then
1189 -# echo $MM_HEADERS > ${TREEROOT}/$id/HDRS
1190 +# Note that this could very well constitute a security risk...
1191 +# if ("$partnum" == 1) then
1192 +# echo $MM_HEADERS > "${TREEROOT}/$id/HDRS"
1193 # endif
1194 set found=0
1195 set ix=1
1196 set list=""
1197 -set limit=$totalnum
1198 -if ($limit == -1) set limit=25
1199 -while ($ix <= $limit)
1200 - if (-e ${TREEROOT}/$id/$ix) then
1201 +set limit="$totalnum"
1202 +if ("$limit" == -1) set limit=25
1203 +while ("$ix" <= "$limit")
1204 + if (-e "${TREEROOT}/$id/$ix") then
1205 set list="$list $ix"
1206 @ found ++
1207 endif
1208 @ ix ++
1210 -if ($found == $totalnum) then
1211 - cd ${TREEROOT}/$id
1212 - cat $list > ${TREEROOT}/$id/FULL
1213 +if ("$found" == "$totalnum") then
1214 + cd "${TREEROOT}/$id"
1215 + cat "$list" > "${TREEROOT}/$id/FULL"
1216 # cat ${TREEROOT}/$id/HDRS $list > ${TREEROOT}/$id/FULL
1217 - rm $list
1218 - echo All parts of this ${totalnum}-part message have now been read.
1219 - metamail -d ${TREEROOT}/$id/FULL
1220 + rm "$list"
1221 + echo All parts of this "${totalnum}"-part message have now been read.
1222 + metamail -d "${TREEROOT}/$id/FULL"
1223 echo WARNING: To save space, the full file is now being deleted.
1224 - echo You will have to read all $totalnum parts again to see the full message again.
1225 - rm ${TREEROOT}/$id/FULL
1226 - rm ${TREEROOT}/$id/CT
1227 -# rm ${TREEROOT}/$id/HDRS
1228 + echo You will have to read all "$totalnum" parts again to see the full message again.
1229 + rm "${TREEROOT}/$id/FULL"
1230 + rm "${TREEROOT}/$id/CT"
1231 +# rm "${TREEROOT}/$id/HDRS"
1233 - rmdir ${TREEROOT}/$id
1234 - rmdir ${TREEROOT} >& /dev/null
1235 + rmdir "${TREEROOT}/$id"
1236 + rmdir "${TREEROOT}" >& /dev/null
1237 else
1238 - if (${totalnum} == -1) then
1239 - echo So far you have only read $found of the several parts of this message.
1240 + if ("${totalnum}" == -1) then
1241 + echo So far you have only read "$found" of the several parts of this message.
1242 else
1243 - echo So far you have only read $found of the $totalnum parts of this message.
1244 + echo So far you have only read "$found" of the "$totalnum" parts of this message.
1245 endif
1246 echo When you have read them all, then you will see the message in full.
1247 endif
1248 diff -d -r -u -P mm2.7.orig/src/bin/showpicture mm2.7/src/bin/showpicture
1249 --- mm2.7.orig/src/bin/showpicture Mon Jun 15 00:30:47 1998
1250 +++ mm2.7/src/bin/showpicture Sat Jun 20 14:27:26 1998
1251 @@ -23,7 +23,7 @@
1252 set X_VIEWER="xloadimage -view -quiet -geometry +1+1"
1253 # set X_VIEWER="xv -geometry +1+1"
1254 endif
1255 -if ($1 == "-viewer" && $#argv > 1) then
1256 +if ("$1" == "-viewer" && $#argv > 1) then
1257 set X_VIEWER = "$2"
1258 shift
1259 shift
1260 @@ -40,7 +40,15 @@
1261 echo be able to see the picture properly.
1262 echo ""
1263 if ($MM_NOTTTY) then
1264 - set fname=${METAMAIL_TMPDIR}/sp.$$
1265 + # Generate file name:
1266 + if ( -x /bin/mktemp ) then
1267 + set fname=`/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1268 + else if ( -x /usr/bin/mktemp ) then
1269 + set fname=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1270 + else
1271 + set fname=${METAMAIL_TMPDIR}/sp.$$
1272 + rm -rf $fname
1273 + endif
1274 echo "The picture is being automatically stored in the file $fname"
1275 echo "If you do not want this file, please delete it."
1276 else
1277 @@ -50,20 +58,28 @@
1278 while ( 1 == 1)
1279 echo -n "File name:"
1280 set fname=$<
1281 - if (! -f $fname) then
1282 + if (! -f "$fname") then
1283 break
1284 else
1285 echo "$fname already exists. Try again"
1286 endif
1288 endif
1289 - cp $1 $fname
1290 - if ($status == 0) echo Wrote file $fname
1291 + cp "$1" "$fname"
1292 + if ($status == 0) echo Wrote file "$fname"
1293 exit 0
1294 endif
1296 if ($#argv == 0) then
1297 - set SQUIRREL=${METAMAIL_TMPDIR}/sp.$$
1298 + # Generate file name:
1299 + if ( -x /bin/mktemp ) then
1300 + set SQUIRREL=`/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1301 + else if ( -x /usr/bin/mktemp ) then
1302 + set SQUIRREL=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1303 + else
1304 + set SQUIRREL=${METAMAIL_TMPDIR}/sp.$$
1305 + rm -rf $SQUIRREL
1306 + endif
1307 cat > $SQUIRREL
1308 else
1309 set SQUIRREL="$*"
1310 diff -d -r -u -P mm2.7.orig/src/bin/sun-audio-file mm2.7/src/bin/sun-audio-file
1311 --- mm2.7.orig/src/bin/sun-audio-file Mon Jun 15 00:30:47 1998
1312 +++ mm2.7/src/bin/sun-audio-file Sat Jun 20 14:28:11 1998
1313 @@ -12,7 +12,7 @@
1314 exit 1
1315 endif
1317 -uudecode -o $fn < $1
1318 +uudecode -o $fn < "$1"
1320 audiotool $fn
1321 -rm -f $fn $1
1322 +rm -f $fn "$1"
1323 diff -d -r -u -P mm2.7.orig/src/bin/sun-message.csh mm2.7/src/bin/sun-message.csh
1324 --- mm2.7.orig/src/bin/sun-message.csh Mon Jun 15 00:30:47 1998
1325 +++ mm2.7/src/bin/sun-message.csh Sat Jun 20 14:29:41 1998
1326 @@ -8,6 +8,10 @@
1327 # $2 is untrustworthy data. Quote it.
1329 mkdir /tmp/decode.$$
1330 +if ( $status != 0 ) then
1331 + echo "Error: cannot create temporary directory"
1332 + exit 1
1333 +endif
1334 cd /tmp/decode.$$
1336 if (! $?METAMAIL_PAGER) then
1337 @@ -21,7 +25,7 @@
1338 exit 1
1339 endif
1341 - uudecode -o $fn $1
1342 + uudecode -o $fn "$1"
1344 echo "The following file was uudecoded:"
1345 echo ""
1346 @@ -40,21 +44,21 @@
1347 echo -n "Which do you prefer (1 - 3)? [$defans] "
1349 set ans = $<
1350 - if (x$ans == x) then
1351 + if ("x$ans" == x) then
1352 set ans = $defans
1353 endif
1354 - if ($ans == 3) then
1355 - rm $1
1356 + if ("$ans" == 3) then
1357 + rm "$1"
1358 cd /tmp; /bin/rm -rf /tmp/decode.$$
1359 exit 0
1360 - else if ($ans == 1) then
1361 + else if ("$ans" == 1) then
1362 ${METAMAIL_PAGER} $fn
1363 - else if ($ans == 2) then
1364 + else if ("$ans" == 2) then
1365 set nfn = ""
1366 echo -n "Save as: $HOME/"
1367 set nfn = $<
1368 - if (x$nfn != x) then
1369 - /bin/cp $fn ${HOME}/$nfn
1370 + if ("x$nfn" != x) then
1371 + /bin/cp $fn "${HOME}/$nfn"
1372 else
1373 echo "Not Saved."
1374 endif
1375 @@ -64,7 +68,7 @@
1376 set defans = "3"
1378 else
1379 - ${METAMAIL_PAGER} $1
1380 + ${METAMAIL_PAGER} "$1"
1381 endif
1384 diff -d -r -u -P mm2.7.orig/src/bin/sun-to-mime mm2.7/src/bin/sun-to-mime
1385 --- mm2.7.orig/src/bin/sun-to-mime Mon Jun 15 00:30:47 1998
1386 +++ mm2.7/src/bin/sun-to-mime Sat Jun 20 14:31:12 1998
1387 @@ -8,10 +8,19 @@
1388 set METAMAIL_TMPDIR=/tmp
1389 endif
1391 -set TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1392 +# Generate temporary file name:
1393 +if ( -x /bin/mktemp ) then
1394 + set TMPFILE=`/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1395 +else if ( -x /usr/bin/mktemp ) then
1396 + set TMPFILE=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1397 +else
1398 + set TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1399 + rm -rf $TMPFILE
1400 +endif
1402 echo "Content-type: multipart/mixed; boundary=--------" > $TMPFILE
1403 echo "" >> $TMPFILE
1404 -sed -e 's/X-Sun-Data-Type:/Content-type:/' >> $TMPFILE < $1
1405 +sed -e 's/X-Sun-Data-Type:/Content-type:/' >> $TMPFILE < "$1"
1406 echo "------------" >> $TMPFILE
1407 #metamail -d -z $TMPFILE
1408 metamail -z $TMPFILE
1409 diff -d -r -u -P mm2.7.orig/src/bin/sun2mime mm2.7/src/bin/sun2mime
1410 --- mm2.7.orig/src/bin/sun2mime Mon Jun 15 00:30:47 1998
1411 +++ mm2.7/src/bin/sun2mime Sat Jun 20 14:31:40 1998
1412 @@ -9,7 +9,16 @@
1413 if [ x$METAMAIL_TMPDIR = x ]; then
1414 METAMAIL_TMPDIR=/tmp
1416 -TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1418 +# Generate temporary file name:
1419 +if [ -x /bin/mktemp ] ; then
1420 + TMPFILE=`/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1421 +elif [ -x /usr/bin/mktemp ] ; then
1422 + TMPFILE=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1423 +else
1424 + TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1425 + rm -rf $TMPFILE
1428 /bin/nawk '
1429 BEGIN { printf("Content-type: multipart/mixed; boundary=--------\n\n")
1430 @@ -36,7 +45,7 @@
1431 print
1433 END { printf("----------\n") }
1434 -' $1 > $TMPFILE
1435 +' "$1" > $TMPFILE
1437 metamail -z $TMPFILE
1438 rm -f $TMPFILE
1439 diff -d -r -u -P mm2.7.orig/src/metamail/mailto.c mm2.7/src/metamail/mailto.c
1440 --- mm2.7.orig/src/metamail/mailto.c Mon Jun 15 00:30:47 1998
1441 +++ mm2.7/src/metamail/mailto.c Sat Jun 20 16:57:20 1998
1442 @@ -61,6 +61,7 @@
1443 #endif
1445 extern char *malloc(), *realloc(), *index(), *getmyname();
1446 +extern FILE *Fopen();
1447 struct mailpart *CreateNewPart();
1449 /* The main data structure for the multiple parts of the mail */
1450 @@ -208,7 +209,7 @@
1451 pager = getenv("PAGER");
1453 strcpy(TmpName, tmpname());
1454 - fp = fopen(TmpName, "w");
1455 + fp = Fopen(TmpName, "w");
1456 if (!fp) fp = stdout;
1457 fprintf(fp, "The following tilde escapes are BSD-mail-compatible:\n");
1458 fprintf(fp, "~? Show help on tilde escapes\n");
1459 @@ -594,7 +595,7 @@
1461 FirstPart = NewPart();
1462 CurrentPart = FirstPart;
1463 - fpout = fopen(CurrentPart->filename, "w");
1464 + fpout = Fopen(CurrentPart->filename, "w");
1465 if (!fpout) {
1466 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1467 cleanexit(-1);
1468 @@ -681,7 +682,7 @@
1469 CurrentPart->next = NewPart();
1470 CurrentPart->next->prev = CurrentPart;
1471 CurrentPart = CurrentPart->next;
1472 - fpout = fopen(CurrentPart->filename, "w");
1473 + fpout = Fopen(CurrentPart->filename, "w");
1474 if (!fpout) {
1475 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1476 cleanexit(-1);
1477 @@ -720,7 +721,7 @@
1478 CurrentPart = CurrentPart->next;
1479 CurrentPart->istext = 0;
1480 CurrentPart->content_type = "message/rfc822";
1481 - fpout = fopen(CurrentPart->filename, "w");
1482 + fpout = Fopen(CurrentPart->filename, "w");
1483 if (!fpout) {
1484 fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
1485 break;
1486 @@ -732,7 +733,7 @@
1487 CurrentPart->next = NewPart();
1488 CurrentPart->next->prev = CurrentPart;
1489 CurrentPart = CurrentPart->next;
1490 - fpout = fopen(CurrentPart->filename, "w");
1491 + fpout = Fopen(CurrentPart->filename, "w");
1492 if (!fpout) {
1493 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1494 cleanexit(-1);
1495 @@ -811,11 +812,11 @@
1496 char Cmd[TMPFILE_NAME_SIZE + 15];
1497 char *s=tmpname();
1498 fclose(fpout);
1499 - fptmp = fopen(s, "w");
1500 + fptmp = Fopen(s, "w");
1501 WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1502 TempCloseStyles(fptmp);
1503 fclose(fptmp);
1504 - fpout = fopen(CurrentPart->filename, "a");
1505 + fpout = Fopen(CurrentPart->filename, "a");
1506 if (!fpout) {
1507 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1508 cleanexit(-1);
1509 @@ -899,7 +900,7 @@
1510 char *fname;
1511 fclose(fpout);
1512 fname = start;
1513 - fptmp = fopen(fname, "w");
1514 + fptmp = Fopen(fname, "w");
1515 WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1516 TempCloseStyles(fptmp);
1517 if(fclose(fptmp)) {
1518 @@ -907,7 +908,7 @@
1519 } else {
1520 printf("Wrote draft to %s\n", fname);
1522 - fpout = fopen(CurrentPart->filename, "a");
1523 + fpout = Fopen(CurrentPart->filename, "a");
1524 if (!fpout) {
1525 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1526 cleanexit(-1);
1527 @@ -972,7 +973,7 @@
1528 CurrentPart = CurrentPart->next;
1529 CurrentPart->istext = 0;
1530 CurrentPart->content_type = "message/rfc822";
1531 - fpout = fopen(CurrentPart->filename, "w");
1532 + fpout = Fopen(CurrentPart->filename, "w");
1533 if (!fpout) {
1534 fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
1535 break;
1536 @@ -994,7 +995,7 @@
1537 CurrentPart->next = NewPart();
1538 CurrentPart->next->prev = CurrentPart;
1539 CurrentPart = CurrentPart->next;
1540 - fpout = fopen(CurrentPart->filename, "w");
1541 + fpout = Fopen(CurrentPart->filename, "w");
1542 if (!fpout) {
1543 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1544 cleanexit(-1);
1545 @@ -1476,7 +1477,7 @@
1546 char DeadFile[1000];
1548 sprintf(DeadFile, "%s/dead.letter", gethome());
1549 - fp = fopen(DeadFile, "w");
1550 + fp = Fopen(DeadFile, "w");
1551 WriteOutMessage(fp, ToList, Subject, CCList, FirstPart);
1552 if(fclose(fp)) {
1553 perror("Could not write ~/dead.letter\n");
1554 @@ -1776,7 +1777,7 @@
1555 printf("Cannot read %s, data insertion cancelled\n", sdum);
1556 return(NULL);
1558 - fpo = fopen(mp->filename, "w");
1559 + fpo = Fopen(mp->filename, "w");
1560 if (!fpo) {
1561 printf("Cannot open temporary file, data insertion cancelled\n");
1562 return(NULL);
1563 @@ -1794,7 +1795,7 @@
1564 int ct;
1565 printf("\nEnter the MIME Content-type value for the data from file %s\n (type '?' for a list of locally-valid content-types): ", sdum);
1566 fflush(stdout);
1567 - gets(LineBuf);
1568 + fgets(LineBuf, sizeof(LineBuf), stdin);
1569 if (index(LineBuf, '/')) {
1570 char lc[100], *s, AnsBuf[100];
1571 strcpy(lc, LineBuf);
1572 @@ -1812,7 +1813,7 @@
1574 if (mc) break;
1575 printf("The MIME content-type '%s' is not listed in your local mailcap files,\nand may not be a valid MIME type. Do you want to use it anyway [no] ? ", LineBuf);
1576 - s = gets(AnsBuf);
1577 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1578 while (s && *s && isspace((unsigned char) *s)) ++s;
1579 if (s && (*s == 'y' || *s == 'Y')) break;
1580 continue;
1581 @@ -1939,7 +1940,7 @@
1582 mp->encoding_type_needed = ENC_NONE;
1584 newfilename = tmpname();
1585 - fpout = fopen(newfilename, "w");
1586 + fpout = Fopen(newfilename, "w");
1587 if (!fpout) {
1588 fprintf(stderr, "Cannot open file %s for writing, no data included.\n", newfilename);
1589 free(CmdBuf);
1590 @@ -2109,7 +2110,7 @@
1591 ContainsEightBitChar(FirstPart->filename)) {
1592 FirstPart->encoding_type_needed = ENC_QP;
1594 - fpout = fopen(FirstPart->filename, "a");
1595 + fpout = Fopen(FirstPart->filename, "a");
1596 free(CmdBuf);
1597 free(CmdBuf2);
1598 return;
1599 @@ -2159,7 +2160,7 @@
1600 lastmp = mp;
1601 mp = mp->next;
1603 - fpout = fopen(lastmp->filename, "a");
1604 + fpout = Fopen(lastmp->filename, "a");
1605 free(CmdBuf);
1606 free(CmdBuf2);
1608 diff -d -r -u -P mm2.7.orig/src/metamail/metamail.c mm2.7/src/metamail/metamail.c
1609 --- mm2.7.orig/src/metamail/metamail.c Mon Jun 15 00:30:47 1998
1610 +++ mm2.7/src/metamail/metamail.c Sat Jun 20 16:54:29 1998
1611 @@ -112,6 +112,7 @@
1613 char *FindParam();
1614 extern FILE *popen();
1615 +extern FILE *Fopen();
1616 static char *nomem = "Out of memory!";
1617 static char *mmversion = MM_VERSTRING;
1618 static char *NoAskDefault = "text,text/plain,text/richtext";
1619 @@ -580,7 +581,7 @@
1620 int overwriteans = -1;
1621 do {
1622 printf("File %s exists. Do you want to overwrite it (y/n) ?\n", Fname);
1623 - s = gets(AnsBuf);
1624 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1625 if (!s) {
1626 overwriteans = 0;
1627 } else {
1628 @@ -646,7 +647,7 @@
1629 if (Fname[0] == 0 || Fname[0] == '\n') {
1630 ConsumeRestOfPart(NULL);
1631 } else {
1632 - fp = fopen(Fname, WRITE_BINARY);
1633 + fp = Fopen(Fname, WRITE_BINARY);
1634 if (!fp) ExitWithError("Cannot open temporary file");
1635 TranslateInputToOutput(InputFP, fp, EncodingCode, ContentType);
1636 ecode = fclose(fp);
1637 @@ -961,7 +962,7 @@
1638 /* Create it, ugh. Also needs to affect later command. */
1639 MkTmpFileName(TmpName);
1640 DeleteSourceFileWhenDone = 1;
1641 - fptmp = fopen(TmpName, WRITE_BINARY);
1642 + fptmp = Fopen(TmpName, WRITE_BINARY);
1643 if (!fptmp) ExitWithError("Can't open temporary file\n");
1644 while (fgets(LineBuf, LINE_BUF_SIZE, stdin)) {
1645 fputs(LineBuf, fptmp);
1646 @@ -1195,7 +1196,7 @@
1648 int j;
1649 FILE *outfp;
1650 - outfp = fopen(SquirrelFile, WRITE_BINARY);
1651 + outfp = Fopen(SquirrelFile, WRITE_BINARY);
1652 if (!outfp) {
1653 fprintf(stderr, "Cannot open %s to squirrel away a portion of a multipart/alternative\n", SquirrelFile);
1654 return(-1);
1655 @@ -1799,7 +1800,7 @@
1656 nameBuf[(cp - def) + 4] = 0;
1657 cp++; /* Now points to value part of environment string. */
1659 - if ((envFile = fopen(nameBuf, "w")) == NULL) {
1660 + if ((envFile = Fopen(nameBuf, "w")) == NULL) {
1661 return(2);
1664 @@ -1824,7 +1825,7 @@
1665 } else {
1666 printf("This message contains '%s'-format data.\nDo you want to view it using the '%s' command (y/n) [y] ? ", ctype, ShortCommand(progname));
1668 - s = gets(AnsBuf);
1669 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1670 if (!s) return(0); /* EOF */
1671 while (s && *s && isspace((unsigned char) *s)) ++s;
1672 if (*s == 'y' || *s == 'Y' || !*s || *s == '\n') return(1);
1673 @@ -2037,7 +2038,7 @@
1674 } else {
1675 /* What follows is REALLY bogus, but all my encoding stuff is pipe-oriented right now... */
1676 MkTmpFileName(TmpFile);
1677 - fp = fopen(TmpFile, WRITE_BINARY);
1678 + fp = Fopen(TmpFile, WRITE_BINARY);
1679 if (!fp) {
1680 fprintf(stderr, "Could not open temporary file\n");
1681 } else {
1682 @@ -2192,7 +2193,7 @@
1683 strcpy(thispart->fname, TmpFileNameBuf);
1684 WriteTmpFile(thispart->fname, thispart->ctype);
1685 strcat(TmpFileNameBuf, "H");
1686 - headfp = fopen(TmpFileNameBuf, "w");
1687 + headfp = Fopen(TmpFileNameBuf, "w");
1688 if (headfp) {
1689 fputs(mailheaders+12, headfp);
1690 /* The +12 gets rid of MM_HEADERS=\n */
1691 @@ -2298,7 +2299,7 @@
1692 FILE *fpout;
1693 int retval = 0;
1695 - fpout = fopen(fname, WRITE_BINARY);
1696 + fpout = Fopen(fname, WRITE_BINARY);
1697 if (!fpout) {
1698 perror("WriteTmpFile");
1699 ExitWithError("Can't create temporary file");
1700 @@ -2519,7 +2520,7 @@
1701 FILE *script;
1703 MkTmpFileName(nameBuf);
1704 - if ((script = fopen(nameBuf, "w")) == NULL) {
1705 + if ((script = Fopen(nameBuf, "w")) == NULL) {
1706 fprintf(stderr, "Unable to open %s for writing\n", nameBuf);
1707 exit(1);
1709 diff -d -r -u -P mm2.7.orig/src/metamail/shared.c mm2.7/src/metamail/shared.c
1710 --- mm2.7.orig/src/metamail/shared.c Mon Jun 15 00:30:47 1998
1711 +++ mm2.7/src/metamail/shared.c Sat Jun 20 16:51:54 1998
1712 @@ -1,6 +1,11 @@
1713 #include <stdio.h>
1714 #include <ctype.h>
1715 #include <config.h>
1716 +#include <unistd.h>
1717 +#include <string.h>
1718 +#include <errno.h>
1719 +#include <fcntl.h>
1720 +#include <sys/stat.h>
1721 #ifdef SYSV
1722 #include <unistd.h>
1723 #include <sys/utsname.h>
1724 @@ -116,5 +121,55 @@
1725 initialized = 1;
1727 return(hostname);
1731 +/* This fopen wrapper function is designed to avoid /tmp-file race
1732 + * conditions where a temporary filename is created and somebody
1733 + * throws a link in your way before the fopen(...,"w"). This
1734 + * would only happen if another user on the system were actively
1735 + * trying to trick you into destroying files.
1736 + * Sorry, but "a" mode is not really handled any safer than fopen,
1737 + * since I really have no criterium for deciding what files are
1738 + * OK to write to. */
1739 +FILE *Fopen(Fopen_path,Fopen_mode)
1740 +char *Fopen_path; char *Fopen_mode;
1742 +#ifdef MSDOS
1743 +return(fopen(Fopen_path,Fopen_mode));
1744 +#else
1745 +int Fopen_fd;
1746 +struct stat Fopen_sb;
1747 +int Fopen_appendmode = 0;
1748 +int Fopen_readmode = 0;
1749 +int Fopen_openflags = 0;
1750 +int Fopen_r;
1751 +if ( strchr(Fopen_mode,'r') != (char *)0 ) return(fopen(Fopen_path,Fopen_mode));
1752 +if ( strchr(Fopen_mode,'a') != (char *)0 ) Fopen_appendmode = 1;
1753 +if ( strchr(Fopen_mode,'+') != (char *)0 ) Fopen_readmode = 1;
1754 +if ( ( Fopen_appendmode && (strchr(Fopen_mode,'w') != (char *)0) ) ||
1755 + ( (! Fopen_appendmode) && (strchr(Fopen_mode,'w') == (char *)0) ) )
1757 + errno = EINVAL ;
1758 + return( (FILE *)0 );
1760 +if ( Fopen_appendmode )
1762 + /* If "a" and file exists, pass it to the real fopen() */
1763 + Fopen_r = stat(Fopen_path,&Fopen_sb) ;
1764 + if ( (Fopen_r != -1) || (errno != ENOENT) )
1765 + return( fopen(Fopen_path,Fopen_mode) );
1767 +if ( Fopen_readmode )
1768 + Fopen_openflags = O_RDWR|O_CREAT|O_EXCL ;
1769 +else
1770 + Fopen_openflags = O_WRONLY|O_CREAT|O_EXCL ;
1771 +if ( Fopen_appendmode ) Fopen_openflags |= O_APPEND ;
1772 +remove( Fopen_path );
1773 +/* 0666? We'd better hope their umask is safe... */
1774 +Fopen_fd = open(Fopen_path,Fopen_openflags,0666);
1775 +if ( Fopen_fd > -1 ) return( fdopen(Fopen_fd,Fopen_mode) );
1776 +return( (FILE *)0 );
1777 +#endif
1780 diff -d -r -u -P mm2.7.orig/src/metamail/splitmail.c mm2.7/src/metamail/splitmail.c
1781 --- mm2.7.orig/src/metamail/splitmail.c Mon Jun 15 00:30:47 1998
1782 +++ mm2.7/src/metamail/splitmail.c Sat Jun 20 15:57:02 1998
1783 @@ -26,6 +26,7 @@
1784 #include <config.h>
1785 #include <ctype.h>
1786 #include <time.h>
1787 +#include <fcntl.h>
1789 #define MINCHUNKSIZE 20000 /* Better be enough to hold the headers, or we die! */
1790 extern char *malloc(), *index(), *getmyname();
1791 @@ -243,6 +244,7 @@
1792 char *deliverycmd, *prefix, *SharedHeaders, *SubjectBuf, *id, *MessageID, *bigbuf, *OrigID;
1794 FILE *fpout;
1795 + int fd;
1796 char OutputFile[1000];
1797 int code;
1798 #if defined(sequent)
1799 @@ -255,7 +257,11 @@
1800 fpout = popen(deliverycmd, "w");
1801 } else {
1802 sprintf(OutputFile, "%s%d", prefix, whichpart);
1803 - fpout = fopen(OutputFile, "w");
1804 + /* fpout = fopen(OutputFile, "w"); */
1805 + remove(OutputFile);
1806 + fpout = NULL;
1807 + fd = open(OutputFile, O_WRONLY|O_CREAT|O_EXCL, 0600);
1808 + if ( fd > -1 ) fpout = fdopen(fd, "w");
1810 if (!fpout) {
1811 fprintf(stderr, "splitmail: Can't open %s for writing\n", DoDeliver ? deliverycmd : OutputFile);