22#include <zypp-core/zyppng/pipelines/Transform>
23#include <zypp-core/zyppng/pipelines/Expected>
24#include <zypp-core/zyppng/pipelines/MTry>
25#include <zypp-media/ng/Provide>
26#include <zypp-media/ng/ProvideSpec>
28#include <zypp/ng/Context>
29#include <zypp/ng/UserRequest>
41 template<
class Executor,
class OpType>
42 struct RepoInfoProvideKeyLogic :
public LogicBase<Executor, OpType> {
46 using ProvideType =
typename ZyppContextType::ProvideType;
47 using MediaHandle =
typename ProvideType::MediaHandle;
50 RepoInfoProvideKeyLogic( ZyppContextRefType &&zyppContext,
zypp::RepoInfo &&info, std::string &&keyID_r,
zypp::Pathname &&targetDirectory_r )
61 MaybeAsyncRef<zypp::filesystem::Pathname> execute () {
63 using zyppng::operators::operator|;
70 importKeysInTargetDir();
76 if (
_info.gpgKeyUrlsEmpty() ) {
89 return _info.gpgKeyUrls()
93 return fetchKey( url )
100 if ( !key.isValid() )
106 }
catch (
const std::exception & e ) {
109 MIL <<
"Key import from url:'"<<url<<
"' failed." << std::endl;
118 return writeKeysToTargetDir();
124 MaybeAsyncRef<zyppng::expected<zypp::ManagedFile>> fetchKey (
const zypp::Url &url ) {
129 void importKeysInTargetDir () {
137 [
this](
const zypp::Pathname & dir_r,
const std::string & str_r ){
151 ERR <<
"Error importing cached key from file '"<<dir_r/str_r<<
"'."<<std::endl;
163 for (
const auto & key:
_tempKeyRing.trustedPublicKeyData()) {
164 MIL <<
"KEY ID in KEYRING: " << key.id() << std::endl;
168 std::ofstream fout( keyFile.
c_str(), std::ios_base::out | std::ios_base::trunc );
183 ERR <<
"Error when exporting key from temporary keychain." << std::endl;
201 struct AsyncRepoInfoProvideKey :
public RepoInfoProvideKeyLogic<AsyncRepoInfoProvideKey, zyppng::AsyncOp<zypp::Pathname>>
203 using RepoInfoProvideKeyLogic::RepoInfoProvideKeyLogic;
206 struct SyncRepoInfoProvideKey :
public RepoInfoProvideKeyLogic<SyncRepoInfoProvideKey, zyppng::SyncOp<zypp::Pathname>>
208 using RepoInfoProvideKeyLogic::RepoInfoProvideKeyLogic;
static const ValueType month
static Date now()
Return the current time.
Base class for Exception.
void dumpTrustedPublicKey(const std::string &id, std::ostream &stream)
void multiKeyImport(const Pathname &keyfile_r, bool trusted_r=false)
Initial import from RpmDb.
std::list< PublicKeyData > trustedPublicKeyData()
Get a list of trusted public key data in the keyring (key data only)
bool isKeyTrusted(const std::string &id)
true if the key id is trusted
@ STRINGEND
Match at string end.
Class representing one GPG Public Keys data.
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
What is known about a repository.
String matching (STRING|SUBSTRING|GLOB|REGEX).
std::string asString() const
Returns a default string representation of the Url object.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Wrapper class for stat/lstat.
const char * c_str() const
String representation.
std::string basename() const
Return the last component of this path.
bool empty() const
Test for an empty path.
Provide a new empty temporary directory and recursively delete it when no longer needed.
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
static expected success(ConsParams &&...params)
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
int unlink(const Pathname &path)
Like 'unlink'.
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::string asString(const Patch::Category &obj)
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)
std::shared_ptr< AsyncOp< T > > AsyncOpRef
typename remove_smart_ptr< T >::type remove_smart_ptr_t
ResultType and_then(const expected< T, E > &exp, Function &&f)
std::conditional_t< detail::is_async_op_v< OpType >, ContextRef, SyncContextRef > MaybeAsyncContextRef
Container< Ret > transform(Container< Msg, CArgs... > &&val, Transformation &&transformation)
zypp::filesystem::TmpDir _tmpKeyRingDir
zypp::KeyRing _tempKeyRing
const zypp::Pathname _targetDirectory_r
const std::string _keyIDStr
JobReportHelper< ZyppContextRefType > _reports
const std::string _keyID_r
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.