36 m_task(*this,es,
"<<verifier exec error: __strerror__>>",
G::Root::nobody())
42 G_ASSERT( !m_config.domain.empty() ) ;
43 G_ASSERT( !request.address.empty() ) ;
44 G_DEBUG(
"GVerifiers::ExecutableVerifier::verify: to=[" << request.address <<
"]" ) ;
45 m_command = request.command ;
48 commandline.add( request.address ) ;
49 commandline.add( request.from_address ) ;
51 commandline.add( m_config.domain ) ;
53 commandline.add( request.auth_extra ) ;
55 G_LOG(
"GVerifiers::ExecutableVerifier: address verifier: executing " << commandline.displayString() ) ;
56 m_to_address = request.address ;
57 m_task.start( commandline ) ;
58 if( m_config.timeout )
59 m_timer.startTimer( m_config.timeout ) ;
62void GVerifiers::ExecutableVerifier::onTimeout()
68 m_done_signal.emit( m_command , result ) ;
71void GVerifiers::ExecutableVerifier::onTaskDone(
int exit_code ,
const std::string & result_in )
73 m_timer.cancelTimer() ;
77 G_WARNING(
"GVerifiers::ExecutableVerifier: address verifier: exec error" ) ;
82 std::string result( result_in ) ;
88 result_parts.reserve( 2U ) ;
90 std::size_t parts = result_parts.size() ;
91 result_parts.resize( 2U ) ;
93 G_LOG(
"GVerifiers::ExecutableVerifier: address verifier: exit code " << exit_code <<
": "
96 if( exit_code == 0 && parts >= 2 )
102 else if( exit_code == 1 && parts >= 2 )
107 else if( exit_code == 100 )
109 status.abort = true ;
113 bool temporary = exit_code == 3 ;
115 std::string response = parts > 0U ?
117 std::string(
"mailbox unavailable") ;
119 std::string reason = parts > 1U ?
121 (
"exit code " +
G::Str::fromInt(exit_code) ) ;
124 temporary , response , reason ) ;
127 doneSignal().emit( m_command , status ) ;
132 return m_done_signal ;
135void GVerifiers::ExecutableVerifier::cancel()
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
static VerifierStatus local(const std::string &recipient, const std::string &full_name, const std::string &mbox)
Constructor for a valid local mailbox.
static VerifierStatus invalid(const std::string &recipient, bool temporary=false, const std::string &response={}, const std::string &reason={})
Factory function for an invalid address.
static VerifierStatus remote(const std::string &recipient, const std::string &address={})
Constructor for a valid remote mailbox.
A Verifier that runs an executable.
ExecutableVerifier(GNet::EventState, const GSmtp::Verifier::Config &, const G::Path &)
Constructor.
std::string displayString() const
Returns a printable string that represents the transport address.
A structure representing an external program, holding a path and a set of arguments.
A Path object represents a file system path.
static std::string & trimRight(std::string &s, std::string_view ws, std::size_t limit=0U)
Trims the rhs of s, taking off up to 'limit' of the 'ws' characters.
static std::string lower(std::string_view)
Returns a copy of 's' in which all seven-bit upper-case characters have been replaced by lower-case c...
static bool headMatch(std::string_view in, std::string_view head) noexcept
Returns true if the string has the given start (or head is empty).
static void splitIntoFields(std::string_view in, StringArray &out, char sep, char escape='\0', bool remove_escapes=true)
Splits the string into fields.
static std::string printable(const std::string &in, char escape='\\')
Returns a printable representation of the given input string, using chacter code ranges 0x20 to 0x7e ...
static unsigned int replaceAll(std::string &s, std::string_view from, std::string_view to)
Does a global replace on string 's', replacing all occurrences of sub-string 'from' with 'to'.
std::vector< std::string > StringArray
A std::vector of std::strings.
Configuration passed to address verifier constructors.
Verification request passed to various GSmtp::Verifier::verify() overrides.