Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gzip: Set file flags after setting file times #21

Closed

Conversation

ricardobranco777
Copy link
Contributor

gzip(1) cannot preserve utimes() because it first sets chflags()

$ /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

@liweitianux
Copy link
Member

See also: freebsd/freebsd-src@c7b6525

dragonflybot pushed a commit that referenced this pull request Mar 6, 2024
Only set the source file flags on the target file after the timestamp
has been set; otherwise setting the timestamp will fail if the flags
don't permit it (i.e., uchg).

To reproduce the issue:
$ /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

GitHub PR: #21
See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=120208
@liweitianux
Copy link
Member

Committed. I'll also cherry-pick it to the 6.4 release. Thank you, @ricardobranco777.

dragonflybot pushed a commit that referenced this pull request Mar 6, 2024
Only set the source file flags on the target file after the timestamp
has been set; otherwise setting the timestamp will fail if the flags
don't permit it (i.e., uchg).

To reproduce the issue:
$ /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

GitHub PR: #21
See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=120208
@ricardobranco777 ricardobranco777 deleted the gzip_times branch March 6, 2024 10:01
iteratee pushed a commit to iteratee/DragonFlyBSD that referenced this pull request Mar 13, 2024
…ime()

Partially based on OpenBSD's wg code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants