summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2008-01-06 10:59:41 +0100
committerChantry Xavier <shiningxc@gmail.com>2008-01-06 10:59:41 +0100
commita71f4c4c6a7775503b29ab856f8a5ce2801f2967 (patch)
treec434e2d5aa23db73330c083758b722ed36e89cc6
parenta27d7f6071969623362785df50546cf48e8f1d2e (diff)
conflict.c : fix for FS#8156, detect conflict between symlink and dir.
The previous fileconflict check (package vs filesystem) skipped the conflict when the file on the filesystem was a directory or a symlink to a directory, no matter what the file in the package was. Now, the conflict will only be skipped if the file in the package is a directory (so compatible with a dir or a dir symlink on the filesystem). So in the case of 8156 (new fileconflict003 pactest for this case), instead of silently ignoring the extraction of the test symlink, pacman will now fail because of a file conflict between the test symlink in the pkg2 package and the test directory on the filesystem. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
-rw-r--r--lib/libalpm/conflict.c17
-rw-r--r--pactest/tests/fileconflict003.py18
2 files changed, 30 insertions, 5 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index adad324f..c093705a 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -386,6 +386,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, char *roo
/* loop over each file to be installed */
for(j = tmpfiles; j; j = j->next) {
+ int skip_conflict = 0;
filestr = j->data;
snprintf(path, PATH_MAX, "%s%s", root, filestr);
@@ -396,11 +397,17 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, char *roo
}
stat(path, &sbuf);
- if(S_ISDIR(lsbuf.st_mode)) {
- _alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
- } else if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(sbuf.st_mode)) {
- _alpm_log(PM_LOG_DEBUG, "%s is a symlink to a dir, hopefully not a conflict\n", path);
- } else {
+ if(path[strlen(path)-1] == '/') {
+ if(S_ISDIR(lsbuf.st_mode)) {
+ _alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
+ skip_conflict = 1;
+ } else if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(sbuf.st_mode)) {
+ _alpm_log(PM_LOG_DEBUG,
+ "%s is a symlink to a dir, hopefully not a conflict\n", path);
+ skip_conflict = 1;
+ }
+ }
+ if(!skip_conflict) {
_alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
/* Make sure the possible conflict is not a symlink that points to a
diff --git a/pactest/tests/fileconflict003.py b/pactest/tests/fileconflict003.py
new file mode 100644
index 00000000..89696fcb
--- /dev/null
+++ b/pactest/tests/fileconflict003.py
@@ -0,0 +1,18 @@
+self.description = "FS#8156"
+
+p1 = pmpkg("pkg1")
+p1.files = ["test/",
+ "test/file"]
+self.addpkg2db("local", p1)
+
+p2 = pmpkg("pkg2")
+p2.files = ["test2/",
+ "test2/file2",
+ "test -> test2"]
+self.addpkg2db("sync", p2)
+
+self.args = "-S pkg2"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_EXIST=pkg1")
+self.addrule("!PKG_EXIST=pkg2")