openbsd-ports/mail/metamail/patches/patch-src_bin_showpartial
sthen cedf61320a use WRKSRC not WRKDIST and regen patches
no need for groff
regen plist
use SUBST_CMD rather than handrolled %%SYSCONFDIR%% subst
2012-03-17 10:57:23 +00:00

82 lines
2.2 KiB
Plaintext

$OpenBSD: patch-src_bin_showpartial,v 1.1 2012/03/17 10:57:23 sthen Exp $
--- src/bin/showpartial.orig Wed Feb 2 23:21:29 1994
+++ src/bin/showpartial Sat Mar 17 10:51:52 2012
@@ -2,23 +2,59 @@
# (The "-fb" might need to be changed to "-f" on some systems)
#
+# Check argument integrity. Don't trust mail headers
+switch ("$1$2$3$4")
+case "*[\t ]*":
+ echo "Illegal white space in arguments\!"
+ echo "Command was:"
+ echo "'$0' '$1' '$2' '$3' '$4'"
+ exit 2
+endsw
+
+# Set a sensible value for the temporary directory, if its not
+# already set. If TMPDIR is set previously, then we will
+# assume it is adequately protected.
if (! $?METAMAIL_TMPDIR) then
- set METAMAIL_TMPDIR=/tmp
+ if ($?TMPDIR) then
+ set METAMAIL_TMPDIR="$TMPDIR"
+ else
+ set METAMAIL_TMPDIR=~/metamail_tmp
+ endif
endif
+# Set a sensible umask value
+umask 077
+
+# Make sure that the temporary directory is available
+if (! -d "$METAMAIL_TMPDIR") then
+
+ if (! -e "$METAMAIL_TMPDIR") then
+ mkdir "$METAMAIL_TMPDIR"
+ else
+ echo "$METAMAIL_TMPDIR exists, but is not a directory"
+ exit 2
+ endif
+
+ if ( $status != 0 || ! -d "$METAMAIL_TMPDIR" ) then
+ echo "Error creating $METAMAIL_TMPDIR"
+ exit 2
+ endif
+
+endif
+
set TREEROOT=${METAMAIL_TMPDIR}/m-prts-`whoami`
if ($#argv < 3 || $#argv > 4) then
echo "Usage: showpartial file id partnum totalnum"
exit -1
endif
-set file=$1
+set file="$1"
# This next line is because message-id can contain weird chars
-set id=`echo $2 | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\`
-@ partnum = $3
-if ($#argv == 3 || $4 == "") then
+set id=`echo "$2" | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\`
+@ partnum = "$3"
+if ($#argv == 3 || "$4" == "") then
set totalnum=-1
else
- @ totalnum = $4
+ @ totalnum = "$4"
endif
if (! -d $TREEROOT) then
@@ -35,9 +71,9 @@ if (! -d ${TREEROOT}/$id) then
exit -1
endif
endif
-cp $file ${TREEROOT}/$id/$partnum
+cp "$file" ${TREEROOT}/$id/$partnum
if ($status) then
- echo cp $file ${TREEROOT}/$id/$partnum failed
+ echo cp "$file" ${TREEROOT}/$id/$partnum failed
exit -1
endif
if ($totalnum == -1) then