17#include <zypp-common/PublicKey.h>
21#include <zypp-core/zyppng/pipelines/Expected>
23#include <zypp/ng/Context>
25#include <zypp/ng/UserRequest>
29 template <
class Executor,
class OpType>
48 using zyppng::operators::operator|;
71 if ( !key.isValid() ) {
72 ERR <<
"Key [" <<
_keyId <<
"] from cache: " <<
cacheDir <<
" is not valid" << std::endl;
76 MIL <<
"Key [" <<
_keyId <<
"] " << key.name() <<
" loaded from cache" << std::endl;
84 MIL <<
"User wants to import key [" <<
_keyId <<
"] " << key.name() <<
" from cache" << std::endl;
86 _context->keyRing()->importKey( key,
true );
117 template <
class Executor,
class OpType>
118 struct VerifyFileSignatureLogic :
public LogicBase<Executor, OpType>
132 struct FoundKeyData {
140 using zyppng::operators::operator|;
167 MIL <<
"Key was updated. Saving new version into trusted keyring: " <<
generalKeyData << std::endl;
181 MIL <<
"Key [" <<
id <<
"] " << key.name() <<
" is not trusted" << std::endl;
190 MIL <<
"User wants to trust key [" <<
id <<
"] " << key.name() << std::endl;
194 MIL <<
"User wants to import key [" <<
id <<
"] " << key.name() << std::endl;
205 MIL <<
"User does not want to trust key [" <<
id <<
"] " << key.name() << std::endl;
213 | [
this, id](
bool success ) {
217 return FoundKeyData{
_keyRing->pimpl().publicKeyExists(
id,
_keyRing->pimpl().trustedKeyRing() ),
_keyRing->pimpl().trustedKeyRing(),
true };
232 MIL <<
"Going to verify signature for " <<
filedesc <<
" ( " << file <<
" ) with " << signature << std::endl;
238 MIL <<
"askUserToAcceptUnsignedFile: " <<
res << std::endl;
247 std::list<zypp::PublicKeyData>
buddies;
249 if (
not zypp::PublicKeyData::isSafeKeyId(
sid ) ) {
250 WAR <<
"buddy " <<
sid <<
": key id is too short to safely identify a gpg key. Skipping it." << std::endl;
253 if (
_keyRing->pimpl().trustedPublicKeyExists(
sid ) ) {
254 MIL <<
"buddy " <<
sid <<
": already in trusted key ring. Not needed." << std::endl;
259 WAR <<
"buddy " <<
sid <<
": not available in the public key ring. Skipping it." << std::endl;
262 if (
pk.providesKey(
id) ) {
263 MIL <<
"buddy " <<
sid <<
": is the signing key. Handled separately." << std::endl;
266 MIL <<
"buddy " <<
sid <<
": candidate for auto import. Remeber it." << std::endl;
270 using zyppng::operators::operator|;
278 if (
res._foundKey ) {
287 if (
_keyRing->pimpl().verifyFile( file, signature,
res._whichKeyRing ) )
292 MIL <<
"Validated with trusted key: importing buddy list..." << std::endl;
303 MIL <<
"askUserToAcceptVerificationFailed: " <<
userAnswer << std::endl;
308 MIL <<
"File [" << file <<
"] ( " <<
filedesc <<
" ) signed with unknown key [" <<
id <<
"]" << std::endl;
310 MIL <<
"askUserToAcceptUnknownKey: " <<
res << std::endl;
325 inline std::pair<bool, zypp::keyring::VerifyFileContext>
makeReturn(
bool res ){
334 auto kr = zyppContext->keyRing();
340 auto kr = zyppContext->keyRing();
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Base class for Exception.
What is known about a repository.
Interim helper class to collect global options and settings.
Wrapper class for stat/lstat.
bool isExist() const
Return whether valid stat info exists.
I/O context for KeyRing::verifyFileSignatureWorkflow.
bool fileValidated() const
Whether the signature was actually successfully verified.
const KeyContext & keyContext() const
KeyContext passed to callbacks
std::string shortFile() const
Short name for file (default: basename).
const Pathname & file() const
File to verify.
bool signatureIdTrusted() const
Whether the SignatureId is in the trusted keyring (not temp.
const Pathname & signature() const
Detached signature or empty.
void resetResults()
Reset all result values to safe defaults.
const std::string & signatureId() const
The id of the gpg key which signed the file.
bool fileAccepted() const
May return true due to user interaction or global defaults even if the signature was not actually ver...
zypp::keyring::VerifyFileContext _verifyContext
zypp::Pathname _whichKeyRing
zypp::PublicKeyData _foundKey
KeyRingReportHelper< ZyppContextRefType > _keyringReport
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
bool provideAndImportKeyFromRepository(SyncContextRef ctx, std::string id_r, zypp::RepoInfo info_r)
Try to find the id in key cache or repository specified in info.
std::pair< bool, zypp::keyring::VerifyFileContext > verifyFileSignature(SyncContextRef zyppContext, zypp::keyring::VerifyFileContext &&context_r)
Follows a signature verification interacting with the user.
zypp::Pathname provideKey(SyncContextRef ctx, zypp::RepoInfo info, std::string keyID_r, zypp::Pathname targetDirectory_r)
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
zypp::KeyRing_Ptr KeyRingRef
ZyppContextRefType _zyppContext
const RepoInfo repoInfo() const
bool empty() const
Is the context unknown?
KeyTrust
User reply options for the askUserToTrustKey callback.
@ KEY_TRUST_AND_IMPORT
Import the key.
@ KEY_TRUST_TEMPORARILY
This basically means, we knew the key, but it was not trusted.
ImportKeyFromRepoLogic(ZyppContextRefType context, std::string &&keyId, zypp::RepoInfo &&info)
ZyppContextRefType _context
ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
typename ProvideType::MediaHandle MediaHandle
typename ProvideType::Res ProvideRes
MaybeAsyncContextRef< OpType > ZyppContextRefType
typename ZyppContextType::ProvideType ProvideType
MaybeAsyncRef< bool > execute()
auto makeReadyResult(T &&res)
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).