Skip to content
Snippets Groups Projects
Commit 997a2f13 authored by Stephan Bosch's avatar Stephan Bosch Committed by Timo Sirainen
Browse files

lib-sieve: storage: dict: Rely on username being available at runtime

parent ad09a2e2
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ sieve_dict_script_open(struct sieve_script *script,
enum sieve_error *error_code_r)
{
struct sieve_storage *storage = script->storage;
struct sieve_instance *svinst = storage->svinst;
struct sieve_dict_script *dscript =
container_of(script, struct sieve_dict_script, script);
struct sieve_dict_storage *dstorage =
......@@ -82,7 +83,7 @@ sieve_dict_script_open(struct sieve_script *script,
dict_escape_string(name), NULL);
struct dict_op_settings set = {
.username = dstorage->username,
.username = svinst->username,
};
ret = dict_lookup(dscript->dict, &set, script->pool, path,
&data_id, &error);
......@@ -113,10 +114,9 @@ sieve_dict_script_get_stream(struct sieve_script *script,
enum sieve_error *error_code_r)
{
struct sieve_storage *storage = script->storage;
struct sieve_instance *svinst = storage->svinst;
struct sieve_dict_script *dscript =
container_of(script, struct sieve_dict_script, script);
struct sieve_dict_storage *dstorage =
container_of(storage, struct sieve_dict_storage, storage);
const char *path, *name = script->name, *data, *error;
int ret;
......@@ -127,7 +127,7 @@ sieve_dict_script_get_stream(struct sieve_script *script,
dict_escape_string(dscript->data_id), NULL);
struct dict_op_settings set = {
.username = dstorage->username,
.username = svinst->username,
};
ret = dict_lookup(dscript->dict, &set, dscript->data_pool, path,
&data, &error);
......
......@@ -34,7 +34,7 @@ sieve_dict_storage_init(struct sieve_storage *storage,
struct sieve_dict_storage *dstorage =
container_of(storage, struct sieve_dict_storage, storage);
struct sieve_instance *svinst = storage->svinst;
const char *value, *uri = storage->location, *username = NULL;
const char *value, *uri = storage->location;
if (options != NULL) {
while (*options != NULL) {
......@@ -42,7 +42,7 @@ sieve_dict_storage_init(struct sieve_storage *storage,
if (str_begins_icase(option, "user=", &value) &&
*value != '\0') {
username = option+5;
/* Ignore */
} else {
sieve_storage_set_critical(
storage, "Invalid option '%s'", option);
......@@ -54,9 +54,6 @@ sieve_dict_storage_init(struct sieve_storage *storage,
}
}
if (username == NULL)
username = svinst->username;
if (svinst->base_dir == NULL) {
sieve_storage_set_critical(
storage,
......@@ -65,14 +62,13 @@ sieve_dict_storage_init(struct sieve_storage *storage,
return -1;
}
e_debug(storage->event, "user=%s, uri=%s", username, uri);
e_debug(storage->event, "user=%s, uri=%s", svinst->username, uri);
dstorage->uri = p_strdup(storage->pool, uri);
dstorage->username = p_strdup(storage->pool, username);
storage->location = p_strconcat(
storage->pool, SIEVE_DICT_STORAGE_DRIVER_NAME, ":",
storage->location, ";user=", username, NULL);
storage->location, ";user=", svinst->username, NULL);
return 0;
}
......@@ -96,7 +92,7 @@ sieve_dict_storage_get_dict(struct sieve_dict_storage *dstorage,
if (ret < 0) {
sieve_storage_set_critical(storage,
"Failed to initialize dict with data '%s' for user '%s': %s",
dstorage->uri, dstorage->username, error);
dstorage->uri, svinst->username, error);
*error_code_r = SIEVE_ERROR_TEMP_FAILURE;
return -1;
}
......
......@@ -18,7 +18,6 @@
struct sieve_dict_storage {
struct sieve_storage storage;
const char *username;
const char *uri;
struct dict *dict;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.