Mimic gzip chown(gid), chmod(), chown(uid) Behavior

Avoids a race condition in which we unintentionally open up permissions to
the wrong group.
This commit is contained in:
W. Felix Handte
2023-01-18 11:57:54 -08:00
parent 1e3eba65a6
commit 0d2d460223
5 changed files with 18 additions and 4 deletions
@@ -3,6 +3,7 @@
set -e
datagen > file
chmod 642 file
zstd file -q --trace-file-stat -o file.zst
zstd -tq file.zst
@@ -35,7 +35,7 @@ Trace:FileStat: > UTIL_stat(file.zst)
Trace:FileStat: < 1
Trace:FileStat: > UTIL_utime(file.zst)
Trace:FileStat: < 0
Trace:FileStat: > UTIL_chmod(file.zst, 420)
Trace:FileStat: > UTIL_chmod(file.zst, 418)
Trace:FileStat: > chmod
Trace:FileStat: < 0
Trace:FileStat: < 0
@@ -3,5 +3,6 @@
set -e
datagen | zstd -q > file.zst
chmod 642 file.zst
zstd -dq --trace-file-stat file.zst
@@ -31,7 +31,7 @@ Trace:FileStat: > UTIL_stat(file)
Trace:FileStat: < 1
Trace:FileStat: > UTIL_utime(file)
Trace:FileStat: < 0
Trace:FileStat: > UTIL_chmod(file, 420)
Trace:FileStat: > UTIL_chmod(file, 418)
Trace:FileStat: > chmod
Trace:FileStat: < 0
Trace:FileStat: < 0