author | Jan Noha <jan.noha@oracle.com> |
Thu, 29 Jan 2015 08:22:55 -0800 | |
changeset 3799 | c3e697abd23b |
parent 1852 | 5bcaefde0b64 |
child 5880 | caab292318a0 |
permissions | -rw-r--r-- |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
1 |
From b3b5611e046b93fb20aa783d6d11d986f33f91f6 Mon Sep 17 00:00:00 2001 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
2 |
From: Paul Eggert <eggert <at> cs.ucla.edu> |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
3 |
Date: Thu, 3 Oct 2013 21:12:09 -0700 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
4 |
Subject: [PATCH] znew: avoid denial-of-service issue |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
5 |
|
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
6 |
Reported by Rich Burridge in <http://bugs.gnu.org/15522>. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
7 |
* znew.in: Rewrite to avoid the need for a temporary file in /tmp. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
8 |
That way, we avoid the need for set -C |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
9 |
and worrying about denial of service. |
1852
5bcaefde0b64
18385582 compress/gzip package bringing in extra dependancies with fix for 15440739
Vladimir Marek <Vladimir.Marek@oracle.com>
parents:
1509
diff
changeset
|
10 |
Use touch -r and python rather than cpmod. |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
11 |
Assume cp -p works, as it's now universal. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
12 |
Quote 'echo' args better, while we're at it. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
13 |
(warn, tmp, cpmod, cpmodarg): Remove. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
14 |
(GZIP): Unset, so that we needn't test for gzip extension. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
15 |
(ext): Now always '.gz'. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
16 |
* znew.1: Document the change of implementation assumptions. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
17 |
--- |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
18 |
diff --git a/znew.1 b/znew.1 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
19 |
index dcdf84f..2a7e5e1 100644 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
20 |
--- a/znew.1 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
21 |
+++ b/znew.1 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
22 |
@@ -32,9 +32,16 @@ Keep a .Z file when it is smaller than the .gz file; implies |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
23 |
.SH "SEE ALSO" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
24 |
gzip(1), zmore(1), zdiff(1), zgrep(1), zforce(1), gzexe(1), compress(1) |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
25 |
.SH BUGS |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
26 |
-.I Znew |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
27 |
-does not maintain the time stamp with the -P option if |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
28 |
-.I cpmod(1) |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
29 |
-is not available and |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
30 |
-.I touch(1) |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
31 |
-does not support the -r option. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
32 |
+If the |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
33 |
+.B \-P |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
34 |
+option is used, |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
35 |
+.I znew |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
36 |
+does not maintain the time stamp if |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
37 |
+.IR touch (1) |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
38 |
+does not support the |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
39 |
+.B \-r |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
40 |
+option, and does not maintain permissions if |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
41 |
+.IR chmod (1) |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
42 |
+does not support the |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
43 |
+.B \-\-reference |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
44 |
+option. |
1852
5bcaefde0b64
18385582 compress/gzip package bringing in extra dependancies with fix for 15440739
Vladimir Marek <Vladimir.Marek@oracle.com>
parents:
1509
diff
changeset
|
45 |
--- gzip-1.5/znew.in 2014-04-24 14:54:00.798820086 +0200 |
5bcaefde0b64
18385582 compress/gzip package bringing in extra dependancies with fix for 15440739
Vladimir Marek <Vladimir.Marek@oracle.com>
parents:
1509
diff
changeset
|
46 |
+++ gzip-1.5/znew.in 2014-04-24 14:53:49.388094138 +0200 |
1509
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
47 |
@@ -21,7 +21,7 @@ |
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
48 |
case $1 in |
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
49 |
--__bindir) bindir=${2?}; shift; shift;; |
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
50 |
esac |
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
51 |
-PATH=$bindir:$PATH; export PATH |
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
52 |
+PATH=/usr/gnu/bin:$bindir:$PATH; export PATH |
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
53 |
|
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
54 |
version="znew (gzip) @VERSION@ |
9b41420b4385
17601897 The gznew script should have /usr/gnu/bin at the front of its PATH.
Rich Burridge <rich.burridge@oracle.com>
parents:
1503
diff
changeset
|
55 |
Copyright (C) 2010-2012 Free Software Foundation, Inc. |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
56 |
@@ -58,33 +58,9 @@ new=0 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
57 |
block=1024 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
58 |
# block is the disk block size (best guess, need not be exact) |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
59 |
|
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
60 |
-warn="(does not preserve modes and timestamp)" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
61 |
-tmp=${TMPDIR-/tmp}/zfoo.$$ |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
62 |
-set -C |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
63 |
-echo hi > $tmp || exit |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
64 |
-if test -z "`(${CPMOD-cpmod} $tmp $tmp) 2>&1`"; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
65 |
- cpmod=${CPMOD-cpmod} |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
66 |
- warn="" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
67 |
-fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
68 |
- |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
69 |
-if test -z "$cpmod" && ${TOUCH-touch} -r $tmp $tmp 2>/dev/null; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
70 |
- cpmod="${TOUCH-touch}" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
71 |
- cpmodarg="-r" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
72 |
- warn="(does not preserve file modes)" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
73 |
-fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
74 |
- |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
75 |
-# check if GZIP env. variable uses -S or --suffix |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
76 |
-gzip -q $tmp |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
77 |
-ext=`echo $tmp* | sed "s|$tmp||"` |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
78 |
-rm -f $tmp* |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
79 |
-if test -z "$ext"; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
80 |
- echo znew: error determining gzip extension |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
81 |
- exit 1 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
82 |
-fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
83 |
-if test "$ext" = ".Z"; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
84 |
- echo znew: cannot use .Z as gzip extension. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
85 |
- exit 1 |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
86 |
-fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
87 |
+# Beware -s or --suffix in $GZIP. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
88 |
+unset GZIP |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
89 |
+ext=.gz |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
90 |
|
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
91 |
for arg |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
92 |
do |
3799
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
93 |
@@ -116,26 +92,33 @@ if test -n "$opt"; then |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
94 |
fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
95 |
|
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
96 |
for i do |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
97 |
- n=`echo $i | sed 's/.Z$//'` |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
98 |
+ n=`echo "$i" | sed 's/.Z$//'` |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
99 |
if test ! -f "$n.Z" ; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
100 |
- echo $n.Z not found |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
101 |
+ echo "$n.Z not found" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
102 |
res=1; continue |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
103 |
fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
104 |
test $keep -eq 1 && old=`wc -c < "$n.Z"` |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
105 |
if test $pipe -eq 1; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
106 |
if gzip -d < "$n.Z" | gzip $opt > "$n$ext"; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
107 |
# Copy file attributes from old file to new one, if possible. |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
108 |
- test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n$ext" 2> /dev/null |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
109 |
+ touch -r"$n.Z" -- "$n$ext" 2>/dev/null |
3799
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
110 |
+ python - "$n.Z" "$n$ext" <<-EOF |
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
111 |
+ import os |
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
112 |
+ import sys |
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
113 |
+ import stat |
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
114 |
+ mode = stat.S_IMODE(os.stat(sys.argv[1]).st_mode) |
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
115 |
+ os.chmod(sys.argv[2], mode) |
c3e697abd23b
20438436 gznew script calling python causes indentation error
Jan Noha <jan.noha@oracle.com>
parents:
1852
diff
changeset
|
116 |
+ EOF |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
117 |
else |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
118 |
- echo error while recompressing $n.Z |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
119 |
+ echo "error while recompressing $n.Z" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
120 |
res=1; continue |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
121 |
fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
122 |
else |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
123 |
if test $check -eq 1; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
124 |
- if cp -p "$n.Z" "$n.$$" 2> /dev/null || cp "$n.Z" "$n.$$"; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
125 |
+ if cp -p "$n.Z" "$n.$$"; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
126 |
: |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
127 |
else |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
128 |
- echo cannot backup "$n.Z" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
129 |
+ echo "cannot backup $n.Z" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
130 |
res=1; continue |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
131 |
fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
132 |
fi |
1852
5bcaefde0b64
18385582 compress/gzip package bringing in extra dependancies with fix for 15440739
Vladimir Marek <Vladimir.Marek@oracle.com>
parents:
1509
diff
changeset
|
133 |
@@ -143,7 +125,7 @@ for i do |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
134 |
: |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
135 |
else |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
136 |
test $check -eq 1 && mv "$n.$$" "$n.Z" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
137 |
- echo error while uncompressing $n.Z |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
138 |
+ echo "error while uncompressing $n.Z" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
139 |
res=1; continue |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
140 |
fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
141 |
if gzip $opt "$n"; then |
1852
5bcaefde0b64
18385582 compress/gzip package bringing in extra dependancies with fix for 15440739
Vladimir Marek <Vladimir.Marek@oracle.com>
parents:
1509
diff
changeset
|
142 |
@@ -151,10 +133,10 @@ for i do |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
143 |
else |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
144 |
if test $check -eq 1; then |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
145 |
mv "$n.$$" "$n.Z" && rm -f "$n" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
146 |
- echo error while recompressing $n |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
147 |
+ echo "error while recompressing $n" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
148 |
else |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
149 |
# compress $n (might be dangerous if disk full) |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
150 |
- echo error while recompressing $n, left uncompressed |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
151 |
+ echo "error while recompressing $n, left uncompressed" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
152 |
fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
153 |
res=1; continue |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
154 |
fi |
1852
5bcaefde0b64
18385582 compress/gzip package bringing in extra dependancies with fix for 15440739
Vladimir Marek <Vladimir.Marek@oracle.com>
parents:
1509
diff
changeset
|
155 |
@@ -175,7 +157,7 @@ for i do |
1503
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
156 |
else |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
157 |
test $pipe -eq 0 && mv "$n.$$" "$n.Z" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
158 |
rm -f "$n$ext" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
159 |
- echo error while testing $n$ext, $n.Z unchanged |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
160 |
+ echo "error while testing $n$ext, $n.Z unchanged" |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
161 |
res=1; continue |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
162 |
fi |
b106d9f581c1
15440739 SUNBT6633578 gzcmp/gzdiff + gznew shell scripts use temporary files unsafely
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
163 |
elif test $pipe -eq 1; then |