mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Check file types match before comparing properties
Bail early in file validation checks if the file type given in the mtree file does not match that in the filesystem. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
ddd2b9e6f6
commit
7d27b2b0f4
@ -43,6 +43,27 @@ static int check_file_exists(const char *pkgname, const char * filepath,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int check_file_type(const char *pkgname, const char *filepath,
|
||||||
|
struct stat *st, struct archive_entry *entry)
|
||||||
|
{
|
||||||
|
mode_t archive_type = archive_entry_filetype(entry);
|
||||||
|
mode_t file_type = st->st_mode;
|
||||||
|
|
||||||
|
if((archive_type == AE_IFREG && !S_ISREG(file_type)) ||
|
||||||
|
(archive_type == AE_IFDIR && !S_ISDIR(file_type)) ||
|
||||||
|
(archive_type == AE_IFLNK && !S_ISLNK(file_type))) {
|
||||||
|
if(config->quiet) {
|
||||||
|
printf("%s %s\n", pkgname, filepath);
|
||||||
|
} else {
|
||||||
|
pm_printf(ALPM_LOG_WARNING, _("%s: %s (File type mismatch)\n"),
|
||||||
|
pkgname, filepath);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int check_file_permissions(const char *pkgname, const char *filepath,
|
static int check_file_permissions(const char *pkgname, const char *filepath,
|
||||||
struct stat *st, struct archive_entry *entry)
|
struct stat *st, struct archive_entry *entry)
|
||||||
{
|
{
|
||||||
@ -97,7 +118,6 @@ static int check_file_time(const char *pkgname, const char *filepath,
|
|||||||
static int check_file_link(const char *pkgname, const char *filepath,
|
static int check_file_link(const char *pkgname, const char *filepath,
|
||||||
struct stat *st, struct archive_entry *entry)
|
struct stat *st, struct archive_entry *entry)
|
||||||
{
|
{
|
||||||
/* TODO - fail early if file is not a symlink */
|
|
||||||
size_t length = st->st_size + 1;
|
size_t length = st->st_size + 1;
|
||||||
char link[length];
|
char link[length];
|
||||||
|
|
||||||
@ -264,6 +284,11 @@ int check_pkg_full(alpm_pkg_t *pkg)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(check_file_type(pkgname, filepath, &st, entry) == 1) {
|
||||||
|
errors++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
file_errors += check_file_permissions(pkgname, filepath, &st, entry);
|
file_errors += check_file_permissions(pkgname, filepath, &st, entry);
|
||||||
|
|
||||||
if(type != AE_IFDIR) {
|
if(type != AE_IFDIR) {
|
||||||
|
Loading…
Reference in New Issue
Block a user