summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2008-02-06 00:29:49 +0100
committerDan McGee <dan@archlinux.org>2008-02-06 02:19:17 +0100
commitb29838c8250125a22016c16180e941d059d55539 (patch)
tree94093931ad6ac779ebc2d74a1d91b457f446d148
parent7d7a33791211b26d69bcf3c23174250dd14e9486 (diff)
downloadpacman-b29838c8250125a22016c16180e941d059d55539.tar.gz
pacman-b29838c8250125a22016c16180e941d059d55539.tar.xz
Don't follow symlinks with -Qo.
Fixes FS#9473 and the issue reported there : http://www.archlinux.org/pipermail/pacman-dev/2008-February/011061.html Only the dirname should be resolved, not the basename. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--src/pacman/query.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index fd2f7927..e999a328 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -70,6 +70,7 @@ static int query_fileowner(alpm_list_t *targets)
int found = 0;
char *filename = alpm_list_getdata(t);
char *bname;
+ char *dname;
char *rpath;
struct stat buf;
alpm_list_t *i, *j;
@@ -88,10 +89,14 @@ static int query_fileowner(alpm_list_t *targets)
}
bname = mbasename(filename);
+ dname = mdirname(filename);
+ rpath = resolve_path(dname);
+ free(dname);
- if(!(rpath = resolve_path(filename))) {
+ if(!rpath) {
fprintf(stderr, _("error: cannot determine real path for '%s': %s\n"),
filename, strerror(errno));
+ free(rpath);
ret++;
continue;
}
@@ -100,7 +105,7 @@ static int query_fileowner(alpm_list_t *targets)
pmpkg_t *info = alpm_list_getdata(i);
for(j = alpm_pkg_get_files(info); j && !found; j = alpm_list_next(j)) {
- char path[PATH_MAX], *ppath;
+ char path[PATH_MAX], *ppath, *pdname;
snprintf(path, PATH_MAX, "%s%s",
alpm_option_get_root(), (const char *)alpm_list_getdata(j));
@@ -109,10 +114,12 @@ static int query_fileowner(alpm_list_t *targets)
continue;
}
- ppath = resolve_path(path);
+ pdname = mdirname(path);
+ ppath = resolve_path(pdname);
+ free(pdname);
if(ppath && strcmp(ppath, rpath) == 0) {
- printf(_("%s is owned by %s %s\n"), rpath,
+ printf(_("%s is owned by %s %s\n"), filename,
alpm_pkg_get_name(info), alpm_pkg_get_version(info));
found = 1;
}