1 diff -d -r -u -P mm2.7.orig/src/bin/audiocompose mm2.7/src/bin/audiocompose
2 --- mm2.7.orig/src/bin/audiocompose Mon Jun 15 00:30:47 1998
3 +++ mm2.7/src/bin/audiocompose Sat Jun 20 14:41:16 1998
9 -if (-e $audiofile && ! -z $audiofile) goto whatnext
11 +if (-e "$audiofile" && ! -z "$audiofile") goto whatnext
14 echo -n "Press RETURN when you are ready to start recording: "
16 # THIS IS UNBELIEVABLY GRUBBY
18 if (! $?RECORD_AUDIO) then
19 - (/bin/cat < $dev > $audiofile) &
20 + (/bin/cat < $dev > "$audiofile") &
22 - ($RECORD_AUDIO > $audiofile) &
23 + ($RECORD_AUDIO > "$audiofile") &
25 -jobs -l > ${METAMAIL_TMPDIR}/AUDCAT.$$
26 -set foo=`/bin/cat ${METAMAIL_TMPDIR}/AUDCAT.$$`
27 -/bin/rm ${METAMAIL_TMPDIR}/AUDCAT.$$
28 +# Generate temporary file name:
29 +if ( -x /bin/mktemp ) then
30 + set TmpAudCat=`/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
31 +else if ( -x /usr/bin/mktemp ) then
32 + set TmpAudCat=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
34 + set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
38 +set foo=`/bin/cat $TmpAudCat`
41 echo -n "press RETURN when you are done recording: "
47 - cat $audiofile > $dev
48 + cat "$audiofile" > $dev
52 diff -d -r -u -P mm2.7.orig/src/bin/audiosend mm2.7/src/bin/audiosend
53 --- mm2.7.orig/src/bin/audiosend Mon Jun 15 00:30:47 1998
54 +++ mm2.7/src/bin/audiosend Sat Jun 20 14:42:48 1998
58 if ( $#argv == 1 ) then
65 echo -n "Press RETURN when you are ready to start recording: "
68 -set fname = ${METAMAIL_TMPDIR}/audio-out.$$
69 -set fnameraw = ${METAMAIL_TMPDIR}/audio-raw.$$
70 +# Generate work file names:
71 +if ( -x /bin/mktemp ) then
72 + set fname=`/bin/mktemp ${METAMAIL_TMPDIR}/audio-out.XXXXXXX` || exit 1
73 +else if ( -x /usr/bin/mktemp ) then
74 + set fname=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/audio-out.XXXXXXX` || exit 1
76 + set fname = ${METAMAIL_TMPDIR}/audio-out.$$
79 +if ( -x /bin/mktemp ) then
80 + set fnameraw=`/bin/mktemp ${METAMAIL_TMPDIR}/audio-raw.XXXXXXX` || exit 1
81 +else if ( -x /usr/bin/mktemp ) then
82 + set fnameraw=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/audio-raw.XXXXXXX` || exit 1
84 + set fnameraw = ${METAMAIL_TMPDIR}/audio-raw.$$
88 echo "To: " "$to" > $fname
89 echo "Subject: " "$subject" >> $fname
92 ($RECORD_AUDIO > $fnameraw) &
94 -jobs -l > ${METAMAIL_TMPDIR}/AUDCAT.$$
95 -set foo=`/bin/cat ${METAMAIL_TMPDIR}/AUDCAT.$$`
96 -/bin/rm ${METAMAIL_TMPDIR}/AUDCAT.$$
97 +# Generate temporary file name:
98 +if ( -x /bin/mktemp ) then
99 + set TmpAudCat=`/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
100 +else if ( -x /usr/bin/mktemp ) then
101 + set TmpAudCat=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/AUDCAT.XXXXXXX` || exit 1
103 + set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
106 +jobs -l > $TmpAudCat
107 +set foo=`/bin/cat $TmpAudCat`
110 echo -n "press RETURN when you are done recording: "
115 echo -n "Sending mail, please wait... "
116 - /usr/lib/sendmail $to $cc < $fname
117 + /usr/lib/sendmail "$to" "$cc" < $fname
121 diff -d -r -u -P mm2.7.orig/src/bin/extcompose mm2.7/src/bin/extcompose
122 --- mm2.7.orig/src/bin/extcompose Mon Jun 15 00:30:47 1998
123 +++ mm2.7/src/bin/extcompose Sat Jun 20 14:47:19 1998
125 echo "Usage: extcompose output-file-name"
135 echo -n "Please enter a number from 1 to 5: "
138 +if ("$ans" == 1) then
139 set accesstype=local-file
140 -else if ($ans == 2) then
141 +else if ("$ans" == 2) then
143 -else if ($ans == 3) then
144 +else if ("$ans" == 3) then
145 set accesstype=anon-ftp
146 -else if ($ans == 4) then
147 +else if ("$ans" == 4) then
149 -else if ($ans == 5) then
150 +else if ("$ans" == 5) then
151 set accesstype=mail-server
153 echo "That is NOT one of your choices."
154 goto chooseaccesstype
156 -if ($accesstype == "ftp" || $accesstype == "anon-ftp") then
157 +if ("$accesstype" == "ftp" || "$accesstype" == "anon-ftp") then
158 echo -n "Enter the full Internet domain name of the FTP site: "
160 echo -n "Enter the name of the directory containing the file (RETURN for top-level): "
163 echo -n "Enter the transfer mode (type 'image' for binary data, RETURN otherwise): "
165 - if ($mode == "") set mode=ascii
166 - echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"\; > $OUTFNAME
167 - echo -n " site="\"$site\" >> $OUTFNAME
168 - if ($directory != "") echo -n "; directory="\"$directory\">> $OUTFNAME
169 - if ($mode != "") echo -n "; mode="\"$mode\">> $OUTFNAME
170 - echo "">> $OUTFNAME
171 -else if ($accesstype == "local-file" || $accesstype == "afs") then
172 + if ("$mode" == "") set mode=ascii
173 + echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"\; > "$OUTFNAME"
174 + echo -n " site="\"$site\" >> "$OUTFNAME"
175 + if ("$directory" != "") echo -n "; directory="\"$directory\">> "$OUTFNAME"
176 + if ("$mode" != "") echo -n "; mode="\"$mode\">> "$OUTFNAME"
177 + echo "">> "$OUTFNAME"
178 +else if ("$accesstype" == "local-file" || "$accesstype" == "afs") then
180 echo -n "Enter the full path name for the file: "
182 - if (! -e $name) then
183 + if (! -e "$name") then
184 echo "The file $name does not seem to exist."
187 - echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"> $OUTFNAME
188 -else if ($accesstype == "mail-server") then
189 + echo "Content-type: message/external-body; access-type=$accesstype; name="\"$name\"> "$OUTFNAME"
190 +else if ("$accesstype" == "mail-server") then
191 echo -n "Enter the full email address for the mailserver: "
193 - echo "Content-type: message/external-body; access-type=$accesstype; server="\"$server\"> $OUTFNAME
194 + echo "Content-type: message/external-body; access-type=$accesstype; server="\"$server\"> "$OUTFNAME"
196 - echo accesstype $accesstype not yet implemented
197 + echo accesstype "$accesstype" not yet implemented
198 goto chooseaccesstype
202 echo "That is not one of your choices."
205 -echo "" >> $OUTFNAME
206 -echo "Content-type: " $ctype >> $OUTFNAME
207 -if ($cenc != "") echo "Content-transfer-encoding: " $cenc >> $OUTFNAME
208 -echo "" >> $OUTFNAME
209 -if ($accesstype == "mail-server") then
210 +echo "" >> "$OUTFNAME"
211 +echo "Content-type: " "$ctype" >> "$OUTFNAME"
212 +if ("$cenc" != "") echo "Content-transfer-encoding: " "$cenc" >> "$OUTFNAME"
213 +echo "" >> "$OUTFNAME"
214 +if ("$accesstype" == "mail-server") then
215 echo "Please enter all the data to be sent to the mailserver in the message body, "
216 echo "ending with ^D or your usual end-of-data character:"
220 diff -d -r -u -P mm2.7.orig/src/bin/getfilename mm2.7/src/bin/getfilename
221 --- mm2.7.orig/src/bin/getfilename Mon Jun 15 00:30:47 1998
222 +++ mm2.7/src/bin/getfilename Sat Jun 20 14:47:43 1998
227 -if (! -r $fnam) then
228 +if (! -r "$fnam") then
235 diff -d -r -u -P mm2.7.orig/src/bin/mailserver mm2.7/src/bin/mailserver
236 --- mm2.7.orig/src/bin/mailserver Mon Jun 15 00:30:47 1998
237 +++ mm2.7/src/bin/mailserver Sat Jun 20 23:01:33 1998
242 -set TmpFile=/tmp/ms.$$
243 +# Generate temporary file name:
244 +if ( -x /bin/mktemp ) then
245 + set TmpFile=`/bin/mktemp /tmp/ms.XXXXXXX` || exit 1
246 +else if ( -x /usr/bin/mktemp ) then
247 + set TmpFile=`/usr/bin/mktemp /tmp/ms.XXXXXXX` || exit 1
249 + set TmpFile=/tmp/ms.$$
253 while ("$FOORAW" != "")
254 set FOO=(` echo "$FOORAW" | tr "[" "x"`)
256 -set BARLC=(`echo $FOO | tr A-Z a-z`)
257 -if ($BARLC[1] == "from:") then
258 +set BARLC=(`echo "$FOO" | tr A-Z a-z`)
259 +if ("$BARLC[1]" == "from:") then
260 if ("$FromName" == "") then
261 - set FromName = ($BAR[2-])
262 + set FromName = ("$BAR[2-]")
264 else if ($BARLC[1] == "reply-to:") then
265 - set FromName = ($BAR[2-])
266 + set FromName = ("$BAR[2-]")
267 else if ($BARLC[1] == "subject:") then
268 - set Subject = ($BAR[2-])
269 + set Subject = ("$BAR[2-]")
276 if ("$FromName" == "") then
278 -From: $LOCALADDR@`hostname`
281 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
282 + echo To: "$MAINTAINER" >> $TmpFile
283 + echo Subject: "$Subject" >> $TmpFile
284 + cat >> $TmpFile <<!
286 The metamail mailserver script, installed locally as $LOCALADDR,
\rhas received a request without any reply address.
289 probably run in some circumstance other than mail delivery.
292 - cat $TmpFile - | /usr/lib/sendmail $MAINTAINER
293 + cat $TmpFile - | /usr/lib/sendmail "$MAINTAINER"
294 # Takes the rest of the message from standard input
299 -set danger=`echo $Subject | fgrep ..`
300 -if ($danger != "") then
302 -From: $LOCALADDR@`hostname`
304 -Subject: Re: $Subject
305 +set danger=`echo "$Subject" | fgrep ..`
306 +if ("$danger" != "") then
307 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
308 + echo To: "$FromName" >> $TmpFile
309 + echo Subject: Re: "$Subject" >> $TmpFile
310 + cat >> $TmpFile <<!
312 For security reasons, this mailserver automatically rejects all requests
313 that contain ".." in the path name.
317 if (! -e "$Subject") then
319 -From: $LOCALADDR@`hostname`
321 -Subject: Re: $Subject
323 -You recently sent mail to this mail-server requesting the file:
326 -That file does not exist, so your request could not be met.
328 -Here is a list of the currently available files:
329 ---------------------------------
331 + # We use a bunch of echo statements rather than a here-document
332 + # so that we can be sure to quote all of our variables properly.
333 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
334 + echo To: "$FromName" >> $TmpFile
335 + echo Subject: Re: "$Subject" >> $TmpFile
336 + echo "" >> $TmpFile
337 + echo "You recently sent mail to this mail-server requesting the file:" >> $TmpFile
338 + echo " $Subject" >> $TmpFile
339 + echo "" >> $TmpFile
340 + echo "That file does not exist, so your request could not be met." >> $TmpFile
341 + echo "" >> $TmpFile
342 + echo "Here is a list of the currently available files:" >> $TmpFile
343 + echo "--------------------------------" >> $TmpFile
345 + echo "" >> $TmpFile
346 /usr/lib/sendmail -t < $TmpFile
351 -if (-e ${Subject}.ct) then
352 - set ct=`cat ${Subject}.ct`
353 +if (-e "${Subject}.ct") then
354 + set ct=`cat "${Subject}.ct"`
356 set ct="application/octet-stream"
359 metasend -b -t "$FromName" -f "$Subject" -m "$ct" -s "Re: $Subject"
360 if ($status != 0) then
362 -From: $LOCALADDR@`hostname`
364 -Subject: Re: $Subject
366 -You recently sent mail to this mail-server requestion the file:
369 -An unanticipated error apparently precluded delivery of the file.
370 -Please accept our apologies.
373 - metasend -b -t "$FromName" -f "$Subject" -m "$ct" -s "Re: $Subject"
376 + # We use a bunch of echo statements rather than a here-document
377 + # so that we can be sure to quote all of our variables properly.
378 + echo From: "$LOCALADDR"@`hostname` > $TmpFile
379 + echo To: "$FromName" >> $TmpFile
380 + echo Subject: Re: "$Subject" >> $TmpFile
381 + echo "" >> $TmpFile
382 + echo "You recently sent mail to this mail-server requestion the file:" >> $TmpFile
383 + echo " $Subject" >> $TmpFile
384 + echo "" >> $TmpFile
385 + echo "An unanticipated error apparently precluded delivery of the file." >> $TmpFile
386 + echo "Please accept our apologies." >> $TmpFile
387 + echo "" >> $TmpFile
388 + echo "Command failed:" >> $TmpFile
389 + echo " metasend -b -t $FromName -f $Subject -m $ct -s Re: $Subject" >> $TmpFile
390 + echo "" >> $TmpFile
391 /usr/lib/sendmail -t < $TmpFile
396 if ("$LOGADDR" != "") then
397 - /usr/lib/sendmail -t <<!
398 -From: ${LOCALADDR}@`hostname`
400 -Subject: Autosend delivery report
401 + echo From: "${LOCALADDR}"@`hostname` > $TmpFile
402 + echo To: "$LOGADDR" >> $TmpFile
403 + echo Subject: Autosend delivery report >> $TmpFile
404 + echo "" >> $TmpFile
405 + echo The file: "$Subject" >> $TmpFile
406 + echo was sent to: "$FromName" >> $TmpFile
407 + echo "" >> $TmpFile
408 + /usr/lib/sendmail -t < $TmpFile
412 -was sent to: $FromName
416 diff -d -r -u -P mm2.7.orig/src/bin/metasend mm2.7/src/bin/metasend
417 --- mm2.7.orig/src/bin/metasend Mon Jun 15 00:30:47 1998
418 +++ mm2.7/src/bin/metasend Sat Jun 20 14:59:30 1998
420 echo "-S requires a following argument, the SPLIT threshhold"
429 echo "-i requires a following argument, the Content-ID value"
438 echo "-I requires a following argument, the multipart Content-ID value"
446 @@ -122,12 +122,12 @@
447 echo "-e requires a following argument, the ENCODING value"
451 - if ($encode == "base64") then
453 + if ("$encode" == "base64") then
454 set encodingprog = "mimencode -b"
455 - else if ($encode == "x-uue") then
456 + else if ("$encode" == "x-uue") then
457 set encodingprog = "uuencode mail-body"
458 - else if ($encode == "7bit") then
459 + else if ("$encode" == "7bit") then
460 set encodingprog = cat
462 set encodingprog = "mimencode -q"
464 echo "-f requires a following argument, the DATA FILE"
468 - if (! -e $datafile) then
469 - echo The file $datafile does not exist.
471 + if (! -e "$datafile") then
472 + echo The file "$datafile" does not exist.
476 @@ -154,10 +154,10 @@
477 echo "-m requires a following argument, the MIME CONTENT-TYPE"
481 -# set ctype=`echo $ctyperaw | tr \" \'`
482 +# set ctyperaw = "$1"
483 +# set ctype=`echo "$ctyperaw" | tr \" \'`
485 - if (`echo $ctype | grep /` == "") then
486 + if (`echo "$ctype" | grep /` == "") then
487 echo "Invalid content-type specified"
490 @@ -228,11 +228,11 @@
493 set ctype${multipart} = "$ctype"
494 - set datafile${multipart} = $datafile
495 - set encode${multipart} = $encode
496 + set datafile${multipart} = "$datafile"
497 + set encode${multipart} = "$encode"
498 set cdescrip${multipart} = "$cdescrip"
499 set cid${multipart} = "$cid"
500 - set isentity${multipart} = $isentity
501 + set isentity${multipart} = "$isentity"
502 set encodingprog${multipart} = "$encodingprog"
505 @@ -247,11 +247,11 @@
509 - echo UNRECOGNIZED METASEND OPTION: $1
510 + echo UNRECOGNIZED METASEND OPTION: "$1"
514 -if ($batchmode == 0) then
515 +if ("$batchmode" == 0) then
519 @@ -271,18 +271,18 @@
520 # set ctype=`echo $ctyperaw | tr \" \'`
523 - if (`echo $ctype | grep /` == "") then
524 + if (`echo "$ctype" | grep /` == "") then
525 echo "Invalid content-type specified"
529 -# if ($ctype != $ctyperaw) echo Double quotes not allowed, using $ctype
530 +# if ("$ctype" != "$ctyperaw") echo Double quotes not allowed, using "$ctype"
531 if (! $?datafile) then
533 echo -n "Name of file containing $ctype data: "
535 - if (! -e $datafile) then
536 - echo The file $datafile does not exist.
537 + if (! -e "$datafile") then
538 + echo The file "$datafile" does not exist.
542 @@ -320,12 +320,12 @@
544 if ("$ans" =~ y*) then
545 set ctype${multipart} = "$ctype"
546 - set datafile${multipart} = $datafile
547 - set encode${multipart} = $encode
548 + set datafile${multipart} = "$datafile"
549 + set encode${multipart} = "$encode"
550 set encodingprog${multipart} = "$encodingprog"
551 set cdescrip${multipart} = "$cdescrip"
552 set cid${multipart} = "$cid"
553 - set isentity${multipart} = $isentity
554 + set isentity${multipart} = "$isentity"
555 set cdescrip = "An object packed by metasend"
562 - if ($outputfile == "") then
563 + if ("$outputfile" == "") then
564 if (! $?to || ! $?subject || ! $?ctype || ! $?datafile) then
565 echo metasend: in batch mode, if output is not directed to a file,-t, -s, -f, and -m are all required
567 @@ -359,12 +359,12 @@
571 - if (! -e $datafile) then
572 - echo metasend: The file $datafile does not exist
573 + if (! -e "$datafile") then
574 + echo metasend: The file "$datafile" does not exist
577 # if (! $?cc) set cc=""
578 -# if ($ctype != $ctyperaw) echo Double quotes not allowed, using $ctype
579 +# if ("$ctype" != "$ctyperaw") echo Double quotes not allowed, using "$ctype"
581 if ("$ctype" =~ text*) then
582 set encodingprog = "mimencode -q"
583 @@ -373,11 +373,11 @@
584 set encodingprog = "mimencode -b"
587 - else if ($encode == "base64") then
588 + else if ("$encode" == "base64") then
589 set encodingprog = "mimencode -b"
590 - else if ($encode == "x-uue") then
591 + else if ("$encode" == "x-uue") then
592 set encodingprog = "uuencode mail-body"
593 - else if ($encode == "7bit") then
594 + else if ("$encode" == "7bit") then
595 set encodingprog = cat
597 set encodingprog = "mimencode -q"
598 @@ -395,14 +395,22 @@
601 set ctype${multipart} = "$ctype"
602 -set datafile${multipart} = $datafile
603 -set encode${multipart} = $encode
604 +set datafile${multipart} = "$datafile"
605 +set encode${multipart} = "$encode"
606 set cdescrip${multipart} = "$cdescrip"
607 set cid${multipart} = "$cid"
608 -set isentity${multipart} = $isentity
609 +set isentity${multipart} = "$isentity"
610 set encodingprog${multipart} = "$encodingprog"
612 -set fname = ${METAMAIL_TMPDIR}/metasend.$$
613 +# Generate file name:
614 +if ( -x /bin/mktemp ) then
615 + set fname=`/bin/mktemp ${METAMAIL_TMPDIR}/metasend.XXXXXXX` || exit 1
616 +else if ( -x /usr/bin/mktemp ) then
617 + set fname=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/metasend.XXXXXXX` || exit 1
619 + set fname=${METAMAIL_TMPDIR}/metasend.$$
622 echo "MIME-Version: 1.0" > $fname
624 echo "To: " "$to" >> $fname
625 @@ -429,17 +437,26 @@
626 echo " boundary="\"$boundary\" >> $fname
628 if ($?preamblefile) then
629 - cat $preamblefile >> $fname
630 + cat "$preamblefile" >> $fname
632 echo "This is a multimedia message in MIME format. If you are reading this" >> $fname
633 echo "prefix, your mail reader does not understand MIME. You may wish" >> $fname
634 echo "to look into upgrading to a newer version of your mail reader." >> $fname
637 - set junkfile=${METAMAIL_TMPDIR}/mmjunk.$$
638 - while ($multipart >= $i)
640 + # Generate temporary file name:
641 + if ( -x /bin/mktemp ) then
642 + set junkfile=`/bin/mktemp ${METAMAIL_TMPDIR}/mmjunk.XXXXXXX` || exit 1
643 + else if ( -x /usr/bin/mktemp ) then
644 + set junkfile=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/mmjunk.XXXXXXX` || exit 1
646 + set junkfile=${METAMAIL_TMPDIR}/mmjunk.$$
649 + while ("$multipart" >= $i)
651 - echo --$boundary >> $fname
652 + echo --"$boundary" >> $fname
653 echo set isentity=\$isentity$i > $junkfile
655 if (! $isentity) then
656 @@ -463,27 +480,27 @@
660 - echo --${boundary}-- >> $fname
661 + echo --"${boundary}"-- >> $fname
664 if (! $isentity) then
665 echo "Content-ID: $cid" >> $fname
666 - echo "Content-type: " $ctype >> $fname
667 - echo "Content-Description: " $cdescrip >> $fname
668 - echo "Content-Transfer-Encoding: " $encode >> $fname
669 + echo "Content-type: " "$ctype" >> $fname
670 + echo "Content-Description: " "$cdescrip" >> $fname
671 + echo "Content-Transfer-Encoding: " "$encode" >> $fname
674 - $encodingprog < $datafile >> $fname
675 + $encodingprog < "$datafile" >> $fname
676 # Ensure last line has trailing carriage return
679 -if ($outputfile == "") then
680 - if ($batchmode == 0) echo -n "Delivering mail, please wait... "
681 - splitmail -s $splitsize -d $fname
682 +if ("$outputfile" == "") then
683 + if ("$batchmode" == 0) echo -n "Delivering mail, please wait... "
684 + splitmail -s "$splitsize" -d "$fname"
686 - if ($batchmode == 0) echo "Mail delivery apparently succeeded."
687 + if ("$batchmode" == 0) echo "Mail delivery apparently succeeded."
689 - else if ($MustDelete == 1) then
690 + else if ("$MustDelete" == 1) then
691 echo Mail delivery failed
698 - mv $fname $outputfile
699 + mv $fname "$outputfile"
703 diff -d -r -u -P mm2.7.orig/src/bin/patch-metamail mm2.7/src/bin/patch-metamail
704 --- mm2.7.orig/src/bin/patch-metamail Mon Jun 15 00:30:47 1998
705 +++ mm2.7/src/bin/patch-metamail Sat Jun 20 23:18:20 1998
708 set PREFIX="mm.patch."
710 +if (! $?METAMAIL_TMPDIR) then
711 + set METAMAIL_TMPDIR=/tmp
714 if ($#argv < 2 || $#argv > 5) then
715 echo Usage: patch-metamail source-tree-root patch-number [hostname [dirname [prefix]]]
721 -if ($#argv > 2) set HOSTNAME=$3
722 -if ($#argv > 3) set DIRNAME=$4
723 -if ($#argv > 4) set PREFIX=$5
725 +set PATCHNUMBER="$2"
726 +if ($#argv > 2) set HOSTNAME="$3"
727 +if ($#argv > 3) set DIRNAME="$4"
728 +if ($#argv > 4) set PREFIX="$5"
730 echo WARNING: This program, if allowed to do so, will attempt to
731 echo install a PATCH file for your metamail sources which are rooted
732 -echo in the directory $TREEROOT.
733 +echo in the directory "$TREEROOT".
735 echo It will use a patch file that it retrieves via anonymous ftp
736 -echo from the host $HOSTNAME, in the directory $DIRNAME,
737 -echo with filenames starting with ${PREFIX}.
738 +echo from the host "$HOSTNAME", in the directory "$DIRNAME",
739 +echo with filenames starting with "${PREFIX}".
741 echo -n "Do you want to install the patch in directory $TREEROOT [y/n] ? "
743 -if ($ans == "y" || $ans == "Y") then
745 +if ("$ans" == "y" || "$ans" == "Y") then
747 set ident=`whoami`@`hostname`
748 - echo Using anonymous ftp with password $ident
751 -user anonymous $ident
754 -get ${PREFIX}${PATCHNUMBER}
757 - patch -p < ${PREFIX}${PATCHNUMBER}
758 + # Generate temporary file name:
759 + if ( -x /bin/mktemp ) then
760 + set TmpFtp=`/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
761 + else if ( -x /usr/bin/mktemp ) then
762 + set TmpFtp=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
764 + set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
767 + echo open "$HOSTNAME" > $TmpFtp
768 + echo user anonymous "$ident" >> $TmpFtp
769 + echo cd "$DIRNAME" >> $TmpFtp
770 + echo binary >> $TmpFtp
771 + echo get "${PREFIX}${PATCHNUMBER}" >> $TmpFtp
772 + echo quit >> $TmpFtp
773 + echo Using anonymous ftp with password "$ident"
776 + patch -p < "${PREFIX}${PATCHNUMBER}"
778 echo Patch not installed
780 diff -d -r -u -P mm2.7.orig/src/bin/rcvAppleSingle mm2.7/src/bin/rcvAppleSingle
781 --- mm2.7.orig/src/bin/rcvAppleSingle Mon Jun 15 00:30:47 1998
782 +++ mm2.7/src/bin/rcvAppleSingle Sat Jun 20 14:08:30 1998
784 # Written by Patrik Faltstrom, paf@nada.kth.se, may 1993
791 # If $AFPDIR environment variable is set, all Macintosh filenames
796 -echo $NAME | grep '^/' > /dev/null
797 +echo "$NAME" | grep '^/' > /dev/null
800 + NAME="$AFPDIR/$NAME"
803 -cvt2cap $FILENAME $NAME
804 +cvt2cap "$FILENAME" "$NAME"
805 echo "Saved AppleMacintosh file as $NAME"
808 diff -d -r -u -P mm2.7.orig/src/bin/showaudio mm2.7/src/bin/showaudio
809 --- mm2.7.orig/src/bin/showaudio Mon Jun 15 00:30:47 1998
810 +++ mm2.7/src/bin/showaudio Sat Jun 20 15:01:55 1998
814 if ("$1" == "-p") then
816 + set AUDIOPHONE="$2"
822 echo -n "Which do you prefer (1 or 2)? "
824 - if ($ans == 2) then
825 + if ("$ans" == 2) then
826 echo "OK, we'll use the telephone..."
827 set AUDIOPHONEFORCE=1
828 echo "In the future, you can avoid this question by setting the environment variable"
829 echo "AUDIOPHONEFORCE to 1"
831 - else if ($ans == 1) then
832 + else if ("$ans" == 1) then
833 echo "OK, Attempting to play the audio using your computer's speaker.."
834 set AUDIOSPEAKERFORCE=1
835 echo "In the future, you can avoid this question by setting the environment variable"
837 set audiohost=$thishost
839 set audiohost=`echo $DISPLAY | sed -e 's/:.*//'`
840 - if ($audiohost == "unix") set audiohost=$thishost
841 - if ($audiohost == "") set audiohost=$thishost
842 + if ("$audiohost" == "unix") set audiohost=$thishost
843 + if ("$audiohost" == "") set audiohost=$thishost
845 if ($?AUDIOHOST) then
846 set audiohost=$AUDIOHOST
848 if ($#argv >= 1) then
849 exec /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $*
851 - cat > ${METAMAIL_TMPDIR}/audio.$$
852 - /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end ${METAMAIL_TMPDIR}/audio.$$
853 - rm ${METAMAIL_TMPDIR}/audio.$$
854 + # Generate temporary file name:
855 + if ( -x /bin/mktemp ) then
856 + set TmpAudio=`/bin/mktemp ${METAMAIL_TMPDIR}/audio.XXXXXXX` || exit 1
857 + else if ( -x /usr/bin/mktemp ) then
858 + set TmpAudio=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/audio.XXXXXXX` || exit 1
860 + set TmpAudio=${METAMAIL_TMPDIR}/audio.$$
864 + /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $TmpAudio
868 else if (-d /usr/sony) then
871 if (! $?MM_NOTTTY) set MM_NOTTTY=0
872 if ($MM_NOTTTY == 1) then
873 - set fname=/tmp/mm.aud.$$
874 + # Generate unique file name:
875 + if ( -x /bin/mktemp ) then
876 + set fname=`/bin/mktemp /tmp/mm.aud.XXXXXXX` || exit 1
877 + else if ( -x /usr/bin/mktemp ) then
878 + set fname=`/usr/bin/mktemp /tmp/mm.aud.XXXXXXX` || exit 1
880 + set fname=/tmp/mm.aud.$$
884 echo -n "Do you want to write the audio out to a file [y] ? "
891 -if ($status == 0) echo Wrote raw audio file: $fname
893 +if ($status == 0) echo Wrote raw audio file: "$fname"
896 diff -d -r -u -P mm2.7.orig/src/bin/showexternal mm2.7/src/bin/showexternal
897 --- mm2.7.orig/src/bin/showexternal Mon Jun 15 00:30:47 1998
898 +++ mm2.7/src/bin/showexternal Sat Jun 20 23:20:49 1998
902 set atype=`echo $2 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
920 -if ("$server" == "" && $atype == "mail-server") then
921 +if ("$server" == "" && "$atype" == "mail-server") then
922 # Backward compatibility with some broken stuff
923 - set server=${name}@${site}
924 - echo WARNING -- old style mailserver syntax, using server $server
925 + set server="${name}@${site}"
926 + echo WARNING -- old style mailserver syntax, using server "$server"
929 set ctype="`grep -i content-type: $bodyfile | sed -e 's/............: //'`"
932 set TMPDIR=${METAMAIL_TMPDIR}/XXXternal.$$
934 +if ( $status != 0 ) then
935 + echo Error creating temporary directory
939 set NEWNAME="mm.ext.$$"
940 set NEEDSCONFIRMATION=1
942 echo automatically using the FTP protocol to a site on the network.
945 - cat > ${METAMAIL_TMPDIR}/ext.junk.$$ <<!
946 + # Generate temporary file name:
947 + if ( -x /bin/mktemp ) then
948 + set TmpExtJunk=`/bin/mktemp ${METAMAIL_TMPDIR}/ext.junk.XXXXXXX` || exit 1
949 + else if ( -x /usr/bin/mktemp ) then
950 + set TmpExtJunk=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/ext.junk.XXXXXXX` || exit 1
952 + set TmpExtJunk=${METAMAIL_TMPDIR}/ext.junk.$$
955 + cat > $TmpExtJunk <<!
956 This mail message contains a POINTER (reference) to data that is
957 not included in the message itself. Rather, the data can be retrieved
958 by sending a special mail message to a mail server on the network.
959 @@ -102,13 +115,13 @@
960 This is the message that will be sent if you choose to go ahead and
961 retreive the external data:
963 -Subject: Automated Mail Server Request
967 - sed -e 1,/^\$/d < $bodyfile >> ${METAMAIL_TMPDIR}/ext.junk.$$
968 - ${METAMAIL_PAGER} ${METAMAIL_TMPDIR}/ext.junk.$$
969 - rm ${METAMAIL_TMPDIR}/ext.junk.$$
970 + echo Subject: Automated Mail Server Request >> $TmpExtJunk
971 + echo To: "$server" >> $TmpExtJunk
972 + echo "" >> $TmpExtJunk
973 + sed -e 1,/^\$/d < $bodyfile >> $TmpExtJunk
974 + ${METAMAIL_PAGER} $TmpExtJunk
978 # IGNORE ALL THE OTHERS -- AUTOMATIC FOR LOCAL-FILE, AFS.
979 @@ -157,17 +170,26 @@
981 set MODECMD="type $mode"
983 + # Generate temporary file name:
984 + if ( -x /bin/mktemp ) then
985 + set TmpFtp=`/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
986 + else if ( -x /usr/bin/mktemp ) then
987 + set TmpFtp=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/mm.ftp.XXXXXXX` || exit 1
989 + set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
992 + echo open "$site" > $TmpFtp
993 + echo user "$username" "$pass" >> $TmpFtp
994 + echo "$DIRCMD" >> $TmpFtp
995 + echo "$MODECMD" >> $TmpFtp
996 + echo get "$name" "$NEWNAME" >> $TmpFtp
997 + echo quit >> $TmpFtp
998 echo OBTAINING MESSAGE BODY USING FTP
999 - echo SITE: $site USER $username
1002 -user $username $pass
1008 - if (! -e $NEWNAME) then
1009 + echo SITE: "$site" USER "$username"
1012 + if (! -e "$NEWNAME") then
1014 cd ${METAMAIL_TMPDIR}
1016 @@ -176,14 +198,14 @@
1020 - if (! -e $name) then
1021 + if (! -e "$name") then
1022 echo local file not found
1023 cd ${METAMAIL_TMPDIR}
1028 - echo GETTING BODY FROM FILE NAMED: $NEWNAME
1029 + set NEWNAME="$name" # Note that this is not trusted data...
1030 + echo GETTING BODY FROM FILE NAMED: "$NEWNAME"
1032 case mail-server: # A very special case
1033 if ("$bodyfile" == "") then
1034 @@ -192,12 +214,12 @@
1038 - echo Subject: Automated Mail Server Request > $NEWNAME
1039 - echo To: ${server} >> $NEWNAME
1040 - echo "" >> $NEWNAME
1041 - sed -e 1,/^\$/d < $bodyfile >> $NEWNAME
1042 - echo "" >> $NEWNAME
1043 - /usr/lib/sendmail -t < $NEWNAME
1044 + echo Subject: Automated Mail Server Request > "$NEWNAME"
1045 + echo To: ${server} >> "$NEWNAME"
1046 + echo "" >> "$NEWNAME"
1047 + sed -e 1,/^\$/d < $bodyfile >> "$NEWNAME"
1048 + echo "" >> "$NEWNAME"
1049 + /usr/lib/sendmail -t < "$NEWNAME"
1051 echo sendmail failed
1052 cd ${METAMAIL_TMPDIR}
1055 cd ${METAMAIL_TMPDIR}
1057 - echo Your $ctype data has been requested from a mail server.
1058 + echo Your "$ctype" data has been requested from a mail server.
1061 echo UNRECOGNIZED ACCESS-TYPE
1062 @@ -214,19 +236,19 @@
1066 -if ($cenc == base64) then
1067 - mimencode -u -b < $NEWNAME > OUT
1069 -else if ($cenc == quoted-printable) then
1070 - mimencode -u -q < $NEWNAME > OUT
1072 +if ("$cenc" == base64) then
1073 + mimencode -u -b < "$NEWNAME" > OUT
1075 +else if ("$cenc" == quoted-printable) then
1076 + mimencode -u -q < "$NEWNAME" > OUT
1081 -if ($atype == "local-file") then
1082 - metamail -p -b -c "$ctype" $NEWNAME
1083 +if ("$atype" == "local-file") then
1084 + metamail -p -b -c "$ctype" "$NEWNAME"
1086 - metamail -p -b -c "$ctype" $TMPDIR/$NEWNAME
1087 + metamail -p -b -c "$ctype" "$TMPDIR/$NEWNAME"
1091 @@ -236,14 +258,14 @@
1095 -if ($NEWNAME != $name) then
1096 +if ("$NEWNAME" != "$name") then
1098 - echo The data just displayed is stored in the file $TMPDIR/$NEWNAME
1099 + echo The data just displayed is stored in the file "$TMPDIR/$NEWNAME"
1100 echo "Do you want to delete it?"
1101 - rm -i $TMPDIR/$NEWNAME
1102 + rm -i "$TMPDIR/$NEWNAME"
1105 -if (! -e ${TMPDIR}/${NEWNAME}) then
1106 +if (! -e "${TMPDIR}/${NEWNAME}") then
1107 cd ${METAMAIL_TMPDIR}
1110 diff -d -r -u -P mm2.7.orig/src/bin/showpartial mm2.7/src/bin/showpartial
1111 --- mm2.7.orig/src/bin/showpartial Mon Jun 15 00:30:47 1998
1112 +++ mm2.7/src/bin/showpartial Sat Jun 20 14:25:55 1998
1115 # This next line is because message-id can contain weird chars
1116 set id=`echo $2 | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\`
1118 -if ($#argv == 3 || $4 == "") then
1120 +if ($#argv == 3 || "$4" == "") then
1126 -if (! -d $TREEROOT) then
1127 +if ( -d $TREEROOT) then
1128 + if (! -o $TREEROOT) then
1129 + echo Error: You do not own $TREEROOT
1135 echo mkdir $TREEROOT failed
1139 -if (! -d ${TREEROOT}/$id) then
1140 - mkdir ${TREEROOT}/$id
1141 +if (! -d "${TREEROOT}/$id") then
1142 + mkdir "${TREEROOT}/$id"
1144 - echo mkdir ${TREEROOT}/$id failed
1145 + echo mkdir "${TREEROOT}/$id" failed
1149 -cp $file ${TREEROOT}/$id/$partnum
1150 +cp "$file" "${TREEROOT}/$id/$partnum"
1152 - echo cp $file ${TREEROOT}/$id/$partnum failed
1153 + echo cp "$file" "${TREEROOT}/$id/$partnum" failed
1156 -if ($totalnum == -1) then
1157 - if (-e ${TREEROOT}/$id/CT) then
1158 - set totalnum=`cat ${TREEROOT}/$id/CT`
1159 +if ("$totalnum" == -1) then
1160 + if (-e "${TREEROOT}/$id/CT") then
1161 + set totalnum=`cat "${TREEROOT}/$id/CT"`
1163 set totalnum=-1 #GROSS HACK
1166 - echo $totalnum >! ${TREEROOT}/$id/CT
1167 + echo "$totalnum" >! "${TREEROOT}/$id/CT"
1169 # Slightly bogus here -- the shell messes up the newlines in the headers
1170 # If you put $MM_HEADERS in quotes, it doesn't help.
1171 -# if ($partnum == 1) then
1172 -# echo $MM_HEADERS > ${TREEROOT}/$id/HDRS
1173 +# Note that this could very well constitute a security risk...
1174 +# if ("$partnum" == 1) then
1175 +# echo $MM_HEADERS > "${TREEROOT}/$id/HDRS"
1180 -set limit=$totalnum
1181 -if ($limit == -1) set limit=25
1182 -while ($ix <= $limit)
1183 - if (-e ${TREEROOT}/$id/$ix) then
1184 +set limit="$totalnum"
1185 +if ("$limit" == -1) set limit=25
1186 +while ("$ix" <= "$limit")
1187 + if (-e "${TREEROOT}/$id/$ix") then
1188 set list="$list $ix"
1193 -if ($found == $totalnum) then
1194 - cd ${TREEROOT}/$id
1195 - cat $list > ${TREEROOT}/$id/FULL
1196 +if ("$found" == "$totalnum") then
1197 + cd "${TREEROOT}/$id"
1198 + cat "$list" > "${TREEROOT}/$id/FULL"
1199 # cat ${TREEROOT}/$id/HDRS $list > ${TREEROOT}/$id/FULL
1201 - echo All parts of this ${totalnum}-part message have now been read.
1202 - metamail -d ${TREEROOT}/$id/FULL
1204 + echo All parts of this "${totalnum}"-part message have now been read.
1205 + metamail -d "${TREEROOT}/$id/FULL"
1206 echo WARNING: To save space, the full file is now being deleted.
1207 - echo You will have to read all $totalnum parts again to see the full message again.
1208 - rm ${TREEROOT}/$id/FULL
1209 - rm ${TREEROOT}/$id/CT
1210 -# rm ${TREEROOT}/$id/HDRS
1211 + echo You will have to read all "$totalnum" parts again to see the full message again.
1212 + rm "${TREEROOT}/$id/FULL"
1213 + rm "${TREEROOT}/$id/CT"
1214 +# rm "${TREEROOT}/$id/HDRS"
1216 - rmdir ${TREEROOT}/$id
1217 - rmdir ${TREEROOT} >& /dev/null
1218 + rmdir "${TREEROOT}/$id"
1219 + rmdir "${TREEROOT}" >& /dev/null
1221 - if (${totalnum} == -1) then
1222 - echo So far you have only read $found of the several parts of this message.
1223 + if ("${totalnum}" == -1) then
1224 + echo So far you have only read "$found" of the several parts of this message.
1226 - echo So far you have only read $found of the $totalnum parts of this message.
1227 + echo So far you have only read "$found" of the "$totalnum" parts of this message.
1229 echo When you have read them all, then you will see the message in full.
1231 diff -d -r -u -P mm2.7.orig/src/bin/showpicture mm2.7/src/bin/showpicture
1232 --- mm2.7.orig/src/bin/showpicture Mon Jun 15 00:30:47 1998
1233 +++ mm2.7/src/bin/showpicture Sat Jun 20 14:27:26 1998
1235 set X_VIEWER="xloadimage -view -quiet -geometry +1+1"
1236 # set X_VIEWER="xv -geometry +1+1"
1238 -if ($1 == "-viewer" && $#argv > 1) then
1239 +if ("$1" == "-viewer" && $#argv > 1) then
1244 echo be able to see the picture properly.
1246 if ($MM_NOTTTY) then
1247 - set fname=${METAMAIL_TMPDIR}/sp.$$
1248 + # Generate file name:
1249 + if ( -x /bin/mktemp ) then
1250 + set fname=`/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1251 + else if ( -x /usr/bin/mktemp ) then
1252 + set fname=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1254 + set fname=${METAMAIL_TMPDIR}/sp.$$
1257 echo "The picture is being automatically stored in the file $fname"
1258 echo "If you do not want this file, please delete it."
1262 echo -n "File name:"
1264 - if (! -f $fname) then
1265 + if (! -f "$fname") then
1268 echo "$fname already exists. Try again"
1273 - if ($status == 0) echo Wrote file $fname
1275 + if ($status == 0) echo Wrote file "$fname"
1279 if ($#argv == 0) then
1280 - set SQUIRREL=${METAMAIL_TMPDIR}/sp.$$
1281 + # Generate file name:
1282 + if ( -x /bin/mktemp ) then
1283 + set SQUIRREL=`/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1284 + else if ( -x /usr/bin/mktemp ) then
1285 + set SQUIRREL=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/sp.XXXXXXX` || exit 1
1287 + set SQUIRREL=${METAMAIL_TMPDIR}/sp.$$
1293 diff -d -r -u -P mm2.7.orig/src/bin/sun-audio-file mm2.7/src/bin/sun-audio-file
1294 --- mm2.7.orig/src/bin/sun-audio-file Mon Jun 15 00:30:47 1998
1295 +++ mm2.7/src/bin/sun-audio-file Sat Jun 20 14:28:11 1998
1300 -uudecode -o $fn < $1
1301 +uudecode -o $fn < "$1"
1306 diff -d -r -u -P mm2.7.orig/src/bin/sun-message.csh mm2.7/src/bin/sun-message.csh
1307 --- mm2.7.orig/src/bin/sun-message.csh Mon Jun 15 00:30:47 1998
1308 +++ mm2.7/src/bin/sun-message.csh Sat Jun 20 14:29:41 1998
1310 # $2 is untrustworthy data. Quote it.
1312 mkdir /tmp/decode.$$
1313 +if ( $status != 0 ) then
1314 + echo "Error: cannot create temporary directory"
1319 if (! $?METAMAIL_PAGER) then
1324 - uudecode -o $fn $1
1325 + uudecode -o $fn "$1"
1327 echo "The following file was uudecoded:"
1330 echo -n "Which do you prefer (1 - 3)? [$defans] "
1333 - if (x$ans == x) then
1334 + if ("x$ans" == x) then
1337 - if ($ans == 3) then
1339 + if ("$ans" == 3) then
1341 cd /tmp; /bin/rm -rf /tmp/decode.$$
1343 - else if ($ans == 1) then
1344 + else if ("$ans" == 1) then
1345 ${METAMAIL_PAGER} $fn
1346 - else if ($ans == 2) then
1347 + else if ("$ans" == 2) then
1349 echo -n "Save as: $HOME/"
1351 - if (x$nfn != x) then
1352 - /bin/cp $fn ${HOME}/$nfn
1353 + if ("x$nfn" != x) then
1354 + /bin/cp $fn "${HOME}/$nfn"
1362 - ${METAMAIL_PAGER} $1
1363 + ${METAMAIL_PAGER} "$1"
1367 diff -d -r -u -P mm2.7.orig/src/bin/sun-to-mime mm2.7/src/bin/sun-to-mime
1368 --- mm2.7.orig/src/bin/sun-to-mime Mon Jun 15 00:30:47 1998
1369 +++ mm2.7/src/bin/sun-to-mime Sat Jun 20 14:31:12 1998
1371 set METAMAIL_TMPDIR=/tmp
1374 -set TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1375 +# Generate temporary file name:
1376 +if ( -x /bin/mktemp ) then
1377 + set TMPFILE=`/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1378 +else if ( -x /usr/bin/mktemp ) then
1379 + set TMPFILE=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1381 + set TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1385 echo "Content-type: multipart/mixed; boundary=--------" > $TMPFILE
1387 -sed -e 's/X-Sun-Data-Type:/Content-type:/' >> $TMPFILE < $1
1388 +sed -e 's/X-Sun-Data-Type:/Content-type:/' >> $TMPFILE < "$1"
1389 echo "------------" >> $TMPFILE
1390 #metamail -d -z $TMPFILE
1391 metamail -z $TMPFILE
1392 diff -d -r -u -P mm2.7.orig/src/bin/sun2mime mm2.7/src/bin/sun2mime
1393 --- mm2.7.orig/src/bin/sun2mime Mon Jun 15 00:30:47 1998
1394 +++ mm2.7/src/bin/sun2mime Sat Jun 20 14:31:40 1998
1396 if [ x$METAMAIL_TMPDIR = x ]; then
1397 METAMAIL_TMPDIR=/tmp
1399 -TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1401 +# Generate temporary file name:
1402 +if [ -x /bin/mktemp ] ; then
1403 + TMPFILE=`/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1404 +elif [ -x /usr/bin/mktemp ] ; then
1405 + TMPFILE=`/usr/bin/mktemp ${METAMAIL_TMPDIR}/suntomime.XXXXXXX` || exit 1
1407 + TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1412 BEGIN { printf("Content-type: multipart/mixed; boundary=--------\n\n")
1416 END { printf("----------\n") }
1420 metamail -z $TMPFILE
1422 diff -d -r -u -P mm2.7.orig/src/metamail/mailto.c mm2.7/src/metamail/mailto.c
1423 --- mm2.7.orig/src/metamail/mailto.c Mon Jun 15 00:30:47 1998
1424 +++ mm2.7/src/metamail/mailto.c Sat Jun 20 16:57:20 1998
1428 extern char *malloc(), *realloc(), *index(), *getmyname();
1429 +extern FILE *Fopen();
1430 struct mailpart *CreateNewPart();
1432 /* The main data structure for the multiple parts of the mail */
1434 pager = getenv("PAGER");
1436 strcpy(TmpName, tmpname());
1437 - fp = fopen(TmpName, "w");
1438 + fp = Fopen(TmpName, "w");
1439 if (!fp) fp = stdout;
1440 fprintf(fp, "The following tilde escapes are BSD-mail-compatible:\n");
1441 fprintf(fp, "~? Show help on tilde escapes\n");
1444 FirstPart = NewPart();
1445 CurrentPart = FirstPart;
1446 - fpout = fopen(CurrentPart->filename, "w");
1447 + fpout = Fopen(CurrentPart->filename, "w");
1449 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1452 CurrentPart->next = NewPart();
1453 CurrentPart->next->prev = CurrentPart;
1454 CurrentPart = CurrentPart->next;
1455 - fpout = fopen(CurrentPart->filename, "w");
1456 + fpout = Fopen(CurrentPart->filename, "w");
1458 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1461 CurrentPart = CurrentPart->next;
1462 CurrentPart->istext = 0;
1463 CurrentPart->content_type = "message/rfc822";
1464 - fpout = fopen(CurrentPart->filename, "w");
1465 + fpout = Fopen(CurrentPart->filename, "w");
1467 fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
1470 CurrentPart->next = NewPart();
1471 CurrentPart->next->prev = CurrentPart;
1472 CurrentPart = CurrentPart->next;
1473 - fpout = fopen(CurrentPart->filename, "w");
1474 + fpout = Fopen(CurrentPart->filename, "w");
1476 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1478 @@ -811,11 +812,11 @@
1479 char Cmd[TMPFILE_NAME_SIZE + 15];
1482 - fptmp = fopen(s, "w");
1483 + fptmp = Fopen(s, "w");
1484 WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1485 TempCloseStyles(fptmp);
1487 - fpout = fopen(CurrentPart->filename, "a");
1488 + fpout = Fopen(CurrentPart->filename, "a");
1490 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1496 - fptmp = fopen(fname, "w");
1497 + fptmp = Fopen(fname, "w");
1498 WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1499 TempCloseStyles(fptmp);
1503 printf("Wrote draft to %s\n", fname);
1505 - fpout = fopen(CurrentPart->filename, "a");
1506 + fpout = Fopen(CurrentPart->filename, "a");
1508 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1511 CurrentPart = CurrentPart->next;
1512 CurrentPart->istext = 0;
1513 CurrentPart->content_type = "message/rfc822";
1514 - fpout = fopen(CurrentPart->filename, "w");
1515 + fpout = Fopen(CurrentPart->filename, "w");
1517 fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
1520 CurrentPart->next = NewPart();
1521 CurrentPart->next->prev = CurrentPart;
1522 CurrentPart = CurrentPart->next;
1523 - fpout = fopen(CurrentPart->filename, "w");
1524 + fpout = Fopen(CurrentPart->filename, "w");
1526 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1528 @@ -1476,7 +1477,7 @@
1529 char DeadFile[1000];
1531 sprintf(DeadFile, "%s/dead.letter", gethome());
1532 - fp = fopen(DeadFile, "w");
1533 + fp = Fopen(DeadFile, "w");
1534 WriteOutMessage(fp, ToList, Subject, CCList, FirstPart);
1536 perror("Could not write ~/dead.letter\n");
1537 @@ -1776,7 +1777,7 @@
1538 printf("Cannot read %s, data insertion cancelled\n", sdum);
1541 - fpo = fopen(mp->filename, "w");
1542 + fpo = Fopen(mp->filename, "w");
1544 printf("Cannot open temporary file, data insertion cancelled\n");
1546 @@ -1794,7 +1795,7 @@
1548 printf("\nEnter the MIME Content-type value for the data from file %s\n (type '?' for a list of locally-valid content-types): ", sdum);
1551 + fgets(LineBuf, sizeof(LineBuf), stdin);
1552 if (index(LineBuf, '/')) {
1553 char lc[100], *s, AnsBuf[100];
1554 strcpy(lc, LineBuf);
1555 @@ -1812,7 +1813,7 @@
1558 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);
1560 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1561 while (s && *s && isspace((unsigned char) *s)) ++s;
1562 if (s && (*s == 'y' || *s == 'Y')) break;
1564 @@ -1939,7 +1940,7 @@
1565 mp->encoding_type_needed = ENC_NONE;
1567 newfilename = tmpname();
1568 - fpout = fopen(newfilename, "w");
1569 + fpout = Fopen(newfilename, "w");
1571 fprintf(stderr, "Cannot open file %s for writing, no data included.\n", newfilename);
1573 @@ -2109,7 +2110,7 @@
1574 ContainsEightBitChar(FirstPart->filename)) {
1575 FirstPart->encoding_type_needed = ENC_QP;
1577 - fpout = fopen(FirstPart->filename, "a");
1578 + fpout = Fopen(FirstPart->filename, "a");
1582 @@ -2159,7 +2160,7 @@
1586 - fpout = fopen(lastmp->filename, "a");
1587 + fpout = Fopen(lastmp->filename, "a");
1591 diff -d -r -u -P mm2.7.orig/src/metamail/metamail.c mm2.7/src/metamail/metamail.c
1592 --- mm2.7.orig/src/metamail/metamail.c Mon Jun 15 00:30:47 1998
1593 +++ mm2.7/src/metamail/metamail.c Sat Jun 20 16:54:29 1998
1597 extern FILE *popen();
1598 +extern FILE *Fopen();
1599 static char *nomem = "Out of memory!";
1600 static char *mmversion = MM_VERSTRING;
1601 static char *NoAskDefault = "text,text/plain,text/richtext";
1603 int overwriteans = -1;
1605 printf("File %s exists. Do you want to overwrite it (y/n) ?\n", Fname);
1607 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1612 if (Fname[0] == 0 || Fname[0] == '\n') {
1613 ConsumeRestOfPart(NULL);
1615 - fp = fopen(Fname, WRITE_BINARY);
1616 + fp = Fopen(Fname, WRITE_BINARY);
1617 if (!fp) ExitWithError("Cannot open temporary file");
1618 TranslateInputToOutput(InputFP, fp, EncodingCode, ContentType);
1621 /* Create it, ugh. Also needs to affect later command. */
1622 MkTmpFileName(TmpName);
1623 DeleteSourceFileWhenDone = 1;
1624 - fptmp = fopen(TmpName, WRITE_BINARY);
1625 + fptmp = Fopen(TmpName, WRITE_BINARY);
1626 if (!fptmp) ExitWithError("Can't open temporary file\n");
1627 while (fgets(LineBuf, LINE_BUF_SIZE, stdin)) {
1628 fputs(LineBuf, fptmp);
1629 @@ -1195,7 +1196,7 @@
1633 - outfp = fopen(SquirrelFile, WRITE_BINARY);
1634 + outfp = Fopen(SquirrelFile, WRITE_BINARY);
1636 fprintf(stderr, "Cannot open %s to squirrel away a portion of a multipart/alternative\n", SquirrelFile);
1638 @@ -1799,7 +1800,7 @@
1639 nameBuf[(cp - def) + 4] = 0;
1640 cp++; /* Now points to value part of environment string. */
1642 - if ((envFile = fopen(nameBuf, "w")) == NULL) {
1643 + if ((envFile = Fopen(nameBuf, "w")) == NULL) {
1647 @@ -1824,7 +1825,7 @@
1649 printf("This message contains '%s'-format data.\nDo you want to view it using the '%s' command (y/n) [y] ? ", ctype, ShortCommand(progname));
1652 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1653 if (!s) return(0); /* EOF */
1654 while (s && *s && isspace((unsigned char) *s)) ++s;
1655 if (*s == 'y' || *s == 'Y' || !*s || *s == '\n') return(1);
1656 @@ -2037,7 +2038,7 @@
1658 /* What follows is REALLY bogus, but all my encoding stuff is pipe-oriented right now... */
1659 MkTmpFileName(TmpFile);
1660 - fp = fopen(TmpFile, WRITE_BINARY);
1661 + fp = Fopen(TmpFile, WRITE_BINARY);
1663 fprintf(stderr, "Could not open temporary file\n");
1665 @@ -2192,7 +2193,7 @@
1666 strcpy(thispart->fname, TmpFileNameBuf);
1667 WriteTmpFile(thispart->fname, thispart->ctype);
1668 strcat(TmpFileNameBuf, "H");
1669 - headfp = fopen(TmpFileNameBuf, "w");
1670 + headfp = Fopen(TmpFileNameBuf, "w");
1672 fputs(mailheaders+12, headfp);
1673 /* The +12 gets rid of MM_HEADERS=\n */
1674 @@ -2298,7 +2299,7 @@
1678 - fpout = fopen(fname, WRITE_BINARY);
1679 + fpout = Fopen(fname, WRITE_BINARY);
1681 perror("WriteTmpFile");
1682 ExitWithError("Can't create temporary file");
1683 @@ -2519,7 +2520,7 @@
1686 MkTmpFileName(nameBuf);
1687 - if ((script = fopen(nameBuf, "w")) == NULL) {
1688 + if ((script = Fopen(nameBuf, "w")) == NULL) {
1689 fprintf(stderr, "Unable to open %s for writing\n", nameBuf);
1692 diff -d -r -u -P mm2.7.orig/src/metamail/shared.c mm2.7/src/metamail/shared.c
1693 --- mm2.7.orig/src/metamail/shared.c Mon Jun 15 00:30:47 1998
1694 +++ mm2.7/src/metamail/shared.c Sat Jun 20 16:51:54 1998
1699 +#include <unistd.h>
1700 +#include <string.h>
1703 +#include <sys/stat.h>
1706 #include <sys/utsname.h>
1707 @@ -116,5 +121,55 @@
1714 +/* This fopen wrapper function is designed to avoid /tmp-file race
1715 + * conditions where a temporary filename is created and somebody
1716 + * throws a link in your way before the fopen(...,"w"). This
1717 + * would only happen if another user on the system were actively
1718 + * trying to trick you into destroying files.
1719 + * Sorry, but "a" mode is not really handled any safer than fopen,
1720 + * since I really have no criterium for deciding what files are
1721 + * OK to write to. */
1722 +FILE *Fopen(Fopen_path,Fopen_mode)
1723 +char *Fopen_path; char *Fopen_mode;
1726 +return(fopen(Fopen_path,Fopen_mode));
1729 +struct stat Fopen_sb;
1730 +int Fopen_appendmode = 0;
1731 +int Fopen_readmode = 0;
1732 +int Fopen_openflags = 0;
1734 +if ( strchr(Fopen_mode,'r') != (char *)0 ) return(fopen(Fopen_path,Fopen_mode));
1735 +if ( strchr(Fopen_mode,'a') != (char *)0 ) Fopen_appendmode = 1;
1736 +if ( strchr(Fopen_mode,'+') != (char *)0 ) Fopen_readmode = 1;
1737 +if ( ( Fopen_appendmode && (strchr(Fopen_mode,'w') != (char *)0) ) ||
1738 + ( (! Fopen_appendmode) && (strchr(Fopen_mode,'w') == (char *)0) ) )
1741 + return( (FILE *)0 );
1743 +if ( Fopen_appendmode )
1745 + /* If "a" and file exists, pass it to the real fopen() */
1746 + Fopen_r = stat(Fopen_path,&Fopen_sb) ;
1747 + if ( (Fopen_r != -1) || (errno != ENOENT) )
1748 + return( fopen(Fopen_path,Fopen_mode) );
1750 +if ( Fopen_readmode )
1751 + Fopen_openflags = O_RDWR|O_CREAT|O_EXCL ;
1753 + Fopen_openflags = O_WRONLY|O_CREAT|O_EXCL ;
1754 +if ( Fopen_appendmode ) Fopen_openflags |= O_APPEND ;
1755 +remove( Fopen_path );
1756 +/* 0666? We'd better hope their umask is safe... */
1757 +Fopen_fd = open(Fopen_path,Fopen_openflags,0666);
1758 +if ( Fopen_fd > -1 ) return( fdopen(Fopen_fd,Fopen_mode) );
1759 +return( (FILE *)0 );
1763 diff -d -r -u -P mm2.7.orig/src/metamail/splitmail.c mm2.7/src/metamail/splitmail.c
1764 --- mm2.7.orig/src/metamail/splitmail.c Mon Jun 15 00:30:47 1998
1765 +++ mm2.7/src/metamail/splitmail.c Sat Jun 20 15:57:02 1998
1772 #define MINCHUNKSIZE 20000 /* Better be enough to hold the headers, or we die! */
1773 extern char *malloc(), *index(), *getmyname();
1775 char *deliverycmd, *prefix, *SharedHeaders, *SubjectBuf, *id, *MessageID, *bigbuf, *OrigID;
1779 char OutputFile[1000];
1781 #if defined(sequent)
1782 @@ -255,7 +257,11 @@
1783 fpout = popen(deliverycmd, "w");
1785 sprintf(OutputFile, "%s%d", prefix, whichpart);
1786 - fpout = fopen(OutputFile, "w");
1787 + /* fpout = fopen(OutputFile, "w"); */
1788 + remove(OutputFile);
1790 + fd = open(OutputFile, O_WRONLY|O_CREAT|O_EXCL, 0600);
1791 + if ( fd > -1 ) fpout = fdopen(fd, "w");
1794 fprintf(stderr, "splitmail: Can't open %s for writing\n", DoDeliver ? deliverycmd : OutputFile);