13#include <zypp/base/Logger.h>
16#include <zypp/Digest.h>
21#undef ZYPP_BASE_LOGGER_LOGGROUP
22#define ZYPP_BASE_LOGGER_LOGGROUP "FileChecker"
39 MIL <<
"File " << file <<
" has no checksum available." << std::endl;
40 if ( report->askUserToAcceptNoDigest(file) )
42 MIL <<
"User accepted " << file <<
" with no checksum." << std::endl;
58 static std::map<std::string,std::string> exceptions;
59 static Date exceptionsAge;
61 if ( !exceptions.empty() && now-exceptionsAge > 12*
Date::hour )
64 WAR <<
"File " << file <<
" has wrong checksum " << real_checksum <<
" (expected " <<
_checksum <<
")" << endl;
67 WAR <<
"User accepted " << file <<
" with WRONG CHECKSUM. (remembered)" << std::endl;
72 WAR <<
"User accepted " << file <<
" with WRONG CHECKSUM." << std::endl;
87 MIL <<
"+ null check on " << file << endl;
94 for ( std::list<FileChecker>::const_iterator it =
_checkers.begin(); it !=
_checkers.end(); ++it )
103 ERR <<
"Invalid checker" << endl;
122 { getZYpp()->keyRing()->importKey( publickey_r,
false ); }
127 if ( not ( sig.empty() ||
PathInfo(sig).isExist() ) )
130 MIL <<
"Checking " << file_r <<
" file validity using digital signature.." << endl;
134 if ( not getZYpp()->keyRing()->verifyFileSignatureWorkflow( self ) )
std::string checksum() const
void operator()(const Pathname &file) const
Try to validate the file.
ChecksumFileChecker(const CheckSum &checksum)
Constructor.
CheckSumCheckException ExceptionType
std::list< FileChecker > _checkers
void add(const FileChecker &checker)
void operator()(const Pathname &file) const
Store and operate on date (time_t).
static const ValueType hour
static Date now()
Return the current time.
void operator()(const Pathname &file) const
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Checks for the validity of a signature.
void operator()(const Pathname &file_r) const
Call KeyRing::verifyFileSignatureWorkflow to verify the file.
void addPublicKey(const PublicKey &publickey_r)
Add a public key to the list of known keys.
SignatureCheckException ExceptionType
SignatureFileChecker()
Default Ctor for unsigned files.
Wrapper class for stat/lstat.
std::string basename() const
Return the last component of this path.
const Pathname & file() const
File to verify.
const Pathname & signature() const
Detached signature or empty.
String related utilities and Regular expression matching.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
function< void(const Pathname &file)> FileChecker
Functor signature used to check files.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.