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> {
44 using ZyppContextRefType = MaybeAsyncContextRef<OpType>;
45 using ZyppContextType = remove_smart_ptr_t<ZyppContextRefType>;
46 using ProvideType =
typename ZyppContextType::ProvideType;
47 using MediaHandle =
typename ProvideType::MediaHandle;
48 using ProvideRes =
typename ProvideType::Res;
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();
93 return fetchKey( url )
100 if ( !key.isValid() )
106 }
catch (
const std::exception & e ) {
109 MIL <<
"Key import from url:'"<<url<<
"' failed." << std::endl;
117 | [
this]( std::list<expected<void>> && ) ->zypp::Pathname {
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;
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;
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
auto transform(Transformation &&transformation)
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
void dumpTrustedPublicKey(const std::string &id, std::ostream &stream)
String matching (STRING|SUBSTRING|GLOB|REGEX).
Class representing one GPG Public Keys data.
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
const char * c_str() const
String representation.
const zypp::Pathname _targetDirectory_r
JobReportHelper< ZyppContextRefType > _reports
What is known about a repository.
std::list< PublicKeyData > trustedPublicKeyData()
Get a list of trusted public key data in the keyring (key data only)
std::string asUserString() const
User string: label (alias or name)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
const std::string _keyIDStr
static const ValueType month
const std::string _keyID_r
std::string asString(TInt val, char zero='0', char one='1')
For printing bits.
bool empty() const
Test for an empty path.
const zypp::RepoInfo _info
std::string asString() const
Returns a default string representation of the Url object.
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Provide a new empty temporary directory and recursively delete it when no longer needed.
zypp::KeyRing _tempKeyRing
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
int unlink(const Pathname &path)
Like 'unlink'.
void multiKeyImport(const Pathname &keyfile_r, bool trusted_r=false)
Initial import from RpmDb.
static expected success(ConsParams &&...params)
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
std::shared_ptr< AsyncOp< T > > AsyncOpRef
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Base class for Exception.
static Date now()
Return the current time.
zypp::Pathname provideKey(SyncContextRef ctx, zypp::RepoInfo info, std::string keyID_r, zypp::Pathname targetDirectory_r)
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
auto and_then(Fun &&function)
zypp::filesystem::TmpDir _tmpKeyRingDir
Wrapper class for ::stat/::lstat.
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.
bool isKeyTrusted(const std::string &id)
true if the key id is trusted