xbps-pkgdb(8): check pkg file mtime (iff the obj is available).
This commit is contained in:
parent
2cae0cba01
commit
3855d2e2fb
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
||||
xbps-0.44 (???):
|
||||
|
||||
* xbps-pkgdb(8): this now checks the modification time of pkg files
|
||||
(iff the pkg metadata has that information).
|
||||
|
||||
* xbps-create(8): modification time of regular files and links is now stored
|
||||
in the package files metadata, will be used in a future version.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2011-2013 Juan Romero Pardines.
|
||||
* Copyright (c) 2011-2015 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -43,8 +43,34 @@
|
||||
* o Check the hash for all installed files, except
|
||||
* configuration files (which is expected if they are modified).
|
||||
*
|
||||
* o Compares stored file modification time.
|
||||
*
|
||||
* Return 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
static bool
|
||||
check_file_mtime(xbps_dictionary_t d, const char *pkg, const char *path)
|
||||
{
|
||||
struct stat sb;
|
||||
uint64_t mtime = 0;
|
||||
const char *file;
|
||||
|
||||
/* if obj is not there, skip silently */
|
||||
if (!xbps_dictionary_get_uint64(d, "mtime", &mtime))
|
||||
return false;
|
||||
|
||||
if (stat(path, &sb) == -1)
|
||||
return true;
|
||||
|
||||
if ((uint64_t)sb.st_mtime != mtime) {
|
||||
xbps_dictionary_get_cstring_nocopy(d, "file", &file);
|
||||
xbps_error_printf("%s: %s mtime mismatch "
|
||||
"(current: %ju, stored %ju)\n",
|
||||
pkg, file, (uint64_t)sb.st_mtime, mtime);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
|
||||
{
|
||||
@ -72,6 +98,9 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
|
||||
free(path);
|
||||
switch (rv) {
|
||||
case 0:
|
||||
if (check_file_mtime(obj, pkgname, path)) {
|
||||
test_broken = true;
|
||||
}
|
||||
break;
|
||||
case ENOENT:
|
||||
xbps_error_printf("%s: unexistent file %s.\n",
|
||||
|
@ -1,4 +1,4 @@
|
||||
.Dd December 15, 2014
|
||||
.Dd February 22, 2014
|
||||
.Dt XBPS-PKGDB 8
|
||||
.Sh NAME
|
||||
.Nm xbps-pkgdb
|
||||
@ -24,6 +24,9 @@ hash that is recorded when package is installed against current one.
|
||||
.It Sy FILES CHECK
|
||||
Checks that all files belonging to a package have not been modified and are
|
||||
not missing.
|
||||
For regular files, its modification time and the SHA256 hash are
|
||||
compared and checked if they differ.
|
||||
For symbolic links the target file is checked that it has not been modified.
|
||||
.It Sy DEPENDENCIES CHECK
|
||||
Checks that all required dependencies for a package are resolved.
|
||||
.It Sy OBSOLETE METADATA CHECK
|
||||
|
Loading…
Reference in New Issue
Block a user