src/keymanagement.c
changeset 2496 389abc0e9b54
parent 2494 56c577c84996
child 2497 b3d58a60b753
     1.1 --- a/src/keymanagement.c	Sun Feb 11 18:31:35 2018 +0100
     1.2 +++ b/src/keymanagement.c	Mon Feb 12 01:52:57 2018 +0100
     1.3 @@ -639,19 +639,19 @@
     1.4  
     1.5              snprintf(identity->user_id, strlen(identity->address) + 6,
     1.6                       "TOFU_%s", identity->address);        
     1.7 -            
     1.8 -            free(identity->fpr);
     1.9 -            identity->fpr = NULL;
    1.10 -            identity->comm_type = PEP_ct_unknown;
    1.11 -             
    1.12 +
    1.13              //    * We've already checked and retrieved
    1.14              //      any applicable temporary identities above. If we're 
    1.15              //      here, none of them fit.
    1.16 +            
    1.17 +            status = elect_pubkey(session, identity);
    1.18 +                         
    1.19              //    * call set_identity() to store
    1.20 +            if (identity->fpr)
    1.21 +                status = get_key_rating(session, identity->fpr, &identity->comm_type);
    1.22 +        
    1.23 +            //    * call set_identity() to store            
    1.24              status = set_identity(session, identity);
    1.25 -            if (status == PEP_STATUS_OK) {
    1.26 -                elect_pubkey(session, identity);
    1.27 -            }
    1.28          }
    1.29      }
    1.30      else {
    1.31 @@ -688,8 +688,37 @@
    1.32          if (stored_ident)
    1.33              status = prepare_updated_identity(session, identity,
    1.34                                                stored_ident, false);
    1.35 -        else // too little info
    1.36 -            status = PEP_CANNOT_FIND_IDENTITY; 
    1.37 +        else  {            
    1.38 +            // too little info. BUT. We see if we can find a key; if so, we create a
    1.39 +            // temp identity, look for a key, and store.
    1.40 +                         
    1.41 +            // create temporary identity, store it, and Return this
    1.42 +            // This means TOFU_ user_id
    1.43 +            identity->user_id = calloc(1, strlen(identity->address) + 6);
    1.44 +            if (!identity->user_id)
    1.45 +                return PEP_OUT_OF_MEMORY;
    1.46 +
    1.47 +            snprintf(identity->user_id, strlen(identity->address) + 6,
    1.48 +                     "TOFU_%s", identity->address);        
    1.49 +        
    1.50 +            identity->username = strdup(identity->address);
    1.51 +            if (!identity->address)
    1.52 +                return PEP_OUT_OF_MEMORY;            
    1.53 +            
    1.54 +            free(identity->fpr);
    1.55 +            identity->fpr = NULL;
    1.56 +            identity->comm_type = PEP_ct_unknown;
    1.57 +
    1.58 +            status = elect_pubkey(session, identity);
    1.59 +                         
    1.60 +            if (identity->fpr)
    1.61 +                status = get_key_rating(session, identity->fpr, &identity->comm_type);
    1.62 +        
    1.63 +            //    * call set_identity() to store            
    1.64 +            status = set_identity(session, identity);
    1.65 +
    1.66 +        }
    1.67 +            
    1.68      }
    1.69      
    1.70      // FIXME: This is legacy. I presume it's a notification for the caller...