1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
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
8 # More information can be found in the files COPYING and README.
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
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
26 -if (-e $audiofile && ! -z $audiofile) goto whatnext
28 +if (-e "$audiofile" && ! -z "$audiofile") goto whatnext
31 echo -n "Press RETURN when you are ready to start recording: "
33 # THIS IS UNBELIEVABLY GRUBBY
35 if (! $?RECORD_AUDIO) then
36 - (/bin/cat < $dev > $audiofile) &
37 + (/bin/cat < $dev > "$audiofile") &
39 - ($RECORD_AUDIO > $audiofile) &
40 + ($RECORD_AUDIO > "$audiofile") &
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
51 + set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
55 +set foo=`/bin/cat $TmpAudCat`
58 echo -n "press RETURN when you are done recording: "
64 - cat $audiofile > $dev
65 + cat "$audiofile" > $dev
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
75 if ( $#argv == 1 ) then
82 echo -n "Press RETURN when you are ready to start recording: "
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
93 + set fname = ${METAMAIL_TMPDIR}/audio-out.$$
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
101 + set fnameraw = ${METAMAIL_TMPDIR}/audio-raw.$$
105 echo "To: " "$to" > $fname
106 echo "Subject: " "$subject" >> $fname
109 ($RECORD_AUDIO > $fnameraw) &
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
120 + set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
123 +jobs -l > $TmpAudCat
124 +set foo=`/bin/cat $TmpAudCat`
127 echo -n "press RETURN when you are done recording: "
132 echo -n "Sending mail, please wait... "
133 - /usr/lib/sendmail $to $cc < $fname
134 + /usr/lib/sendmail "$to" "$cc" < $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
142 echo "Usage: extcompose output-file-name"
152 echo -n "Please enter a number from 1 to 5: "
155 +if ("$ans" == 1) then
156 set accesstype=local-file
157 -else if ($ans == 2) then
158 +else if ("$ans" == 2) then
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
166 -else if ($ans == 5) then
167 +else if ("$ans" == 5) then
168 set accesstype=mail-server
170 echo "That is NOT one of your choices."
171 goto chooseaccesstype
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: "
177 echo -n "Enter the name of the directory containing the file (RETURN for top-level): "
180 echo -n "Enter the transfer mode (type 'image' for binary data, RETURN otherwise): "
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
197 echo -n "Enter the full path name for the file: "
199 - if (! -e $name) then
200 + if (! -e "$name") then
201 echo "The file $name does not seem to exist."
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: "
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"
213 - echo accesstype $accesstype not yet implemented
214 + echo accesstype "$accesstype" not yet implemented
215 goto chooseaccesstype
219 echo "That is not one of your choices."
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:"
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
244 -if (! -r $fnam) then
245 +if (! -r "$fnam") then
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
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
266 + set TmpFile=/tmp/ms.$$
270 while ("$FOORAW" != "")
271 set FOO=(` echo "$FOORAW" | tr "[" "x"`)
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-]")
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-]")
293 if ("$FromName" == "") then
295 -From: $LOCALADDR@`hostname`
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.
306 probably run in some circumstance other than mail delivery.
309 - cat $TmpFile - | /usr/lib/sendmail $MAINTAINER
310 + cat $TmpFile - | /usr/lib/sendmail "$MAINTAINER"
311 # Takes the rest of the message from standard input
316 -set danger=`echo $Subject | fgrep ..`
317 -if ($danger != "") then
319 -From: $LOCALADDR@`hostname`
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.
334 if (! -e "$Subject") then
336 -From: $LOCALADDR@`hostname`
338 -Subject: Re: $Subject
340 -You recently sent mail to this mail-server requesting the file:
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
362 + echo "" >> $TmpFile
363 /usr/lib/sendmail -t < $TmpFile
368 -if (-e ${Subject}.ct) then
369 - set ct=`cat ${Subject}.ct`
370 +if (-e "${Subject}.ct") then
371 + set ct=`cat "${Subject}.ct"`
373 set ct="application/octet-stream"
376 metasend -b -t "$FromName" -f "$Subject" -m "$ct" -s "Re: $Subject"
377 if ($status != 0) then
379 -From: $LOCALADDR@`hostname`
381 -Subject: Re: $Subject
383 -You recently sent mail to this mail-server requestion the file:
386 -An unanticipated error apparently precluded delivery of the file.
387 -Please accept our apologies.
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
413 if ("$LOGADDR" != "") then
414 - /usr/lib/sendmail -t <<!
415 -From: ${LOCALADDR}@`hostname`
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
429 -was sent to: $FromName
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
437 echo "-S requires a following argument, the SPLIT threshhold"
446 echo "-i requires a following argument, the Content-ID value"
455 echo "-I requires a following argument, the multipart Content-ID value"
463 @@ -122,12 +122,12 @@
464 echo "-e requires a following argument, the ENCODING value"
468 - if ($encode == "base64") then
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
479 set encodingprog = "mimencode -q"
481 echo "-f requires a following argument, the DATA FILE"
485 - if (! -e $datafile) then
486 - echo The file $datafile does not exist.
488 + if (! -e "$datafile") then
489 + echo The file "$datafile" does not exist.
493 @@ -154,10 +154,10 @@
494 echo "-m requires a following argument, the MIME CONTENT-TYPE"
498 -# set ctype=`echo $ctyperaw | tr \" \'`
499 +# set ctyperaw = "$1"
500 +# set ctype=`echo "$ctyperaw" | tr \" \'`
502 - if (`echo $ctype | grep /` == "") then
503 + if (`echo "$ctype" | grep /` == "") then
504 echo "Invalid content-type specified"
507 @@ -228,11 +228,11 @@
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"
522 @@ -247,11 +247,11 @@
526 - echo UNRECOGNIZED METASEND OPTION: $1
527 + echo UNRECOGNIZED METASEND OPTION: "$1"
531 -if ($batchmode == 0) then
532 +if ("$batchmode" == 0) then
536 @@ -271,18 +271,18 @@
537 # set ctype=`echo $ctyperaw | tr \" \'`
540 - if (`echo $ctype | grep /` == "") then
541 + if (`echo "$ctype" | grep /` == "") then
542 echo "Invalid content-type specified"
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
550 echo -n "Name of file containing $ctype data: "
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.
559 @@ -320,12 +320,12 @@
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"
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
584 @@ -359,12 +359,12 @@
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
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"
598 if ("$ctype" =~ text*) then
599 set encodingprog = "mimencode -q"
600 @@ -373,11 +373,11 @@
601 set encodingprog = "mimencode -b"
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
614 set encodingprog = "mimencode -q"
615 @@ -395,14 +395,22 @@
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
636 + set fname=${METAMAIL_TMPDIR}/metasend.$$
639 echo "MIME-Version: 1.0" > $fname
641 echo "To: " "$to" >> $fname
642 @@ -429,17 +437,26 @@
643 echo " boundary="\"$boundary\" >> $fname
645 if ($?preamblefile) then
646 - cat $preamblefile >> $fname
647 + cat "$preamblefile" >> $fname
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
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
663 + set junkfile=${METAMAIL_TMPDIR}/mmjunk.$$
666 + while ("$multipart" >= $i)
668 - echo --$boundary >> $fname
669 + echo --"$boundary" >> $fname
670 echo set isentity=\$isentity$i > $junkfile
672 if (! $isentity) then
673 @@ -463,27 +480,27 @@
677 - echo --${boundary}-- >> $fname
678 + echo --"${boundary}"-- >> $fname
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
691 - $encodingprog < $datafile >> $fname
692 + $encodingprog < "$datafile" >> $fname
693 # Ensure last line has trailing carriage return
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"
703 - if ($batchmode == 0) echo "Mail delivery apparently succeeded."
704 + if ("$batchmode" == 0) echo "Mail delivery apparently succeeded."
706 - else if ($MustDelete == 1) then
707 + else if ("$MustDelete" == 1) then
708 echo Mail delivery failed
715 - mv $fname $outputfile
716 + mv $fname "$outputfile"
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
725 set PREFIX="mm.patch."
727 +if (! $?METAMAIL_TMPDIR) then
728 + set METAMAIL_TMPDIR=/tmp
731 if ($#argv < 2 || $#argv > 5) then
732 echo Usage: patch-metamail source-tree-root patch-number [hostname [dirname [prefix]]]
738 -if ($#argv > 2) set HOSTNAME=$3
739 -if ($#argv > 3) set DIRNAME=$4
740 -if ($#argv > 4) set PREFIX=$5
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".
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}".
758 echo -n "Do you want to install the patch in directory $TREEROOT [y/n] ? "
760 -if ($ans == "y" || $ans == "Y") then
762 +if ("$ans" == "y" || "$ans" == "Y") then
764 set ident=`whoami`@`hostname`
765 - echo Using anonymous ftp with password $ident
768 -user anonymous $ident
771 -get ${PREFIX}${PATCHNUMBER}
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
781 + set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
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"
793 + patch -p < "${PREFIX}${PATCHNUMBER}"
795 echo Patch not installed
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
801 # Written by Patrik Faltstrom, paf@nada.kth.se, may 1993
808 # If $AFPDIR environment variable is set, all Macintosh filenames
813 -echo $NAME | grep '^/' > /dev/null
814 +echo "$NAME" | grep '^/' > /dev/null
817 + NAME="$AFPDIR/$NAME"
820 -cvt2cap $FILENAME $NAME
821 +cvt2cap "$FILENAME" "$NAME"
822 echo "Saved AppleMacintosh file as $NAME"
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
831 if ("$1" == "-p") then
833 + set AUDIOPHONE="$2"
839 echo -n "Which do you prefer (1 or 2)? "
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"
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"
854 set audiohost=$thishost
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
862 if ($?AUDIOHOST) then
863 set audiohost=$AUDIOHOST
865 if ($#argv >= 1) then
866 exec /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $*
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
877 + set TmpAudio=${METAMAIL_TMPDIR}/audio.$$
881 + /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $TmpAudio
885 else if (-d /usr/sony) then
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
897 + set fname=/tmp/mm.aud.$$
901 echo -n "Do you want to write the audio out to a file [y] ? "
908 -if ($status == 0) echo Wrote raw audio file: $fname
910 +if ($status == 0) echo Wrote raw audio file: "$fname"
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
919 set atype=`echo $2 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
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"
946 set ctype="`grep -i content-type: $bodyfile | sed -e 's/............: //'`"
949 set TMPDIR=${METAMAIL_TMPDIR}/XXXternal.$$
951 +if ( $status != 0 ) then
952 + echo Error creating temporary directory
956 set NEWNAME="mm.ext.$$"
957 set NEEDSCONFIRMATION=1
959 echo automatically using the FTP protocol to a site on the network.
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
969 + set TmpExtJunk=${METAMAIL_TMPDIR}/ext.junk.$$
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
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
995 # IGNORE ALL THE OTHERS -- AUTOMATIC FOR LOCAL-FILE, AFS.
996 @@ -157,17 +170,26 @@
998 set MODECMD="type $mode"
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
1006 + set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
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
1019 -user $username $pass
1025 - if (! -e $NEWNAME) then
1026 + echo SITE: "$site" USER "$username"
1029 + if (! -e "$NEWNAME") then
1031 cd ${METAMAIL_TMPDIR}
1033 @@ -176,14 +198,14 @@
1037 - if (! -e $name) then
1038 + if (! -e "$name") then
1039 echo local file not found
1040 cd ${METAMAIL_TMPDIR}
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"
1049 case mail-server: # A very special case
1050 if ("$bodyfile" == "") then
1051 @@ -192,12 +214,12 @@
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"
1068 echo sendmail failed
1069 cd ${METAMAIL_TMPDIR}
1072 cd ${METAMAIL_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.
1078 echo UNRECOGNIZED ACCESS-TYPE
1079 @@ -214,19 +236,19 @@
1083 -if ($cenc == base64) then
1084 - mimencode -u -b < $NEWNAME > OUT
1086 -else if ($cenc == quoted-printable) then
1087 - mimencode -u -q < $NEWNAME > OUT
1089 +if ("$cenc" == base64) then
1090 + mimencode -u -b < "$NEWNAME" > OUT
1092 +else if ("$cenc" == quoted-printable) then
1093 + mimencode -u -q < "$NEWNAME" > OUT
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"
1103 - metamail -p -b -c "$ctype" $TMPDIR/$NEWNAME
1104 + metamail -p -b -c "$ctype" "$TMPDIR/$NEWNAME"
1108 @@ -236,14 +258,14 @@
1112 -if ($NEWNAME != $name) then
1113 +if ("$NEWNAME" != "$name") then
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"
1122 -if (! -e ${TMPDIR}/${NEWNAME}) then
1123 +if (! -e "${TMPDIR}/${NEWNAME}") then
1124 cd ${METAMAIL_TMPDIR}
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
1132 # This next line is because message-id can contain weird chars
1133 set id=`echo $2 | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\`
1135 -if ($#argv == 3 || $4 == "") then
1137 +if ($#argv == 3 || "$4" == "") then
1143 -if (! -d $TREEROOT) then
1144 +if ( -d $TREEROOT) then
1145 + if (! -o $TREEROOT) then
1146 + echo Error: You do not own $TREEROOT
1152 echo mkdir $TREEROOT failed
1156 -if (! -d ${TREEROOT}/$id) then
1157 - mkdir ${TREEROOT}/$id
1158 +if (! -d "${TREEROOT}/$id") then
1159 + mkdir "${TREEROOT}/$id"
1161 - echo mkdir ${TREEROOT}/$id failed
1162 + echo mkdir "${TREEROOT}/$id" failed
1166 -cp $file ${TREEROOT}/$id/$partnum
1167 +cp "$file" "${TREEROOT}/$id/$partnum"
1169 - echo cp $file ${TREEROOT}/$id/$partnum failed
1170 + echo cp "$file" "${TREEROOT}/$id/$partnum" failed
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"`
1180 set totalnum=-1 #GROSS HACK
1183 - echo $totalnum >! ${TREEROOT}/$id/CT
1184 + echo "$totalnum" >! "${TREEROOT}/$id/CT"
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"
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"
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
1218 - echo All parts of this ${totalnum}-part message have now been read.
1219 - metamail -d ${TREEROOT}/$id/FULL
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
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.
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.
1246 echo When you have read them all, then you will see the message in full.
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
1252 set X_VIEWER="xloadimage -view -quiet -geometry +1+1"
1253 # set X_VIEWER="xv -geometry +1+1"
1255 -if ($1 == "-viewer" && $#argv > 1) then
1256 +if ("$1" == "-viewer" && $#argv > 1) then
1261 echo be able to see the picture properly.
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
1271 + set fname=${METAMAIL_TMPDIR}/sp.$$
1274 echo "The picture is being automatically stored in the file $fname"
1275 echo "If you do not want this file, please delete it."
1279 echo -n "File name:"
1281 - if (! -f $fname) then
1282 + if (! -f "$fname") then
1285 echo "$fname already exists. Try again"
1290 - if ($status == 0) echo Wrote file $fname
1292 + if ($status == 0) echo Wrote file "$fname"
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
1304 + set SQUIRREL=${METAMAIL_TMPDIR}/sp.$$
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
1317 -uudecode -o $fn < $1
1318 +uudecode -o $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
1327 # $2 is untrustworthy data. Quote it.
1329 mkdir /tmp/decode.$$
1330 +if ( $status != 0 ) then
1331 + echo "Error: cannot create temporary directory"
1336 if (! $?METAMAIL_PAGER) then
1341 - uudecode -o $fn $1
1342 + uudecode -o $fn "$1"
1344 echo "The following file was uudecoded:"
1347 echo -n "Which do you prefer (1 - 3)? [$defans] "
1350 - if (x$ans == x) then
1351 + if ("x$ans" == x) then
1354 - if ($ans == 3) then
1356 + if ("$ans" == 3) then
1358 cd /tmp; /bin/rm -rf /tmp/decode.$$
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
1366 echo -n "Save as: $HOME/"
1368 - if (x$nfn != x) then
1369 - /bin/cp $fn ${HOME}/$nfn
1370 + if ("x$nfn" != x) then
1371 + /bin/cp $fn "${HOME}/$nfn"
1379 - ${METAMAIL_PAGER} $1
1380 + ${METAMAIL_PAGER} "$1"
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
1388 set METAMAIL_TMPDIR=/tmp
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
1398 + set TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1402 echo "Content-type: multipart/mixed; boundary=--------" > $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
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
1424 + TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1429 BEGIN { printf("Content-type: multipart/mixed; boundary=--------\n\n")
1433 END { printf("----------\n") }
1437 metamail -z $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
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 */
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");
1461 FirstPart = NewPart();
1462 CurrentPart = FirstPart;
1463 - fpout = fopen(CurrentPart->filename, "w");
1464 + fpout = Fopen(CurrentPart->filename, "w");
1466 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
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");
1475 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
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");
1484 fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
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");
1493 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1495 @@ -811,11 +812,11 @@
1496 char Cmd[TMPFILE_NAME_SIZE + 15];
1499 - fptmp = fopen(s, "w");
1500 + fptmp = Fopen(s, "w");
1501 WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1502 TempCloseStyles(fptmp);
1504 - fpout = fopen(CurrentPart->filename, "a");
1505 + fpout = Fopen(CurrentPart->filename, "a");
1507 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
1513 - fptmp = fopen(fname, "w");
1514 + fptmp = Fopen(fname, "w");
1515 WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1516 TempCloseStyles(fptmp);
1520 printf("Wrote draft to %s\n", fname);
1522 - fpout = fopen(CurrentPart->filename, "a");
1523 + fpout = Fopen(CurrentPart->filename, "a");
1525 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
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");
1534 fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
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");
1543 fprintf(stderr, "mailto: Can't open temporary file %s\n", CurrentPart->filename);
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);
1553 perror("Could not write ~/dead.letter\n");
1554 @@ -1776,7 +1777,7 @@
1555 printf("Cannot read %s, data insertion cancelled\n", sdum);
1558 - fpo = fopen(mp->filename, "w");
1559 + fpo = Fopen(mp->filename, "w");
1561 printf("Cannot open temporary file, data insertion cancelled\n");
1563 @@ -1794,7 +1795,7 @@
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);
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 @@
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);
1577 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1578 while (s && *s && isspace((unsigned char) *s)) ++s;
1579 if (s && (*s == 'y' || *s == 'Y')) break;
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");
1588 fprintf(stderr, "Cannot open file %s for writing, no data included.\n", newfilename);
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");
1599 @@ -2159,7 +2160,7 @@
1603 - fpout = fopen(lastmp->filename, "a");
1604 + fpout = Fopen(lastmp->filename, "a");
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
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";
1620 int overwriteans = -1;
1622 printf("File %s exists. Do you want to overwrite it (y/n) ?\n", Fname);
1624 + s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1629 if (Fname[0] == 0 || Fname[0] == '\n') {
1630 ConsumeRestOfPart(NULL);
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);
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 @@
1650 - outfp = fopen(SquirrelFile, WRITE_BINARY);
1651 + outfp = Fopen(SquirrelFile, WRITE_BINARY);
1653 fprintf(stderr, "Cannot open %s to squirrel away a portion of a multipart/alternative\n", SquirrelFile);
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) {
1664 @@ -1824,7 +1825,7 @@
1666 printf("This message contains '%s'-format data.\nDo you want to view it using the '%s' command (y/n) [y] ? ", ctype, ShortCommand(progname));
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 @@
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);
1680 fprintf(stderr, "Could not open temporary file\n");
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");
1689 fputs(mailheaders+12, headfp);
1690 /* The +12 gets rid of MM_HEADERS=\n */
1691 @@ -2298,7 +2299,7 @@
1695 - fpout = fopen(fname, WRITE_BINARY);
1696 + fpout = Fopen(fname, WRITE_BINARY);
1698 perror("WriteTmpFile");
1699 ExitWithError("Can't create temporary file");
1700 @@ -2519,7 +2520,7 @@
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);
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
1716 +#include <unistd.h>
1717 +#include <string.h>
1720 +#include <sys/stat.h>
1723 #include <sys/utsname.h>
1724 @@ -116,5 +121,55 @@
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;
1743 +return(fopen(Fopen_path,Fopen_mode));
1746 +struct stat Fopen_sb;
1747 +int Fopen_appendmode = 0;
1748 +int Fopen_readmode = 0;
1749 +int Fopen_openflags = 0;
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) ) )
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 ;
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 );
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
1789 #define MINCHUNKSIZE 20000 /* Better be enough to hold the headers, or we die! */
1790 extern char *malloc(), *index(), *getmyname();
1792 char *deliverycmd, *prefix, *SharedHeaders, *SubjectBuf, *id, *MessageID, *bigbuf, *OrigID;
1796 char OutputFile[1000];
1798 #if defined(sequent)
1799 @@ -255,7 +257,11 @@
1800 fpout = popen(deliverycmd, "w");
1802 sprintf(OutputFile, "%s%d", prefix, whichpart);
1803 - fpout = fopen(OutputFile, "w");
1804 + /* fpout = fopen(OutputFile, "w"); */
1805 + remove(OutputFile);
1807 + fd = open(OutputFile, O_WRONLY|O_CREAT|O_EXCL, 0600);
1808 + if ( fd > -1 ) fpout = fdopen(fd, "w");
1811 fprintf(stderr, "splitmail: Can't open %s for writing\n", DoDeliver ? deliverycmd : OutputFile);