ENGINE-394: Add case in update_identity for identities which have an address and username, where retrieved user_id is TOFU and usernames don't match enigmail_tests_pre_revision_2535
authorKrista Bennett <krista@pep-project.org>
Sat, 24 Feb 2018 19:12:11 +0100
branchenigmail_tests_pre_revision_2535
changeset 2538be573c5f4782
parent 2534 9d17c132c770
child 2542 b7f6df848795
ENGINE-394: Add case in update_identity for identities which have an address and username, where retrieved user_id is TOFU and usernames don't match
src/keymanagement.c
     1.1 --- a/src/keymanagement.c	Sat Feb 24 16:41:17 2018 +0100
     1.2 +++ b/src/keymanagement.c	Sat Feb 24 19:12:11 2018 +0100
     1.3 @@ -655,8 +655,6 @@
     1.4                                                stored_ident, true);
     1.5          }
     1.6          else {
     1.7 -            // create temporary identity, store it, and Return this
     1.8 -            // This means TOFU_ user_id
     1.9              identity->user_id = calloc(1, strlen(identity->address) + 6);
    1.10              if (!identity->user_id)
    1.11                  return PEP_OUT_OF_MEMORY;
    1.12 @@ -664,19 +662,32 @@
    1.13              snprintf(identity->user_id, strlen(identity->address) + 6,
    1.14                       "TOFU_%s", identity->address);        
    1.15  
    1.16 -            //    * We've already checked and retrieved
    1.17 -            //      any applicable temporary identities above. If we're 
    1.18 -            //      here, none of them fit.
    1.19 +            status = get_identity(session, 
    1.20 +                                  identity->address, 
    1.21 +                                  identity->user_id, 
    1.22 +                                  &stored_ident);
    1.23 +
    1.24 +            if (status == PEP_STATUS_OK && stored_ident) {
    1.25 +                status = prepare_updated_identity(session,
    1.26 +                                                  identity,
    1.27 +                                                  stored_ident, true);
    1.28 +            }
    1.29 +            else {
    1.30 +                         
    1.31 +                //    * We've already checked and retrieved
    1.32 +                //      any applicable temporary identities above. If we're 
    1.33 +                //      here, none of them fit.
    1.34 +                
    1.35 +                status = elect_pubkey(session, identity);
    1.36 +                             
    1.37 +                //    * call set_identity() to store
    1.38 +                if (identity->fpr)
    1.39 +                    status = get_key_rating(session, identity->fpr, &identity->comm_type);
    1.40              
    1.41 -            status = elect_pubkey(session, identity);
    1.42 -                         
    1.43 -            //    * call set_identity() to store
    1.44 -            if (identity->fpr)
    1.45 -                status = get_key_rating(session, identity->fpr, &identity->comm_type);
    1.46 -        
    1.47 -            //    * call set_identity() to store
    1.48 -            adjust_pep_trust_status(session, identity);            
    1.49 -            status = set_identity(session, identity);
    1.50 +                //    * call set_identity() to store
    1.51 +                adjust_pep_trust_status(session, identity);            
    1.52 +                status = set_identity(session, identity);
    1.53 +            }
    1.54          }
    1.55      }
    1.56      else {