ENGINE-463: Fixed trust reconciliation ENGINE-463
authorKrista Bennett <krista@pep-project.org>
Fri, 05 Oct 2018 08:44:30 +0200
branchENGINE-463
changeset 2997ee1d19039d8d
parent 2995 6f2f9a7c060e
child 2998 744b331f78c7
ENGINE-463: Fixed trust reconciliation
src/pEpEngine.c
     1.1 --- a/src/pEpEngine.c	Fri Oct 05 00:57:35 2018 +0200
     1.2 +++ b/src/pEpEngine.c	Fri Oct 05 08:44:30 2018 +0200
     1.3 @@ -2667,7 +2667,7 @@
     1.4                        
     1.5      int result = sqlite3_step(session->delete_person);
     1.6      
     1.7 -    if (result != SQLITE_OK)
     1.8 +    if (result != SQLITE_DONE)
     1.9          status = PEP_UNKNOWN_ERROR;
    1.10          
    1.11      sqlite3_reset(session->delete_person);
    1.12 @@ -3209,20 +3209,30 @@
    1.13          const char* curr_fpr = trust_curr->label;
    1.14          new_ident->fpr = strdup(curr_fpr); 
    1.15          status = get_trust(session, new_ident);
    1.16 -        if (status == PEP_STATUS_OK) {
    1.17 -            new_ident->comm_type = reconcile_trust(trust_curr->value,
    1.18 -                                                   new_ident->comm_type);
    1.19 -            if (new_is_pep) {
    1.20 -                PEP_comm_type confirmed_bit = new_ident->comm_type & PEP_ct_confirmed;
    1.21 -                if ((new_ident->comm_type | PEP_ct_confirmed) == PEP_ct_OpenPGP)
    1.22 -                    new_ident->comm_type = PEP_ct_pEp_unconfirmed | confirmed_bit;
    1.23 -            }
    1.24 -
    1.25 -            status = set_trust(session, new_ident);
    1.26 -            if (status != PEP_STATUS_OK) {
    1.27 +        switch (status) {
    1.28 +            case PEP_STATUS_OK:
    1.29 +                new_ident->comm_type = reconcile_trust(trust_curr->value,
    1.30 +                                                       new_ident->comm_type);
    1.31 +                break;
    1.32 +            case PEP_CANNOT_FIND_IDENTITY:
    1.33 +                new_ident->comm_type = trust_curr->value;
    1.34 +                break;
    1.35 +            default:
    1.36                  goto pEp_free;
    1.37 -            }                                        
    1.38          }
    1.39 +        new_ident->comm_type = reconcile_trust(trust_curr->value,
    1.40 +                                               new_ident->comm_type);
    1.41 +        if (new_is_pep) {
    1.42 +            PEP_comm_type confirmed_bit = new_ident->comm_type & PEP_ct_confirmed;
    1.43 +            if ((new_ident->comm_type | PEP_ct_confirmed) == PEP_ct_OpenPGP)
    1.44 +                new_ident->comm_type = PEP_ct_pEp_unconfirmed | confirmed_bit;
    1.45 +        }
    1.46 +
    1.47 +        status = set_trust(session, new_ident);
    1.48 +        if (status != PEP_STATUS_OK) {
    1.49 +            goto pEp_free;
    1.50 +        }                  
    1.51 +                              
    1.52          free(new_ident->fpr);
    1.53          new_ident->fpr = NULL;
    1.54          new_ident->comm_type = 0;