mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-06 03:50:08 +02:00
remove potentially problematic cache for e2ee setting
This commit is contained in:
parent
814df2d72a
commit
fcff3f795b
5 changed files with 10 additions and 35 deletions
|
@ -2035,9 +2035,13 @@ static uint32_t send_msg_raw(dc_context_t* context, dc_chat_t* chat, const dc_ms
|
|||
}
|
||||
}
|
||||
|
||||
/* check if we can guarantee E2EE for this message. If we can, we won't send the message without E2EE later (because of a reset, changed settings etc. - messages may be delayed significally if there is no network present) */
|
||||
/* check if we can guarantee E2EE for this message.
|
||||
if we guarantee E2EE, and circumstances change
|
||||
so that E2EE is no longer available at a later point (reset, changed settings),
|
||||
we do not send the message out at all */
|
||||
int do_guarantee_e2ee = 0;
|
||||
if (context->e2ee_enabled && dc_param_get_int(msg->param, DC_PARAM_FORCE_PLAINTEXT, 0)==0)
|
||||
int e2ee_enabled = dc_sqlite3_get_config_int(context->sql, "e2ee_enabled", DC_E2EE_DEFAULT_ENABLED);
|
||||
if (e2ee_enabled && dc_param_get_int(msg->param, DC_PARAM_FORCE_PLAINTEXT, 0)==0)
|
||||
{
|
||||
int can_encrypt = 1, all_mutual = 1; /* be optimistic */
|
||||
stmt = dc_sqlite3_prepare(context->sql,
|
||||
|
|
|
@ -207,28 +207,6 @@ void* dc_get_userdata(dc_context_t* context)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function reads some simple integer flags for fast and easy access.
|
||||
* To keep multi-thread-safety, we must not cache strings this way.
|
||||
* The function is called by dc_config_set*() and by dc_open().
|
||||
*
|
||||
* @private @memberof dc_context_t
|
||||
* @param context The context object as created by dc_context_new().
|
||||
* @param key Name of the value to update, NULL to update all.
|
||||
* @return None.
|
||||
*/
|
||||
static void update_config_cache(dc_context_t* context, const char* key)
|
||||
{
|
||||
if (context==NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key==NULL || strcmp(key, "e2ee_enabled")==0) {
|
||||
context->e2ee_enabled = dc_sqlite3_get_config_int(context->sql, "e2ee_enabled", DC_E2EE_DEFAULT_ENABLED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open context database. If the given file does not exist, it is
|
||||
* created and can be set up using dc_set_config() afterwards.
|
||||
|
@ -274,8 +252,6 @@ int dc_open(dc_context_t* context, const char* dbfile, const char* blobdir)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
update_config_cache(context, NULL);
|
||||
|
||||
success = 1;
|
||||
|
||||
cleanup:
|
||||
|
@ -434,7 +410,6 @@ int dc_set_config(dc_context_t* context, const char* key, const char* value)
|
|||
}
|
||||
|
||||
cleanup:
|
||||
update_config_cache(context, key);
|
||||
free(rel_path);
|
||||
return ret;
|
||||
}
|
||||
|
@ -550,11 +525,8 @@ char* dc_get_info(dc_context_t* context)
|
|||
contacts = dc_get_real_contact_cnt(context);
|
||||
|
||||
is_configured = dc_sqlite3_get_config_int(context->sql, "configured", 0);
|
||||
|
||||
dbversion = dc_sqlite3_get_config_int(context->sql, "dbversion", 0);
|
||||
|
||||
e2ee_enabled = context->e2ee_enabled;
|
||||
|
||||
e2ee_enabled = dc_sqlite3_get_config_int(context->sql, "e2ee_enabled", DC_E2EE_DEFAULT_ENABLED);
|
||||
mdns_enabled = dc_sqlite3_get_config_int(context->sql, "mdns_enabled", DC_MDNS_DEFAULT_ENABLED);
|
||||
|
||||
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, "SELECT COUNT(*) FROM keypairs;");
|
||||
|
|
|
@ -89,8 +89,6 @@ struct _dc_context
|
|||
|
||||
uint32_t cmdline_sel_chat_id; /**< Internal */
|
||||
|
||||
int e2ee_enabled; /**< Internal */
|
||||
|
||||
#define DC_LOG_RINGBUF_SIZE 200
|
||||
pthread_mutex_t log_ringbuf_critical; /**< Internal */
|
||||
char* log_ringbuf[DC_LOG_RINGBUF_SIZE];
|
||||
|
|
|
@ -335,7 +335,7 @@ void dc_e2ee_encrypt(dc_context_t* context, const clist* recipients_addr,
|
|||
|
||||
/* init autocrypt header from db */
|
||||
autocryptheader->prefer_encrypt = DC_PE_NOPREFERENCE;
|
||||
if (context->e2ee_enabled) {
|
||||
if (dc_sqlite3_get_config_int(context->sql, "e2ee_enabled", DC_E2EE_DEFAULT_ENABLED)) {
|
||||
autocryptheader->prefer_encrypt = DC_PE_MUTUAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,8 @@ char* dc_render_setup_file(dc_context_t* context, const char* passphrase)
|
|||
self_addr = dc_sqlite3_get_config(context->sql, "configured_addr", NULL);
|
||||
dc_key_load_self_private(curr_private_key, self_addr, context->sql);
|
||||
|
||||
char* payload_key_asc = dc_key_render_asc(curr_private_key, context->e2ee_enabled? "Autocrypt-Prefer-Encrypt: mutual\r\n" : NULL);
|
||||
int e2ee_enabled = dc_sqlite3_get_config_int(context->sql, "e2ee_enabled", DC_E2EE_DEFAULT_ENABLED);
|
||||
char* payload_key_asc = dc_key_render_asc(curr_private_key, e2ee_enabled? "Autocrypt-Prefer-Encrypt: mutual\r\n" : NULL);
|
||||
if (payload_key_asc==NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue