components/gzip/patches/znew.patch
branchs11u2-sru
changeset 3388 68cefdb716e2
parent 2799 1d47fff1ffff
child 3811 6e696f960e14
equal deleted inserted replaced
3385:cb76431f36d7 3388:68cefdb716e2
     5 
     5 
     6 Reported by Rich Burridge in <http://bugs.gnu.org/15522>.
     6 Reported by Rich Burridge in <http://bugs.gnu.org/15522>.
     7 * znew.in: Rewrite to avoid the need for a temporary file in /tmp.
     7 * znew.in: Rewrite to avoid the need for a temporary file in /tmp.
     8 That way, we avoid the need for set -C
     8 That way, we avoid the need for set -C
     9 and worrying about denial of service.
     9 and worrying about denial of service.
    10 Use touch -r and chmod --reference rather than cpmod.
    10 Use touch -r and python rather than cpmod.
    11 Assume cp -p works, as it's now universal.
    11 Assume cp -p works, as it's now universal.
    12 Quote 'echo' args better, while we're at it.
    12 Quote 'echo' args better, while we're at it.
    13 (warn, tmp, cpmod, cpmodarg): Remove.
    13 (warn, tmp, cpmod, cpmodarg): Remove.
    14 (GZIP): Unset, so that we needn't test for gzip extension.
    14 (GZIP): Unset, so that we needn't test for gzip extension.
    15 (ext): Now always '.gz'.
    15 (ext): Now always '.gz'.
    40 +option, and does not maintain permissions if
    40 +option, and does not maintain permissions if
    41 +.IR chmod (1)
    41 +.IR chmod (1)
    42 +does not support the
    42 +does not support the
    43 +.B \-\-reference
    43 +.B \-\-reference
    44 +option.
    44 +option.
    45 diff --git a/znew.in b/znew.in
    45 --- gzip-1.5/znew.in	2014-04-24 14:54:00.798820086 +0200
    46 index 9bd3ce9..d16311a 100644
    46 +++ gzip-1.5/znew.in	2014-04-24 14:53:49.388094138 +0200
    47 --- a/znew.in
       
    48 +++ b/znew.in
       
    49 @@ -21,7 +21,7 @@
    47 @@ -21,7 +21,7 @@
    50  case $1 in
    48  case $1 in
    51  --__bindir) bindir=${2?}; shift; shift;;
    49  --__bindir) bindir=${2?}; shift; shift;;
    52  esac
    50  esac
    53 -PATH=$bindir:$PATH; export PATH
    51 -PATH=$bindir:$PATH; export PATH
    90 +unset GZIP
    88 +unset GZIP
    91 +ext=.gz
    89 +ext=.gz
    92  
    90  
    93  for arg
    91  for arg
    94  do
    92  do
    95 @@ -116,26 +92,27 @@ if test -n "$opt"; then
    93 @@ -116,26 +92,32 @@ if test -n "$opt"; then
    96  fi
    94  fi
    97  
    95  
    98  for i do
    96  for i do
    99 -  n=`echo $i | sed 's/.Z$//'`
    97 -  n=`echo $i | sed 's/.Z$//'`
   100 +  n=`echo "$i" | sed 's/.Z$//'`
    98 +  n=`echo "$i" | sed 's/.Z$//'`
   107    if test $pipe -eq 1; then
   105    if test $pipe -eq 1; then
   108      if gzip -d < "$n.Z" | gzip $opt > "$n$ext"; then
   106      if gzip -d < "$n.Z" | gzip $opt > "$n$ext"; then
   109        # Copy file attributes from old file to new one, if possible.
   107        # Copy file attributes from old file to new one, if possible.
   110 -      test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n$ext" 2> /dev/null
   108 -      test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n$ext" 2> /dev/null
   111 +      touch -r"$n.Z" -- "$n$ext" 2>/dev/null
   109 +      touch -r"$n.Z" -- "$n$ext" 2>/dev/null
   112 +      chmod --reference="$n.Z" -- "$n$ext" 2>/dev/null
   110 +      python -c '
       
   111 +	      import os
       
   112 +	      import sys
       
   113 +	      mode = os.stat(sys.argv[1]).st_mode & 07777
       
   114 +	      os.chmod(sys.argv[2], mode)
       
   115 +      ' "$n.Z" "$n$ext"
   113      else
   116      else
   114 -      echo error while recompressing $n.Z
   117 -      echo error while recompressing $n.Z
   115 +      echo "error while recompressing $n.Z"
   118 +      echo "error while recompressing $n.Z"
   116        res=1; continue
   119        res=1; continue
   117      fi
   120      fi
   124 -        echo cannot backup "$n.Z"
   127 -        echo cannot backup "$n.Z"
   125 +        echo "cannot backup $n.Z"
   128 +        echo "cannot backup $n.Z"
   126          res=1; continue
   129          res=1; continue
   127        fi
   130        fi
   128      fi
   131      fi
   129 @@ -143,7 +120,7 @@ for i do
   132 @@ -143,7 +125,7 @@ for i do
   130        :
   133        :
   131      else
   134      else
   132        test $check -eq 1 && mv "$n.$$" "$n.Z"
   135        test $check -eq 1 && mv "$n.$$" "$n.Z"
   133 -      echo error while uncompressing $n.Z
   136 -      echo error while uncompressing $n.Z
   134 +      echo "error while uncompressing $n.Z"
   137 +      echo "error while uncompressing $n.Z"
   135        res=1; continue
   138        res=1; continue
   136      fi
   139      fi
   137      if gzip $opt "$n"; then
   140      if gzip $opt "$n"; then
   138 @@ -151,10 +128,10 @@ for i do
   141 @@ -151,10 +133,10 @@ for i do
   139      else
   142      else
   140        if test $check -eq 1; then
   143        if test $check -eq 1; then
   141          mv "$n.$$" "$n.Z" && rm -f "$n"
   144          mv "$n.$$" "$n.Z" && rm -f "$n"
   142 -        echo error while recompressing $n
   145 -        echo error while recompressing $n
   143 +        echo "error while recompressing $n"
   146 +        echo "error while recompressing $n"
   146 -        echo error while recompressing $n, left uncompressed
   149 -        echo error while recompressing $n, left uncompressed
   147 +        echo "error while recompressing $n, left uncompressed"
   150 +        echo "error while recompressing $n, left uncompressed"
   148        fi
   151        fi
   149        res=1; continue
   152        res=1; continue
   150      fi
   153      fi
   151 @@ -175,7 +152,7 @@ for i do
   154 @@ -175,7 +157,7 @@ for i do
   152      else
   155      else
   153        test $pipe -eq 0 && mv "$n.$$" "$n.Z"
   156        test $pipe -eq 0 && mv "$n.$$" "$n.Z"
   154        rm -f "$n$ext"
   157        rm -f "$n$ext"
   155 -      echo error while testing $n$ext, $n.Z unchanged
   158 -      echo error while testing $n$ext, $n.Z unchanged
   156 +      echo "error while testing $n$ext, $n.Z unchanged"
   159 +      echo "error while testing $n$ext, $n.Z unchanged"
   157        res=1; continue
   160        res=1; continue
   158      fi
   161      fi
   159    elif test $pipe -eq 1; then
   162    elif test $pipe -eq 1; then
   160 -- 
       
   161 1.8.3.1