str_truncate(path, strlen(DICT_PATH_SHARED));
str_append(path, key->key->key);
- ret = dict_lookup(iter->conn->dict, iter->pool,
+ ret = dict_lookup(iter->conn->dict, NULL, iter->pool,
str_c(path), &key->value, &error);
if (ret > 0) {
e_debug(authdb_event(iter->auth_request),
/* <key> */
dict_connection_cmd_async(cmd);
event_add_str(cmd->event, "key", line);
- dict_lookup_async(cmd->conn->dict, line, cmd_lookup_callback, cmd);
+ dict_lookup_async(cmd->conn->dict, NULL, line, cmd_lookup_callback, cmd);
return 1;
}
i_zero(&ctx);
ctx.pool = pool_alloconly_create("doveadm dict lookup", 512);
ctx.ret = -2;
- dict_lookup_async(dict, key, dict_lookup_callback, &ctx);
+ dict_lookup_async(dict, NULL, key, dict_lookup_callback, &ctx);
while (ctx.ret == -2)
dict_wait(dict);
if (ctx.ret < 0) {
test_set_expected(dict, &res);
- test_assert(dict_lookup(dict, pool, "shared/dictmap/hello/world", &value, &error) == 1);
+ test_assert(dict_lookup(dict, NULL, pool, "shared/dictmap/hello/world", &value, &error) == 1);
test_assert_strcmp(value, "one");
if (error != NULL)
i_error("dict_lookup failed: %s", error);
dict_set(t, key, value);
if (dict_transaction_commit(&t, &error) < 0)
i_fatal("dict_transaction_commit(%s) failed: %s", key, error);
- if (dict_lookup(dict, pool_datastack_create(), key, &got_value,
+ if (dict_lookup(dict, NULL, pool_datastack_create(), key, &got_value,
&error) < 0)
i_fatal("dict_lookup(%s) failed: %s", key, error);
test_assert_strcmp(got_value, value);
i_zero(&lookup);
lookup.ret = -2;
- dict_lookup_async(_dict, key, client_dict_lookup_callback, &lookup);
+ dict_lookup_async(_dict, NULL, key, client_dict_lookup_callback, &lookup);
if (lookup.ret == -2)
client_dict_wait(_dict);
dict = xlua_dict_getptr(L, 1, NULL);
key = luaL_checkstring(L, 2);
- dict_lookup_async(dict, key, lua_dict_lookup_callback, L);
+ dict_lookup_async(dict, NULL, key, lua_dict_lookup_callback, L);
return lua_dict_async_continue(L,
lua_yieldk(L, 0, 0, lua_dict_async_continue), 0);
}
}
-int dict_lookup(struct dict *dict, pool_t pool, const char *key,
+int dict_lookup(struct dict *dict, const struct dict_op_settings *set ATTR_UNUSED,
+ pool_t pool, const char *key,
const char **value_r, const char **error_r)
{
struct event *event = event_create(dict->event);
}
#undef dict_lookup_async
-void dict_lookup_async(struct dict *dict, const char *key,
- dict_lookup_callback_t *callback, void *context)
+void dict_lookup_async(struct dict *dict, const struct dict_op_settings *set ATTR_UNUSED,
+ const char *key, dict_lookup_callback_t *callback,
+ void *context)
{
if (dict->v.lookup_async == NULL) {
struct dict_lookup_result result;
i_zero(&result);
/* event is going to be sent by dict_lookup */
- result.ret = dict_lookup(dict, pool_datastack_create(),
+ result.ret = dict_lookup(dict, NULL, pool_datastack_create(),
key, &result.value, &result.error);
const char *const values[] = { result.value, NULL };
result.values = values;
struct event *event_parent;
};
+struct dict_op_settings {
+ const char *username;
+ /* home directory for the user, if known */
+ const char *home_dir;
+};
+
struct dict_lookup_result {
int ret;
/* Lookup value for key. Set it to NULL if it's not found.
Returns 1 if found, 0 if not found and -1 if lookup failed. */
-int dict_lookup(struct dict *dict, pool_t pool,
+int dict_lookup(struct dict *dict, const struct dict_op_settings *set, pool_t pool,
const char *key, const char **value_r, const char **error_r);
-void dict_lookup_async(struct dict *dict, const char *key,
- dict_lookup_callback_t *callback, void *context);
-#define dict_lookup_async(dict, key, callback, context) \
- dict_lookup_async(dict, key, (dict_lookup_callback_t *)(callback), \
+void dict_lookup_async(struct dict *dict, const struct dict_op_settings *set,
+ const char *key, dict_lookup_callback_t *callback,
+ void *context);
+#define dict_lookup_async(dict, set, key, callback, context) \
+ dict_lookup_async(dict, set, key, (dict_lookup_callback_t *)(callback), \
1 ? (context) : \
CALLBACK_TYPECHECK(callback, \
void (*)(const struct dict_lookup_result *, typeof(context))))
switch (i_rand_limit(4)) {
case 0:
pending++;
- dict_lookup_async(dict, key, lookup_callback, NULL);
+ dict_lookup_async(dict, NULL, key, lookup_callback, NULL);
break;
case 1: {
struct dict_transaction_context *trans;
if (file->value != NULL)
return 0;
- ret = dict_lookup(fs->dict, file->pool, file->key, &file->value, &error);
+ ret = dict_lookup(fs->dict, NULL, file->pool, file->key, &file->value, &error);
if (ret > 0)
return 0;
else if (ret < 0) {
/* do a synchronous dict lookup */
lookup_key = t_strconcat(DICT_PATH_SHARED, azp, "/", alg, "/", key_id,
NULL);
- if ((ret = dict_lookup(set->key_dict, pool_datastack_create(),
+ if ((ret = dict_lookup(set->key_dict, NULL, pool_datastack_create(),
lookup_key, &base64_key, error_r)) < 0) {
return -1;
} else if (ret == 0) {
/* do a synchronous dict lookup */
lookup_key = t_strconcat(DICT_PATH_SHARED, azp, "/", alg, "/", key_id,
NULL);
- if ((ret = dict_lookup(set->key_dict, pool_datastack_create(),
+ if ((ret = dict_lookup(set->key_dict, NULL, pool_datastack_create(),
lookup_key, &key_str, error_r)) < 0) {
return -1;
} else if (ret == 0) {
if (index_storage_get_dict(box, type_flags, &dict, &mailbox_prefix) < 0)
return -1;
- ret = dict_lookup(dict, pool_datastack_create(),
+ ret = dict_lookup(dict, NULL, pool_datastack_create(),
key_get_prefixed(type_flags, mailbox_prefix, key),
&value_r->value, &error);
if (ret < 0) {
const char *key, *value, *error;
key = want_bytes ? DICT_QUOTA_CURRENT_BYTES_PATH :
DICT_QUOTA_CURRENT_COUNT_PATH;
- ret = dict_lookup(root->dict, unsafe_data_stack_pool,
+ ret = dict_lookup(root->dict, NULL, unsafe_data_stack_pool,
key, &value, &error);
if (ret < 0) {
*error_r = t_strdup_printf(