Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Nov 2010 18:24:09 +0000
From:      Alexander Best <arundel@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   changing gzip's symlink handling to be consistent with bzip2, xz and GNU gzip
Message-ID:  <20101115182409.GA97839@freebsd.org>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
hi there,

any thoughts on this patch? it changes the semantics of gzip so that it is
consistent with the semantics of bzip2, xz and for more important GNU gzip.

cheers.
alex

-- 
a13x

[-- Attachment #2 --]
diff --git a/usr.bin/gzip/gzip.1 b/usr.bin/gzip/gzip.1
index 848a4b3..8eab82c 100644
--- a/usr.bin/gzip/gzip.1
+++ b/usr.bin/gzip/gzip.1
@@ -25,7 +25,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd April 27, 2010
+.Dd November 15, 2010
 .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
diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c
index d86e84b..15fcf95 100644
--- a/usr.bin/gzip/gzip.c
+++ b/usr.bin/gzip/gzip.c
@@ -1781,7 +1781,7 @@ handle_pathname(char *path)
 	}
 
 retry:
-	if (stat(path, &sb) != 0) {
+	if (fflag && 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?20101115182409.GA97839>