intermittent commit ENGINE-329
authorKrista Bennett <krista@pep-project.org>
Fri, 26 Jan 2018 10:33:37 +0100
branchENGINE-329
changeset 245751a4829805b9
parent 2456 713e5eead807
child 2458 2dfe65bd3613
intermittent commit
src/pgp_gpg.c
src/pgp_gpg.h
     1.1 --- a/src/pgp_gpg.c	Thu Jan 25 15:50:21 2018 +0100
     1.2 +++ b/src/pgp_gpg.c	Fri Jan 26 10:33:37 2018 +0100
     1.3 @@ -292,9 +292,9 @@
     1.4  
     1.5          gpg.gpgme_get_engine_info
     1.6              = (gpgme_get_engine_info_t) (intptr_t) dlsym(gpgme,
     1.7 -            "gpgme_get_engine_info");
     1.8          assert(gpg.gpgme_get_engine_info);
     1.9  
    1.10 +        "gpgme_get_engine_info");
    1.11          gpgme_engine_info_t info;
    1.12          int err = gpg.gpgme_get_engine_info(&info);
    1.13          assert(err == GPG_ERR_NO_ERROR);
    1.14 @@ -1945,18 +1945,19 @@
    1.15      PEP_STATUS first_fail = PEP_STATUS_OK;
    1.16  
    1.17      // 1. get keys
    1.18 -    PEP_status status = pgp_find_private_keys(session, NULL, &priv_keylist);
    1.19 +    first_fail = pgp_find_private_keys(session, NULL, &priv_keylist);
    1.20  
    1.21      bool has_already_failed = (first_fail != PEP_STATUS_OK);
    1.22  
    1.23      if (status == PEP_STATUS_OK) {    
    1.24          stringlist_t* keylist_curr;    
    1.25 +        
    1.26          // 2. for each key
    1.27          for (keylist_curr = priv_keylist; keylist_curr; keylist_curr = keylist_curr->next) {
    1.28              // a. get key data
    1.29              if (!keylist_curr->value)
    1.30                  continue;
    1.31 -                
    1.32 +    
    1.33              gpgme_error = gpg.gpgme_get_key(session->ctx, keylist_curr->value, &key, 1);
    1.34              gpgme_error = _GPGERR(gpgme_error);
    1.35              assert(gpgme_error != GPG_ERR_ENOMEM);
    1.36 @@ -1982,18 +1983,30 @@
    1.37              if (key && gpgme_error == GPG_ERR_NO_ERROR) {
    1.38                  if (key->revoked || key->disabled)
    1.39                      first_fail = (has_already_failed ? first_fail : PEP_KEY_UNSUITABLE);
    1.40 -                
    1.41 -                    
    1.42 +                else {
    1.43 +                    if (key->fpr && key->private && key->can_encrypt && key->can_sign) {
    1.44 +                        if (key->owner_trust == GPGME_VALIDITY_ULTIMATE &&
    1.45 +                                            key->uids && key->uids->address) { 
    1.46 +                            pEp_identity* new_id = new_identity(key->uids->address,
    1.47 +                                                                key->uids->fpr,
    1.48 +                                                                PEP_OWN_USERID,
    1.49 +                                                                key->uids->name);
    1.50 +                            if (!new_id)
    1.51 +                                status = PEP_OUT_OF_MEMORY;
    1.52 +                            else    
    1.53 +                                status = myself(new_id);
    1.54 +                                
    1.55 +                            first_fail = (has_already_failed ? first_fail : status);
    1.56 +                        }
    1.57 +                    }
    1.58 +                }
    1.59              }
    1.60              
    1.61 -            // a. ensure keypair
    1.62 -            // b. ensure ultimately trusted
    1.63 -            // c. get the name / address
    1.64 -            // d. create identity
    1.65 +            has_already_failed = first_fail != PEP_STATUS_OK;
    1.66          }
    1.67      }
    1.68 +    return first_fail;
    1.69  }
    1.70 -//gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx, const char *pattern[], int secret_only, int reserved)
    1.71  
    1.72  PEP_STATUS pgp_send_key(PEP_SESSION session, const char *pattern)
    1.73  {
     2.1 --- a/src/pgp_gpg.h	Thu Jan 25 15:50:21 2018 +0100
     2.2 +++ b/src/pgp_gpg.h	Fri Jan 26 10:33:37 2018 +0100
     2.3 @@ -114,5 +114,4 @@
     2.4          const char* email
     2.5      );
     2.6  
     2.7 -
     2.8  #define PGP_BINARY_PATH pgp_binary