diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2015-12-04 14:14:31 -0500 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-12-05 17:46:12 +1000 |
commit | bb5e6c3b767e923fdb6cbdd75a930838c9b2a018 (patch) | |
tree | 9187320f1fef6a15a85c8225ab7a0fbf0bb6e7dd /lib | |
parent | 8a373096f590925465f624d7b0bf466b02143ce1 (diff) | |
download | pacman-bb5e6c3b767e923fdb6cbdd75a930838c9b2a018.tar.xz |
always unlink files before extraction
libarchive will not extract a directory over an existing directory
symlink, making it impossible to replace a symlink with a directory
across packages. Adding the ARCHIVE_EXTRACT_UNLINK and
ARCHIVE_EXTRACT_SECURE_SYMLINKS causes libarchive to unlink the existing
symlink and prevents it from extracting any paths that contain
a symlink, which we should not be doing anyway.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/add.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 2684e94f..63eda49b 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -112,7 +112,9 @@ static int perform_extraction(alpm_handle_t *handle, struct archive *archive, int ret; const int archive_flags = ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | - ARCHIVE_EXTRACT_TIME; + ARCHIVE_EXTRACT_TIME | + ARCHIVE_EXTRACT_UNLINK | + ARCHIVE_EXTRACT_SECURE_SYMLINKS; archive_entry_set_pathname(entry, filename); @@ -301,13 +303,6 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, strcpy(filename + filename_len, ".pacnew"); } - if(handle->trans->flags & ALPM_TRANS_FLAG_FORCE) { - /* if FORCE was used, unlink() each file (whether it's there - * or not) before extracting. This prevents the old "Text file busy" - * error that crops up if forcing a glibc or pacman upgrade. */ - unlink(filename); - } - _alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename); if(perform_extraction(handle, archive, entry, filename)) { errors++; |