From 5906aef6958208b9705083ad56881fc63a326dff Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Tue, 31 May 2016 16:58:05 +0300 Subject: fix info --who-owns to work with relative filenames fixes #5656 --- src/info.c | 17 ++++++++++++----- 1 file 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) { -- cgit v1.2.3