aboutsummaryrefslogtreecommitdiff
path: root/src/xz/file_io.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2021-01-11 23:41:16 +0200
committerLasse Collin <lasse.collin@tukaani.org>2021-01-11 23:41:16 +0200
commit074259f4f3966aeac6edb205fecbc1a8d2b58bb2 (patch)
tree1a7f4ffedfe9ce2cd36f56ff23156db3b5d4ae43 /src/xz/file_io.c
parentScripts: Fix exit status of xzgrep. (diff)
downloadxz-074259f4f3966aeac6edb205fecbc1a8d2b58bb2.tar.xz
xz: Make --keep accept symlinks, hardlinks, and setuid/setgid/sticky.
Previously this required using --force but that has other effects too which might be undesirable. Changing the behavior of --keep has a small risk of breaking existing scripts but since this is a fairly special corner case I expect the likehood of breakage to be low enough. I think the new behavior is more logical. The only reason for the old behavior was to be consistent with gzip and bzip2. Thanks to Vincent Lefevre and Sebastian Andrzej Siewior.
Diffstat (limited to 'src/xz/file_io.c')
-rw-r--r--src/xz/file_io.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/xz/file_io.c b/src/xz/file_io.c
index e1a37d5f..80b56d38 100644
--- a/src/xz/file_io.c
+++ b/src/xz/file_io.c
@@ -536,8 +536,9 @@ io_open_src_real(file_pair *pair)
}
// Symlinks are not followed unless writing to stdout or --force
- // was used.
- const bool follow_symlinks = opt_stdout || opt_force;
+ // or --keep was used.
+ const bool follow_symlinks
+ = opt_stdout || opt_force || opt_keep_original;
// We accept only regular files if we are writing the output
// to disk too. bzip2 allows overriding this with --force but
@@ -674,7 +675,7 @@ io_open_src_real(file_pair *pair)
}
#ifndef TUKLIB_DOSLIKE
- if (reg_files_only && !opt_force) {
+ if (reg_files_only && !opt_force && !opt_keep_original) {
if (pair->src_st.st_mode & (S_ISUID | S_ISGID)) {
// gzip rejects setuid and setgid files even
// when --force was used. bzip2 doesn't check
@@ -683,7 +684,7 @@ io_open_src_real(file_pair *pair)
// and setgid bits there.
//
// We accept setuid and setgid files if
- // --force was used. We drop these bits
+ // --force or --keep was used. We drop these bits
// explicitly in io_copy_attr().
message_warning(_("%s: File has setuid or "
"setgid bit set, skipping"),