28 template <
class Executor,
class OpType>
47 using zyppng::operators::operator|;
71 ERR <<
"Key [" <<
_keyId <<
"] from cache: " <<
cacheDir <<
" is not valid" << std::endl;
75 MIL <<
"Key [" <<
_keyId <<
"] " << key.
name() <<
" loaded from cache" << std::endl;
83 MIL <<
"User wants to import key [" <<
_keyId <<
"] " << key.
name() <<
" from cache" << std::endl;
85 _context->keyRing()->importKey( key,
true );
104 ERR <<
"Not implemented yet" << std::endl;
135 template <
class Executor,
class OpType>
136 struct VerifyFileSignatureLogic :
public LogicBase<Executor, OpType>
149 struct FoundKeyData {
157 using zyppng::operators::operator|;
184 MIL <<
"Key was updated. Saving new version into trusted keyring: " <<
generalKeyData << std::endl;
198 MIL <<
"Key [" <<
id <<
"] " << key.name() <<
" is not trusted" << std::endl;
207 MIL <<
"User wants to trust key [" <<
id <<
"] " << key.name() << std::endl;
211 MIL <<
"User wants to import key [" <<
id <<
"] " << key.name() << std::endl;
222 MIL <<
"User does not want to trust key [" <<
id <<
"] " << key.name() << std::endl;
230 | [
this, id](
bool success ) {
234 return FoundKeyData{
_keyRing->pimpl().publicKeyExists(
id,
_keyRing->pimpl().trustedKeyRing() ),
_keyRing->pimpl().trustedKeyRing(),
true };
249 MIL <<
"Going to verify signature for " <<
filedesc <<
" ( " << file <<
" ) with " << signature << std::endl;
255 MIL <<
"askUserToAcceptUnsignedFile: " <<
res << std::endl;
264 std::list<zypp::PublicKeyData>
buddies;
267 WAR <<
"buddy " <<
sid <<
": key id is too short to safely identify a gpg key. Skipping it." << std::endl;
270 if (
_keyRing->pimpl().trustedPublicKeyExists(
sid ) ) {
271 MIL <<
"buddy " <<
sid <<
": already in trusted key ring. Not needed." << std::endl;
276 WAR <<
"buddy " <<
sid <<
": not available in the public key ring. Skipping it." << std::endl;
279 if (
pk.providesKey(
id) ) {
280 MIL <<
"buddy " <<
sid <<
": is the signing key. Handled separately." << std::endl;
283 MIL <<
"buddy " <<
sid <<
": candidate for auto import. Remeber it." << std::endl;
287 using zyppng::operators::operator|;
295 if (
res._foundKey ) {
303 executor()->infoVerify(
filedesc,
res._foundKey, keyContext );
304 if (
_keyRing->pimpl().verifyFile( file, signature,
res._whichKeyRing ) )
309 MIL <<
"Validated with trusted key: importing buddy list..." << std::endl;
310 executor()->reportAutoImportKey(
buddies,
res._foundKey, keyContext );
320 MIL <<
"askUserToAcceptVerificationFailed: " <<
userAnswer << std::endl;
325 MIL <<
"File [" << file <<
"] ( " <<
filedesc <<
" ) signed with unknown key [" <<
id <<
"]" << std::endl;
327 MIL <<
"askUserToAcceptUnknownKey: " <<
res << std::endl;
341 inline std::pair<bool, zypp::keyring::VerifyFileContext>
makeReturn(
bool res ){
347 struct AsyncVerifyFileSignatureExecutor :
public VerifyFileSignatureLogic<AsyncVerifyFileSignatureExecutor, AsyncOp<std::pair<bool,zypp::keyring::VerifyFileContext>>>
350 using VerifyFileSignatureLogic::VerifyFileSignatureLogic;
358 _(
"File '%s' is unsigned, continue?")) % file;
362 _(
"File '%s' from repository '%s' is unsigned, continue?"))
363 % file %
keycontext.repoInfo().asUserString();
368 return req->choice ();
373 auto req = TrustKeyRequest::create(
374 _(
"Do you want to reject the key, trust temporarily, or trust always?"),
379 return static_cast<KeyTrust
>(req->choice());
389 const std::string &
lbl =
zypp::str::Format(
PL_(
"Received %1% new package signing key from repository \"%2%\":",
390 "Received %1% new package signing keys from repository \"%2%\":",
400 label =
zypp::str::Format(
_(
"Signature verification failed for file '%1%'.") ) % file;
403 label =
zypp::str::Format(
_(
"Signature verification failed for file '%1%' from repository '%2%'.") ) % file %
keycontext.repoInfo().asUserString();
406 label += std::string(
" ") +
_(
"Continue?");
409 return req->choice ();
419 _(
"File '%s' is signed with an unknown key '%s'. Continue?")) % file % id;
423 _(
"File '%s' from repository '%s' is signed with an unknown key '%s'. Continue?"))
424 % file %
keycontext.repoInfo().asUserString() % id;
428 return req->choice ();
432 struct SyncVerifyFileSignatureExecutor :
public VerifyFileSignatureLogic<SyncVerifyFileSignatureExecutor, SyncOp<std::pair<bool,zypp::keyring::VerifyFileContext>>>
435 using VerifyFileSignatureLogic::VerifyFileSignatureLogic;
463 auto kr = zyppContext->keyRing();
464 return SyncVerifyFileSignatureExecutor::run( std::move(zyppContext), std::move(
kr), std::move(
context_r) );
469 auto kr = zyppContext->keyRing();
470 return AsyncVerifyFileSignatureExecutor::run( std::move(zyppContext), std::move(
kr), std::move(
context_r) );
475 return SyncVerifyFileSignatureExecutor::run( std::move(zyppContext), std::move(keyRing), std::move(
context_r) );
480 return AsyncVerifyFileSignatureExecutor::run( std::move(zyppContext), std::move(keyRing), std::move(
context_r) );
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...
const RepoInfo repoInfo() const
#define PL_(MSG1, MSG2, N)