libzypp 17.35.11
signaturecheckwf.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9
10#include "signaturecheckwf.h"
11#include "keyringwf.h"
12#include "logichelpers.h"
13
14#include <zypp/ZYppFactory.h>
17
18namespace zyppng {
19
20 namespace {
21
22 using namespace zyppng::operators;
23
24 template <class Executor, class OpType>
25 struct VerifySignatureLogic : public LogicBase<Executor,OpType> {
26
28 using ZyppContextRefType = MaybeAsyncContextRef<OpType>;
29
30 VerifySignatureLogic( ZyppContextRefType &&zyppCtx, zypp::keyring::VerifyFileContext &&ctx )
31 : _zyppCtx( std::move(zyppCtx) )
32 , _verifyCtx( std::move(ctx) ) { }
33
35
37 if ( not ( sig.empty() || zypp::PathInfo(sig).isExist() ) ) {
39 }
40
41 MIL << "Checking " << _verifyCtx.file ()<< " file validity using digital signature.." << std::endl;
42
44 | []( auto &&res ) {
45 if ( not res.first )
46 return expected<zypp::keyring::VerifyFileContext>::error( ZYPP_EXCPT_PTR( zypp::SignatureCheckException( "Signature verification failed for " + res.second.file().basename() ) ) );
47 return expected<zypp::keyring::VerifyFileContext>::success ( std::move( res.second ) );
48 };
49 }
50
51 protected:
52 ZyppContextRefType _zyppCtx;
54 };
55 }
56
68}
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Wrapper class for stat/lstat.
Definition PathInfo.h:222
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:282
I/O context for KeyRing::verifyFileSignatureWorkflow.
const Pathname & file() const
File to verify.
const Pathname & signature() const
Detached signature or empty.
static expected success(ConsParams &&...params)
Definition expected.h:115
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
Definition Arch.h:364
std::pair< bool, zypp::keyring::VerifyFileContext > verifyFileSignature(SyncContextRef zyppContext, zypp::keyring::VerifyFileContext &&context_r)
Follows a signature verification interacting with the user.
Definition keyringwf.cc:332
expected< zypp::keyring::VerifyFileContext > verifySignature(SyncContextRef ctx, zypp::keyring::VerifyFileContext context)
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
Definition asyncop.h:297
ZyppContextRefType _zyppCtx
zypp::keyring::VerifyFileContext _verifyCtx
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition Exception.h:428
#define MIL
Definition Logger.h:98