50 line += readResult.second;
52 switch ( readResult.first ) {
54 case io::ReceiveUpToResult::Success:
59 case io::ReceiveUpToResult::Timeout:
63 case io::ReceiveUpToResult::Error:
64 case io::ReceiveUpToResult::EndOfFile:
73 WAR <<
"ABORT by callback: pid " << prog_r.
getpid() << endl;
76 return prog_r.
close();
83 if ( not line_r.empty() && line_r.back() ==
'\n' )
85 return cb_r( std::move(line_r) );
91 return cb_r ? cb_r( std::nullopt ) :
true;
95 if ( cb_r && not line_r.empty() )
96 cb_r( std::move(line_r) );
158 [
this](
const Pathname & dir_r,
const char *
const name_r ) ->
bool {
174 [&,
this](
const Pathname & dir_r,
const char *
const name_r ) ->
bool {
189 INT <<
"chroot PluginRepoverification does not yet work." << endl;
194 args.push_back( pluginPath.asString() );
196 args.push_back(
"--file" );
197 args.push_back( file_r.
asString() );
198 args.push_back(
"--fsig" );
200 args.push_back(
"--fkey" );
202 args.push_back(
"--ralias" );
209 jobReport.
set(
"CmdId",
unsigned(cmd.getpid()) );
211 jobReport.set(
"CmdName",
"Repoverification plugin "+plugin_r );
212 jobReport.set(
"RepoInfo", data_r.
_repoinfo );
214 std::optional<std::ostringstream> buffer;
215 jobReport.debug(
"?" );
216 if ( not jobReport.haskey(
"!" ) )
217 buffer = std::ostringstream();
219 int ret = monitor( cmd, [&jobReport,&buffer,&cmd]( std::optional<std::string> line_r )->
bool {
221 DBG <<
"["<<cmd.getpid()<<
"> " << *line_r << endl;
222 if ( buffer ) (*buffer) << *line_r << endl;
223 return jobReport.data( *line_r );
226 return jobReport.debug(
"ping" );
232 const std::string & msg {
str::Format(
"Metadata rejected by '%1%' plugin (returned %2%)" ) % plugin_r % ret };
235 if ( buffer ) excp.
addHistory( buffer->str() );
253 {
return str <<
"PluginRepoverification::Impl"; }
257 {
return str << obj; }
266 PluginRepoverification::PluginRepoverification()
270 PluginRepoverification::PluginRepoverification( Pathname plugindir_r, Pathname chroot_r )
271 : _pimpl( new
Impl(
std::move(plugindir_r),
std::move(chroot_r) ) )
274 PluginRepoverification::~PluginRepoverification()
278 bool PluginRepoverification::isNeeded()
const
281 bool PluginRepoverification::checkIfNeeded()
302 PluginRepoverification::Checker::Checker(
Impl* pimpl_r )
void addHistory(const std::string &msg_r)
Add some message text to the history.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
int close() override
Wait for the progamm to complete.
std::vector< std::string > Arguments
bool kill()
Kill the program.
bool running()
Return whether program is running.
What is known about a repository.
Remember a files attributes to detect content changes.
const Pathname & path() const
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
void setBlocking(bool mode)
Set the blocking mode of the input stream.
FILE * inputFile() const
Return the input stream.
Wrapper class for stat/lstat.
static Pathname stripprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r with any root_r dir prefix striped.
bool emptyOrRoot() const
Test for "" or "/".
const std::string & asString() const
String representation.
std::string alias() const
unique identifier for this source.
Exceptiontype thrown if a plugins verification fails.
PluginRepoverification::Checker data storage.
Impl(RW_pointer< PluginRepoverification::Impl > parent_r, Pathname &&sigpathLocal_r, Pathname &&keypathLocal_r, RepoInfo &&repo_r)
RW_pointer< PluginRepoverification::Impl > _parent
FileChecker checking all repoverification plugins.
void operator()(const Pathname &file_r) const
Check the downloaded master index file.
PluginRepoverification implementation.
void pluginVerify(std::string plugin_r, const Pathname &file_r, const PluginRepoverification::Checker::Impl &data_r) const
const Pathname & plugindir() const
Impl & operator=(Impl &&)=delete
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
Impl(Pathname &&plugindir_r, Pathname &&chroot_r)
Impl(const Impl &)=delete
std::ostream & operator<<(std::ostream &str, const PluginRepoverification::Impl &obj)
Stream output.
void verifyWorkflow(const Pathname &file_r, RW_pointer< PluginRepoverification::Checker::Impl > datap_r) const
WatchFile _watchPlugindir
Impl & operator=(const Impl &)=delete
friend std::ostream & dumpOn(std::ostream &str, const Impl &obj)
std::ostream & dumpOn(std::ostream &str, const PluginRepoverification::Impl &obj)
Verbose stream output.
Repository metadata verification beyond GPG.
RW_pointer< Impl > _pimpl
Implementation class.
String related utilities and Regular expression matching.
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
std::pair< ReceiveUpToResult, std::string > receiveUpto(FILE *file, char c, timeout_type timeout, bool failOnUnblockError)
static constexpr timeout_type no_timeout
std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
bool operator==(const RepoType &obj1, const RepoType &obj2)
std::string numstring(char n, int w=0)
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Wrapper for const correct access via Smart pointer types.
JobReport convenience sending this instance of UserData with each message.
bool reportFinalLineUnlessEmpty(std::string &line_r, Callback &cb_r)
Monitor(io::timeout_type timeout_r=io::no_timeout)
bool reportTimeout(Callback &cb_r)
int operator()(ExternalProgram &prog_r, Callback cb_r=Callback())
bool reportLine(std::string &line_r, Callback &cb_r)
io::timeout_type _timeout
std::function< bool(std::optional< std::string >)> Callback
Report a line of output (without trailing NL) otherwise a life ping on timeout.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.