ENGINE-409: fixed key_reset_trust
authorKrista Bennett <krista@pep-project.org>
Tue, 27 Mar 2018 11:57:37 +0200
changeset 25869749e509f3ec
parent 2585 88d9763930cd
child 2587 b7eb979f90f5
ENGINE-409: fixed key_reset_trust
src/keymanagement.c
src/pEpEngine.c
     1.1 --- a/src/keymanagement.c	Fri Mar 23 16:39:45 2018 +0100
     1.2 +++ b/src/keymanagement.c	Tue Mar 27 11:57:37 2018 +0200
     1.3 @@ -1253,12 +1253,19 @@
     1.4          goto pep_free;
     1.5          
     1.6      PEP_comm_type new_trust = PEP_ct_unknown;
     1.7 +    status = get_key_rating(session, ident->fpr, &new_trust);
     1.8 +    if (status != PEP_STATUS_OK)
     1.9 +        goto pep_free;
    1.10  
    1.11 -    if (input_copy->comm_type != PEP_ct_mistrusted)
    1.12 -        new_trust = input_copy->comm_type & ~PEP_ct_confirmed;
    1.13 -
    1.14 -    // We'll return the status from the input_copy cache afterward
    1.15 -    input_copy->comm_type = new_trust;
    1.16 +    bool pep_user = false;
    1.17 +    
    1.18 +    status = is_pep_user(session, ident, &pep_user);
    1.19 +    
    1.20 +    if (pep_user && new_trust >= PEP_ct_unconfirmed_encryption)
    1.21 +        input_copy->comm_type = PEP_ct_pEp_unconfirmed;
    1.22 +    else
    1.23 +        input_copy->comm_type = new_trust;
    1.24 +        
    1.25      status = set_trust(session, input_copy);
    1.26      
    1.27      if (status != PEP_STATUS_OK)
    1.28 @@ -1298,7 +1305,7 @@
    1.29      }
    1.30      
    1.31      char* user_default = NULL;
    1.32 -    status = get_main_user_fpr(session, tmp_ident->user_id, &user_default);
    1.33 +    get_main_user_fpr(session, tmp_ident->user_id, &user_default);
    1.34      
    1.35      if (!EMPTYSTR(user_default)) {
    1.36          if (strcmp(user_default, ident->fpr) == 0)
     2.1 --- a/src/pEpEngine.c	Fri Mar 23 16:39:45 2018 +0100
     2.2 +++ b/src/pEpEngine.c	Tue Mar 27 11:57:37 2018 +0200
     2.3 @@ -418,7 +418,7 @@
     2.4      "   values (upper(replace(?1,' ',''))) ;";
     2.5          
     2.6  static const char *sql_delete_mistrusted_key = 
     2.7 -    "delete from blacklist_keys where fpr = upper(replace(?1,' ','')) ;";
     2.8 +    "delete from mistrusted_keys where fpr = upper(replace(?1,' ','')) ;";
     2.9  
    2.10  static const char *sql_is_mistrusted_key = 
    2.11      "select count(*) from mistrusted_keys where fpr = upper(replace(?1,' ','')) ;";
    2.12 @@ -2908,10 +2908,14 @@
    2.13      case SQLITE_ROW: {
    2.14          const char* _fpr = 
    2.15              (const char *) sqlite3_column_text(session->get_main_user_fpr, 0);
    2.16 -        if (_fpr)
    2.17 +        if (_fpr) {
    2.18              *main_fpr = strdup(_fpr);
    2.19 -        if (!(*main_fpr))
    2.20 -            status = PEP_OUT_OF_MEMORY;
    2.21 +            if (!(*main_fpr))
    2.22 +                status = PEP_OUT_OF_MEMORY;
    2.23 +        }
    2.24 +        else {
    2.25 +            status = PEP_KEY_NOT_FOUND;
    2.26 +        }
    2.27          break;
    2.28      }
    2.29      default: