summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2017-01-03 08:06:22 +0100
committerAllan McRae <allan@archlinux.org>2017-01-04 04:59:15 +0100
commitb6753eeb7ead3fa7bfdb053babe877319a722115 (patch)
treea52ce452c8be2d07741c5dd9738819accc3e799d /lib/libalpm
parent8a19c4a78251c5e34ecf508a65d943ca2dc833c7 (diff)
downloadpacman-b6753eeb7ead3fa7bfdb053babe877319a722115.tar.gz
pacman-b6753eeb7ead3fa7bfdb053babe877319a722115.tar.xz
conflict: skip dir children when replacing a file
When replacing a file with a directory, any files under that directory do not need to be checked for conflicts. This prevents possible false-positive conflicts where the file being replaced is a symlink. We were already skipping the directory children when the file was owned by the previous version of a package being upgraded. This extends that to other packages being removed. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/conflict.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 2e6f7f78..878cfb94 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -503,6 +503,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
struct stat lsbuf;
char path[PATH_MAX];
size_t pathlen;
+ int pfile_isdir;
pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
relative_path = path + rootlen;
@@ -514,7 +515,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
- if(path[pathlen - 1] == '/') {
+ pfile_isdir = path[pathlen - 1] == '/';
+ if(pfile_isdir) {
if(S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n");
continue;
@@ -551,6 +553,18 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG,
"local file will be removed, not a conflict\n");
resolved_conflict = 1;
+ if(pfile_isdir) {
+ /* go ahead and skip any files inside filestr as they will
+ * necessarily be resolved by replacing the file with a dir
+ * NOTE: afterward, j will point to the last file inside filestr */
+ size_t fslen = strlen(filestr);
+ for( ; j->next; j = j->next) {
+ const char *filestr2 = j->next->data;
+ if(strncmp(filestr, filestr2, fslen) != 0) {
+ break;
+ }
+ }
+ }
}
}