ENGINE-455: and compiling ain't linking either. ENGINE-455
authorKrista Bennett <krista@pep-project.org>
Mon, 20 Aug 2018 12:25:57 +0200
branchENGINE-455
changeset 285953694809c009
parent 2858 46f167eebe58
child 2860 978b009c17fa
ENGINE-455: and compiling ain't linking either.
src/pgp_gpg.c
src/pgp_gpg_internal.h
     1.1 --- a/src/pgp_gpg.c	Mon Aug 20 12:01:21 2018 +0200
     1.2 +++ b/src/pgp_gpg.c	Mon Aug 20 12:25:57 2018 +0200
     1.3 @@ -106,14 +106,14 @@
     1.4                              // Option has *not* been *explicitly* set. So we can set it.
     1.5                              gpgme_conf_arg_t new_val;
     1.6                              if (opt->type == GPGME_CONF_NONE)
     1.7 -                                gpgme_error = gpgme_conf_arg_new(&new_val, opt->type, NULL);    
     1.8 +                                gpgme_error = gpg.gpgme_conf_arg_new(&new_val, opt->type, NULL);    
     1.9                              else     
    1.10 -                                gpgme_error = gpgme_conf_arg_new(&new_val, opt->type, _v->value);
    1.11 +                                gpgme_error = gpg.gpgme_conf_arg_new(&new_val, opt->type, _v->value);
    1.12                                  
    1.13                              if (gpgme_error != GPG_ERR_NO_ERROR)
    1.14                                  return false;
    1.15                                  
    1.16 -                            gpgme_error = gpgme_conf_opt_change(opt, 0, new_val);    
    1.17 +                            gpgme_error = gpg.gpgme_conf_opt_change(opt, 0, new_val);    
    1.18                              if (gpgme_error != GPG_ERR_NO_ERROR)
    1.19                                  return false;
    1.20                          }
    1.21 @@ -121,7 +121,7 @@
    1.22                      }
    1.23                  }
    1.24              }
    1.25 -            gpgme_error_t gpgme_err = gpgme_op_conf_save(session->ctx, curr_conf);
    1.26 +            gpgme_error_t gpgme_err = gpg.gpgme_op_conf_save(session->ctx, curr_conf);
    1.27              if (gpgme_err != GPG_ERR_NO_ERROR)
    1.28                  return false;
    1.29              return true;
    1.30 @@ -264,80 +264,6 @@
    1.31  
    1.32      if (in_first) {
    1.33          
    1.34 -        gpgme_conf_comp_t configs; 
    1.35 -
    1.36 -        gpgme_error = gpgme_op_conf_load(session->ctx, &configs);
    1.37 -        
    1.38 -        stringlist_t *conf_keys   = new_stringlist("keyserver");
    1.39 -        bloblist_t   *conf_values = make_conf_val(GPGME_CONF_STRING,
    1.40 -                                                  "hkp://keys.gnupg.net");
    1.41 -
    1.42 -        bloblist_t** nextval = &(conf_values->next);
    1.43 -                                                          
    1.44 -        stringlist_add(conf_keys, "cert-digest-algo");
    1.45 -        *nextval = make_conf_val(GPGME_CONF_STRING, "SHA256");
    1.46 -        nextval = &((*nextval)->next);
    1.47 -
    1.48 -        stringlist_add(conf_keys, "no-emit-version");
    1.49 -        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
    1.50 -        nextval = &((*nextval)->next);
    1.51 -        
    1.52 -        stringlist_add(conf_keys, "no-comments");
    1.53 -        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
    1.54 -        nextval = &((*nextval)->next);
    1.55 -
    1.56 -        stringlist_add(conf_keys, "personal-cipher-preferences");
    1.57 -        *nextval = make_conf_val(GPGME_CONF_STRING, "AES AES256 AES192 CAST5");
    1.58 -        nextval = &((*nextval)->next);
    1.59 -
    1.60 -        stringlist_add(conf_keys, "personal-digest-preferences");
    1.61 -        *nextval = make_conf_val(GPGME_CONF_STRING, "SHA256 SHA512 SHA384 SHA224");
    1.62 -        nextval = &((*nextval)->next);
    1.63 -
    1.64 -        stringlist_add(conf_keys, "ignore-time-conflict");
    1.65 -        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
    1.66 -        nextval = &((*nextval)->next);
    1.67 -
    1.68 -        stringlist_add(conf_keys, "allow-freeform-uid");
    1.69 -        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
    1.70 -        nextval = &((*nextval)->next);
    1.71 -
    1.72 -        bResult = ensure_config_values(session, configs, 
    1.73 -                                       "gpg", conf_keys, 
    1.74 -                                       conf_values);
    1.75 -        
    1.76 -        free_stringlist(conf_keys);
    1.77 -        free_bloblist(conf_values);
    1.78 -
    1.79 -        assert(bResult);
    1.80 -        if (!bResult) {
    1.81 -            status = PEP_INIT_NO_GPG_HOME;
    1.82 -            goto pep_error;
    1.83 -        }
    1.84 -
    1.85 -        uint32_t temp_uint = 300;
    1.86 -        conf_keys = new_stringlist("default-cache-ttl");
    1.87 -        conf_values = make_conf_val(GPGME_CONF_UINT32, &temp_uint);
    1.88 -        nextval = &(conf_values->next);
    1.89 -
    1.90 -        temp_uint = 1200;
    1.91 -        stringlist_add(conf_keys, "max-cache-ttl");
    1.92 -        *nextval = make_conf_val(GPGME_CONF_UINT32, &temp_uint);        
    1.93 -        nextval = &((*nextval)->next);
    1.94 -
    1.95 -        bResult = ensure_config_values(session, configs, 
    1.96 -                                       "gpg-agent", conf_keys, 
    1.97 -                                       conf_values);
    1.98 -        
    1.99 -        free_stringlist(conf_keys);
   1.100 -        free_bloblist(conf_values);
   1.101 -
   1.102 -        assert(bResult);
   1.103 -        if (!bResult) {
   1.104 -            status = PEP_INIT_CANNOT_CONFIG_GPG_AGENT;
   1.105 -            goto pep_error;
   1.106 -        }
   1.107 -
   1.108          gpgme = dlopen(LIBGPGME, RTLD_LAZY);
   1.109          if (gpgme == NULL) {
   1.110              status = PEP_INIT_CANNOT_LOAD_GPGME;
   1.111 @@ -568,6 +494,23 @@
   1.112              dlsym(gpgme, "gpgme_io_write");
   1.113          assert(gpg.gpgme_io_write);
   1.114  
   1.115 +        gpg.gpgme_conf_arg_new = (gpgme_conf_arg_new_t) (intptr_t)
   1.116 +            dlsym(gpgme, "gpgme_conf_arg_new");
   1.117 +        assert(gpg.gpgme_conf_arg_new);
   1.118 +
   1.119 +        gpg.gpgme_op_conf_load = (gpgme_op_conf_load_t) (intptr_t)
   1.120 +            dlsym(gpgme, "gpgme_op_conf_load");
   1.121 +        assert(gpg.gpgme_op_conf_load);
   1.122 +
   1.123 +        gpg.gpgme_op_conf_save = (gpgme_op_conf_save_t) (intptr_t)
   1.124 +            dlsym(gpgme, "gpgme_op_conf_save");
   1.125 +        assert(gpg.gpgme_op_conf_save);
   1.126 +
   1.127 +        gpg.gpgme_conf_opt_change = (gpgme_conf_opt_change_t) (intptr_t)
   1.128 +            dlsym(gpgme, "gpgme_conf_opt_change");
   1.129 +        assert(gpg.gpgme_conf_opt_change);
   1.130 +
   1.131 +
   1.132          gpg.version = gpg.gpgme_check(NULL);
   1.133  
   1.134          const char * const cLocal = setlocale(LC_ALL, NULL);
   1.135 @@ -578,6 +521,85 @@
   1.136  #ifdef LC_MESSAGES // Windoze
   1.137          gpg.gpgme_set_locale (NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL));
   1.138  #endif
   1.139 +
   1.140 +        // Set up gpg and gpg-agent configs
   1.141 +        gpgme_conf_comp_t configs; 
   1.142 +
   1.143 +        gpgme_error = gpg.gpgme_op_conf_load(session->ctx, &configs);
   1.144 +        if (gpgme_error != GPG_ERR_NO_ERROR) {
   1.145 +            status = PEP_INIT_GPGME_INIT_FAILED;
   1.146 +            goto pep_error;
   1.147 +        }
   1.148 +        
   1.149 +        stringlist_t *conf_keys   = new_stringlist("keyserver");
   1.150 +        bloblist_t   *conf_values = make_conf_val(GPGME_CONF_STRING,
   1.151 +                                                  "hkp://keys.gnupg.net");
   1.152 +
   1.153 +        bloblist_t** nextval = &(conf_values->next);
   1.154 +                                                          
   1.155 +        stringlist_add(conf_keys, "cert-digest-algo");
   1.156 +        *nextval = make_conf_val(GPGME_CONF_STRING, "SHA256");
   1.157 +        nextval = &((*nextval)->next);
   1.158 +
   1.159 +        stringlist_add(conf_keys, "no-emit-version");
   1.160 +        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
   1.161 +        nextval = &((*nextval)->next);
   1.162 +        
   1.163 +        stringlist_add(conf_keys, "no-comments");
   1.164 +        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
   1.165 +        nextval = &((*nextval)->next);
   1.166 +
   1.167 +        stringlist_add(conf_keys, "personal-cipher-preferences");
   1.168 +        *nextval = make_conf_val(GPGME_CONF_STRING, "AES AES256 AES192 CAST5");
   1.169 +        nextval = &((*nextval)->next);
   1.170 +
   1.171 +        stringlist_add(conf_keys, "personal-digest-preferences");
   1.172 +        *nextval = make_conf_val(GPGME_CONF_STRING, "SHA256 SHA512 SHA384 SHA224");
   1.173 +        nextval = &((*nextval)->next);
   1.174 +
   1.175 +        stringlist_add(conf_keys, "ignore-time-conflict");
   1.176 +        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
   1.177 +        nextval = &((*nextval)->next);
   1.178 +
   1.179 +        stringlist_add(conf_keys, "allow-freeform-uid");
   1.180 +        *nextval = make_conf_val(GPGME_CONF_NONE, NULL); // placeholder
   1.181 +        nextval = &((*nextval)->next);
   1.182 +
   1.183 +        bResult = ensure_config_values(session, configs, 
   1.184 +                                       "gpg", conf_keys, 
   1.185 +                                       conf_values);
   1.186 +        
   1.187 +        free_stringlist(conf_keys);
   1.188 +        free_bloblist(conf_values);
   1.189 +
   1.190 +        assert(bResult);
   1.191 +        if (!bResult) {
   1.192 +            status = PEP_INIT_NO_GPG_HOME;
   1.193 +            goto pep_error;
   1.194 +        }
   1.195 +
   1.196 +        uint32_t temp_uint = 300;
   1.197 +        conf_keys = new_stringlist("default-cache-ttl");
   1.198 +        conf_values = make_conf_val(GPGME_CONF_UINT32, &temp_uint);
   1.199 +        nextval = &(conf_values->next);
   1.200 +
   1.201 +        temp_uint = 1200;
   1.202 +        stringlist_add(conf_keys, "max-cache-ttl");
   1.203 +        *nextval = make_conf_val(GPGME_CONF_UINT32, &temp_uint);        
   1.204 +        nextval = &((*nextval)->next);
   1.205 +
   1.206 +        bResult = ensure_config_values(session, configs, 
   1.207 +                                       "gpg-agent", conf_keys, 
   1.208 +                                       conf_values);
   1.209 +        
   1.210 +        free_stringlist(conf_keys);
   1.211 +        free_bloblist(conf_values);
   1.212 +
   1.213 +        assert(bResult);
   1.214 +        if (!bResult) {
   1.215 +            status = PEP_INIT_CANNOT_CONFIG_GPG_AGENT;
   1.216 +            goto pep_error;
   1.217 +        }
   1.218      }
   1.219  
   1.220      gpg.gpgme_check(NULL);
   1.221 @@ -589,13 +611,6 @@
   1.222      }
   1.223      assert(session->ctx);
   1.224  
   1.225 -    gpgme_conf_comp_t configs;
   1.226 -    gpgme_error = gpgme_op_conf_load(session->ctx, &configs);
   1.227 -    if (gpgme_error != GPG_ERR_NO_ERROR) {
   1.228 -        status = PEP_INIT_GPGME_INIT_FAILED;
   1.229 -        goto pep_error;
   1.230 -    }
   1.231 -
   1.232      gpgme_error = gpg.gpgme_set_protocol(session->ctx, GPGME_PROTOCOL_OpenPGP);
   1.233      gpgme_error = _GPGERR(gpgme_error);
   1.234      assert(gpgme_error == GPG_ERR_NO_ERROR);
     2.1 --- a/src/pgp_gpg_internal.h	Mon Aug 20 12:01:21 2018 +0200
     2.2 +++ b/src/pgp_gpg_internal.h	Mon Aug 20 12:25:57 2018 +0200
     2.3 @@ -93,6 +93,13 @@
     2.4  #endif
     2.5  #endif
     2.6  
     2.7 +typedef gpgme_error_t(*gpgme_conf_arg_new_t)(gpgme_conf_arg_t *ARG_P,
     2.8 +    gpgme_conf_type_t TYPE, const void *VALUE);
     2.9 +typedef gpgme_error_t(*gpgme_op_conf_load_t)(gpgme_ctx_t CTX, 
    2.10 +    gpgme_conf_comp_t *CONF_P);
    2.11 +typedef gpgme_error_t(*gpgme_op_conf_save_t)(gpgme_ctx_t CTX, gpgme_conf_comp_t COMP);
    2.12 +typedef gpgme_error_t(*gpgme_conf_opt_change_t)(gpgme_conf_opt_t OPT, 
    2.13 +    int RESET, gpgme_conf_arg_t ARG);
    2.14  
    2.15  typedef gpgme_error_t(*gpgme_set_passphrase_cb_t)(gpgme_ctx_t ctx, 
    2.16  		gpgme_passphrase_cb_t passfunc, void *hook_value);
    2.17 @@ -151,5 +158,10 @@
    2.18      gpgme_op_edit_t gpgme_op_edit;
    2.19      gpgme_io_write_t gpgme_io_write;
    2.20  
    2.21 +    gpgme_conf_arg_new_t gpgme_conf_arg_new;
    2.22 +    gpgme_op_conf_load_t gpgme_op_conf_load;
    2.23 +    gpgme_op_conf_save_t gpgme_op_conf_save;
    2.24 +    gpgme_conf_opt_change_t gpgme_conf_opt_change;
    2.25 +
    2.26      gpgme_set_passphrase_cb_t gpgme_set_passphrase_cb;
    2.27  };