summaryrefslogtreecommitdiff
path: root/comms/mgetty+sendfax/patches/patch-aa
blob: 486fc9f36a9cd5ac4b611dee084322e776484477 (plain)
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
$NetBSD: patch-aa,v 1.5 2009/10/03 11:43:49 is Exp $

--- fax/faxspool.in.orig	2007-01-19 08:38:22.000000000 +0100
+++ fax/faxspool.in
@@ -407,11 +407,11 @@ fs_cvt_pdf()
 
 # user name (for fax header only! auth is done by faxq-helper via getuid())
 ##########
-if user=`logname 2>/dev/null`
-then :
+if [ `id -u` = 0 ]; then
+    user=root
 else
     id=`id`
-    user=`expr "$id" : "[^( ]*(\([^)]*\)"`
+    user=`logname`
 fi
 test -z "$user" && user=$LOGNAME
 test -z "$user" && user=$USER
@@ -653,12 +653,14 @@ fi
 #
 # mkdir a directory in $TMP (or /tmp), convert input to G3 in there
 #
-spooldir=${TMP:-/tmp}/$new_seq.$$.`date +%S`
+spooldirprefix=$new_seq.$$.`date +%S`
+spooldir=`mktemp -d -t $spooldirprefix`
 
-if ( umask 077 ; mkdir $spooldir ) ; then
-    $echo "spooling to $spooldir (->$new_seq)..."
-else
+if [ $? -ne 0 ] 
+then
     $echo "ERROR: can't create work dir '$spooldir', giving up" >&2 ; exit 6
+else
+    $echo "spooling to $spooldir (->$new_seq)..."
 fi
 
 #
@@ -675,9 +677,9 @@ do
     if [ x$file = x- ]
     then
 	$echo "spooling $file (stdin)..."
-	trap "rm /tmp/faxsp.$$" 0
-        cat - >/tmp/faxsp.$$
-	file=/tmp/faxsp.$$
+	file=`mktemp -t faxsp.$$`
+	trap "rm $file" 0
+        cat - > $file
     else
 	$echo "spooling $file..."
     fi