[dovecot-cvs] dovecot/src/auth auth-cache.c, 1.19, 1.20 auth-request.c, 1.67, 1.68
tss at dovecot.org
tss at dovecot.org
Sun Oct 15 17:43:18 UTC 2006
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv23644
Modified Files:
auth-cache.c auth-request.c
Log Message:
auth cache didn't work properly with multiple passdbs.
Index: auth-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-cache.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- auth-cache.c 13 Oct 2006 16:37:14 -0000 1.19
+++ auth-cache.c 15 Oct 2006 16:43:14 -0000 1.20
@@ -157,8 +157,9 @@
*expired_r = FALSE;
+ /* %! is prepended automatically. it contains the passdb ID number. */
str = t_str_new(256);
- var_expand(str, key,
+ var_expand(str, t_strconcat("%!/", key, NULL),
auth_request_get_var_expand_table(request,
auth_request_str_escape));
@@ -194,8 +195,9 @@
struct auth_cache_node *node;
size_t data_size, alloc_size, value_len = strlen(value);
+ /* %! is prepended automatically. it contains the passdb ID number. */
str = t_str_new(256);
- var_expand(str, key,
+ var_expand(str, t_strconcat("%!/", key, NULL),
auth_request_get_var_expand_table(request,
auth_request_str_escape));
Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- auth-request.c 15 Oct 2006 16:20:01 -0000 1.67
+++ auth-request.c 15 Oct 2006 16:43:15 -0000 1.68
@@ -353,6 +353,23 @@
return TRUE;
}
+static void
+auth_request_verify_plain_callback_finish(enum passdb_result result,
+ struct auth_request *request)
+{
+ if (!auth_request_handle_passdb_callback(&result, request)) {
+ /* try next passdb */
+ auth_request_verify_plain(request, request->mech_password,
+ request->private_callback.verify_plain);
+ } else {
+ auth_request_ref(request);
+ request->private_callback.verify_plain(result, request);
+ safe_memset(request->mech_password, 0,
+ strlen(request->mech_password));
+ auth_request_unref(&request);
+ }
+}
+
void auth_request_verify_plain_callback(enum passdb_result result,
struct auth_request *request)
{
@@ -376,17 +393,7 @@
}
}
- if (!auth_request_handle_passdb_callback(&result, request)) {
- /* try next passdb */
- auth_request_verify_plain(request, request->mech_password,
- request->private_callback.verify_plain);
- } else {
- auth_request_ref(request);
- request->private_callback.verify_plain(result, request);
- safe_memset(request->mech_password, 0,
- strlen(request->mech_password));
- auth_request_unref(&request);
- }
+ auth_request_verify_plain_callback_finish(result, request);
}
void auth_request_verify_plain(struct auth_request *request,
@@ -418,7 +425,7 @@
cache_key = passdb_cache == NULL ? NULL : passdb->cache_key;
if (passdb_cache_verify_plain(request, cache_key, password,
&result, FALSE)) {
- callback(result, request);
+ auth_request_verify_plain_callback_finish(result, request);
return;
}
@@ -433,6 +440,26 @@
}
}
+static void
+auth_request_lookup_credentials_callback_finish(enum passdb_result result,
+ const char *password,
+ struct auth_request *request)
+{
+ if (!auth_request_handle_passdb_callback(&result, request)) {
+ /* try next passdb */
+ auth_request_lookup_credentials(request, request->credentials,
+ request->private_callback.lookup_credentials);
+ } else {
+ if (request->auth->verbose_debug_passwords &&
+ result == PASSDB_RESULT_OK) {
+ auth_request_log_debug(request, "password",
+ "Credentials: %s", password);
+ }
+ request->private_callback.
+ lookup_credentials(result, password, request);
+ }
+}
+
void auth_request_lookup_credentials_callback(enum passdb_result result,
const char *password,
struct auth_request *request)
@@ -464,19 +491,8 @@
}
}
- if (!auth_request_handle_passdb_callback(&result, request)) {
- /* try next passdb */
- auth_request_lookup_credentials(request, request->credentials,
- request->private_callback.lookup_credentials);
- } else {
- if (request->auth->verbose_debug_passwords &&
- result == PASSDB_RESULT_OK) {
- auth_request_log_debug(request, "password",
- "Credentials: %s", password);
- }
- request->private_callback.
- lookup_credentials(result, password, request);
- }
+ auth_request_lookup_credentials_callback_finish(result, password,
+ request);
}
void auth_request_lookup_credentials(struct auth_request *request,
@@ -496,8 +512,11 @@
if (passdb_cache_lookup_credentials(request, cache_key,
&password, &scheme,
&result, FALSE)) {
- passdb_handle_credentials(result, password, scheme,
- callback, request);
+ password = result != PASSDB_RESULT_OK ? NULL :
+ passdb_get_credentials(request, password,
+ scheme);
+ auth_request_lookup_credentials_callback_finish(
+ result, password, request);
return;
}
}
@@ -894,6 +913,7 @@
{ 'r', NULL },
{ 'p', NULL },
{ 'w', NULL },
+ { '!', NULL },
{ '\0', NULL }
};
struct var_expand_table *tab;
@@ -921,6 +941,8 @@
tab[8].value = escape_func(auth_request->mech_password,
auth_request);
}
+ tab[9].value = auth_request->passdb == NULL ? "" :
+ dec2str(auth_request->passdb->id);
return tab;
}
More information about the dovecot-cvs
mailing list