ENGINE-293: compiling again. Need to fix test cases and see what I have wrought with the PEP_OWN_USERID removals. After that, next step is to really fix myself() ENGINE-293
authorKrista Bennett <krista@pep-project.org>
Tue, 05 Dec 2017 10:00:48 +0100
branchENGINE-293
changeset 23043bd45e2b8f92
parent 2303 e7b3fa443f3e
child 2305 f617e0acae94
ENGINE-293: compiling again. Need to fix test cases and see what I have wrought with the PEP_OWN_USERID removals. After that, next step is to really fix myself()
src/keymanagement.c
src/message_api.c
src/pEpEngine.c
src/pEp_internal.h
src/sync_actions.c
src/sync_impl.c
     1.1 --- a/src/keymanagement.c	Mon Dec 04 18:23:14 2017 +0100
     1.2 +++ b/src/keymanagement.c	Tue Dec 05 10:00:48 2017 +0100
     1.3 @@ -125,7 +125,6 @@
     1.4          }
     1.5          snprintf(identity->user_id, strlen(identity->address) + 6,
     1.6                   "TOFU_%s", identity->address);
     1.7 -        }
     1.8      }
     1.9   
    1.10      status = get_identity(session,
    1.11 @@ -443,7 +442,7 @@
    1.12  
    1.13      if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.14              (EMPTYSTR(identity->user_id) ||
    1.15 -            (own_id && strcmp(identity->user_id, own_id) == 0)))
    1.16 +            (own_id && strcmp(identity->user_id, own_id) == 0))))
    1.17          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.18  
    1.19      identity->comm_type = PEP_ct_pEp;
    1.20 @@ -1078,7 +1077,7 @@
    1.21              status = get_identity(session, my_user_id, address, &my_id);
    1.22              
    1.23              if (status == PEP_STATUS_OK && my_id) {
    1.24 -                if (my_id->fpr && strcasecmp(my_id->fpr, fpr) == 0)) {
    1.25 +                if (my_id->fpr && strcasecmp(my_id->fpr, fpr) == 0) {
    1.26                      // We're done. It was already here.
    1.27                      // FIXME: Do we check trust/revocation/?
    1.28                      goto pep_free;
    1.29 @@ -1092,22 +1091,20 @@
    1.30              if (my_id) {
    1.31                  free(my_id->fpr);
    1.32                  my_id->fpr = my_user_id;
    1.33 -                my_user_id->comm_type = PEP_ct_pEp;
    1.34 +                my_id->comm_type = PEP_ct_pEp;
    1.35 +                my_id->me = true; // just in case? 
    1.36              }
    1.37              else { // Else, we need a new identity
    1.38 -                status = new_identity(session, address, fpr, my_user_id, NULL, &my_id); 
    1.39 +                my_id = new_identity(address, fpr, my_user_id, NULL); 
    1.40                  if (status != PEP_STATUS_OK)
    1.41                      goto pep_free; 
    1.42 -                my_user_id->me = true;
    1.43 -                my_user_id->comm_type = PEP_ct_pEp;
    1.44 +                my_id->me = true;
    1.45 +                my_id->comm_type = PEP_ct_pEp;
    1.46              }
    1.47          }
    1.48          else {
    1.49              // I think the prerequisite should be that at least one own identity
    1.50              // already in the DB, so REALLY look at this.
    1.51 -            // status = new_identity(session, address, fpr, "PEP_OWN_USERID", NULL); 
    1.52 -            // my_user_id->me = true;
    1.53 -            // my_user_id->comm_type = PEP_ct_pEp;
    1.54              return PEP_CANNOT_FIND_IDENTITY;
    1.55          }
    1.56          
     2.1 --- a/src/message_api.c	Mon Dec 04 18:23:14 2017 +0100
     2.2 +++ b/src/message_api.c	Tue Dec 05 10:00:48 2017 +0100
     2.3 @@ -2577,7 +2577,7 @@
     2.4      // 1. Check to see if this message is to us and contains an own key imported 
     2.5      // from own trusted message 
     2.6      if (msg && *rating >= PEP_rating_trusted && imported_private_key_address &&
     2.7 -        msg->to && _identity_me(msg->to) {
     2.8 +        msg->to && msg->to->ident && _identity_me(msg->to->ident)) {
     2.9  
    2.10          // flag it as such
    2.11          *flags |= PEP_decrypt_flag_own_private_key;
     3.1 --- a/src/pEpEngine.c	Mon Dec 04 18:23:14 2017 +0100
     3.2 +++ b/src/pEpEngine.c	Tue Dec 05 10:00:48 2017 +0100
     3.3 @@ -1230,9 +1230,11 @@
     3.4      sqlite3_reset(session->get_own_userid);
     3.5  
     3.6      const int result = sqlite3_step(session->get_own_userid);
     3.7 +    const char* id;
     3.8 +    
     3.9      switch (result) {
    3.10          case SQLITE_ROW:
    3.11 -            const char* id = (const char *) sqlite3_column_text(session->get_own_userid, 0);
    3.12 +            id = (const char *) sqlite3_column_text(session->get_own_userid, 0);
    3.13              if (!id) {
    3.14                  // Shouldn't happen.
    3.15                  status = PEP_UNKNOWN_ERROR;
    3.16 @@ -1246,7 +1248,7 @@
    3.17          default:
    3.18              // Technically true, given how we find it, but FIXME we need a more descriptive error
    3.19              status = PEP_CANNOT_FIND_IDENTITY;
    3.20 -            *identity = NULL;
    3.21 +            *userid = NULL;
    3.22      }
    3.23  
    3.24      *userid = retval;
    3.25 @@ -1533,7 +1535,7 @@
    3.26  
    3.27      // 1. Get own user_id
    3.28      char* user_id = NULL;
    3.29 -    PEP_STATUS status = get_own_userid(session, &user_id);
    3.30 +    status = get_own_userid(session, &user_id);
    3.31      
    3.32      // No user_id is returned in this case, no need to free;
    3.33      if (status != PEP_STATUS_OK)
     4.1 --- a/src/pEp_internal.h	Mon Dec 04 18:23:14 2017 +0100
     4.2 +++ b/src/pEp_internal.h	Tue Dec 05 10:00:48 2017 +0100
     4.3 @@ -151,8 +151,9 @@
     4.4      // Own keys
     4.5      sqlite3_stmt *own_key_is_listed;
     4.6      sqlite3_stmt *own_identities_retrieve;
     4.7 -    sqlite3_stmt *own_userid_by_address;
     4.8      sqlite3_stmt *own_keys_retrieve;
     4.9 +    sqlite3_stmt *get_own_userid;
    4.10 +
    4.11  //    sqlite3_stmt *set_own_key;
    4.12  
    4.13      // sequence value
     5.1 --- a/src/sync_actions.c	Mon Dec 04 18:23:14 2017 +0100
     5.2 +++ b/src/sync_actions.c	Tue Dec 05 10:00:48 2017 +0100
     5.3 @@ -58,10 +58,10 @@
     5.4      Identity me = NULL;
     5.5      
     5.6      char* own_id = NULL;
     5.7 -    status = get_own_userid(session, &own_id);
     5.8 +    PEP_STATUS status = get_own_userid(session, &own_id);
     5.9      if (own_id) {
    5.10 -        PEP_STATUS status = get_identity(session, partner->address, own_id,
    5.11 -                &me);
    5.12 +        status = get_identity(session, partner->address, own_id,
    5.13 +                              &me);
    5.14          free(own_id);
    5.15      }
    5.16      if (status == PEP_OUT_OF_MEMORY)
    5.17 @@ -277,7 +277,8 @@
    5.18          if (status != PEP_STATUS_OK)
    5.19              break;
    5.20      }
    5.21 -
    5.22 +    
    5.23 +    free(own_id);
    5.24      return status;
    5.25  }
    5.26      
     6.1 --- a/src/sync_impl.c	Mon Dec 04 18:23:14 2017 +0100
     6.2 +++ b/src/sync_impl.c	Tue Dec 05 10:00:48 2017 +0100
     6.3 @@ -631,11 +631,13 @@
     6.4                              if (status != PEP_STATUS_OK)
     6.5                                  goto free_all;
     6.6                              
     6.7 +                            pEp_identity* _from = NULL;
     6.8 +                            
     6.9                              if (own_id) {    
    6.10 -                                pEp_identity *_from = new_identity(NULL, 
    6.11 -                                                                   keylist->value,
    6.12 -                                                                   own_id,
    6.13 -                                                                   NULL);
    6.14 +                                _from = new_identity(NULL, 
    6.15 +                                                     keylist->value,
    6.16 +                                                     own_id,
    6.17 +                                                     NULL);
    6.18                              }
    6.19                              else {
    6.20                                  status = own_id_status;