Fixed weird non-grouped reset all case - was masked by later use of myself and came out of the refactor sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 27 Jan 2020 11:33:24 +0100
branchsync
changeset 4361f13151f0b577
parent 4360 1ab2ccbf5f9f
child 4362 9d62b5b79f73
Fixed weird non-grouped reset all case - was masked by later use of myself and came out of the refactor
src/key_reset.c
sync/cond_act_sync.yml2
     1.1 --- a/src/key_reset.c	Thu Jan 23 16:27:55 2020 +0100
     1.2 +++ b/src/key_reset.c	Mon Jan 27 11:33:24 2020 +0100
     1.3 @@ -1204,33 +1204,36 @@
     1.4                      for (curr_ident = key_idents; curr_ident && curr_ident->ident; 
     1.5                                                      curr_ident = curr_ident->next) {
     1.6                          
     1.7 +                        pEp_identity* this_ident = curr_ident->ident;
     1.8                          // Do the full reset on this identity        
     1.9                          // Base case for is_own_private starts here
    1.10 -                        // tmp ident is an actual identity now (not just a skeleton?)
    1.11 +                        // Note that we reset this key for ANY own ident that has it. And if 
    1.12 +                        // tmp_ident did NOT have this key, it won't matter. We will reset the 
    1.13 +                        // key for all idents for this user.
    1.14                          status = revoke_key(session, fpr_copy, NULL);
    1.15                          
    1.16                          // If we have a full identity, we have some cleanup and generation tasks here
    1.17 -                        if (!EMPTYSTR(tmp_ident->address)) {
    1.18 +                        if (!EMPTYSTR(this_ident->address)) {
    1.19                              // generate new key
    1.20                              if (status == PEP_STATUS_OK) {
    1.21 -                                tmp_ident->fpr = NULL;
    1.22 -                                status = myself(session, tmp_ident);
    1.23 +                                this_ident->fpr = NULL;
    1.24 +                                status = myself(session, this_ident);
    1.25                              }
    1.26 -                            if (status == PEP_STATUS_OK && tmp_ident->fpr && strcmp(fpr_copy, tmp_ident->fpr) != 0)
    1.27 -                                new_key = strdup(tmp_ident->fpr);
    1.28 +                            if (status == PEP_STATUS_OK && this_ident->fpr && strcmp(fpr_copy, this_ident->fpr) != 0)
    1.29 +                                new_key = strdup(this_ident->fpr);
    1.30                              // Error handling?    
    1.31                              
    1.32                              // mistrust fpr from trust
    1.33 -                            tmp_ident->fpr = fpr_copy;
    1.34 +                            this_ident->fpr = fpr_copy;
    1.35                                                              
    1.36 -                            tmp_ident->comm_type = PEP_ct_mistrusted;
    1.37 -                            status = set_trust(session, tmp_ident);
    1.38 -                            tmp_ident->fpr = NULL;
    1.39 +                            this_ident->comm_type = PEP_ct_mistrusted;
    1.40 +                            status = set_trust(session, this_ident);
    1.41 +                            this_ident->fpr = NULL;
    1.42                              
    1.43                              // Done with old use of ident.
    1.44                              if (status == PEP_STATUS_OK) {
    1.45 -                                // Update fpr for outgoing
    1.46 -                                status = myself(session, tmp_ident);
    1.47 +                                // Generate new key
    1.48 +                                status = myself(session, this_ident);
    1.49                              }
    1.50                          }    
    1.51                          
    1.52 @@ -1255,11 +1258,10 @@
    1.53                              
    1.54                              tmp_ident->fpr = fpr_copy;
    1.55                              if (status == PEP_STATUS_OK)
    1.56 -                                status = send_key_reset_to_recents(session, tmp_ident, fpr_copy, new_key);        
    1.57 +                                status = send_key_reset_to_recents(session, this_ident, fpr_copy, new_key);        
    1.58                              tmp_ident->fpr = NULL;    
    1.59                          }                    
    1.60 -                        // Ident list gets freed below, do not free here!
    1.61 -                    }
    1.62 +                    }  // Ident list gets freed below, do not free here!
    1.63                  }
    1.64                  // Ok, we've either now reset for each own identity with this key, or 
    1.65                  // we got an error and want to bail anyway.
     2.1 --- a/sync/cond_act_sync.yml2	Thu Jan 23 16:27:55 2020 +0100
     2.2 +++ b/sync/cond_act_sync.yml2	Mon Jan 27 11:33:24 2020 +0100
     2.3 @@ -277,7 +277,6 @@
     2.4          assert(status == PEP_STATUS_OK);
     2.5          if (status)
     2.6              return status;
     2.7 -        assert(strcmp(me->fpr, session->sync_state.comm_partner.sender_fpr) != 0);
     2.8  
     2.9          assert(me->fpr && me->fpr[0]);
    2.10          if (!(me->fpr && me->fpr[0])) {
    2.11 @@ -312,7 +311,6 @@
    2.12              return PEP_OUT_OF_MEMORY;
    2.13          }
    2.14  
    2.15 -        assert(strcmp(me->fpr, partner->fpr) != 0);
    2.16          status = session->notifyHandshake(me, partner, «$type»);
    2.17          if (status)
    2.18              return status;