]> git.pld-linux.org Git - packages/metamail.git/blob - metamail-ohnonotagain.patch
13a75a98b257ccd896affbbbcca163befc9eb7c2
[packages/metamail.git] / metamail-ohnonotagain.patch
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
4 @@ -28,8 +28,8 @@
5      set dev=/dev/audio
6  endif
7  
8 -set audiofile=$1
9 -if (-e $audiofile && ! -z $audiofile) goto whatnext
10 +set audiofile="$1"
11 +if (-e "$audiofile" && ! -z "$audiofile") goto whatnext
12  
13  record:
14  echo -n "Press RETURN when you are ready to start recording: "
15 @@ -38,13 +38,22 @@
16  # THIS IS UNBELIEVABLY GRUBBY
17  onintr cleanup
18  if (! $?RECORD_AUDIO) then
19 -    (/bin/cat < $dev > $audiofile) &
20 +    (/bin/cat < $dev > "$audiofile") &
21  else
22 -    ($RECORD_AUDIO > $audiofile) &
23 +    ($RECORD_AUDIO > "$audiofile") &
24  endif
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
33 +else
34 +    set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
35 +    rm -rf $TmpAudCat
36 +endif
37 +jobs -l > $TmpAudCat
38 +set foo=`/bin/cat $TmpAudCat`
39 +/bin/rm $TmpAudCat
40  set PID=$foo[2]
41  echo -n "press RETURN when you are done recording: "
42  set foo=$<
43 @@ -63,7 +72,7 @@
44  set which = $<
45      switch ("$which")
46          case 1:
47 -          cat $audiofile > $dev
48 +          cat "$audiofile" > $dev
49            breaksw
50          case 2:
51            goto record
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
55 @@ -29,7 +29,7 @@
56  endif
57  
58  if ( $#argv == 1 ) then
59 -    set to = $1
60 +    set to = "$1"
61  else
62      echo -n "To: "
63      set to = $<
64 @@ -43,8 +43,23 @@
65  echo -n "Press RETURN when you are ready to start recording: "
66  set foo = $<
67  
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
75 +else
76 +    set fname = ${METAMAIL_TMPDIR}/audio-out.$$
77 +    rm -rf $fname
78 +endif
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
83 +else
84 +    set fnameraw = ${METAMAIL_TMPDIR}/audio-raw.$$
85 +    rm -rf $fnameraw
86 +endif
87  
88  echo "To: " "$to" > $fname
89  echo "Subject: " "$subject" >> $fname
90 @@ -60,9 +75,18 @@
91  else
92      ($RECORD_AUDIO > $fnameraw) &
93  endif
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
102 +else
103 +    set TmpAudCat=${METAMAIL_TMPDIR}/AUDCAT.$$
104 +    rm -rf $TmpAudCat
105 +endif
106 +jobs -l > $TmpAudCat
107 +set foo=`/bin/cat $TmpAudCat`
108 +/bin/rm $TmpAudCat
109  set PID=$foo[2]
110  echo -n "press RETURN when you are done recording: "
111  set foo=$<
112 @@ -86,7 +110,7 @@
113      switch ("$which")
114          case 1:
115            echo -n "Sending mail, please wait...  "
116 -          /usr/lib/sendmail $to  $cc < $fname
117 +          /usr/lib/sendmail "$to" "$cc" < $fname
118            if (! $status) then
119              echo "Done."
120              rm $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
124 @@ -6,7 +6,7 @@
125      echo "Usage:  extcompose output-file-name"
126      exit 1
127  endif
128 -set OUTFNAME=$1
129 +set OUTFNAME="$1"
130  
131  chooseaccesstype:
132  echo ""
133 @@ -19,21 +19,21 @@
134  echo ""
135  echo -n "Please enter a number from 1 to 5: "
136  set ans=$<
137 -if ($ans == 1)  then
138 +if ("$ans" == 1)  then
139      set accesstype=local-file
140 -else if ($ans == 2) then
141 +else if ("$ans" == 2) then
142      set accesstype=afs
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
148      set accesstype=ftp
149 -else if ($ans == 5) then
150 +else if ("$ans" == 5) then
151      set accesstype=mail-server
152  else
153      echo "That is NOT one of your choices."
154      goto chooseaccesstype
155  endif
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: "
159      set site=$<
160      echo -n "Enter the name of the directory containing the file (RETURN for top-level): "
161 @@ -42,27 +42,27 @@
162      set name = $<
163      echo -n "Enter the transfer mode (type 'image' for binary data, RETURN otherwise): "
164      set mode = $<
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
179  fname:
180      echo -n "Enter the full path name for the file: "
181      set name = $<
182 -    if (! -e $name) then
183 +    if (! -e "$name") then
184         echo "The file $name does not seem to exist."
185         goto fname
186      endif
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: "
192      set server=$<
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"
195  else
196 -    echo accesstype $accesstype not yet implemented
197 +    echo accesstype "$accesstype" not yet implemented
198      goto chooseaccesstype
199  endif
200  
201 @@ -92,12 +92,12 @@
202          echo "That is not one of your choices."
203          goto getcenc
204  endsw
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:"
217 -    cat >> $OUTFNAME
218 +    cat >> "$OUTFNAME"
219  endif
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
223 @@ -8,9 +8,9 @@
224      echo Aborted
225      exit -1
226  endif
227 -if (! -r  $fnam) then
228 +if (! -r "$fnam") then
229      echo No such file
230      exit -1
231  endif
232 -cp $fnam $2
233 +cp "$fnam" "$2"
234  exit 0
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
238 @@ -28,20 +28,28 @@
239  rehash
240  set FromName=""
241  set Subject=""
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
248 +else
249 +    set TmpFile=/tmp/ms.$$
250 +    rm -rf $TmpFile
251 +endif
252  set FOORAW=$<
253  while ("$FOORAW" != "") 
254  set FOO=(` echo "$FOORAW" | tr "[" "x"`)
255  set BAR=($FOO)
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-]")
263         endif
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-]")
270  endif
271  set FOORAW=$<
272  end
273 @@ -52,10 +60,10 @@
274  endif
275  
276  if ("$FromName" == "") then
277 -       cat > $TmpFile <<!
278 -From: $LOCALADDR@`hostname`
279 -To: $MAINTAINER
280 -Subject: $Subject
281 +       echo From: "$LOCALADDR"@`hostname` > $TmpFile
282 +       echo To: "$MAINTAINER" >> $TmpFile
283 +       echo Subject: "$Subject" >> $TmpFile
284 +       cat >> $TmpFile <<!
285  
286  The metamail mailserver script, installed locally as $LOCALADDR, \rhas received a request without any reply address.
287  
288 @@ -68,18 +76,18 @@
289  probably run in some circumstance other than mail delivery.
290  --------------------
291  !
292 -       cat $TmpFile - | /usr/lib/sendmail $MAINTAINER
293 +       cat $TmpFile - | /usr/lib/sendmail "$MAINTAINER"
294         # Takes the rest of the message from standard input
295         rm $TmpFile
296         exit 0
297  endif
298  
299 -set danger=`echo $Subject | fgrep ..`
300 -if ($danger != "") then
301 -       cat > $TmpFile <<!
302 -From: $LOCALADDR@`hostname`
303 -To: $FromName
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 <<!
311  
312  For security reasons, this mailserver automatically rejects all requests 
313  that contain ".." in the path name.
314 @@ -93,60 +101,64 @@
315  
316  cd $ROOTDIR
317  if (! -e "$Subject") then
318 -       cat > $TmpFile <<!
319 -From: $LOCALADDR@`hostname`
320 -To: $FromName
321 -Subject: Re: $Subject
322 -
323 -You recently sent mail to this mail-server requesting the file: 
324 -       $Subject
325 -
326 -That file does not exist, so your request could not be met.
327 -
328 -Here is a list of the currently available files:
329 ---------------------------------
330 -!
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
344         ls -R >> $TmpFile
345 +       echo "" >> $TmpFile
346         /usr/lib/sendmail -t < $TmpFile
347         rm $TmpFile
348         exit 0
349  endif
350  
351 -if (-e ${Subject}.ct) then
352 -       set ct=`cat ${Subject}.ct`
353 +if (-e "${Subject}.ct") then
354 +       set ct=`cat "${Subject}.ct"`
355  else 
356         set ct="application/octet-stream"
357  endif
358  
359  metasend -b -t "$FromName" -f "$Subject" -m "$ct" -s "Re: $Subject"
360  if ($status != 0) then
361 -       cat > $TmpFile <<!
362 -From: $LOCALADDR@`hostname`
363 -To: $FromName
364 -Subject: Re: $Subject
365 -
366 -You recently sent mail to this mail-server requestion the file: 
367 -       $Subject
368 -
369 -An unanticipated error apparently precluded delivery of the file.
370 -Please accept our apologies.
371 -
372 -Command failed: 
373 -  metasend -b -t "$FromName" -f "$Subject" -m "$ct" -s "Re: $Subject"
374 -
375 -!
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
392         rm $TmpFile
393         exit 0
394  endif
395  
396  if ("$LOGADDR" != "") then
397 -       /usr/lib/sendmail -t <<!
398 -From: ${LOCALADDR}@`hostname`
399 -To: $LOGADDR
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
409 +endif
410  
411 -The file: $Subject 
412 -was sent to: $FromName
413 -!
414 +rm -f $TmpFile
415  exit 0
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
419 @@ -45,7 +45,7 @@
420                  echo "-S requires a following argument, the SPLIT threshhold"
421                  exit -1
422              endif
423 -            set splitsize=$1
424 +            set splitsize="$1"
425              shift
426              breaksw
427          case "-b":
428 @@ -68,7 +68,7 @@
429                  echo "-i requires a following argument, the Content-ID value"
430                  exit -1
431              endif
432 -            set cid=$1
433 +            set cid="$1"
434              shift
435              breaksw
436          case "-I":
437 @@ -77,7 +77,7 @@
438                  echo "-I requires a following argument, the multipart Content-ID value"
439                  exit -1
440              endif
441 -            set multicid=$1
442 +            set multicid="$1"
443              shift
444              breaksw
445          case "-s":
446 @@ -122,12 +122,12 @@
447                  echo "-e requires a following argument, the ENCODING value"
448                  exit -1
449              endif
450 -            set encode=$1
451 -            if ($encode == "base64") then
452 +            set encode="$1"
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
461             else
462                 set encodingprog = "mimencode -q"
463 @@ -141,9 +141,9 @@
464                  echo "-f requires a following argument, the DATA FILE"
465                  exit -1
466              endif
467 -            set datafile=$1
468 -            if (! -e  $datafile) then
469 -                echo The file $datafile does not exist.
470 +            set datafile="$1"
471 +            if (! -e "$datafile") then
472 +                echo The file "$datafile" does not exist.
473                  exit -1
474              endif
475              shift
476 @@ -154,10 +154,10 @@
477                  echo "-m requires a following argument, the MIME CONTENT-TYPE"
478                  exit -1
479              endif
480 -#            set ctyperaw = $1
481 -#            set  ctype=`echo $ctyperaw | tr \" \'`
482 +#            set ctyperaw = "$1"
483 +#            set  ctype=`echo "$ctyperaw" | tr \" \'`
484         set ctype = "$1"
485 -       if (`echo $ctype | grep /` == "") then
486 +       if (`echo "$ctype" | grep /` == "") then
487             echo "Invalid content-type specified"
488             exit -1
489         endif
490 @@ -228,11 +228,11 @@
491                 endif
492         endif
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"
503         unset ctype
504         unset datafile
505 @@ -247,11 +247,11 @@
506         shift
507         breaksw
508          default:
509 -            echo UNRECOGNIZED METASEND OPTION: $1
510 +            echo UNRECOGNIZED METASEND OPTION: "$1"
511              exit -1
512      endsw
513  end
514 -if ($batchmode == 0) then
515 +if ("$batchmode" == 0) then
516      if (! $?to) then
517          echo -n "To: "
518          set to = $<
519 @@ -271,18 +271,18 @@
520  #        set  ctype=`echo $ctyperaw | tr \" \'`
521          set ctype = "$<"
522      endif
523 -    if (`echo $ctype | grep /` == "") then
524 +    if (`echo "$ctype" | grep /` == "") then
525          echo "Invalid content-type specified"
526          unset ctype
527          goto anotherpart
528      endif
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
532          getfile:
533          echo -n "Name of file containing $ctype data: "
534          set datafile = $<
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.
539              goto getfile
540          endif
541      endif
542 @@ -320,12 +320,12 @@
543      set ans=$<
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"
556         set isentity=0
557         unset ctype
558 @@ -339,7 +339,7 @@
559              goto anotherpart
560       endif
561  else
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
566          exit -1
567 @@ -359,12 +359,12 @@
568          exit -1
569        endif
570      endif    
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
575          exit -1
576      endif
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"
580      if (! $?encode) then
581          if ("$ctype" =~ text*) then
582         set encodingprog = "mimencode -q"
583 @@ -373,11 +373,11 @@
584              set encodingprog = "mimencode -b"
585              set encode = base64
586          endif
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
596      else
597          set encodingprog = "mimencode -q"
598 @@ -395,14 +395,22 @@
599          endif
600  endif
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"
611  
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
618 +else
619 +    set fname=${METAMAIL_TMPDIR}/metasend.$$
620 +    rm -rf $fname
621 +endif
622  echo "MIME-Version: 1.0" > $fname
623  if ($?to) then
624      echo "To: " "$to" >> $fname
625 @@ -429,17 +437,26 @@
626      echo "     boundary="\"$boundary\" >> $fname
627      echo "" >> $fname
628      if ($?preamblefile) then
629 -        cat $preamblefile >> $fname
630 +        cat "$preamblefile" >> $fname
631      else
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
635      endif
636      set i=1
637 -    set junkfile=${METAMAIL_TMPDIR}/mmjunk.$$
638 -    while  ($multipart >= $i)
639 +
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
645 +    else
646 +        set junkfile=${METAMAIL_TMPDIR}/mmjunk.$$
647 +        rm -rf $junkfile
648 +    endif
649 +    while  ("$multipart" >= $i)
650         echo "" >> $fname
651 -       echo --$boundary >> $fname
652 +       echo --"$boundary" >> $fname
653         echo set isentity=\$isentity$i > $junkfile
654         source $junkfile
655         if (! $isentity) then
656 @@ -463,27 +480,27 @@
657      end
658      rm $junkfile
659      echo "" >> $fname
660 -    echo --${boundary}-- >> $fname
661 +    echo --"${boundary}"-- >> $fname
662      echo "" >> $fname
663  else 
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
672      endif
673      echo  "" >> $fname
674 -    $encodingprog < $datafile >> $fname
675 +    $encodingprog < "$datafile" >> $fname
676      # Ensure last line has trailing carriage return
677      echo "" >> $fname
678  endif
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"
685      if (! $status) then
686 -        if ($batchmode == 0) echo "Mail delivery apparently succeeded."
687 +        if ("$batchmode" == 0) echo "Mail delivery apparently succeeded."
688          rm $fname
689 -    else if ($MustDelete == 1) then
690 +    else if ("$MustDelete" == 1) then
691          echo Mail delivery failed
692          rm $fname
693          exit -1
694 @@ -492,7 +509,7 @@
695          exit -1
696      endif
697  else
698 -    mv $fname $outputfile
699 +    mv $fname "$outputfile"
700      if ($status) exit -1
701  endif
702  exit 0
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
706 @@ -5,40 +5,53 @@
707  set DIRNAME=pub/nsb
708  set PREFIX="mm.patch."
709  
710 +if (! $?METAMAIL_TMPDIR) then
711 +    set METAMAIL_TMPDIR=/tmp
712 +endif
713 +
714  if ($#argv < 2 || $#argv > 5) then
715         echo Usage:  patch-metamail source-tree-root patch-number [hostname [dirname [prefix]]]
716         exit -1
717  endif
718  
719 -set TREEROOT=$1
720 -set PATCHNUMBER=$2
721 -if ($#argv > 2) set HOSTNAME=$3
722 -if ($#argv > 3) set DIRNAME=$4
723 -if ($#argv > 4) set PREFIX=$5
724 +set TREEROOT="$1"
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"
729         
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".
734  echo ""
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}".
740  echo ""
741  echo -n "Do you want to install the patch in directory $TREEROOT [y/n] ? "
742  set ans=$<
743 -if ($ans == "y" || $ans == "Y") then
744 -    cd $TREEROOT
745 +if ("$ans" == "y" || "$ans" == "Y") then
746 +    cd "$TREEROOT"
747      set ident=`whoami`@`hostname`
748 -    echo Using anonymous ftp with password $ident
749 -    ftp -n <<!
750 -open $HOSTNAME
751 -user anonymous $ident
752 -cd $DIRNAME
753 -binary
754 -get ${PREFIX}${PATCHNUMBER}
755 -quit
756 -!
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
763 +    else
764 +        set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
765 +        rm -rf $TmpFtp
766 +    endif
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"
774 +    ftp -n < $TmpFtp
775 +    rm -f $TmpFtp
776 +    patch -p < "${PREFIX}${PATCHNUMBER}"
777  else
778         echo Patch not installed
779  endif
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
783 @@ -13,7 +13,7 @@
784  # Written by Patrik Faltstrom, paf@nada.kth.se, may 1993
785  #
786  
787 -FILENAME=$1
788 +FILENAME="$1"
789  
790  #
791  # If $AFPDIR environment variable is set, all Macintosh filenames
792 @@ -31,12 +31,12 @@
793     exit 1
794  fi
795  
796 -echo $NAME | grep '^/' > /dev/null
797 +echo "$NAME" | grep '^/' > /dev/null
798  if [ $? = 1 ]; then
799 -  NAME=$AFPDIR/$NAME
800 +  NAME="$AFPDIR/$NAME"
801  fi
802  
803 -cvt2cap $FILENAME $NAME
804 +cvt2cap "$FILENAME" "$NAME"
805  echo "Saved AppleMacintosh file as $NAME"
806  exit 0
807  
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
811 @@ -33,7 +33,7 @@
812  set ORG="Bellcore"
813  set STDINPUT=0
814  if ("$1" == "-p") then
815 -    set AUDIOPHONE=$2
816 +    set AUDIOPHONE="$2"
817      shift
818      shift
819  endif
820 @@ -73,13 +73,13 @@
821      echo ""
822      echo -n "Which do you prefer (1 or 2)? "
823      set ans=$<
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"
830         goto playphone
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"
836 @@ -93,8 +93,8 @@
837  set audiohost=$thishost
838  if ($?DISPLAY) then
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
844  endif
845  if ($?AUDIOHOST) then
846         set audiohost=$AUDIOHOST
847 @@ -127,9 +127,18 @@
848      if ($#argv >= 1) then
849         exec /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $*
850      else
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
859 +       else
860 +           set TmpAudio=${METAMAIL_TMPDIR}/audio.$$
861 +           rm -rf $TmpAudio
862 +       endif
863 +       cat > $TmpAudio
864 +       /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $TmpAudio
865 +       rm $TmpAudio
866         exit 0
867      endif
868  else if (-d /usr/sony) then
869 @@ -198,7 +207,15 @@
870  echo ""
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
879 +    else
880 +        set fname=/tmp/mm.aud.$$
881 +        rm -rf $fname
882 +    endif
883  else
884      echo -n "Do you want to write the audio out to a file [y] ? "
885      set ANS=$<
886 @@ -206,7 +223,7 @@
887      echo -n "File name:"
888      set fname=$<
889  endif
890 -cp $1 $fname
891 -if ($status == 0) echo Wrote raw audio file: $fname
892 +cp "$1" "$fname"
893 +if ($status == 0) echo Wrote raw audio file: "$fname"
894  exit 0
895  
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
899 @@ -40,14 +40,14 @@
900  endsw
901  set bodyfile="$1"
902  set atype=`echo $2 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
903 -set name=$3
904 +set name="$3"
905  if ($#argv > 3) then
906      set site="$4"
907  else 
908      set site=""
909  endif
910  if ($#argv > 4) then
911 -    set dir=$5
912 +    set dir="$5"
913  else
914      set dir=""
915  endif
916 @@ -62,10 +62,10 @@
917      set server=""
918  endif
919  
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"
927  endif
928  
929  set ctype="`grep -i content-type: $bodyfile | sed -e 's/............: //'`"
930 @@ -75,6 +75,10 @@
931  set pass=""
932  set TMPDIR=${METAMAIL_TMPDIR}/XXXternal.$$
933  mkdir $TMPDIR
934 +if ( $status != 0 ) then
935 +    echo Error creating temporary directory
936 +    exit 1
937 +endif
938  pushd $TMPDIR
939  set NEWNAME="mm.ext.$$"
940  set NEEDSCONFIRMATION=1
941 @@ -90,7 +94,16 @@
942         echo automatically using  the FTP protocol to a site on the network.
943         breaksw
944      case mail-server:  
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
951 +       else
952 +           set TmpExtJunk=${METAMAIL_TMPDIR}/ext.junk.$$
953 +           rm -rf $TmpExtJunk
954 +       endif
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:
962  
963 -Subject: Automated Mail Server Request
964 -To: ${server}
965 -
966  !
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
975 +       rm $TmpExtJunk
976         breaksw
977      default:
978         # IGNORE ALL THE OTHERS -- AUTOMATIC FOR LOCAL-FILE, AFS.
979 @@ -157,17 +170,26 @@
980         else
981             set MODECMD="type $mode"
982         endif
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
988 +       else
989 +           set TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$
990 +           rm -rf $TmpFtp
991 +       endif
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
1000 -       $FTP -n <<!
1001 -open $site
1002 -user $username $pass
1003 -$DIRCMD
1004 -$MODECMD
1005 -get $name $NEWNAME
1006 -quit
1007 -!
1008 -       if (! -e $NEWNAME) then
1009 +       echo SITE: "$site" USER "$username"
1010 +       $FTP -n < $TmpFtp
1011 +       rm -f $TmpFtp
1012 +       if (! -e "$NEWNAME") then
1013             echo FTP failed.
1014             cd ${METAMAIL_TMPDIR}
1015             rm -rf $TMPDIR
1016 @@ -176,14 +198,14 @@
1017         breaksw
1018      case afs:
1019      case local-file:
1020 -       if (! -e $name) then
1021 +       if (! -e "$name") then
1022             echo local file not found
1023             cd ${METAMAIL_TMPDIR}
1024             rm -rf $TMPDIR
1025             exit -1
1026         endif
1027 -       set NEWNAME=$name
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"
1031         breaksw
1032      case mail-server:  # A very special case
1033         if ("$bodyfile" == "") then
1034 @@ -192,12 +214,12 @@
1035             rm -rf $TMPDIR
1036             exit -1
1037         endif
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"
1050         if ($status) then
1051             echo sendmail failed
1052             cd ${METAMAIL_TMPDIR}
1053 @@ -206,7 +228,7 @@
1054         endif
1055         cd ${METAMAIL_TMPDIR}
1056         rm -rf $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.
1059         exit 0
1060      default:
1061         echo UNRECOGNIZED ACCESS-TYPE
1062 @@ -214,19 +236,19 @@
1063         rm -rf $TMPDIR
1064         exit -1
1065  endsw
1066 -if ($cenc == base64) then
1067 -       mimencode -u -b < $NEWNAME > OUT
1068 -       mv OUT $NEWNAME
1069 -else if ($cenc == quoted-printable) then
1070 -       mimencode -u -q < $NEWNAME > OUT
1071 -       mv OUT $NEWNAME
1072 +if ("$cenc" == base64) then
1073 +       mimencode -u -b < "$NEWNAME" > OUT
1074 +       mv OUT "$NEWNAME"
1075 +else if ("$cenc" == quoted-printable) then
1076 +       mimencode -u -q < "$NEWNAME" > OUT
1077 +       mv OUT "$NEWNAME"
1078  endif
1079  
1080  popd
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"
1085  else
1086 -    metamail -p -b -c "$ctype" $TMPDIR/$NEWNAME
1087 +    metamail -p -b -c "$ctype" "$TMPDIR/$NEWNAME"
1088  endif
1089  
1090  if ($status) then
1091 @@ -236,14 +258,14 @@
1092         exit -1
1093  endif
1094  
1095 -if ($NEWNAME != $name) then
1096 +if ("$NEWNAME" != "$name") then
1097         echo ""
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"
1103  endif
1104  
1105 -if (! -e ${TMPDIR}/${NEWNAME}) then
1106 +if (! -e "${TMPDIR}/${NEWNAME}") then
1107      cd ${METAMAIL_TMPDIR}
1108      rmdir $TMPDIR
1109  endif
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
1113 @@ -14,78 +14,84 @@
1114  set file="$1"
1115  # This next line is because message-id can contain weird chars
1116  set id=`echo $2 | tr -d  \!\$\&\*\(\)\|\'\"\;\/\<\>\\` 
1117 -@ partnum = $3
1118 -if ($#argv == 3 || $4 == "") then
1119 +@ partnum = "$3"
1120 +if ($#argv == 3 || "$4" == "") then
1121      set totalnum=-1
1122  else
1123      @ totalnum = "$4"
1124  endif
1125  
1126 -if (! -d  $TREEROOT)  then
1127 +if ( -d $TREEROOT)  then
1128 +    if (! -o $TREEROOT) then
1129 +        echo Error: You do not own $TREEROOT
1130 +        exit -1
1131 +    endif
1132 +else
1133      mkdir $TREEROOT
1134      if ($status) then 
1135          echo mkdir $TREEROOT failed
1136          exit -1
1137      endif
1138  endif
1139 -if (! -d ${TREEROOT}/$id) then 
1140 -    mkdir ${TREEROOT}/$id
1141 +if (! -d "${TREEROOT}/$id") then 
1142 +    mkdir "${TREEROOT}/$id"
1143      if ($status) then 
1144 -        echo mkdir ${TREEROOT}/$id failed
1145 +        echo mkdir "${TREEROOT}/$id" failed
1146          exit -1
1147      endif
1148  endif
1149 -cp $file ${TREEROOT}/$id/$partnum
1150 +cp "$file" "${TREEROOT}/$id/$partnum"
1151  if ($status) then 
1152 -    echo cp $file ${TREEROOT}/$id/$partnum failed
1153 +    echo cp "$file" "${TREEROOT}/$id/$partnum" failed
1154      exit -1
1155  endif
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"`
1162      else
1163         set totalnum=-1  #GROSS HACK
1164      endif
1165  else
1166 -    echo $totalnum >! ${TREEROOT}/$id/CT
1167 +    echo "$totalnum" >! "${TREEROOT}/$id/CT"
1168  endif
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"
1176  # endif
1177  set found=0
1178  set ix=1
1179  set list=""
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"
1189         @ found ++
1190      endif
1191      @ ix ++
1192  end
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
1200 -    rm $list
1201 -    echo All parts of this ${totalnum}-part message have now been read.
1202 -    metamail -d  ${TREEROOT}/$id/FULL
1203 +    rm "$list"
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"
1215      cd
1216 -    rmdir ${TREEROOT}/$id
1217 -    rmdir ${TREEROOT} >& /dev/null
1218 +    rmdir "${TREEROOT}/$id"
1219 +    rmdir "${TREEROOT}" >& /dev/null
1220  else
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.
1225      else
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.
1228      endif
1229      echo When you have read them all, then you will see the message in full.
1230  endif
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
1234 @@ -23,7 +23,7 @@
1235  set X_VIEWER="xloadimage -view -quiet -geometry +1+1"
1236  # set X_VIEWER="xv -geometry +1+1"
1237  endif
1238 -if ($1 == "-viewer" && $#argv > 1) then
1239 +if ("$1" == "-viewer" && $#argv > 1) then
1240      set X_VIEWER = "$2"
1241      shift
1242      shift
1243 @@ -40,7 +40,15 @@
1244      echo be able to see the picture properly.
1245      echo ""
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
1253 +        else
1254 +            set fname=${METAMAIL_TMPDIR}/sp.$$
1255 +            rm -rf $fname
1256 +        endif
1257          echo "The picture is being automatically stored in the file $fname"
1258          echo "If you do not want this file, please delete it."
1259      else
1260 @@ -50,20 +58,28 @@
1261          while ( 1 == 1)
1262              echo -n "File name:"
1263              set fname=$<
1264 -            if (! -f $fname) then
1265 +            if (! -f "$fname") then
1266                  break
1267              else
1268                  echo "$fname already exists. Try again"
1269              endif
1270          end
1271      endif
1272 -    cp $1 $fname
1273 -    if ($status == 0) echo Wrote file $fname
1274 +    cp "$1" "$fname"
1275 +    if ($status == 0) echo Wrote file "$fname"
1276      exit 0
1277  endif
1278  
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
1286 +    else
1287 +        set SQUIRREL=${METAMAIL_TMPDIR}/sp.$$
1288 +        rm -rf $SQUIRREL
1289 +    endif
1290      cat > $SQUIRREL
1291  else
1292      set SQUIRREL="$*"
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
1296 @@ -12,7 +12,7 @@
1297         exit 1
1298  endif
1299  
1300 -uudecode -o $fn < $1
1301 +uudecode -o $fn < "$1"
1302  
1303  audiotool $fn
1304 -rm -f $fn $1
1305 +rm -f $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
1309 @@ -8,6 +8,10 @@
1310  # $2 is untrustworthy data. Quote it.
1311  #
1312  mkdir /tmp/decode.$$
1313 +if ( $status != 0 ) then
1314 +    echo "Error: cannot create temporary directory"
1315 +    exit 1
1316 +endif
1317  cd /tmp/decode.$$
1318  
1319  if (! $?METAMAIL_PAGER) then
1320 @@ -21,7 +25,7 @@
1321             exit 1
1322      endif
1323  
1324 -    uudecode -o $fn $1
1325 +    uudecode -o $fn "$1"
1326  
1327      echo "The following file was uudecoded:"
1328      echo ""
1329 @@ -40,21 +44,21 @@
1330         echo -n "Which do you prefer (1 - 3)? [$defans] "
1331  
1332         set ans = $< 
1333 -       if (x$ans == x) then
1334 +       if ("x$ans" == x) then
1335             set ans = $defans
1336         endif
1337 -       if ($ans == 3)  then
1338 -           rm $1
1339 +       if ("$ans" == 3)  then
1340 +           rm "$1"
1341             cd /tmp; /bin/rm -rf /tmp/decode.$$
1342             exit 0
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
1348             set nfn = ""
1349             echo -n "Save as: $HOME/"
1350             set nfn = $<
1351 -           if (x$nfn != x) then
1352 -               /bin/cp $fn ${HOME}/$nfn
1353 +           if ("x$nfn" != x) then
1354 +               /bin/cp $fn "${HOME}/$nfn"
1355             else
1356                 echo "Not Saved."
1357             endif
1358 @@ -64,7 +68,7 @@
1359         set defans = "3"
1360      end
1361  else
1362 -    ${METAMAIL_PAGER} $1
1363 +    ${METAMAIL_PAGER} "$1"
1364  endif
1365  
1366  
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
1370 @@ -8,10 +8,19 @@
1371      set METAMAIL_TMPDIR=/tmp
1372  endif
1373  
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
1380 +else
1381 +    set TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1382 +    rm -rf $TMPFILE
1383 +endif
1384 +
1385  echo "Content-type: multipart/mixed; boundary=--------" > $TMPFILE
1386  echo "" >> $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
1395 @@ -9,7 +9,16 @@
1396  if [ x$METAMAIL_TMPDIR = x ]; then
1397      METAMAIL_TMPDIR=/tmp
1398  fi
1399 -TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1400 +
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
1406 +else
1407 +    TMPFILE=${METAMAIL_TMPDIR}/suntomime.$$
1408 +    rm -rf $TMPFILE
1409 +fi
1410  
1411  /bin/nawk '
1412    BEGIN { printf("Content-type: multipart/mixed; boundary=--------\n\n")
1413 @@ -36,7 +45,7 @@
1414        print
1415    }
1416    END { printf("----------\n") }
1417 -' $1 > $TMPFILE
1418 +' "$1" > $TMPFILE
1419  
1420  metamail -z $TMPFILE
1421  rm -f $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
1425 @@ -61,6 +61,7 @@
1426  #endif
1427  
1428  extern char *malloc(), *realloc(), *index(), *getmyname();
1429 +extern FILE *Fopen();
1430  struct mailpart *CreateNewPart();
1431  
1432  /* The main data structure for the multiple parts of the mail */
1433 @@ -208,7 +209,7 @@
1434         pager = getenv("PAGER");
1435  
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");
1442 @@ -594,7 +595,7 @@
1443      }
1444      FirstPart = NewPart();
1445      CurrentPart = FirstPart;
1446 -    fpout = fopen(CurrentPart->filename, "w");
1447 +    fpout = Fopen(CurrentPart->filename, "w");
1448      if (!fpout) {
1449          fprintf(stderr, "mailto:  Can't open temporary file %s\n", CurrentPart->filename);
1450          cleanexit(-1);
1451 @@ -681,7 +682,7 @@
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");
1457                      if (!fpout) {
1458                          fprintf(stderr, "mailto:  Can't open temporary file %s\n", CurrentPart->filename);
1459                          cleanexit(-1);
1460 @@ -720,7 +721,7 @@
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");
1466                      if (!fpout) {
1467                          fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
1468                          break;
1469 @@ -732,7 +733,7 @@
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");
1475                      if (!fpout) {
1476                          fprintf(stderr, "mailto:  Can't open temporary file %s\n", CurrentPart->filename);
1477                          cleanexit(-1);
1478 @@ -811,11 +812,11 @@
1479                      char Cmd[TMPFILE_NAME_SIZE + 15];
1480                      char *s=tmpname();
1481                      fclose(fpout);
1482 -                    fptmp = fopen(s, "w");
1483 +                    fptmp = Fopen(s, "w");
1484                      WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1485                      TempCloseStyles(fptmp);
1486                      fclose(fptmp);
1487 -                    fpout = fopen(CurrentPart->filename, "a");
1488 +                    fpout = Fopen(CurrentPart->filename, "a");
1489                      if (!fpout) {
1490                          fprintf(stderr, "mailto:  Can't open temporary file %s\n", CurrentPart->filename);
1491                          cleanexit(-1);
1492 @@ -899,7 +900,7 @@
1493                      char *fname;
1494                      fclose(fpout);
1495                      fname = start;
1496 -                    fptmp = fopen(fname, "w");
1497 +                    fptmp = Fopen(fname, "w");
1498                      WriteOutMessage(fptmp, ToList, Subject, CCList, FirstPart);
1499                      TempCloseStyles(fptmp);
1500                      if(fclose(fptmp)) {
1501 @@ -907,7 +908,7 @@
1502                      } else {
1503                          printf("Wrote draft to %s\n", fname);
1504                      }
1505 -                    fpout = fopen(CurrentPart->filename, "a");
1506 +                    fpout = Fopen(CurrentPart->filename, "a");
1507                      if (!fpout) {
1508                          fprintf(stderr, "mailto:  Can't open temporary file %s\n", CurrentPart->filename);
1509                          cleanexit(-1);
1510 @@ -972,7 +973,7 @@
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");
1516                      if (!fpout) {
1517                          fprintf(stderr, "mailto: Cannot open temporary file %s\n", CurrentPart->filename);
1518                          break;
1519 @@ -994,7 +995,7 @@
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");
1525                      if (!fpout) {
1526                          fprintf(stderr, "mailto:  Can't open temporary file %s\n", CurrentPart->filename);
1527                          cleanexit(-1);
1528 @@ -1476,7 +1477,7 @@
1529      char DeadFile[1000];
1530  
1531      sprintf(DeadFile, "%s/dead.letter", gethome());
1532 -    fp = fopen(DeadFile, "w");
1533 +    fp = Fopen(DeadFile, "w");
1534      WriteOutMessage(fp, ToList, Subject, CCList, FirstPart);
1535      if(fclose(fp)) {
1536          perror("Could not write ~/dead.letter\n");
1537 @@ -1776,7 +1777,7 @@
1538              printf("Cannot read %s, data insertion cancelled\n", sdum);
1539              return(NULL);
1540          }
1541 -        fpo = fopen(mp->filename, "w");
1542 +        fpo = Fopen(mp->filename, "w");
1543          if (!fpo) {
1544              printf("Cannot open temporary file, data insertion cancelled\n");
1545              return(NULL);
1546 @@ -1794,7 +1795,7 @@
1547                  int ct;
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);
1549                  fflush(stdout);
1550 -                gets(LineBuf);
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 @@
1556                      }
1557                      if (mc) break;
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);
1559 -                    s = gets(AnsBuf);
1560 +                    s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1561                      while (s && *s && isspace((unsigned char) *s)) ++s;
1562                      if (s && (*s == 'y' || *s == 'Y')) break;
1563                      continue;
1564 @@ -1939,7 +1940,7 @@
1565              mp->encoding_type_needed = ENC_NONE;
1566          }
1567          newfilename = tmpname();
1568 -        fpout = fopen(newfilename, "w");
1569 +        fpout = Fopen(newfilename, "w");
1570          if (!fpout) {
1571              fprintf(stderr, "Cannot open file %s for writing, no data included.\n", newfilename);
1572              free(CmdBuf);
1573 @@ -2109,7 +2110,7 @@
1574               ContainsEightBitChar(FirstPart->filename)) {
1575              FirstPart->encoding_type_needed = ENC_QP;
1576          }
1577 -        fpout = fopen(FirstPart->filename, "a");
1578 +        fpout = Fopen(FirstPart->filename, "a");
1579          free(CmdBuf);
1580          free(CmdBuf2);
1581          return;
1582 @@ -2159,7 +2160,7 @@
1583          lastmp = mp;
1584          mp = mp->next;
1585      }
1586 -    fpout = fopen(lastmp->filename, "a");
1587 +    fpout = Fopen(lastmp->filename, "a");
1588      free(CmdBuf);
1589      free(CmdBuf2);
1590  }
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
1594 @@ -112,6 +112,7 @@
1595  
1596  char *FindParam();
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";
1602 @@ -580,7 +581,7 @@
1603                                  int overwriteans = -1;
1604                                  do {
1605                                      printf("File %s exists.  Do you want to overwrite it (y/n) ?\n", Fname);
1606 -                                    s = gets(AnsBuf);
1607 +                                    s = fgets(AnsBuf, sizeof(AnsBuf), stdin);
1608                                      if (!s) {
1609                                          overwriteans = 0;
1610                                      } else {
1611 @@ -646,7 +647,7 @@
1612          if (Fname[0] == 0 || Fname[0] == '\n') {
1613              ConsumeRestOfPart(NULL);
1614          } else {
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);
1619              ecode = fclose(fp);
1620 @@ -961,7 +962,7 @@
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 @@
1630  {
1631      int j;
1632      FILE *outfp;
1633 -    outfp = fopen(SquirrelFile, WRITE_BINARY);
1634 +    outfp = Fopen(SquirrelFile, WRITE_BINARY);
1635      if (!outfp) {
1636          fprintf(stderr, "Cannot open %s to squirrel away a portion of a multipart/alternative\n", SquirrelFile);
1637          return(-1);
1638 @@ -1799,7 +1800,7 @@
1639      nameBuf[(cp - def) + 4] = 0;
1640      cp++;               /* Now points to value part of environment string. */
1641  
1642 -    if ((envFile = fopen(nameBuf, "w")) == NULL) {
1643 +    if ((envFile = Fopen(nameBuf, "w")) == NULL) {
1644          return(2);
1645      }
1646  
1647 @@ -1824,7 +1825,7 @@
1648          } else {
1649              printf("This message contains '%s'-format data.\nDo you want to view it using the '%s' command (y/n) [y] ? ", ctype, ShortCommand(progname));
1650          }
1651 -        s = gets(AnsBuf);
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 @@
1657      } else {
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);
1662          if (!fp) {
1663              fprintf(stderr, "Could not open temporary file\n");
1664          } else {
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");
1671                              if (headfp) {
1672                                  fputs(mailheaders+12, headfp);
1673                                  /* The +12 gets rid of MM_HEADERS=\n */
1674 @@ -2298,7 +2299,7 @@
1675      FILE *fpout;
1676      int retval = 0;
1677  
1678 -    fpout = fopen(fname, WRITE_BINARY);
1679 +    fpout = Fopen(fname, WRITE_BINARY);
1680      if (!fpout) {
1681          perror("WriteTmpFile");
1682          ExitWithError("Can't create temporary file");
1683 @@ -2519,7 +2520,7 @@
1684      FILE *script;
1685  
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);
1690          exit(1);
1691      }
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
1695 @@ -1,6 +1,11 @@
1696  #include <stdio.h>
1697  #include <ctype.h>
1698  #include <config.h>
1699 +#include <unistd.h>
1700 +#include <string.h>
1701 +#include <errno.h>
1702 +#include <fcntl.h>
1703 +#include <sys/stat.h>
1704  #ifdef SYSV
1705  #include <unistd.h>
1706  #include <sys/utsname.h>
1707 @@ -116,5 +121,55 @@
1708          initialized = 1;
1709      }
1710      return(hostname);
1711 +}
1712 +
1713 +
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;
1724 +{
1725 +#ifdef MSDOS
1726 +return(fopen(Fopen_path,Fopen_mode));
1727 +#else
1728 +int Fopen_fd;
1729 +struct stat Fopen_sb;
1730 +int Fopen_appendmode = 0;
1731 +int Fopen_readmode = 0;
1732 +int Fopen_openflags = 0;
1733 +int Fopen_r;
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) ) )
1739 +    {
1740 +    errno = EINVAL ;
1741 +    return( (FILE *)0 );
1742 +    }
1743 +if ( Fopen_appendmode )
1744 +    {
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) );
1749 +    }
1750 +if ( Fopen_readmode )
1751 +    Fopen_openflags = O_RDWR|O_CREAT|O_EXCL ;
1752 +else
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 );
1760 +#endif
1761  }
1762  
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
1766 @@ -26,6 +26,7 @@
1767  #include <config.h>
1768  #include <ctype.h>
1769  #include <time.h>
1770 +#include <fcntl.h>
1771  
1772  #define MINCHUNKSIZE 20000 /* Better be enough to hold the headers, or we die! */
1773  extern char *malloc(), *index(), *getmyname();
1774 @@ -243,6 +244,7 @@
1775  char *deliverycmd, *prefix, *SharedHeaders, *SubjectBuf, *id, *MessageID, *bigbuf, *OrigID;
1776  {
1777      FILE *fpout;
1778 +    int fd;
1779      char OutputFile[1000];
1780      int code;
1781  #if defined(sequent)
1782 @@ -255,7 +257,11 @@
1783          fpout = popen(deliverycmd, "w");
1784      } else {
1785          sprintf(OutputFile, "%s%d", prefix, whichpart);
1786 -        fpout = fopen(OutputFile, "w");
1787 +        /* fpout = fopen(OutputFile, "w"); */
1788 +        remove(OutputFile);
1789 +        fpout = NULL;
1790 +        fd = open(OutputFile, O_WRONLY|O_CREAT|O_EXCL, 0600);
1791 +        if ( fd > -1 ) fpout = fdopen(fd, "w");
1792      }
1793      if (!fpout) {
1794         fprintf(stderr, "splitmail: Can't open %s for writing\n", DoDeliver ? deliverycmd : OutputFile);
This page took 0.188306 seconds and 2 git commands to generate.