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

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

parent 997a2f13
No related branches found
No related tags found
No related merge requests found
...@@ -1201,9 +1201,9 @@ db_ldap_get_var_expand_table(struct ldap_connection *conn, const char *name) ...@@ -1201,9 +1201,9 @@ db_ldap_get_var_expand_table(struct ldap_connection *conn, const char *name)
memcpy(tab, auth_request_var_expand_static_tab, memcpy(tab, auth_request_var_expand_static_tab,
auth_count * sizeof(*tab)); auth_count * sizeof(*tab));
tab[0].value = ldap_escape(lstorage->username); tab[0].value = ldap_escape(svinst->username);
tab[1].value = ldap_escape(t_strcut(lstorage->username, '@')); tab[1].value = ldap_escape(t_strcut(svinst->username, '@'));
tab[2].value = strchr(lstorage->username, '@'); tab[2].value = strchr(svinst->username, '@');
if (tab[2].value != NULL) if (tab[2].value != NULL)
tab[2].value = ldap_escape(tab[2].value+1); tab[2].value = ldap_escape(tab[2].value+1);
tab[3].value = ldap_escape(svinst->home_dir); tab[3].value = ldap_escape(svinst->home_dir);
......
...@@ -47,7 +47,7 @@ sieve_ldap_storage_init(struct sieve_storage *storage, ...@@ -47,7 +47,7 @@ sieve_ldap_storage_init(struct sieve_storage *storage,
struct sieve_ldap_storage *lstorage = struct sieve_ldap_storage *lstorage =
container_of(storage, struct sieve_ldap_storage, storage); container_of(storage, struct sieve_ldap_storage, storage);
struct sieve_instance *svinst = storage->svinst; struct sieve_instance *svinst = storage->svinst;
const char *value, *username = NULL; const char *value;
if (options != NULL) { if (options != NULL) {
while (*options != NULL) { while (*options != NULL) {
...@@ -55,7 +55,7 @@ sieve_ldap_storage_init(struct sieve_storage *storage, ...@@ -55,7 +55,7 @@ sieve_ldap_storage_init(struct sieve_storage *storage,
if (str_begins_icase(option, "user=", &value) && if (str_begins_icase(option, "user=", &value) &&
*value != '\0') { *value != '\0') {
username = value; /* Ignore */
} else { } else {
sieve_storage_set_critical( sieve_storage_set_critical(
storage, "Invalid option '%s'", option); storage, "Invalid option '%s'", option);
...@@ -67,22 +67,18 @@ sieve_ldap_storage_init(struct sieve_storage *storage, ...@@ -67,22 +67,18 @@ sieve_ldap_storage_init(struct sieve_storage *storage,
} }
} }
if (username == NULL)
username = svinst->username;
e_debug(storage->event, "user=%s, config=%s", e_debug(storage->event, "user=%s, config=%s",
username, storage->location); svinst->username, storage->location);
if (sieve_ldap_storage_read_settings(lstorage, storage->location) < 0) if (sieve_ldap_storage_read_settings(lstorage, storage->location) < 0)
return -1; return -1;
lstorage->username = p_strdup(storage->pool, username);
lstorage->config_file = p_strdup(storage->pool, storage->location); lstorage->config_file = p_strdup(storage->pool, storage->location);
lstorage->conn = sieve_ldap_db_init(lstorage); lstorage->conn = sieve_ldap_db_init(lstorage);
storage->location = p_strconcat( storage->location = p_strconcat(
storage->pool, SIEVE_LDAP_STORAGE_DRIVER_NAME, ":", storage->pool, SIEVE_LDAP_STORAGE_DRIVER_NAME, ":",
storage->location, ";user=", username, NULL); storage->location, ";user=", svinst->username, NULL);
return 0; return 0;
} }
......
...@@ -66,7 +66,6 @@ struct sieve_ldap_storage { ...@@ -66,7 +66,6 @@ struct sieve_ldap_storage {
time_t set_mtime; time_t set_mtime;
const char *config_file; const char *config_file;
const char *username; // FIXME: needed?
struct ldap_connection *conn; struct ldap_connection *conn;
}; };
......
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.