From fc2689100470c2feae5d70c01efa073294bb8b1e Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 23 May 2011 09:40:21 +0000 Subject: [PATCH] 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 --- usr.bin/gzip/gzip.1 | 8 ++++---- usr.bin/gzip/gzip.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.bin/gzip/gzip.1 b/usr.bin/gzip/gzip.1 index 848a4b391c94..c0dc670a2cf2 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 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 diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index 474575caf9a0..927493eced7d 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -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 .gz if we're decompressing */ if (dflag && s == NULL && errno == ENOENT) { len = strlen(path);