34 m_command(
GSmtp::Verifier::Command::VRFY) ,
37 m_task(*this,es,
"<<verifier exec error: __strerror__>>",
G::Root::nobody())
41void GVerifiers::ExecutableVerifier::verify( GSmtp::Verifier::Command command ,
const std::string & to_address ,
45 G_DEBUG(
"GVerifiers::ExecutableVerifier::verify: to=[" << to_address <<
"]" ) ;
48 commandline.add( to_address ) ;
49 commandline.add( info.mail_from_parameter ) ;
50 commandline.add( info.client_ip.displayString() ) ;
51 commandline.add( info.domain ) ;
53 commandline.add( info.auth_extra ) ;
55 G_LOG(
"GVerifiers::ExecutableVerifier: address verifier: executing " << commandline.displayString() ) ;
56 m_to_address = to_address ;
57 m_task.start( commandline ) ;
59 m_timer.startTimer( m_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 tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
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::ExceptionSink, const G::Path &, unsigned int timeout)
Constructor.
A structure representing an external program, holding a path and a set of arguments.
A Path object represents a file system path.
static unsigned int replaceAll(std::string &s, string_view from, string_view to)
Does a global replace on string 's', replacing all occurrences of sub-string 'from' with 'to'.
static std::string lower(string_view)
Returns a copy of 's' in which all seven-bit upper-case characters have been replaced by lower-case c...
static std::string & trimRight(std::string &s, 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 printable(const std::string &in, char escape='\\')
Returns a printable representation of the given input string, using chacter code ranges 0x20 to 0x7e ...
static void splitIntoFields(string_view in, StringArray &out, char sep, char escape='\0', bool remove_escapes=true)
Splits the string into fields.
static bool headMatch(const std::string &in, string_view head) noexcept
Returns true if the string has the given start (or head is empty).
std::vector< std::string > StringArray
A std::vector of std::strings.
Extra information passed to GSmtp::Verifier::verify().