summaryrefslogtreecommitdiff
path: root/src/info.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2016-05-31 16:58:05 +0300
committerTimo Teräs <timo.teras@iki.fi>2016-05-31 16:58:05 +0300
commit5906aef6958208b9705083ad56881fc63a326dff (patch)
treebd85978f09d52d237abbee23a8f3a530649c840d /src/info.c
parentc43e4fe599d9e881913c472a79769875d4d5f409 (diff)
downloadapk-tools-5906aef6958208b9705083ad56881fc63a326dff.tar.gz
apk-tools-5906aef6958208b9705083ad56881fc63a326dff.tar.bz2
apk-tools-5906aef6958208b9705083ad56881fc63a326dff.tar.xz
apk-tools-5906aef6958208b9705083ad56881fc63a326dff.zip
fix info --who-owns to work with relative filenames
fixes #5656
Diffstat (limited to 'src/info.c')
-rw-r--r--src/info.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/info.c b/src/info.c
index 886d4fa..ae5fe9a 100644
--- a/src/info.c
+++ b/src/info.c
@@ -95,13 +95,19 @@ static void info_who_owns(struct info_ctx *ctx, struct apk_database *db,
struct apk_dependency dep;
struct apk_ostream *os;
const char *via;
- char **parg, buf[PATH_MAX];
+ char **parg, fnbuf[PATH_MAX], buf[PATH_MAX];
+ apk_blob_t fn;
ssize_t r;
apk_dependency_array_init(&deps);
foreach_array_item(parg, args) {
+ if (*parg[0] != '/' && realpath(*parg, fnbuf))
+ fn = APK_BLOB_STR(fnbuf);
+ else
+ fn = APK_BLOB_STR(*parg);
+
via = "";
- pkg = apk_db_get_file_owner(db, APK_BLOB_STR(*parg));
+ pkg = apk_db_get_file_owner(db, fn);
if (pkg == NULL) {
r = readlinkat(db->root_fd, *parg, buf, sizeof(buf));
if (r > 0 && r < PATH_MAX && buf[0] == '/') {
@@ -111,7 +117,8 @@ static void info_who_owns(struct info_ctx *ctx, struct apk_database *db,
}
if (pkg == NULL) {
- apk_error("%s: Could not find owner package", *parg);
+ apk_error(BLOB_FMT ": Could not find owner package",
+ BLOB_PRINTF(fn));
ctx->errors++;
continue;
}
@@ -124,8 +131,8 @@ static void info_who_owns(struct info_ctx *ctx, struct apk_database *db,
};
apk_deps_add(&deps, &dep);
} else {
- printf("%s %sis owned by " PKG_VER_FMT "\n",
- *parg, via, PKG_VER_PRINTF(pkg));
+ printf(BLOB_FMT " %sis owned by " PKG_VER_FMT "\n",
+ BLOB_PRINTF(fn), via, PKG_VER_PRINTF(pkg));
}
}
if (apk_verbosity < 1 && deps->num != 0) {