From owner-freebsd-bugs@FreeBSD.ORG Fri Feb 1 16:00:05 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 470E316A41B for ; Fri, 1 Feb 2008 16:00:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 27B4213C467 for ; Fri, 1 Feb 2008 16:00:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m11G05kO000914 for ; Fri, 1 Feb 2008 16:00:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m11G05hB000913; Fri, 1 Feb 2008 16:00:05 GMT (envelope-from gnats) Resent-Date: Fri, 1 Feb 2008 16:00:05 GMT Resent-Message-Id: <200802011600.m11G05hB000913@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ighighi Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 274A616A46D for ; Fri, 1 Feb 2008 15:54:30 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 1887013C4FF for ; Fri, 1 Feb 2008 15:54:30 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m11FqbLd065814 for ; Fri, 1 Feb 2008 15:52:37 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m11FqbO4065813; Fri, 1 Feb 2008 15:52:37 GMT (envelope-from nobody) Message-Id: <200802011552.m11FqbO4065813@www.freebsd.org> Date: Fri, 1 Feb 2008 15:52:37 GMT From: Ighighi To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/120208: [patch]: gzip cannot preserve utimes() because it first sets chflags() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2008 16:00:05 -0000 >Number: 120208 >Category: bin >Synopsis: [patch]: gzip cannot preserve utimes() because it first sets chflags() >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 01 16:00:04 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Ighighi >Release: 6.3-STABLE >Organization: >Environment: FreeBSD orion 6.3-STABLE FreeBSD 6.3-STABLE #0: Fri Jan 25 17:39:39 VET 2008 root@orion.nebula.mil:/usr/obj/usr/src/sys/CUSTOM i386 >Description: gzip(1) cannot preserve file's times from input files because it first sets the file's flags. It happens with the immutable flag. >How-To-Repeat: $ /usr/bin/touch /tmp/foo $ /bin/chflags uchg /tmp/foo $ /usr/bin/gzip -v /tmp/foo gzip: couldn't utimes: /tmp/foo.gz: Operation not permitted /tmp/foo: -99.9% -- replaced with /tmp/foo.gz >Fix: Attached patch available Patch attached with submission follows: --- gzip.c.orig 2007-08-05 22:31:25.000000000 -0400 +++ gzip.c 2008-02-01 11:08:35.953127226 -0430 @@ -1075,14 +1077,14 @@ copymodes(int fd, const struct stat *sbp if (fchmod(fd, sb.st_mode) < 0) maybe_warn("couldn't fchmod: %s", file); - /* only try flags if they exist already */ - if (sb.st_flags != 0 && fchflags(fd, sb.st_flags) < 0) - maybe_warn("couldn't fchflags: %s", file); - TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atimespec); TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtimespec); if (futimes(fd, times) < 0) maybe_warn("couldn't utimes: %s", file); + + /* only try flags if they exist already */ + if (sb.st_flags != 0 && fchflags(fd, sb.st_flags) < 0) + maybe_warn("couldn't fchflags: %s", file); } #endif >Release-Note: >Audit-Trail: >Unformatted: