From da0dcc29cf038de7dee9b16987b508e45d56ae91 Mon Sep 17 00:00:00 2001
From: Dave Reisner <dreisner@archlinux.org>
Date: Wed, 20 Jun 2012 16:18:42 -0400
Subject: query: avoid false ownership matches for files in root

Check for an exact match when querying ownership of files in the root.
Previously, our test was too simple and would match the the basename of
package files against the query parameter, e.g.

  $ pacman -Qo config
  /config is owned by cower-git 20120614-1

Adds a new test to verify this behavior, query007.py.

Fixes FS#30388.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
---
 src/pacman/query.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'src')

diff --git a/src/pacman/query.c b/src/pacman/query.c
index a1cc1cf9..08974105 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -207,8 +207,10 @@ static int query_fileowner(alpm_list_t *targets)
 
 				/* for files in '/', there is no directory name to match */
 				if(!rpath) {
-					print_query_fileowner(filename, info);
-					found = 1;
+					if(strcmp(pkgfile, bname) == 0) {
+						print_query_fileowner(filename, info);
+						found = 1;
+					}
 					continue;
 				}
 
-- 
cgit v1.2.3-70-g09d2