summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-06-26 18:19:09 +0200
committerAllan McRae <allan@archlinux.org>2014-08-03 10:46:32 +0200
commit71da296d01ee564d39012415d7e1981c42723648 (patch)
treef8e0e0235299df55289761325711e7a350cd450d
parentc3835c157a870de8f4ac554f6d72e78e49c4e46b (diff)
downloadpacman-71da296d01ee564d39012415d7e1981c42723648.tar.gz
pacman-71da296d01ee564d39012415d7e1981c42723648.tar.xz
check_pkg_fast: check file type
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
-rw-r--r--src/pacman/check.c15
-rw-r--r--test/pacman/tests/querycheck_fast_file_type.py2
2 files changed, 13 insertions, 4 deletions
diff --git a/src/pacman/check.c b/src/pacman/check.c
index 60a038a1..7109c7a8 100644
--- a/src/pacman/check.c
+++ b/src/pacman/check.c
@@ -210,14 +210,25 @@ int check_pkg_fast(alpm_pkg_t *pkg)
const alpm_file_t *file = filelist->files + i;
struct stat st;
const char *path = file->name;
+ size_t plen = strlen(path);
- if(rootlen + 1 + strlen(path) > PATH_MAX) {
+ if(rootlen + 1 + plen > PATH_MAX) {
pm_printf(ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path);
continue;
}
strcpy(filepath + rootlen, path);
- errors += check_file_exists(pkgname, filepath, &st);
+ if(check_file_exists(pkgname, filepath, &st) == 0) {
+ int expect_dir = path[plen - 1] == '/' ? 1 : 0;
+ int is_dir = S_ISDIR(st.st_mode) ? 1 : 0;
+ if(expect_dir != is_dir) {
+ pm_printf(ALPM_LOG_WARNING, _("%s: %s (File type mismatch)\n"),
+ pkgname, filepath);
+ ++errors;
+ }
+ } else {
+ ++errors;
+ }
}
if(!config->quiet) {
diff --git a/test/pacman/tests/querycheck_fast_file_type.py b/test/pacman/tests/querycheck_fast_file_type.py
index a19fceeb..f53badaf 100644
--- a/test/pacman/tests/querycheck_fast_file_type.py
+++ b/test/pacman/tests/querycheck_fast_file_type.py
@@ -10,5 +10,3 @@ self.args = "-Qk"
self.addrule("PACMAN_RETCODE=1")
self.addrule("PACMAN_OUTPUT=warning.*(File type mismatch)")
-
-self.expectfailure = True