patch-src_bin_showpartial 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. $OpenBSD: patch-src_bin_showpartial,v 1.1 2012/03/17 10:57:23 sthen Exp $
  2. --- src/bin/showpartial.orig Wed Feb 2 23:21:29 1994
  3. +++ src/bin/showpartial Sat Mar 17 10:51:52 2012
  4. @@ -2,23 +2,59 @@
  5. # (The "-fb" might need to be changed to "-f" on some systems)
  6. #
  7. +# Check argument integrity. Don't trust mail headers
  8. +switch ("$1$2$3$4")
  9. +case "*[\t ]*":
  10. + echo "Illegal white space in arguments\!"
  11. + echo "Command was:"
  12. + echo "'$0' '$1' '$2' '$3' '$4'"
  13. + exit 2
  14. +endsw
  15. +
  16. +# Set a sensible value for the temporary directory, if its not
  17. +# already set. If TMPDIR is set previously, then we will
  18. +# assume it is adequately protected.
  19. if (! $?METAMAIL_TMPDIR) then
  20. - set METAMAIL_TMPDIR=/tmp
  21. + if ($?TMPDIR) then
  22. + set METAMAIL_TMPDIR="$TMPDIR"
  23. + else
  24. + set METAMAIL_TMPDIR=~/metamail_tmp
  25. + endif
  26. endif
  27. +# Set a sensible umask value
  28. +umask 077
  29. +
  30. +# Make sure that the temporary directory is available
  31. +if (! -d "$METAMAIL_TMPDIR") then
  32. +
  33. + if (! -e "$METAMAIL_TMPDIR") then
  34. + mkdir "$METAMAIL_TMPDIR"
  35. + else
  36. + echo "$METAMAIL_TMPDIR exists, but is not a directory"
  37. + exit 2
  38. + endif
  39. +
  40. + if ( $status != 0 || ! -d "$METAMAIL_TMPDIR" ) then
  41. + echo "Error creating $METAMAIL_TMPDIR"
  42. + exit 2
  43. + endif
  44. +
  45. +endif
  46. +
  47. set TREEROOT=${METAMAIL_TMPDIR}/m-prts-`whoami`
  48. if ($#argv < 3 || $#argv > 4) then
  49. echo "Usage: showpartial file id partnum totalnum"
  50. exit -1
  51. endif
  52. -set file=$1
  53. +set file="$1"
  54. # This next line is because message-id can contain weird chars
  55. -set id=`echo $2 | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\`
  56. -@ partnum = $3
  57. -if ($#argv == 3 || $4 == "") then
  58. +set id=`echo "$2" | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\`
  59. +@ partnum = "$3"
  60. +if ($#argv == 3 || "$4" == "") then
  61. set totalnum=-1
  62. else
  63. - @ totalnum = $4
  64. + @ totalnum = "$4"
  65. endif
  66. if (! -d $TREEROOT) then
  67. @@ -35,9 +71,9 @@ if (! -d ${TREEROOT}/$id) then
  68. exit -1
  69. endif
  70. endif
  71. -cp $file ${TREEROOT}/$id/$partnum
  72. +cp "$file" ${TREEROOT}/$id/$partnum
  73. if ($status) then
  74. - echo cp $file ${TREEROOT}/$id/$partnum failed
  75. + echo cp "$file" ${TREEROOT}/$id/$partnum failed
  76. exit -1
  77. endif
  78. if ($totalnum == -1) then