Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 May 2011 09:40:21 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r222211 - head/usr.bin/gzip
Message-ID:  <201105230940.p4N9eLQ1014007@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon May 23 09:40:21 2011
New Revision: 222211
URL: http://svn.freebsd.org/changeset/base/222211

Log:
  Match symbolic link handling behavior with GNU gzip, bzip2 and xz:
  
  When we are operating on a symbolic link pointing to an existing
  file, bail out by default, but go ahead if -f is specified.
  
  Submitted by:	arundel
  MFC after:	2 weeks

Modified:
  head/usr.bin/gzip/gzip.1
  head/usr.bin/gzip/gzip.c

Modified: head/usr.bin/gzip/gzip.1
==============================================================================
--- head/usr.bin/gzip/gzip.1	Mon May 23 09:02:44 2011	(r222210)
+++ head/usr.bin/gzip/gzip.1	Mon May 23 09:40:21 2011	(r222211)
@@ -25,7 +25,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd April 27, 2010
+.Dd May 23, 2011
 .Dt GZIP 1
 .Os
 .Sh NAME
@@ -127,9 +127,9 @@ stream, leaving files intact.
 This option selects decompression rather than compression.
 .It Fl f , -force
 This option turns on force mode.
-This allows files with multiple links, overwriting of pre-existing
-files, reading from or writing to a terminal, and when combined
-with the
+This allows files with multiple links, symbolic links to regular files,
+overwriting of pre-existing files, reading from or writing to a terminal,
+and when combined with the
 .Fl c
 option, allowing non-compressed data to pass through unchanged.
 .It Fl h , -help

Modified: head/usr.bin/gzip/gzip.c
==============================================================================
--- head/usr.bin/gzip/gzip.c	Mon May 23 09:02:44 2011	(r222210)
+++ head/usr.bin/gzip/gzip.c	Mon May 23 09:40:21 2011	(r222211)
@@ -1782,7 +1782,7 @@ handle_pathname(char *path)
 	}
 
 retry:
-	if (stat(path, &sb) != 0) {
+	if (stat(path, &sb) != 0 || (fflag == 0 && lstat(path, &sb) != 0)) {
 		/* lets try <path>.gz if we're decompressing */
 		if (dflag && s == NULL && errno == ENOENT) {
 			len = strlen(path);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105230940.p4N9eLQ1014007>