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 ) );
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() )
126 : _pimpl {
new Impl( std::move(script_r) ) }
130 : _pimpl {
new Impl( std::move(script_r), std::move(args_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 ); }
193 : _pimpl {
new Impl() }
197 : _pimpl {
new Impl( cmdline_r, plugindir_r ) }
200 SigcheckPlugins::operator
bool()
const 201 {
return bool(*_pimpl); }
SigcheckPlugins()
No plugins.
bool hasKey(const std::string &key_r) const
Whether the header list contains at least one entry for key_r.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Command frame for communication with PluginScript.
Exception thrown by SigcheckPlugins.
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
void launch(const Pathname &chroot_r=Pathname())
const std::string & command() const
Return the frame command.
String related utilities and Regular expression matching.
const Pathname & script() const
Return the script path if set.
void launch(const Pathname &chroot_r)
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.
PluginFrame receive() const
Receive a PluginFrame.
void sigcheck(const Pathname &data_r, const Pathname &sig_r=Pathname(), const Pathname &key_r=Pathname()) const
Let plugin do the signature check.
Impl(const std::string &cmdline_r, const Pathname &plugindir_r)
SigcheckPlugin(const SigcheckPlugin &)=delete
const Plugins & plugins()
All plugins (their addresses can be captured).
std::string _keyExtension
bool empty() const
Test for an empty path.
std::string _sigExtension
void sigcheck(const Pathname &data_r, const Pathname &sig_r=Pathname(), const Pathname &key_r=Pathname()) const
std::vector< std::string > Args
void send(const PluginFrame &frame_r) const
Send a PluginFrame.
Impl(Pathname script_r, Args args_r)
Pathname getChroot() const
Return a connected scripts chroot or an empty Pathname.
bool isAckCommand() const
Convenience to identify an ACK command.
std::string sigExtension() const
Extension of a signature file to retrieve.
std::string unBSEscape(std::string_view word_r)
std::vector< std::string_view > splitBSEscaped(std::string_view line_r, std::string_view chars_r, unsigned maxSplits_r)
std::string keyExtension() const
Extension of a key file to retrieve.
void launch(const Pathname &chroot_r=Pathname())
Launch all plugins (optionally chrooted).
int close()
Close any open connection.
Base class for Exception.
std::vector< SigcheckPlugin > Plugins
const std::string & getHeader(const std::string &key_r) const
Return header value for key_r.
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
RW_pointer< Impl > _pimpl
Interface to plugin scripts using a Stomp inspired communication protocol.
Easy-to use interface to the ZYPP dependency resolver.
std::string sprint(Args &&... args)
Print words as string.
RW_pointer< Impl > _pimpl
detail::Dump< Tp > dump(const Tp &obj_r)
static Pathname stripprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r with any root_r dir prefix striped.
bool isOpen() const
Whether we are connected to a script.
void launch(const Pathname &chroot_r=Pathname())
Launch the plugin.
Handle a bunch of SigcheckPlugins.
void openChrooted(const Pathname &chroot_r)
Like open() but runs the script chrooted into chroot_r.