conflict.c: fix directory ownership check
* append "/" to directories before searching package file lists * use lstat over stat so symlinks aren't resolved * fix the inverted check for stat's return value Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
15b667ef36
commit
d8c2ab0e6f
|
@ -323,7 +323,7 @@ static int dir_belongsto_pkgs(alpm_handle_t *handle, const char *dirpath,
|
|||
|
||||
while((ent = readdir(dir)) != NULL) {
|
||||
const char *name = ent->d_name;
|
||||
int owned = 0;
|
||||
int owned = 0, is_dir = 0;
|
||||
alpm_list_t *i;
|
||||
struct stat sbuf;
|
||||
|
||||
|
@ -331,8 +331,16 @@ static int dir_belongsto_pkgs(alpm_handle_t *handle, const char *dirpath,
|
|||
continue;
|
||||
}
|
||||
|
||||
snprintf(path, PATH_MAX, "%s%s", dirpath, name);
|
||||
snprintf(full_path, PATH_MAX, "%s%s", handle->root, path);
|
||||
snprintf(full_path, PATH_MAX, "%s%s%s", handle->root, dirpath, name);
|
||||
|
||||
if(lstat(full_path, &sbuf) != 0) {
|
||||
_alpm_log(handle, ALPM_LOG_DEBUG, "could not stat %s\n", full_path);
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
is_dir = S_ISDIR(sbuf.st_mode);
|
||||
|
||||
snprintf(path, PATH_MAX, "%s%s%s", dirpath, name, is_dir ? "/" : "");
|
||||
|
||||
for(i = pkgs; i && !owned; i = i->next) {
|
||||
if(alpm_filelist_contains(alpm_pkg_get_files(i->data), path)) {
|
||||
|
@ -340,7 +348,7 @@ static int dir_belongsto_pkgs(alpm_handle_t *handle, const char *dirpath,
|
|||
}
|
||||
}
|
||||
|
||||
if(owned && stat(full_path, &sbuf) != 0 && S_ISDIR(sbuf.st_mode)) {
|
||||
if(owned && is_dir) {
|
||||
owned = dir_belongsto_pkgs(handle, path, pkgs);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
self.description = "Dir->file transition filesystem conflict resolved by removal (with subdirectory)"
|
||||
|
||||
lp1 = pmpkg("foo")
|
||||
lp1.files = ["foo/bar/"]
|
||||
self.addpkg2db("local", lp1)
|
||||
|
||||
sp1 = pmpkg("foo", "2-1")
|
||||
sp1.conflicts = ["foo"]
|
||||
sp1.files = ["foo"]
|
||||
self.addpkg2db("sync", sp1)
|
||||
|
||||
self.args = "-S %s" % sp1.name
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=foo|2-1")
|
||||
self.addrule("FILE_EXIST=foo")
|
|
@ -0,0 +1,17 @@
|
|||
self.description = "Dir->file transition filesystem conflict resolved by removal (with symlink)"
|
||||
|
||||
self.filesystem = ["baz/quux"]
|
||||
|
||||
lp1 = pmpkg("foo")
|
||||
lp1.files = ["foo/bar -> ../baz/"]
|
||||
self.addpkg2db("local", lp1)
|
||||
|
||||
sp1 = pmpkg("foo", "2-1")
|
||||
sp1.files = ["foo"]
|
||||
self.addpkg2db("sync", sp1)
|
||||
|
||||
self.args = "-S %s" % sp1.name
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=foo|2-1")
|
||||
self.addrule("FILE_EXIST=foo")
|
Loading…
Reference in New Issue