ENGINE-455: abandoning and/or shelving for now; it appears gpgme only supports gpgconf's limited options. I don't think there's a way for us to insert additional options this way, so the clean solution isn't clean after all. Will talk to neal. ENGINE-455
authorKrista Bennett <krista@pep-project.org>
Tue, 21 Aug 2018 12:19:04 +0200
branchENGINE-455
changeset 2860978b009c17fa
parent 2859 53694809c009
ENGINE-455: abandoning and/or shelving for now; it appears gpgme only supports gpgconf's limited options. I don't think there's a way for us to insert additional options this way, so the clean solution isn't clean after all. Will talk to neal.
src/pgp_gpg.c
     1.1 --- a/src/pgp_gpg.c	Mon Aug 20 12:25:57 2018 +0200
     1.2 +++ b/src/pgp_gpg.c	Tue Aug 21 12:19:04 2018 +0200
     1.3 @@ -14,48 +14,6 @@
     1.4  static void *gpgme;
     1.5  static struct gpg_s gpg;
     1.6  
     1.7 -// typedef struct _pep_gpgme_val_list {
     1.8 -//     gpgme_conf_arg_t type;
     1.9 -//     void* value;
    1.10 -//     _pep_gpgme_val_list* next;
    1.11 -// } pep_gpgme_val_list_t;
    1.12 -// 
    1.13 -// static pep_gpgme_val_list_t* new_pep_conf_val(gpgme_conf_arg_t type,
    1.14 -//                                                 void* value) {
    1.15 -//     pep_gpgme_val_list_t* retval = calloc(1, sizeof(pep_gpgme_val_list_t));
    1.16 -//     if (!retval)
    1.17 -//         return NULL;
    1.18 -//     retval->type = type;
    1.19 -//     retval->value = value;
    1.20 -//     return retval;    
    1.21 -// }
    1.22 -// 
    1.23 -// static pep_gpgme_val_list_t* add_pep_conf_val(pep_gpgme_val_list_t* list, 
    1.24 -//                                               gpgme_conf_arg_t type,
    1.25 -//                                               void* value) {
    1.26 -//     pep_gpgme_val_list_t* newnode = new_pep_conf_val(type, value);
    1.27 -//     if (!newnode)
    1.28 -//         return NULL;
    1.29 -// 
    1.30 -//     if (list) {
    1.31 -//         pep_gpgme_val_list_t** last_next = &(list->next);
    1.32 -//         while (*last_next)
    1.33 -//             last_next = &((*last_next)->next);
    1.34 -// 
    1.35 -//         *last_next = new_node;
    1.36 -//     }
    1.37 -//     return newnode; 
    1.38 -// }
    1.39 -
    1.40 -// // the lists are never long, so this should be fine.
    1.41 -// static void free_pep_conf_val_list(pep_gpgme_val_list_t* head) {
    1.42 -//     if (head) {
    1.43 -//         free_pep_conf_val_list(head->next);
    1.44 -//         free(value);
    1.45 -//         free(head);
    1.46 -//     }
    1.47 -// }
    1.48 -
    1.49  bloblist_t* make_conf_val(gpgme_conf_type_t type, const void* value) {    
    1.50      char* strval = NULL;
    1.51      void* otherval = NULL;
    1.52 @@ -91,13 +49,13 @@
    1.53                                   stringlist_t *keys, 
    1.54                                   bloblist_t *values)
    1.55  {    
    1.56 -    gpgme_conf_comp_t curr_conf = configs;
    1.57 +    gpgme_conf_comp_t curr_conf;
    1.58      gpgme_conf_opt_t opt;
    1.59      gpgme_error_t gpgme_error;
    1.60      stringlist_t *_k;
    1.61      bloblist_t *_v;
    1.62       
    1.63 -    while (curr_conf) {
    1.64 +    for (curr_conf = configs; curr_conf; curr_conf = curr_conf->next) {
    1.65          if (strcmp(curr_conf->name, conf_name) == 0) {
    1.66              for (_k = keys, _v = values; _k != NULL; _k = _k->next, _v = _v->next) {
    1.67                  for (opt = curr_conf->options; opt; opt = opt->next) {
    1.68 @@ -522,7 +480,25 @@
    1.69          gpg.gpgme_set_locale (NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL));
    1.70  #endif
    1.71  
    1.72 -        // Set up gpg and gpg-agent configs
    1.73 +    }
    1.74 +
    1.75 +    gpg.gpgme_check(NULL);
    1.76 +    gpgme_error = gpg.gpgme_new(&session->ctx);
    1.77 +    gpgme_error = _GPGERR(gpgme_error);
    1.78 +    if (gpgme_error != GPG_ERR_NO_ERROR) {
    1.79 +        status = PEP_INIT_GPGME_INIT_FAILED;
    1.80 +        goto pep_error;
    1.81 +    }
    1.82 +    assert(session->ctx);
    1.83 +
    1.84 +    gpgme_error = gpg.gpgme_set_protocol(session->ctx, GPGME_PROTOCOL_OpenPGP);
    1.85 +    gpgme_error = _GPGERR(gpgme_error);
    1.86 +    assert(gpgme_error == GPG_ERR_NO_ERROR);
    1.87 +
    1.88 +    gpg.gpgme_set_armor(session->ctx, 1);
    1.89 +
    1.90 +    // Set up gpg and gpg-agent configs
    1.91 +    if (in_first) {
    1.92          gpgme_conf_comp_t configs; 
    1.93  
    1.94          gpgme_error = gpg.gpgme_op_conf_load(session->ctx, &configs);
    1.95 @@ -602,20 +578,6 @@
    1.96          }
    1.97      }
    1.98  
    1.99 -    gpg.gpgme_check(NULL);
   1.100 -    gpgme_error = gpg.gpgme_new(&session->ctx);
   1.101 -    gpgme_error = _GPGERR(gpgme_error);
   1.102 -    if (gpgme_error != GPG_ERR_NO_ERROR) {
   1.103 -        status = PEP_INIT_GPGME_INIT_FAILED;
   1.104 -        goto pep_error;
   1.105 -    }
   1.106 -    assert(session->ctx);
   1.107 -
   1.108 -    gpgme_error = gpg.gpgme_set_protocol(session->ctx, GPGME_PROTOCOL_OpenPGP);
   1.109 -    gpgme_error = _GPGERR(gpgme_error);
   1.110 -    assert(gpgme_error == GPG_ERR_NO_ERROR);
   1.111 -
   1.112 -    gpg.gpgme_set_armor(session->ctx, 1);
   1.113  
   1.114      return PEP_STATUS_OK;
   1.115