/******************************************************************************/
/* We define two queries that will be used to authenticate users from the */
/* database. QUERY will be used to check for normal mailboxes and */
/* VIRTUAL will query virtual domains */
/* Furthermore we define the query that will allow us to expand aliases */
/******************************************************************************/
/* virtual host query */
/* please read the README.queries file */
#ifndef VIRTUAL
#ifdef FUNKY_VIRTUAL_QUERIES
#ifdef HOST_HAS_PRECEDENCE
#define VIRTUAL_SORTING "wild_h, wild_u"
#else
#define VIRTUAL_SORTING "wild_u, wild_h"
#endif
#define VIRTUAL1 "select username, ext, virtual_host rlike '[%_]' as wild_h, virtual_username rlike '[%_]' as wild_u from virtual where '"
#define VIRTUAL2 "' like virtual_username and '"
#define VIRTUAL3 "' like virtual_host order by " VIRTUAL_SORTING " limit 1"
#else
#define VIRTUAL1 "select username, ext from virtual where (virtual_username='' or virtual_username='"
#define VIRTUAL2 "') and virtual_host='"
#define VIRTUAL3 "' order by virtual_username desc limit 1"
#endif
#define VIRTUAL VIRTUAL1 VIRTUAL2 VIRTUAL3
#endif
/* standard query */
#define QUERY "select uid, gid, home, '/bin/false' from mailbox where username='"
/* if we couldn't find a user we process an alias */
#ifndef ALIAS
#ifdef FUNKY_ALIAS_QUERIES
#ifdef ALIAS_HAS_PRECEDENCE
#define ALIAS_SORTING "wild_a, wild_u"
#define WILD "alias rlike '[%_]' as wild_a, username rlike '[%_]' as wild_u from alias where '"
#else
#define ALIAS_SORTING "wild_u, wild_a"
#define WILD "username rlike '[%_]' as wild_u, alias rlike '[%_]' as wild_a from alias where '"
#endif
#define ALIAS1 "select alias_username, alias_host, " WILD
#define ALIAS2 "' like username and '"
#define ALIAS3 "' like alias order by " ALIAS_SORTING
#else
#define ALIAS1 "select alias_username, alias_host from alias where username='"
#define ALIAS2 "' and alias='"
#define ALIAS3 "'"
#endif
#define ALIAS ALIAS1 ALIAS2 ALIAS3
#endif
/* is this domain in rcpthosts? */
#ifndef RCPTHOSTS
#define RCPTHOSTS "select host from rcpthosts where host='"
#endif
syntax highlighted by Code2HTML, v. 0.9.1