ENGINE-174 / ENGINE-153: Hopefully ratings now do the right thing. HOPEFULLY. Engine tests pass, but we still have this problem for me, anyway, about running unit tests from the make script vs. directly in the directory. elect_pubkey/find_keys somehow doesn't find the key in update_identity, whereas it works locally and from gpg, it works fine. Puzzling, but this has come up before and isn't us directly, I think. ENGINE-174
authorKrista Grothoff <krista@pep-project.org>
Thu, 02 Mar 2017 17:54:02 +0100
branchENGINE-174
changeset 1615858298055d48
parent 1613 04ebdc275924
child 1617 4f66da605597
ENGINE-174 / ENGINE-153: Hopefully ratings now do the right thing. HOPEFULLY. Engine tests pass, but we still have this problem for me, anyway, about running unit tests from the make script vs. directly in the directory. elect_pubkey/find_keys somehow doesn't find the key in update_identity, whereas it works locally and from gpg, it works fine. Puzzling, but this has come up before and isn't us directly, I think.
src/message_api.c
src/stringlist.c
test/Makefile
     1.1 --- a/src/message_api.c	Tue Feb 28 10:08:59 2017 +0100
     1.2 +++ b/src/message_api.c	Thu Mar 02 17:54:02 2017 +0100
     1.3 @@ -789,7 +789,7 @@
     1.4  
     1.5  static PEP_rating key_rating(PEP_SESSION session, const char *fpr)
     1.6  {
     1.7 -    PEP_comm_type comm_type = PEP_ct_unknown;
     1.8 +    PEP_comm_type bare_comm_type = PEP_ct_unknown;
     1.9  
    1.10      assert(session);
    1.11      assert(fpr);
    1.12 @@ -797,11 +797,20 @@
    1.13      if (session == NULL || fpr == NULL)
    1.14          return PEP_rating_undefined;
    1.15  
    1.16 -    PEP_STATUS status = get_key_rating(session, fpr, &comm_type);
    1.17 +    PEP_STATUS status = get_key_rating(session, fpr, &bare_comm_type);
    1.18      if (status != PEP_STATUS_OK)
    1.19          return PEP_rating_undefined;
    1.20  
    1.21 -    return _rating(comm_type, PEP_rating_undefined);
    1.22 +    /* FIXME: All this tells us is that the bare key is ok. It's
    1.23 +       fine to check - if there's something wrong with the key in
    1.24 +       the keyring we should probably do something about it -
    1.25 +       but it doesn't deal with overall trust. We also need 
    1.26 +       trust in here. */
    1.27 +    
    1.28 +    PEP_comm_type least_trust_type = PEP_ct_unknown;
    1.29 +    status = least_trust(session, fpr, &least_trust_type);
    1.30 +
    1.31 +    return _rating(least_trust_type, PEP_rating_undefined);
    1.32  }
    1.33  
    1.34  static PEP_rating worst_rating(PEP_rating rating1, PEP_rating rating2) {
    1.35 @@ -839,9 +848,10 @@
    1.36              if (status != PEP_STATUS_OK)
    1.37                  return PEP_rating_undefined;
    1.38              if (ct == PEP_ct_unknown){
    1.39 +                /* per edouard, we reduce reliable+ ratings to reliable because
    1.40 +                   ct unknown */
    1.41                  if (rating >= PEP_rating_reliable){
    1.42 -                    //rating = worst_rating(rating, PEP_rating_reliable);
    1.43 -                    rating = PEP_rating_reliable; /*KG - really???*/
    1.44 +                    rating = PEP_rating_reliable; 
    1.45                  }
    1.46              }
    1.47              else{
    1.48 @@ -1514,6 +1524,20 @@
    1.49          while (*tail_pp) {
    1.50              tail_pp = &((*tail_pp)->next);
    1.51          }
    1.52 +        stringlist_t* second_list = *keylist_in_out;
    1.53 +        if (second_list) {
    1.54 +            char* listhead_val = second_list->value;
    1.55 +            if (!listhead_val || listhead_val[0] == '\0') {
    1.56 +                /* remove head, basically. This can happen when,
    1.57 +                   for example, the signature is detached and
    1.58 +                   verification is not seen directly after
    1.59 +                   decryption, so no signer is presumed in
    1.60 +                   the first construction of the keylist */
    1.61 +                *keylist_in_out = (*keylist_in_out)->next;
    1.62 +                second_list->next = NULL;
    1.63 +                free_stringlist(second_list);
    1.64 +            }
    1.65 +        }
    1.66          *tail_pp = *keylist_in_out;
    1.67      }
    1.68      
    1.69 @@ -1935,8 +1959,10 @@
    1.70                      if (_from == NULL)
    1.71                          goto enomem;
    1.72                      status = get_trust(session, _from);
    1.73 -                    if (_from->comm_type != PEP_ct_unknown)
    1.74 -                        *rating = worst_rating(*rating, _rating(_from->comm_type, PEP_rating_undefined));
    1.75 +                    if (_from->comm_type != PEP_ct_unknown) {
    1.76 +                        *rating = worst_rating(_rating(_from->comm_type, PEP_rating_undefined),
    1.77 +                                  kl_rating);
    1.78 +                    }
    1.79                      free_identity(_from);
    1.80                      if (status == PEP_CANNOT_FIND_IDENTITY)
    1.81                         status = PEP_STATUS_OK;
     2.1 --- a/src/stringlist.c	Tue Feb 28 10:08:59 2017 +0100
     2.2 +++ b/src/stringlist.c	Thu Mar 02 17:54:02 2017 +0100
     2.3 @@ -163,13 +163,13 @@
     2.4  
     2.5  DYNAMIC_API void free_stringlist(stringlist_t *stringlist)
     2.6  {
     2.7 -    stringlist_t *curr = stringlist;;
     2.8 +    stringlist_t *curr = stringlist;
     2.9      
    2.10      while (curr) {
    2.11          stringlist_t *next = curr->next;
    2.12          free(curr->value);
    2.13 +        curr->value = NULL;
    2.14          free(curr);
    2.15          curr = next;
    2.16      }
    2.17  }
    2.18 -
     3.1 --- a/test/Makefile	Tue Feb 28 10:08:59 2017 +0100
     3.2 +++ b/test/Makefile	Thu Mar 02 17:54:02 2017 +0100
     3.3 @@ -25,7 +25,7 @@
     3.4  
     3.5  UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
     3.6  UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
     3.7 -UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
     3.8 +UNIT_TESTS_RUN=$(subst .cc,_gdb,$(UNIT_TESTS_SOURCE))
     3.9  
    3.10  all: $(TARGET) $(UNIT_TESTS)
    3.11