summaryrefslogtreecommitdiff
path: root/mail/metamail/files/patch-bin_showpicture
blob: 54bf6df331b722203a68e3aaf3f0207709551308 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--- bin/showpicture.orig	1994-02-07 17:59:54 UTC
+++ bin/showpicture
@@ -15,15 +15,42 @@
 # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
 #
 
+# 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
 
 if (! $?X_VIEWER) then
-set X_VIEWER="xloadimage -view -quiet -geometry +1+1"
+  set X_VIEWER="xloadimage -view -quiet -geometry +1+1"
 # set X_VIEWER="xv -geometry +1+1"
 endif
-if ($1 == "-viewer" && $#argv > 1) then
+if ("$1" == "-viewer" && $#argv > 1) then
     set X_VIEWER = "$2"
     shift
     shift
@@ -57,7 +84,7 @@ if (! $?DISPLAY) then
             endif
         end
     endif
-    cp $1 $fname
+    cp "$1" $fname
     if ($status == 0) echo Wrote file $fname
     exit 0
 endif