Browse Source

ENGINE-379 and probably other problems: was calling set_identity from within set_as_pep_user, which was called by get_trust, which is called from set_identity. So... yeah. Bad.

doc_update_sequoia
Krista Bennett 4 years ago
parent
commit
f3aa429f86
2 changed files with 32 additions and 25 deletions
  1. +13
    -2
      src/keymanagement.c
  2. +19
    -23
      src/pEpEngine.c

+ 13
- 2
src/keymanagement.c View File

@ -975,6 +975,8 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
}
status = set_identity(session, identity);
if (status == PEP_STATUS_OK)
status = set_as_pep_user(session, identity);
pep_free:
free(default_own_id);
@ -1144,7 +1146,12 @@ DYNAMIC_API PEP_STATUS undo_last_mistrust(PEP_SESSION session) {
else {
status = delete_mistrusted_key(session, cached_ident->fpr);
if (status == PEP_STATUS_OK) {
status = set_identity(session, cached_ident);
status = set_identity(session, cached_ident);
// THIS SHOULDN'T BE NECESSARY - PREVIOUS VALUE WAS IN THE DB
// if (status == PEP_STATUS_OK) {
// if ((cached_ident->comm_type | PEP_ct_confirmed) == PEP_ct_pEp)
// status = set_as_pep_user(session, cached_ident);
// }
free_identity(session->cached_mistrusted);
}
}
@ -1326,7 +1333,11 @@ DYNAMIC_API PEP_STATUS trust_personal_key(
free(ident_copy->fpr);
ident_copy->fpr = strdup(cached_fpr);
ident_copy->comm_type = tmp_id->comm_type;
status = set_identity(session, ident_copy); // replace identity default
status = set_identity(session, ident_copy); // replace identity default
if (status == PEP_STATUS_OK) {
if ((ident_copy->comm_type | PEP_ct_confirmed) == PEP_ct_pEp)
status = set_as_pep_user(session, ident_copy);
}
}
}
else { // we're setting this on the default fpr


+ 19
- 23
src/pEpEngine.c View File

@ -1463,7 +1463,7 @@ DYNAMIC_API PEP_STATUS log_event(
const char *comment
)
{
PEP_STATUS status = PEP_STATUS_OK;
// PEP_STATUS status = PEP_STATUS_OK;
int result;
assert(session);
@ -2241,12 +2241,20 @@ PEP_STATUS set_or_update_with_identity(PEP_SESSION session,
PEP_STATUS _set_trust_internal(PEP_SESSION session, pEp_identity* identity,
bool guard_transaction) {
PEP_STATUS status = set_or_update_with_identity(session, identity,
_set_or_update_trust,
exists_trust_entry,
session->update_trust,
session->set_trust,
guard_transaction);
return set_or_update_with_identity(session, identity,
_set_or_update_trust,
exists_trust_entry,
session->update_trust,
session->set_trust,
guard_transaction);
}
// This is the TOP-LEVEL function. If you're calling from set_identity,
// you can't use this one.
PEP_STATUS set_trust(PEP_SESSION session, pEp_identity* identity) {
PEP_STATUS status = PEP_STATUS_OK;
status = _set_trust_internal(session, identity, true);
if (status == PEP_STATUS_OK) {
if ((identity->comm_type | PEP_ct_confirmed) == PEP_ct_pEp)
status = set_as_pep_user(session, identity);
@ -2254,10 +2262,6 @@ PEP_STATUS _set_trust_internal(PEP_SESSION session, pEp_identity* identity,
return status;
}
PEP_STATUS set_trust(PEP_SESSION session, pEp_identity* identity) {
return _set_trust_internal(session, identity, true);
}
PEP_STATUS set_person(PEP_SESSION session, pEp_identity* identity,
bool guard_transaction) {
return set_or_update_with_identity(session, identity,
@ -2278,6 +2282,7 @@ PEP_STATUS set_identity_entry(PEP_SESSION session, pEp_identity* identity,
guard_transaction);
}
// This will NOT call set_as_pep_user; you have to do that separately.
DYNAMIC_API PEP_STATUS set_identity(
PEP_SESSION session, const pEp_identity *identity
)
@ -2368,7 +2373,7 @@ pep_free:
return status;
}
// This ONLY sets the user flag, and creates a shell identity if necessary.
// This ONLY sets the user flag. Must be called outside of a transaction.
PEP_STATUS set_as_pep_user(PEP_SESSION session, pEp_identity* user) {
assert(session);
@ -2387,17 +2392,8 @@ PEP_STATUS set_as_pep_user(PEP_SESSION session, pEp_identity* user) {
if (status != PEP_STATUS_OK)
return status;
if (!person_exists) {
if (!user->address)
return PEP_ILLEGAL_VALUE;
// create shell identity
pEp_identity* tmp_id = new_identity(user->address, NULL, user->user_id, user->username);
status = set_identity(session, tmp_id); // this creates the person
free_identity(tmp_id);
if (status != PEP_STATUS_OK)
return status;
}
if (!person_exists)
status = set_person(session, user, true);
// Ok, let's set it.
sqlite3_reset(session->set_as_pep_user);


Loading…
Cancel
Save