Mercurial > dovecot > core-2.2
changeset 20855:0b12b2cb67dd
auth: Pass userdb fields to worker
If this is not done, then those userdb handlers
that need access to userdb variables for e.g.
interpolation, cannot access them.
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Wed, 12 Oct 2016 12:04:10 +0300 |
parents | e706c8ff0922 |
children | 0b861a3aceca |
files | src/auth/auth-request.c src/auth/auth-worker-client.c |
diffstat | 2 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/auth-request.c Tue Oct 11 13:18:53 2016 +0300 +++ b/src/auth/auth-request.c Wed Oct 12 12:04:10 2016 +0300 @@ -7,6 +7,7 @@ #include "sha1.h" #include "hex-binary.h" #include "str.h" +#include "array.h" #include "safe-memset.h" #include "str-sanitize.h" #include "strescape.h" @@ -334,6 +335,15 @@ str_append(dest, "\tsuccessful"); if (request->mech_name != NULL) auth_str_add_keyvalue(dest, "mech", request->mech_name); + /* export any userdb fields */ + if (request->userdb_reply != NULL) { + const ARRAY_TYPE(auth_field) *fields = auth_fields_export(request->userdb_reply); + const struct auth_field *field; + array_foreach(fields, field) { + str_printfa(dest, "\tuserdb_%s=", field->key); + str_append_tabescaped(dest, field->value); + } + } } bool auth_request_import_info(struct auth_request *request, @@ -442,7 +452,11 @@ request->skip_password_check = TRUE; else if (strcmp(key, "mech") == 0) request->mech_name = p_strdup(request->pool, value); - else + else if (strncmp(key, "userdb_", 7) == 0) { + if (request->userdb_reply == NULL) + request->userdb_reply = auth_fields_init(request->pool); + auth_fields_add(request->userdb_reply, key+7, value, 0); + } else return FALSE; return TRUE;
--- a/src/auth/auth-worker-client.c Tue Oct 11 13:18:53 2016 +0300 +++ b/src/auth/auth-worker-client.c Wed Oct 12 12:04:10 2016 +0300 @@ -437,7 +437,8 @@ return FALSE; } - auth_request_init_userdb_reply(auth_request); + if (auth_request->userdb_reply == NULL) + auth_request_init_userdb_reply(auth_request); auth_request->userdb->userdb->iface-> lookup(auth_request, lookup_user_callback); return TRUE; @@ -605,7 +606,7 @@ unsigned int id; bool ret = FALSE; - args = t_strsplit_tab(line); + args = t_strsplit_tabescaped(line); if (args[0] == NULL || args[1] == NULL || args[2] == NULL || str_to_uint(args[0], &id) < 0) { i_error("BUG: Invalid input: %s", line);