41 const std::string & mechanism ,
const std::string & extra )
43 G_DEBUG(
"GSmtp::ExecutableVerifier::verify: to \"" << to <<
"\": from \"" << from <<
"\": "
44 <<
"ip \"" << ip.
displayString(
false) <<
"\": auth-mechanism \"" << mechanism <<
"\": "
45 <<
"auth-extra \"" << extra <<
"\"" ) ;
47 std::string user =
G::Str::head( to , to.find(
'@') , to ) ;
48 std::string host =
G::Str::tail( to , to.find(
'@') , std::string() ) ;
54 doneSignal().emit( to , status ) ;
58 const std::string & user ,
const std::string & host ,
const std::string & fqdn ,
const std::string & from ,
59 const GNet::Address & ip ,
const std::string & mechanism ,
const std::string & extra )
const
62 args.push_back( address ) ;
63 args.push_back( user ) ;
64 args.push_back( host ) ;
65 args.push_back( fqdn ) ;
66 args.push_back( from ) ;
68 args.push_back( mechanism ) ;
69 args.push_back( extra ) ;
70 G_LOG(
"GSmtp::ExecutableVerifier: executing " << m_exe.exe() <<
" " << address <<
" " << user <<
" "
71 << host <<
" " << fqdn <<
" " << from <<
" " << ip.
displayString(
false) <<
" "
72 <<
"\"" << mechanism <<
"\" \"" << extra <<
"\"" ) ;
74 std::string response ;
85 if( ( rc == 0 || rc == 1 ) && response_parts.size() >= 2 )
89 status.
full_name = response_parts.front() ;
90 response_parts.pop_front() ;
91 status.
address = response_parts.front() ;
95 throw Verifier::AbortRequest() ;
104 status.
help =
"rejected by external verifier program" ;
111 return m_done_signal ;
static int spawn(Identity nobody, const Path &exe, const Strings &args, std::string *pipe_result_p=NULL, int error_return=127, std::string(*error_decode_fn)(int)=0)
Runs a command in an unprivileged child process.
static std::string printable(const std::string &in, char escape= '\\')
Returns a printable represention of the given input string.
static Identity nobody()
Returns the 'nobody' identity.
virtual void verify(const std::string &rcpt_to_parameter, const std::string &mail_from_parameter, const GNet::Address &client_ip, const std::string &auth_mechanism, const std::string &auth_extra)
Final override from GSmtp::Verifier.
std::list< std::string > Strings
A std::list of std::strings.
static void splitIntoFields(const std::string &in, Strings &out, const std::string &seperators, char escape= '\0', bool discard_bogus_escapes=true)
Splits the string into fields.
A structure representing an external program, holding a path and a set of arguments.
The Address class encapsulates an IP transport address.
static std::string fqdn()
Returns the fully-qualified-domain-name.
static std::string fromInt(int i)
Converts int 'i' to a string.
static std::string tail(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the last part of the string after the given position.
std::string displayString(bool with_port=true, bool with_scope_id=false) const
Returns a string which represents the address for debugging and diagnostics purposes.
static unsigned int replaceAll(std::string &s, const std::string &from, const std::string &to)
Does a global replace on string 's', replacing all occurences of sub-string 'from' with 'to'...
static std::string head(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the first part of the string up to just before the given position.
static void trimRight(std::string &s, const std::string &ws, size_type limit=0U)
Trims the rhs of s, taking off up to 'limit' of the 'ws' characters.
static std::string upper(const std::string &s)
Returns a copy of 's' in which all lowercase characters have been replaced by uppercase characters...
ExecutableVerifier(const G::Executable &)
Constructor.
A structure returned by GSmtp::Verifier to describe the status of a rcpt-to recipient.
virtual void reset()
Final override from GSmtp::Verifier.
virtual G::Signal2< std::string, VerifierStatus > & doneSignal()
Final override from GSmtp::Verifier.