diff options
author | zoulasc <christos@zoulas.com> | 2020-01-20 13:20:42 +0100 |
---|---|---|
committer | Martin Matuska <martin@matuska.org> | 2020-01-20 15:31:07 +0100 |
commit | b51d6b621533b6ea7a0a9c4770cc23c2d62a88cf (patch) | |
tree | 204b5972b4a5201ae678a38fd25b670c1f48a14c /tar/cmdline.c | |
parent | 06721c2ad050be144e4cc1719f197fbcfba438eb (diff) | |
download | libarchive-b51d6b621533b6ea7a0a9c4770cc23c2d62a88cf.tar.gz |
Introduce archive_write_disk(3) flag ARCHIVE_EXTRACT_SAFE_WRITES
This flag changes the way that regular files are extracted:
Instead of removing existing files first and re-creating them in
order to replace their contents, a temporary file is created and
when writing to the temporary file is completed, the file is
rename(2)d to the final destination name.
This has the effect of presenting a consistent view of the file to
the system (either the file with the new contents or the file with
the old contents). Removing and overwriting the file has the
undesired side effect that the the system can either not see the
file at all (from the time it is being removed till the time it is
being re-created), or worse it can see partial file contents. This
is problematic when extracting system files (for example shared
libraries).
If the existing file that is going to be overwritten is a hard link,
for now we unlink it before calling rename(2). This can be done
correctly by creating a hardlink to a tmpnam(3) generated file
and then use rename(2), but that is fairly intrusive and requires
refactoring.
Fixes #1289
Diffstat (limited to 'tar/cmdline.c')
-rw-r--r-- | tar/cmdline.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tar/cmdline.c b/tar/cmdline.c index 21558e12..b80937ff 100644 --- a/tar/cmdline.c +++ b/tar/cmdline.c @@ -123,6 +123,7 @@ static const struct bsdtar_option { { "no-fflags", 0, OPTION_NO_FFLAGS }, { "no-mac-metadata", 0, OPTION_NO_MAC_METADATA }, { "no-recursion", 0, 'n' }, + { "no-safe-writes", 0, OPTION_NO_SAFE_WRITES }, { "no-same-owner", 0, OPTION_NO_SAME_OWNER }, { "no-same-permissions", 0, OPTION_NO_SAME_PERMISSIONS }, { "no-xattr", 0, OPTION_NO_XATTRS }, @@ -144,6 +145,7 @@ static const struct bsdtar_option { { "posix", 0, OPTION_POSIX }, { "preserve-permissions", 0, 'p' }, { "read-full-blocks", 0, 'B' }, + { "safe-writes", 0, OPTION_SAFE_WRITES }, { "same-owner", 0, OPTION_SAME_OWNER }, { "same-permissions", 0, 'p' }, { "strip-components", 1, OPTION_STRIP_COMPONENTS }, |