E-MailRelay
guserverifier.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file guserverifier.h
19///
20
21#ifndef G_USER_VERIFIER_H
22#define G_USER_VERIFIER_H
23
24#include "gdef.h"
25#include "gverifier.h"
26#include "geventstate.h"
27#include "gslot.h"
28#include "gtimer.h"
29#include <utility>
30
31namespace GVerifiers
32{
33 class UserVerifier ;
34}
35
36//| \class GVerifiers::UserVerifier
37/// A concrete Verifier class that verifies against the password database
38/// (ie. getpwnam() or LookupAccountName()).
39///
40/// The first part of the recipient address has to match an entry in the
41/// password database and the second part has to match the configured domain
42/// name. A sub-range for the password database entries can be configured
43/// via the 'spec' string. This has a sensible default that excludes
44/// system accounts. The domain name match is case insensitive.
45///
46/// By default the matching addresses are returned as valid local
47/// mailboxes and non-matching addresses are rejected. With "remote"
48/// the matching addresses are returned as remote. With "check" the
49/// non-matching addresses are returned as valid and remote.
50///
51/// The returned mailbox names are the account names as read from the
52/// password database, optionally with seven-bit uppercase letters
53/// converted to lowercase.
54///
56{
57public:
59 const GSmtp::Verifier::Config & config , const std::string & spec ) ;
60 ///< Constructor. The spec string is semi-colon separated list
61 ///< of values including a uid range and "lc"/"lowercase"
62 ///< eg. "1000-1002;pm;lc".
63
64private: // overrides
65 void verify( const GSmtp::Verifier::Request & ) override ; // GSmtp::Verifier
66 G::Slot::Signal<GSmtp::Verifier::Command,const GSmtp::VerifierStatus&> & doneSignal() override ; // GSmtp::Verifier
67 void cancel() override ; // GSmtp::Verifier
68
69private:
70 void onTimeout() ;
71 bool lookup( std::string_view , std::string_view , std::string * = nullptr , std::string * = nullptr ) const ;
72 static std::string_view dequote( std::string_view ) ;
73
74private:
76 GSmtp::Verifier::Command m_command {GSmtp::Verifier::Command::RCPT} ;
79 GSmtp::VerifierStatus m_result ;
80 Signal m_done_signal ;
81 std::pair<int,int> m_range ;
82 bool m_config_lc {false} ;
83 bool m_config_check {false} ;
84 bool m_config_remote {false} ;
85} ;
86
87#endif
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
A timer class template in which the timeout is delivered to the specified method.
Definition: gtimer.h:141
A structure returned by GSmtp::Verifier to describe the status of a 'rcpt-to' or 'vrfy' recipient.
An asynchronous interface that verifies recipient 'to' addresses.
Definition: gverifier.h:43
A concrete Verifier class that verifies against the password database (ie.
Definition: guserverifier.h:56
UserVerifier(GNet::EventState es, const GSmtp::Verifier::Config &config, const std::string &spec)
Constructor.
Address verifier classes.
Configuration passed to address verifier constructors.
Definition: gverifier.h:57
Verification request passed to various GSmtp::Verifier::verify() overrides.
Definition: gverifier.h:47