19#undef ZYPP_BASE_LOGGER_LOGGROUP
20#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::plugin"
25 struct ProtocolError : SigcheckPluginException {
26 ProtocolError(
const PluginScript & script_r,
const PluginFrame & got_r, std::string_view expected_r )
27 : SigcheckPluginException(
str::sprint( script_r.script(),
"protocol error: got",got_r.command(),
"expected",expected_r ))
29 if ( got_r.isErrorCommand() && not got_r.body().empty() ) {
31 static constexpr size_t maxErrorMessageSize = 2048;
32 addHistory( got_r.body().asString( maxErrorMessageSize ) );
56 _script.openChrooted( chroot_r );
59 PluginFrame frame(
"PLUGINBEGIN", { {
"version",
"0"} } );
67 if ( ret.
command() !=
"PLUGINSETUP" ) {
70 if ( ret.
hasKey(
"sig_extension" ) )
72 if ( ret.
hasKey(
"key_extension" ) )
97 if ( not sig_r.empty() )
99 if ( not key_r.empty() )
134 {
return _pimpl->launch( chroot_r ); }
137 {
return _pimpl->_sigExtension; }
140 {
return _pimpl->_keyExtension; }
143 {
return _pimpl->sigcheck( data_r, sig_r, key_r ); }
163 if ( plugpath.
empty() ) {
169 if ( not plugpath.
empty() ) {
170 if ( plugargs.empty() )
171 _plugins.emplace_back( std::move(plugpath) );
173 _plugins.emplace_back( std::move(plugpath), std::move(plugargs) );
182 {
for (
auto & plugin :
_plugins ) plugin.launch( chroot_r ); }
197 :
_pimpl { new
Impl( cmdline_r, plugindir_r ) }
200 SigcheckPlugins::operator
bool()
const
204 {
return _pimpl->_plugins; }
207 {
return _pimpl->launch( chroot_r ); }
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Base class for Exception.
static Pathname stripprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r with any root_r dir prefix striped.
Command frame for communication with PluginScript.
const std::string & command() const
Return the frame command.
void addHeader(const std::string &key_r, const std::string &value_r=std::string())
Add header for key_r leaving already existing headers for key_r unchanged.
const std::string & getHeader(const std::string &key_r) const
Return header value for key_r.
bool isAckCommand() const
Convenience to identify an ACK command.
bool hasKey(const std::string &key_r) const
Whether the header list contains at least one entry for key_r.
Interface to plugin scripts using a Stomp inspired communication protocol.
std::string sigExtension() const
Extension of a signature file to retrieve.
RW_pointer< Impl > _pimpl
SigcheckPlugin(const SigcheckPlugin &)=delete
void launch(const Pathname &chroot_r=Pathname())
Launch the plugin.
void sigcheck(const Pathname &data_r, const Pathname &sig_r=Pathname(), const Pathname &key_r=Pathname()) const
Let plugin do the signature check.
std::string keyExtension() const
Extension of a key file to retrieve.
std::vector< std::string > Args
const Plugins & plugins()
All plugins (their addresses can be captured).
SigcheckPlugins(const SigcheckPlugins &)=delete
void launch(const Pathname &chroot_r=Pathname())
Launch all plugins (optionally chrooted).
RW_pointer< Impl > _pimpl
SigcheckPlugins()
No plugins.
std::vector< SigcheckPlugin > Plugins
bool empty() const
Test for an empty path.
String related utilities and Regular expression matching.
std::string sprint(Args &&... args)
Print words as string.
std::vector< std::string_view > splitBSEscaped(std::string_view line_r, std::string_view chars_r, unsigned maxSplits_r)
std::string unBSEscape(std::string_view word_r)
Easy-to use interface to the ZYPP dependency resolver.
detail::Dump< Tp > dump(const Tp &obj_r)
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Exception thrown by SigcheckPlugins.
void sigcheck(const Pathname &data_r, const Pathname &sig_r=Pathname(), const Pathname &key_r=Pathname()) const
std::string _keyExtension
std::string _sigExtension
Impl(Pathname script_r, Args args_r)
void launch(const Pathname &chroot_r)
void launch(const Pathname &chroot_r=Pathname())
Impl(const std::string &cmdline_r, const Pathname &plugindir_r)