bin/120208: [patch]: gzip cannot preserve utimes() because it first sets chflags()

Ighighi ighighi at gmail.com
Fri Feb 1 08:00:05 PST 2008


>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 at 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(&times[0], &sb.st_atimespec);
 	TIMESPEC_TO_TIMEVAL(&times[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:


More information about the freebsd-bugs mailing list