diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/auth/userdb-prefetch.c | |
parent | Initial commit. (diff) | |
download | dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/auth/userdb-prefetch.c')
-rw-r--r-- | src/auth/userdb-prefetch.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/auth/userdb-prefetch.c b/src/auth/userdb-prefetch.c new file mode 100644 index 0000000..a5730b9 --- /dev/null +++ b/src/auth/userdb-prefetch.c @@ -0,0 +1,59 @@ +/* Copyright (c) 2004-2018 Dovecot authors, see the included COPYING file */ + +#include "auth-common.h" +#include "userdb.h" + +#ifdef USERDB_PREFETCH + +#include "str.h" +#include "var-expand.h" + + +static void prefetch_lookup(struct auth_request *auth_request, + userdb_callback_t *callback) +{ + /* auth_request_set_field() should have already placed the userdb_* + values to userdb_reply. */ + if (!auth_request->userdb_prefetch_set) { + if (auth_request_get_auth(auth_request)->userdbs->next == NULL) { + /* no other userdbs */ + if (auth_request->userdb_lookup) { + e_error(authdb_event(auth_request), + "userdb lookup not possible with only userdb prefetch"); + } else { + e_error(authdb_event(auth_request), + "passdb didn't return userdb entries"); + } + callback(USERDB_RESULT_INTERNAL_FAILURE, auth_request); + return; + } + /* more userdbs, they may know the user */ + e_debug(authdb_event(auth_request), + "passdb didn't return userdb entries, " + "trying the next userdb"); + callback(USERDB_RESULT_USER_UNKNOWN, auth_request); + return; + } + + e_debug(authdb_event(auth_request), "success"); + callback(USERDB_RESULT_OK, auth_request); +} + +struct userdb_module_interface userdb_prefetch = { + "prefetch", + + NULL, + NULL, + NULL, + + prefetch_lookup, + + NULL, + NULL, + NULL +}; +#else +struct userdb_module_interface userdb_prefetch = { + .name = "prefetch" +}; +#endif |