From 7a42e24400499873c3b9e1e2315edc808d753734 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Sat, 30 Jun 2007 00:49:17 +0200 Subject: libalpm/add.c : fix for FS #7484 Adds the ARCHIVE_EXTRACT_NO_OVERWRITE libarchive flags for extracting files and directories. This will prevent symlinks for being overwritten by directories. All other files that need to be extracted should already have been deleted previously by pacman. This flag is not used for extracting files in backup array to /tmp/alpm_XXXX, because this file is created by mkstemp first, and so needs to be overwritten by the file from the archive. Signed-off-by: Chantry Xavier --- lib/libalpm/add.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index c9bcea5e..a8da745c 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -704,7 +704,15 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) archive_entry_set_pathname(entry, filename); - int ret = archive_read_extract(archive, entry, archive_flags); + /* FS #7484 + * By default, libarchive 2.2.3 overwrites existing symlinks by directories from the archive, + * which isn't the behavior we want. + * This can be avoided by using the ARCHIVE_EXTRACT_NO_OVERWRITE flag, and this works + * fine because all files where an overwrite could be needed are deleted first : + * 1) if it's an upgrade, existing files are removed when the old pkg is removed + * 2) if there is a file conflict, but --force is used, then files are also removed : see above + */ + int ret = archive_read_extract(archive, entry, archive_flags | ARCHIVE_EXTRACT_NO_OVERWRITE); if(ret == ARCHIVE_WARN) { /* operation succeeded but a non-critical error was encountered */ _alpm_log(PM_LOG_DEBUG, _("warning extracting %s (%s)"), -- cgit v1.2.3-24-g4f1b