[pacman-dev] [PATCH] 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> --- src/pacman/query.c | 7 +++++-- test/pacman/tests/query007.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/pacman/tests/query007.py diff --git a/src/pacman/query.c b/src/pacman/query.c index a1cc1cf..a7e93c5 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -190,6 +190,7 @@ static int query_fileowner(alpm_list_t *targets) } free(dname); + for(i = alpm_db_get_pkgcache(db_local); i && !found; i = alpm_list_next(i)) { alpm_pkg_t *info = i->data; alpm_filelist_t *filelist = alpm_pkg_get_files(info); @@ -207,8 +208,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; } diff --git a/test/pacman/tests/query007.py b/test/pacman/tests/query007.py new file mode 100644 index 0000000..35bb0ca --- /dev/null +++ b/test/pacman/tests/query007.py @@ -0,0 +1,11 @@ +self.description = "Query ownership of file in root" + +sp = pmpkg("dummy") +sp.files = ["etc/config"] +self.addpkg2db("local", sp) + +self.filesystem = ["config"] + +self.args = "-Qo /config" + +self.addrule("PACMAN_RETCODE=1") -- 1.7.11
On 21/06/12 06:23, Dave Reisner wrote:
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> ---
I can not replicate this issue so it was likely already fixed by my "-Qo <dir>" patch. I seem to remember encountering something like that... It would be really good if someone could review the patches that Andrew and I sent to this list for that... Anyway, the pactest looks good. Allan
On Thu, Jun 21, 2012 at 08:55:44AM +1000, Allan McRae wrote:
On 21/06/12 06:23, Dave Reisner wrote:
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> ---
I can not replicate this issue so it was likely already fixed by my "-Qo <dir>" patch. I seem to remember encountering something like that... It would be really good if someone could review the patches that Andrew and I sent to this list for that...
Anyway, the pactest looks good.
Allan
Ah, if that's the case then I'll just drop the fix and add the test as expectedfail.
participants (3)
-
Allan McRae
-
Dave Reisner
-
Dave Reisner