Browse Source

explicitly clear trust info out of database

add_key_notification archive/ENGINE-654
parent
commit
4745ffaa0a
3 changed files with 37 additions and 3 deletions
  1. +3
    -1
      src/key_reset.c
  2. +32
    -0
      src/pEpEngine.c
  3. +2
    -2
      src/pEp_internal.h

+ 3
- 1
src/key_reset.c View File

@ -564,13 +564,15 @@ PEP_STATUS key_reset(
} // end is_own_private
else {
// if it's mistrusted, make it not be so.
bool mistrusted_key = false;
is_mistrusted_key(session, fpr_copy, &mistrusted_key);
if (mistrusted_key)
delete_mistrusted_key(session, fpr_copy);
if (tmp_ident->user_id)
status = clear_trust_info(session, tmp_ident->user_id, fpr_copy);
// This is a public key (or a private key that isn't ours, which means
// we want it gone anyway)
//


+ 32
- 0
src/pEpEngine.c View File

@ -336,6 +336,10 @@ static const char *sql_update_trust =
"update trust set comm_type = ?3 "
" where user_id = ?1 and pgp_keypair_fpr = upper(replace(?2,' ',''));";
static const char *sql_clear_trust_info =
"delete from trust "
" where user_id = ?1 and pgp_keypair_fpr = upper(replace(?2,' ',''));";
static const char *sql_update_trust_to_pEp =
"update trust set comm_type = comm_type + 71 "
" where (user_id = ?1 "
@ -1760,6 +1764,10 @@ DYNAMIC_API PEP_STATUS init(
NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_clear_trust_info,
(int)strlen(sql_clear_trust_info), &_session->clear_trust_info, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_trust,
(int)strlen(sql_set_trust), &_session->set_trust, NULL);
assert(int_result == SQLITE_OK);
@ -2034,6 +2042,8 @@ DYNAMIC_API void release(PEP_SESSION session)
sqlite3_finalize(session->set_pEp_version);
if (session->exists_trust_entry)
sqlite3_finalize(session->exists_trust_entry);
if (session->clear_trust_info)
sqlite3_finalize(session->clear_trust_info);
if (session->set_trust)
sqlite3_finalize(session->set_trust);
if (session->update_trust)
@ -2998,6 +3008,28 @@ PEP_STATUS set_pgp_keypair(PEP_SESSION session, const char* fpr) {
return PEP_STATUS_OK;
}
PEP_STATUS clear_trust_info(PEP_SESSION session,
const char* user_id,
const char* fpr) {
if (!session || EMPTYSTR(fpr) || EMPTYSTR(user_id))
return PEP_ILLEGAL_VALUE;
int result;
sqlite3_reset(session->clear_trust_info);
sqlite3_bind_text(session->clear_trust_info, 1, user_id, -1,
SQLITE_STATIC);
sqlite3_bind_text(session->clear_trust_info, 2, fpr, -1,
SQLITE_STATIC);
result = Sqlite3_step(session->clear_trust_info);
sqlite3_reset(session->clear_trust_info);
if (result != SQLITE_DONE) {
return PEP_UNKNOWN_ERROR;
}
return PEP_STATUS_OK;
}
static PEP_STATUS _set_or_update_trust(PEP_SESSION session,
pEp_identity* identity,
sqlite3_stmt* set_or_update) {


+ 2
- 2
src/pEp_internal.h View File

@ -200,7 +200,8 @@ struct _pEpSession {
sqlite3_stmt *exists_identity_entry;
sqlite3_stmt *set_identity_flags;
sqlite3_stmt *unset_identity_flags;
sqlite3_stmt *set_pEp_version;
sqlite3_stmt *set_pEp_version;
sqlite3_stmt *clear_trust_info;
sqlite3_stmt *set_trust;
sqlite3_stmt *update_trust;
sqlite3_stmt *exists_trust_entry;
@ -566,4 +567,3 @@ static inline int Sqlite3_step(sqlite3_stmt* stmt)
} while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
return rc;
}

Loading…
Cancel
Save