ENGINE-427
authorKrista Bennett <krista@pep-project.org>
Fri, 27 Jul 2018 13:17:34 +0200
changeset 2784dcb0d2263697
parent 2779 7618e2247a78
parent 2783 83dafb06379c
child 2786 2de6c76a9fbc
ENGINE-427
     1.1 --- a/src/pEpEngine.c	Wed Jun 27 17:10:24 2018 +0200
     1.2 +++ b/src/pEpEngine.c	Fri Jul 27 13:17:34 2018 +0200
     1.3 @@ -6,6 +6,7 @@
     1.4  #include "cryptotech.h"
     1.5  #include "transport.h"
     1.6  #include "blacklist.h"
     1.7 +#include "wrappers.h"
     1.8  
     1.9  #include <time.h>
    1.10  #include <stdlib.h>
    1.11 @@ -427,6 +428,64 @@
    1.12      "insert or replace into alternate_user_id (alternate_id, default_id) "
    1.13      "values (?2, ?1) ;";
    1.14      
    1.15 +static const char* sql_get_cached_engine_version =
    1.16 +    "select version from version_info where id = 1 ;";
    1.17 +
    1.18 +static const char* sql_set_cached_engine_version =
    1.19 +    "insert or replace into version_info (id, version)"
    1.20 +    "values (1, ?1) ; ";
    1.21 +
    1.22 +
    1.23 +PEP_STATUS set_engine_version_in_DB(PEP_SESSION session, 
    1.24 +                                                  char** version_str)
    1.25 +{
    1.26 +    PEP_STATUS status = PEP_STATUS_OK;
    1.27 +    int result;
    1.28 +
    1.29 +    if (!(session && version_str))
    1.30 +        return PEP_ILLEGAL_VALUE;
    1.31 +
    1.32 +    sqlite3_reset(session->set_cached_engine_version);
    1.33 +    sqlite3_bind_text(session->set_cached_engine_version, 1, *version_str, -1,
    1.34 +            SQLITE_STATIC);
    1.35 +
    1.36 +    result = sqlite3_step(session->set_cached_engine_version);
    1.37 +    sqlite3_reset(session->set_cached_engine_version);
    1.38 +    if (result != SQLITE_DONE) {
    1.39 +        return PEP_UNKNOWN_ERROR;
    1.40 +    }
    1.41 +
    1.42 +    
    1.43 +    return status;
    1.44 +}
    1.45 +
    1.46 +PEP_STATUS get_engine_version_from_DB(PEP_SESSION session, 
    1.47 +                                      char** version_str)
    1.48 +{
    1.49 +    PEP_STATUS status = PEP_STATUS_OK;
    1.50 +    int result;
    1.51 +
    1.52 +    if (!(session && version_str))
    1.53 +        return PEP_ILLEGAL_VALUE;
    1.54 +
    1.55 +    sqlite3_reset(session->get_cached_engine_version);
    1.56 +    result = sqlite3_step(session->get_cached_engine_version);
    1.57 +    switch (result) {
    1.58 +    case SQLITE_ROW: {
    1.59 +        *version_str = strdup((const char *) sqlite3_column_text(session->get_cached_engine_version,
    1.60 +                       0));
    1.61 +        break;
    1.62 +    } 
    1.63 +    default:
    1.64 +        status = PEP_UNKNOWN_ERROR;
    1.65 +    }
    1.66 +
    1.67 +    sqlite3_reset(session->get_cached_engine_version);
    1.68 +    
    1.69 +    return status;
    1.70 +}
    1.71 +
    1.72 +    
    1.73  static int user_version(void *_version, int count, char **text, char **name)
    1.74  {
    1.75      assert(_version);
    1.76 @@ -498,6 +557,93 @@
    1.77  PEP_STATUS pgp_import_ultimately_trusted_keypairs(PEP_SESSION session);
    1.78  #endif // USE_GPG
    1.79  
    1.80 +
    1.81 +static int parse_three_part_version_string(char* version, 
    1.82 +                                            int* major, 
    1.83 +                                            int* minor, 
    1.84 +                                            int* patch) {
    1.85 +    if (!major || !minor || !patch)
    1.86 +        return -1;
    1.87 +        
    1.88 +    char* ver_token = strtok(version, ".");
    1.89 +    if (ver_token == NULL) {
    1.90 +        *major = -1;
    1.91 +        return -1;
    1.92 +    }
    1.93 +    *major = atoi(ver_token);
    1.94 +    ver_token = strtok(NULL, ".");
    1.95 +    if (ver_token == NULL) {
    1.96 +        *minor = -1;
    1.97 +        return -1;
    1.98 +    }
    1.99 +    *minor = atoi(ver_token);
   1.100 +    ver_token = strtok(NULL, ".");
   1.101 +    if (ver_token == NULL) {
   1.102 +        *patch = -1;
   1.103 +        return -1;
   1.104 +    }
   1.105 +    *patch = atoi(ver_token);
   1.106 +    return 0;
   1.107 +}
   1.108 +
   1.109 +int compare_engine_versions(int major1, int minor1, int patch1,
   1.110 +                            int major2, int minor2, int patch2) {
   1.111 +    if (major1 != major2)
   1.112 +        return (major1 < major2 ? -1 : 1);
   1.113 +    if (minor1 != minor2)
   1.114 +        return (minor1 < minor2 ? -1 : 1);
   1.115 +    if (patch1 != patch2)
   1.116 +        return (patch1 < patch2 ? -1 : 1);
   1.117 +    return 0;    
   1.118 +}
   1.119 +
   1.120 +PEP_STATUS compare_cached_engine_version_to_other(PEP_SESSION session,
   1.121 +                                                  int* result, 
   1.122 +                                                  int major, 
   1.123 +                                                  int minor, 
   1.124 +                                                  int patch) {
   1.125 +    if (!result)
   1.126 +        return PEP_ILLEGAL_VALUE;
   1.127 +        
   1.128 +    PEP_STATUS status = PEP_STATUS_OK;
   1.129 +    char* cached_engine_version = NULL;
   1.130 +    status = get_engine_version_from_DB(session, &cached_engine_version);
   1.131 +    if (status != PEP_STATUS_OK)
   1.132 +        return status;
   1.133 +        
   1.134 +    if (cached_engine_version && cached_engine_version[0] != '\0') {
   1.135 +        char* cached_version_info = strdup(cached_engine_version);
   1.136 +
   1.137 +        int cmajor = -1;
   1.138 +        int cminor = -1;
   1.139 +        int cpatch = -1;
   1.140 +        int success = parse_three_part_version_string(cached_version_info, 
   1.141 +                                                      &cmajor, 
   1.142 +                                                      &cminor, 
   1.143 +                                                      &cpatch);
   1.144 +        
   1.145 +        if (success != 0 || cmajor < 0 || cminor < 0 || cpatch < 0) {
   1.146 +            status = PEP_UNKNOWN_ERROR;
   1.147 +        }
   1.148 +        else 
   1.149 +            *result = compare_engine_versions(cmajor, cminor, cpatch,
   1.150 +                                              major, minor, patch);
   1.151 +        free(cached_version_info);
   1.152 +        //free(cached_engine_version);                                    
   1.153 +    }
   1.154 +    else {
   1.155 +        return PEP_UNKNOWN_ERROR;
   1.156 +    }
   1.157 +    return status;    
   1.158 +}
   1.159 +
   1.160 +PEP_STATUS compare_cached_engine_version_to_curr(PEP_SESSION session, int* result) {
   1.161 +    return compare_cached_engine_version_to_other(session, result, 
   1.162 +                                                  PEP_ENGINE_MAJOR,
   1.163 +                                                  PEP_ENGINE_MINOR,
   1.164 +                                                  PEP_ENGINE_PATCH);
   1.165 +}
   1.166 +
   1.167  DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
   1.168  {
   1.169      PEP_STATUS status = PEP_STATUS_OK;
   1.170 @@ -1033,9 +1179,7 @@
   1.171          if (version < atoi(_DDL_USER_VERSION)) {
   1.172              int_result = sqlite3_exec(
   1.173                  _session->db,
   1.174 -                "pragma user_version = "_DDL_USER_VERSION";\n"
   1.175 -                "insert or replace into version_info (id, version)"
   1.176 -                    "values (1, '" PEP_ENGINE_VERSION "');",
   1.177 +                "pragma user_version = "_DDL_USER_VERSION";\n",
   1.178                  NULL,
   1.179                  NULL,
   1.180                  NULL
   1.181 @@ -1056,6 +1200,14 @@
   1.182              (int)strlen(sql_trustword), &_session->trustword, NULL);
   1.183      assert(int_result == SQLITE_OK);
   1.184  
   1.185 +    int_result = sqlite3_prepare_v2(_session->db, sql_get_cached_engine_version,
   1.186 +            (int)strlen(sql_get_cached_engine_version), &_session->get_cached_engine_version, NULL);
   1.187 +    assert(int_result == SQLITE_OK);
   1.188 +
   1.189 +    int_result = sqlite3_prepare_v2(_session->db, sql_set_cached_engine_version,
   1.190 +            (int)strlen(sql_set_cached_engine_version), &_session->set_cached_engine_version, NULL);
   1.191 +    assert(int_result == SQLITE_OK);
   1.192 +
   1.193      int_result = sqlite3_prepare_v2(_session->db, sql_get_identity,
   1.194              (int)strlen(sql_get_identity), &_session->get_identity, NULL);
   1.195      assert(int_result == SQLITE_OK);
   1.196 @@ -1306,6 +1458,17 @@
   1.197      if (status != PEP_STATUS_OK)
   1.198          goto pep_error;
   1.199  
   1.200 +    // Because of ENGINE-427 hotfix, we can only update the version here.
   1.201 +    int_result = sqlite3_exec(
   1.202 +        _session->db,
   1.203 +        "insert or replace into version_info (id, version)"
   1.204 +            "values (1, '" PEP_ENGINE_VERSION "');",
   1.205 +        NULL,
   1.206 +        NULL,
   1.207 +        NULL
   1.208 +    );
   1.209 +    assert(int_result == SQLITE_OK);
   1.210 +
   1.211      // runtime config
   1.212  
   1.213      if (very_first)
   1.214 @@ -1372,6 +1535,10 @@
   1.215                  sqlite3_finalize(session->log);
   1.216              if (session->trustword)
   1.217                  sqlite3_finalize(session->trustword);
   1.218 +            if (session->get_cached_engine_version)
   1.219 +                sqlite3_finalize(session->get_cached_engine_version);                
   1.220 +            if (session->set_cached_engine_version)
   1.221 +                sqlite3_finalize(session->set_cached_engine_version);                                
   1.222              if (session->get_identity)
   1.223                  sqlite3_finalize(session->get_identity);
   1.224              if (session->get_identity_without_trust_check)
     2.1 --- a/src/pEpEngine.h	Wed Jun 27 17:10:24 2018 +0200
     2.2 +++ b/src/pEpEngine.h	Fri Jul 27 13:17:34 2018 +0200
     2.3 @@ -1275,6 +1275,12 @@
     2.4  
     2.5  PEP_STATUS set_pgp_keypair(PEP_SESSION session, const char* fpr);
     2.6  
     2.7 +PEP_STATUS compare_cached_engine_version_to_other(PEP_SESSION session,
     2.8 +                                                  int* result, 
     2.9 +                                                  int major, 
    2.10 +                                                  int minor, 
    2.11 +                                                  int patch);
    2.12 +
    2.13  #ifdef __cplusplus
    2.14  }
    2.15  #endif
     3.1 --- a/src/pEp_internal.h	Wed Jun 27 17:10:24 2018 +0200
     3.2 +++ b/src/pEp_internal.h	Fri Jul 27 13:17:34 2018 +0200
     3.3 @@ -1,7 +1,12 @@
     3.4  // This file is under GNU General Public License 3.0
     3.5  // see LICENSE.txt
     3.6  
     3.7 -#define PEP_ENGINE_VERSION "0.9.0"
     3.8 +
     3.9 +// THESE MUST ALL BE CHANGED TOGETHER!!!!
    3.10 +#define PEP_ENGINE_VERSION "1.0.440"
    3.11 +#define PEP_ENGINE_MAJOR 1
    3.12 +#define PEP_ENGINE_MINOR 0
    3.13 +#define PEP_ENGINE_PATCH 440
    3.14  
    3.15  // maximum attachment size to import as key 1MB, maximum of 20 attachments
    3.16  
    3.17 @@ -128,6 +133,8 @@
    3.18  
    3.19      sqlite3_stmt *log;
    3.20      sqlite3_stmt *trustword;
    3.21 +    sqlite3_stmt *get_cached_engine_version;
    3.22 +    sqlite3_stmt *set_cached_engine_version;    
    3.23      sqlite3_stmt *get_identity;
    3.24      sqlite3_stmt *get_identity_without_trust_check;
    3.25      sqlite3_stmt *get_identities_by_address;
     4.1 --- a/src/pgp_gpg.c	Wed Jun 27 17:10:24 2018 +0200
     4.2 +++ b/src/pgp_gpg.c	Fri Jul 27 13:17:34 2018 +0200
     4.3 @@ -14,6 +14,234 @@
     4.4  static void *gpgme;
     4.5  static struct gpg_s gpg;
     4.6  
     4.7 +struct _str_ptr_and_bit {
     4.8 +    const char* key;
     4.9 +    int bit;
    4.10 +};
    4.11 +
    4.12 +typedef struct _str_ptr_and_bit str_ptr_and_bit;
    4.13 +
    4.14 +int strptrcmp(const void* a, const void* b) {
    4.15 +    return (int)((((str_ptr_and_bit*)(a))->key) - (((str_ptr_and_bit*)(b))->key));
    4.16 +}
    4.17 +
    4.18 +// This is in response to ENGINE-427. We should NOT be aiming to keep this here.
    4.19 +bool quickfix_config(stringlist_t* keys, const char* config_file_path) {
    4.20 +    static char buf[MAX_LINELENGTH];
    4.21 +    size_t num_keys = stringlist_length(keys);
    4.22 +
    4.23 +    // Open file
    4.24 +
    4.25 +    FILE *f = Fopen(config_file_path, "r");    
    4.26 +       
    4.27 +    if (f == NULL)
    4.28 +        return false;
    4.29 +
    4.30 +    int i;
    4.31 +    stringlist_t* _k;
    4.32 +    stringlist_t* lines = new_stringlist(NULL);
    4.33 +    int found = 0;
    4.34 +
    4.35 +    char* s = NULL;
    4.36 +
    4.37 +    // Go through every line in the file
    4.38 +    while ((s = Fgets(buf, MAX_LINELENGTH, f))) {
    4.39 +        // pointers to the keys found in this string
    4.40 +        str_ptr_and_bit* found_keys = (str_ptr_and_bit*)(calloc(num_keys, sizeof(str_ptr_and_bit)));
    4.41 +        int num_found_keys = 0;
    4.42 +
    4.43 +        char* rest;
    4.44 +        char* line_token = strtok_r(s, "\r\n", &rest);
    4.45 +        if (!line_token)
    4.46 +            line_token = s;
    4.47 +            
    4.48 +        if (*line_token == '#' || *line_token == '\0') {
    4.49 +            stringlist_add(lines, strdup(line_token));
    4.50 +            continue;
    4.51 +        }
    4.52 +
    4.53 +        bool only_key_on_line = false;
    4.54 +        for (_k = keys, i = 1; _k; _k = _k->next, i<<=1) {
    4.55 +            char* keypos = strstr(line_token, _k->value);
    4.56 +            if (!keypos)
    4.57 +                continue;
    4.58 +            size_t keystr_len = strlen(_k->value);
    4.59 +            char* nextpos = keypos + keystr_len;
    4.60 +            bool notkey = false;
    4.61 +            
    4.62 +            if (keypos != line_token) {
    4.63 +                char prevchar = *(keypos - 1);
    4.64 +                switch (prevchar) {
    4.65 +                    case '-':
    4.66 +                    case ':':
    4.67 +                    case '/':
    4.68 +                        notkey = true;
    4.69 +                        break;
    4.70 +                    default:
    4.71 +                        break;
    4.72 +                }
    4.73 +            }
    4.74 +
    4.75 +            if (*nextpos && !notkey) {
    4.76 +                char nextchar = *nextpos;
    4.77 +                switch (nextchar) {
    4.78 +                    case '-':
    4.79 +                    case ':':
    4.80 +                    case '/':
    4.81 +                        notkey = true;
    4.82 +                        break;
    4.83 +                    default:
    4.84 +                        break;
    4.85 +                }
    4.86 +            }
    4.87 +            else if (line_token == keypos) {
    4.88 +                only_key_on_line = true;
    4.89 +                if (!(found & i)) {
    4.90 +                    found |= i;
    4.91 +                    stringlist_add(lines, strdup(line_token));
    4.92 +                    num_found_keys++;
    4.93 +                }
    4.94 +                break;
    4.95 +            }
    4.96 +
    4.97 +            if (!notkey) {
    4.98 +                // Ok, it's not just the key with a null terminator. So...
    4.99 +                // add a pointer to the key to the list from this string
   4.100 +                found_keys[num_found_keys].key = keypos; 	
   4.101 +                found_keys[num_found_keys].bit = i;
   4.102 +                num_found_keys++;
   4.103 +            }
   4.104 +            
   4.105 +            // Check to see if there are more annoying occurences of this 
   4.106 +            // key in the string
   4.107 +            for (keypos = strstr(nextpos, _k->value); 
   4.108 +                keypos; keypos = strstr(nextpos, _k->value)) {
   4.109 +                notkey = false;
   4.110 +                nextpos = keypos + keystr_len;
   4.111 +                char prevchar = *(keypos - 1);
   4.112 +                switch (prevchar) {
   4.113 +                    case '-':
   4.114 +                    case ':':
   4.115 +                    case '/':
   4.116 +                        notkey = true;
   4.117 +                        break;
   4.118 +                    default:
   4.119 +                        break;
   4.120 +                }
   4.121 +                if (!notkey) {
   4.122 +                    char nextchar = *nextpos;
   4.123 +                    switch (nextchar) {
   4.124 +                        case '-':
   4.125 +                        case ':':
   4.126 +                        case '/':
   4.127 +                            notkey = true;
   4.128 +                            break;
   4.129 +                        default:
   4.130 +                            break;
   4.131 +                    }
   4.132 +                }    
   4.133 +                if (notkey)
   4.134 +                    continue;
   4.135 +                found_keys[num_found_keys].key = keypos; 	
   4.136 +                found_keys[num_found_keys].bit = i;
   4.137 +                num_found_keys++;     
   4.138 +            }
   4.139 +        }
   4.140 +        
   4.141 +        if (!only_key_on_line) {
   4.142 +            if (num_found_keys == 0)
   4.143 +                stringlist_add(lines, strdup(line_token));        
   4.144 +            else if (num_found_keys == 1 && (line_token == found_keys[0].key)) {
   4.145 +                if (!(found & found_keys[0].bit)) {
   4.146 +                    stringlist_add(lines, strdup(line_token)); 
   4.147 +                    found |= found_keys[0].bit;
   4.148 +                }
   4.149 +            }
   4.150 +            else {
   4.151 +                qsort(found_keys, num_found_keys, sizeof(str_ptr_and_bit), strptrcmp);
   4.152 +                int j;
   4.153 +                const char* curr_start = line_token;
   4.154 +                const char* next_start = NULL;
   4.155 +                for (j = 0; j < num_found_keys; j++, curr_start = next_start) {
   4.156 +                    next_start = found_keys[j].key;
   4.157 +                    if (curr_start == next_start)
   4.158 +                        continue;
   4.159 +                    size_t copy_len = next_start - curr_start;
   4.160 +                    const char* movable_end = next_start - 1;
   4.161 +                    while (copy_len > 0 && (*movable_end == ' ' || *movable_end == '\t' || *movable_end == '\0')) {
   4.162 +                        movable_end--;
   4.163 +                        copy_len--;
   4.164 +                    }
   4.165 +                    if (copy_len > 0) {
   4.166 +                        if (j == 0 || !(found & found_keys[j - 1].bit)) {
   4.167 +                            // if j is 0 here, the first thing in the string wasn't a key, or we'd have continued.
   4.168 +                            // otherwise, regardless of the value of j, we check that the "last" key (j-1) isn't already
   4.169 +                            // found and dealt with.
   4.170 +                            // Having passed that, we copy.
   4.171 +                            stringlist_add(lines, strndup(curr_start, copy_len));
   4.172 +                            if (j > 0)
   4.173 +                                found |= found_keys[j-1].bit;
   4.174 +                        }
   4.175 +                    }
   4.176 +                }
   4.177 +                if (!(found & found_keys[num_found_keys - 1].bit)) {
   4.178 +                    stringlist_add(lines, strdup(found_keys[num_found_keys - 1].key));
   4.179 +                    found |= found_keys[num_found_keys - 1].bit;
   4.180 +                }            
   4.181 +            }
   4.182 +        }
   4.183 +        free(found_keys);
   4.184 +        found_keys = NULL;
   4.185 +    } // End of file
   4.186 +    // then write all lines to file.
   4.187 +    const char* line_end;
   4.188 +#ifdef WIN32
   4.189 +    line_end = "\r\n";
   4.190 +#else
   4.191 +    line_end = "\n";
   4.192 +#endif    
   4.193 +    size_t cf_path_len = strlen(config_file_path);
   4.194 +    size_t new_buf_size = cf_path_len + 5; // + .old\0
   4.195 +    char* old_config_path_fname = (char*)calloc(new_buf_size, 1);
   4.196 +    if (!old_config_path_fname)
   4.197 +        return false;
   4.198 +    strlcpy(old_config_path_fname, config_file_path, new_buf_size);
   4.199 +    strlcat(old_config_path_fname, ".old", new_buf_size);
   4.200 +    int ret = Fclose(f);
   4.201 +    assert(ret == 0);
   4.202 +    if (ret != 0)
   4.203 +        return false;
   4.204 +    
   4.205 +    ret = rename(config_file_path, old_config_path_fname);
   4.206 +    assert(ret == 0);
   4.207 +    if (ret != 0)
   4.208 +        return false;
   4.209 +
   4.210 +    // Ok, now open the thing for writing.
   4.211 +    f = Fopen(config_file_path, "w");
   4.212 +    
   4.213 +    assert(f);
   4.214 +    if (f == NULL)
   4.215 +        return false;
   4.216 +  
   4.217 +    stringlist_t* cur_string;
   4.218 +    
   4.219 +    for (cur_string = lines; cur_string; cur_string = cur_string->next) {
   4.220 +        ret = Fprintf(f, "%s%s", cur_string->value, line_end);
   4.221 +        assert(ret >= 0);
   4.222 +        if (ret < 0)
   4.223 +            return false;
   4.224 +    }
   4.225 +    free_stringlist(lines); // FIXME: memory
   4.226 +    
   4.227 +    ret = Fclose(f);
   4.228 +    assert(ret == 0);
   4.229 +    if (ret != 0)
   4.230 +        return false;
   4.231 +
   4.232 +    return true;
   4.233 +}
   4.234 +
   4.235  static bool ensure_config_values(stringlist_t *keys, stringlist_t *values, const char* config_file_path)
   4.236  {
   4.237      static char buf[MAX_LINELENGTH];
   4.238 @@ -39,6 +267,7 @@
   4.239          return false;
   4.240  
   4.241      if (f != NULL) {
   4.242 +                
   4.243          int length = stringlist_length(keys);
   4.244  
   4.245          // make sure we 1) have the same number of keys and values
   4.246 @@ -262,11 +491,28 @@
   4.247          stringlist_add(conf_keys, "allow-freeform-uid");
   4.248          stringlist_add(conf_values, "");
   4.249  
   4.250 +
   4.251 +        // ENGINE-427 - quick fix here. This will be removed in a few
   4.252 +        // versions, but we need to clean up our mess.
   4.253 +        int compare_result = -1;
   4.254 +        status = compare_cached_engine_version_to_other(session,
   4.255 +                                                        &compare_result, 
   4.256 +                                                        1, 0, 440);            
   4.257 +
   4.258 +        bResult = true;
   4.259 +        // status != OK => no cached engine version, i.e. first-time run.
   4.260 +        if (compare_result < 0 && status == PEP_STATUS_OK)
   4.261  #if defined(WIN32) || defined(NDEBUG)
   4.262 -        bResult = ensure_config_values(conf_keys, conf_values, gpg_conf());
   4.263 +            bResult = quickfix_config(conf_keys, gpg_conf());
   4.264 +        if (bResult)
   4.265 +            bResult = ensure_config_values(conf_keys, conf_values, gpg_conf());
   4.266  #else
   4.267 -        bResult = ensure_config_values(conf_keys, conf_values, gpg_conf(false));
   4.268 +            bResult = quickfix_config(conf_keys, gpg_conf(false));
   4.269 +        if (bResult)
   4.270 +            bResult = ensure_config_values(conf_keys, conf_values, gpg_conf(false));
   4.271  #endif
   4.272 +        status = PEP_STATUS_OK;
   4.273 +        
   4.274          free_stringlist(conf_keys);
   4.275          free_stringlist(conf_values);
   4.276  
   4.277 @@ -299,7 +545,6 @@
   4.278          gpgme = dlopen(LIBGPGME, RTLD_LAZY);
   4.279          if (gpgme == NULL) {
   4.280              // FIXME: Hotfix here?
   4.281 -            
   4.282              status = PEP_INIT_CANNOT_LOAD_GPGME;
   4.283              goto pep_error;
   4.284          }
     5.1 --- a/test/include/EngineTestSuite.h	Wed Jun 27 17:10:24 2018 +0200
     5.2 +++ b/test/include/EngineTestSuite.h	Fri Jul 27 13:17:34 2018 +0200
     5.3 @@ -34,12 +34,17 @@
     5.4          unsigned int number_of_tests;
     5.5          unsigned int on_test_number;
     5.6          
     5.7 +        string temp_test_home;
     5.8 +        
     5.9          virtual void setup();
    5.10          virtual void tear_down();
    5.11          
    5.12          void set_full_env();
    5.13 +	    void set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path);
    5.14          void restore_full_env();
    5.15          void initialise_test_home();
    5.16          void set_my_name();    
    5.17 +	
    5.18 +	    void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);
    5.19  };
    5.20  #endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/include/GPGConfFixTests.h	Fri Jul 27 13:17:34 2018 +0200
     6.3 @@ -0,0 +1,29 @@
     6.4 +// This file is under GNU General Public License 3.0
     6.5 +// see LICENSE.txt
     6.6 +
     6.7 +#ifndef G_P_G_CONF_FIX_H
     6.8 +#define G_P_G_CONF_FIX_H
     6.9 +
    6.10 +#include <string>
    6.11 +#include "EngineTestIndividualSuite.h"
    6.12 +
    6.13 +using namespace std;
    6.14 +
    6.15 +class GPGConfFixTests : public EngineTestIndividualSuite {
    6.16 +    public:
    6.17 +        GPGConfFixTests(string test_suite, string test_home_dir);
    6.18 +
    6.19 +    protected:
    6.20 +	void setup();
    6.21 +
    6.22 +    private:
    6.23 +        void check_conf_fix_broken_conf_old_db_0();
    6.24 +        void check_conf_fix_broken_conf_old_db_1();
    6.25 +        void check_conf_fix_broken_conf_old_db_2();
    6.26 +        void check_conf_fix_broken_conf_old_db_3();
    6.27 +        void check_conf_fix_broken_conf_old_db_4();
    6.28 +        void check_conf_fix_broken_conf_old_db_5();
    6.29 +        void check_conf_fix_broken_conf_old_db_6();        
    6.30 +};
    6.31 +
    6.32 +#endif
     7.1 --- a/test/src/EngineTestSuite.cc	Wed Jun 27 17:10:24 2018 +0200
     7.2 +++ b/test/src/EngineTestSuite.cc	Fri Jul 27 13:17:34 2018 +0200
     7.3 @@ -5,6 +5,10 @@
     7.4  #include <unistd.h>
     7.5  #include <ftw.h>
     7.6  #include <assert.h>
     7.7 +#include <fstream>
     7.8 +#include <iostream>
     7.9 +#include <sys/types.h>
    7.10 +#include <sys/stat.h>
    7.11  
    7.12  #include "platform_unix.h"
    7.13  
    7.14 @@ -30,7 +34,37 @@
    7.15      number_of_tests++;
    7.16  }
    7.17  
    7.18 +void EngineTestSuite::copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name) {
    7.19 +    string conf_dest_path = dest_path;
    7.20 +    
    7.21 +    struct stat pathinfo;
    7.22 +
    7.23 +    if(stat(conf_dest_path.c_str(), &pathinfo) != 0) {
    7.24 +        int errchk = mkdir(conf_dest_path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
    7.25 +        if (errchk != 0)
    7.26 +            throw std::runtime_error("Error accessing conf file directory.");
    7.27 +    }
    7.28 +    
    7.29 +    conf_dest_path += "/";
    7.30 +    conf_dest_path += conf_dest_name;
    7.31 +    
    7.32 +    ifstream src(conf_orig_path);
    7.33 +    ofstream dst(conf_dest_path.c_str(), ios::trunc);
    7.34 +    
    7.35 +    assert(src);
    7.36 +    assert(dst);
    7.37 +    
    7.38 +    dst << src.rdbuf();
    7.39 +     
    7.40 +    src.close();
    7.41 +    dst.close();
    7.42 +}
    7.43 +
    7.44  void EngineTestSuite::set_full_env() {
    7.45 +    set_full_env(NULL, NULL, NULL);
    7.46 +}
    7.47 +
    7.48 +void EngineTestSuite::set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path) {
    7.49      int success = 0;
    7.50      struct stat dirchk;
    7.51      
    7.52 @@ -59,7 +93,7 @@
    7.53              throw std::runtime_error("Error creating a test directory.");
    7.54      }
    7.55  
    7.56 -    string temp_test_home = test_home + "/" + my_name;
    7.57 +    temp_test_home = test_home + "/" + my_name;
    7.58      
    7.59      int errchk = mkdir(temp_test_home.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
    7.60      if (errchk != 0)
    7.61 @@ -85,7 +119,7 @@
    7.62      cout << "home is " << home << endl;
    7.63      assert(temp_test_home.compare(home) != 0);
    7.64      assert(temp_test_home.compare(home + "/") != 0);
    7.65 -    assert(temp_test_home.compare(home + "/.gnupg") != 0);
    7.66 +    assert(temp_test_home.compare(home + "") != 0);
    7.67      assert(temp_test_home.compare(home + ".gnupg") != 0);
    7.68      assert(temp_test_home.compare(prev_gpg_home) != 0);
    7.69      assert(temp_test_home.compare(prev_gpg_home + "/.gnupg") != 0);
    7.70 @@ -110,7 +144,14 @@
    7.71      success = setenv("HOME", temp_test_home.c_str(), 1);
    7.72      if (success != 0)
    7.73          throw std::runtime_error("SETUP: Cannot set test_home for init.");
    7.74 -    
    7.75 +
    7.76 +    if (gpg_conf_copy_path)
    7.77 +        copy_conf_file_to_test_dir((temp_test_home + "/.gnupg").c_str(), gpg_conf_copy_path, "gpg.conf");
    7.78 +    if (gpg_agent_conf_file_copy_path)        
    7.79 +        copy_conf_file_to_test_dir((temp_test_home + "/.gnupg").c_str(), gpg_agent_conf_file_copy_path, "gpg-agent.conf");
    7.80 +    if (db_conf_file_copy_path)
    7.81 +        copy_conf_file_to_test_dir(temp_test_home.c_str(), db_conf_file_copy_path, ".pEp_management.db");
    7.82 +        
    7.83      unix_local_db(true);
    7.84      gpg_conf(true);
    7.85      gpg_agent_conf(true);
     8.1 --- a/test/src/SuiteMaker.cc	Wed Jun 27 17:10:24 2018 +0200
     8.2 +++ b/test/src/SuiteMaker.cc	Fri Jul 27 13:17:34 2018 +0200
     8.3 @@ -39,6 +39,7 @@
     8.4  #include "NewUpdateIdAndMyselfTests.h"
     8.5  #include "StringlistTests.h"
     8.6  #include "LeastColorGroupTests.h"
     8.7 +#include "GPGConfFixTests.h"
     8.8  #include "ExternalRevokeTests.h"
     8.9  #include "EncryptForIdentityTests.h"
    8.10  #include "TrustwordsTests.h"
    8.11 @@ -78,6 +79,7 @@
    8.12      "NewUpdateIdAndMyselfTests",
    8.13      "StringlistTests",
    8.14      "LeastColorGroupTests",
    8.15 +    "GPGConfFixTests",
    8.16      "ExternalRevokeTests",
    8.17      "EncryptForIdentityTests",
    8.18      "TrustwordsTests",
    8.19 @@ -90,7 +92,7 @@
    8.20  };
    8.21  
    8.22  // This file is generated, so magic constants are ok.
    8.23 -int SuiteMaker::num_suites = 36;
    8.24 +int SuiteMaker::num_suites = 37;
    8.25  
    8.26  void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
    8.27      if (strcmp(test_class_name, "MapAsn1Tests") == 0)
    8.28 @@ -147,6 +149,8 @@
    8.29          *test_suite = new StringlistTests(test_class_name, test_home);
    8.30      else if (strcmp(test_class_name, "LeastColorGroupTests") == 0)
    8.31          *test_suite = new LeastColorGroupTests(test_class_name, test_home);
    8.32 +    else if (strcmp(test_class_name, "GPGConfFixTests") == 0)
    8.33 +        *test_suite = new GPGConfFixTests(test_class_name, test_home);
    8.34      else if (strcmp(test_class_name, "ExternalRevokeTests") == 0)
    8.35          *test_suite = new ExternalRevokeTests(test_class_name, test_home);
    8.36      else if (strcmp(test_class_name, "EncryptForIdentityTests") == 0)
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/src/engine_tests/GPGConfFixTests.cc	Fri Jul 27 13:17:34 2018 +0200
     9.3 @@ -0,0 +1,117 @@
     9.4 +// This file is under GNU General Public License 3.0
     9.5 +// see LICENSE.txt
     9.6 +
     9.7 +#include <stdlib.h>
     9.8 +#include <string>
     9.9 +#include <iostream>
    9.10 +#include <fstream>
    9.11 +
    9.12 +#include "pEpEngine.h"
    9.13 +
    9.14 +#include "EngineTestIndividualSuite.h"
    9.15 +#include "GPGConfFixTests.h"
    9.16 +
    9.17 +using namespace std;
    9.18 +
    9.19 +GPGConfFixTests::GPGConfFixTests(string suitename, string temp_test_home_dir) :
    9.20 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, temp_test_home_dir) {
    9.21 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_0"),
    9.22 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_0)));
    9.23 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_1"),
    9.24 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_1)));
    9.25 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_2"),
    9.26 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_2)));
    9.27 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_3"),
    9.28 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_3)));
    9.29 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_4"),
    9.30 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_4)));
    9.31 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_5"),
    9.32 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_5)));
    9.33 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_conf_fix_broken_conf_old_db_6"),
    9.34 +                                                                      static_cast<Func>(&GPGConfFixTests::check_conf_fix_broken_conf_old_db_6)));                                                                      
    9.35 +}
    9.36 +
    9.37 +void GPGConfFixTests::setup() {
    9.38 +    EngineTestSuite::setup();
    9.39 +}
    9.40 +
    9.41 +static bool file_bytes_equal(const char* file_path_1, const char* file_path_2) {
    9.42 +    ifstream f1(file_path_1);
    9.43 +    ifstream f2(file_path_2);
    9.44 +
    9.45 +    char c1, c2;
    9.46 +    
    9.47 +    while (f1.get(c1)) {
    9.48 +        if (f2.get(c2)) {
    9.49 +            if (c1 != c2) {
    9.50 +                if (c1 == '\n' && c2 == ' ') {
    9.51 +                    if (f2.get(c2)) {
    9.52 +                        if (c1 == c2)
    9.53 +                            continue;
    9.54 +                    }    
    9.55 +                }
    9.56 +                else if (c2 == '\n' && c1 == ' ') {
    9.57 +                    if (f1.get(c1)) {
    9.58 +                        if (c1 == c2)
    9.59 +                            continue;
    9.60 +                    }                        
    9.61 +                }
    9.62 +                return false;
    9.63 +            }
    9.64 +        }
    9.65 +        else {
    9.66 +            if (c1 == '\n' || c1 == ' ') {
    9.67 +                while (f1.get(c1)) {
    9.68 +                    if (c2 == '\n' || c2 == ' ')
    9.69 +                        continue;
    9.70 +                    return false;
    9.71 +                }
    9.72 +            }
    9.73 +        }        
    9.74 +    }
    9.75 +    while (f2.get(c2)) {
    9.76 +        if (c2 == '\n' || c2 == ' ')
    9.77 +            continue;
    9.78 +        return false;
    9.79 +    }
    9.80 +    
    9.81 +    return true;
    9.82 +    
    9.83 +}
    9.84 +
    9.85 +void GPGConfFixTests::check_conf_fix_broken_conf_old_db_0() {
    9.86 +    set_full_env("test_files/427_bad_gpg_conf_0", NULL, "test_files/427_old_db");
    9.87 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_0", (temp_test_home + "/.gnupg/gpg.conf").c_str()));
    9.88 +}
    9.89 +
    9.90 +void GPGConfFixTests::check_conf_fix_broken_conf_old_db_1() {
    9.91 +    set_full_env("test_files/427_bad_gpg_conf_1", NULL, "test_files/427_old_db");    
    9.92 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_1", (temp_test_home + "/.gnupg/gpg.conf").c_str()));
    9.93 +    
    9.94 +}
    9.95 +
    9.96 +void GPGConfFixTests::check_conf_fix_broken_conf_old_db_2() {
    9.97 +    set_full_env("test_files/427_bad_gpg_conf_2", NULL, "test_files/427_old_db");        
    9.98 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_2", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
    9.99 +}
   9.100 +
   9.101 +void GPGConfFixTests::check_conf_fix_broken_conf_old_db_3() {
   9.102 +    set_full_env("test_files/427_bad_gpg_conf_3", NULL, "test_files/427_old_db");    
   9.103 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_3", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   9.104 +}
   9.105 +
   9.106 +void GPGConfFixTests::check_conf_fix_broken_conf_old_db_4() {
   9.107 +    set_full_env("test_files/427_bad_gpg_conf_4", NULL, "test_files/427_old_db");        
   9.108 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_4", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   9.109 +}
   9.110 +
   9.111 +void GPGConfFixTests::check_conf_fix_broken_conf_old_db_5() {
   9.112 +    set_full_env("test_files/427_bad_gpg_conf_5", NULL, "test_files/427_old_db");        
   9.113 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_5", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   9.114 +}
   9.115 +
   9.116 +void GPGConfFixTests::check_conf_fix_broken_conf_old_db_6() {
   9.117 +    set_full_env("test_files/427_bad_gpg_conf_6", NULL, "test_files/427_old_db");        
   9.118 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_6", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   9.119 +}
   9.120 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/test_files/427_bad_gpg_conf_0	Fri Jul 27 13:17:34 2018 +0200
    10.3 @@ -0,0 +1,2 @@
    10.4 +personal-cipher-preferences AES 
    10.5 +no-emit-version
    10.6 \ No newline at end of file
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/test_files/427_bad_gpg_conf_1	Fri Jul 27 13:17:34 2018 +0200
    11.3 @@ -0,0 +1,6 @@
    11.4 +comment No Comment
    11.5 +keyid-format 0xlongignore-time-conflict 
    11.6 +personal-cipher-preferences AES 
    11.7 +ignore-time-conflict 
    11.8 +ignore-time-conflict 
    11.9 +allow-freeform-uid
   11.10 \ No newline at end of file
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/test_files/427_bad_gpg_conf_2	Fri Jul 27 13:17:34 2018 +0200
    12.3 @@ -0,0 +1,6 @@
    12.4 +comment No Commentallow-freeform-uid
    12.5 +keyid-format 0xlongignore-time-conflict 
    12.6 +personal-cipher-preferences AES 
    12.7 +ignore-time-conflict 
    12.8 +ignore-time-conflict 
    12.9 +allow-freeform-uid
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/test_files/427_bad_gpg_conf_3	Fri Jul 27 13:17:34 2018 +0200
    13.3 @@ -0,0 +1,6 @@
    13.4 +comment No Commentallow-freeform-uidallow-freeform-uid
    13.5 +keyid-format 0xlongignore-time-conflict 
    13.6 +personal-cipher-preferences AES 
    13.7 +ignore-time-conflict 
    13.8 +ignore-time-conflict 
    13.9 +allow-freeform-uid
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/test_files/427_bad_gpg_conf_4	Fri Jul 27 13:17:34 2018 +0200
    14.3 @@ -0,0 +1,6 @@
    14.4 +comment No Commentallow-freeform-uidcert-digest-algo SHA256 ignore-time-conflict-buttsallow-freeform-uid
    14.5 +keyid-format 0xlongignore-time-conflict 
    14.6 +personal-cipher-preferences AES 
    14.7 +ignore-time-conflict 
    14.8 +ignore-time-conflict 
    14.9 +allow-freeform-uid
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/test_files/427_bad_gpg_conf_5	Fri Jul 27 13:17:34 2018 +0200
    15.3 @@ -0,0 +1,6 @@
    15.4 +comment No Commentallow-freeform-uidallow-freeform-uidallow-freeform-uid
    15.5 +keyid-format 0xlongignore-time-conflict 
    15.6 +personal-cipher-preferences AES 
    15.7 +ignore-time-conflict 
    15.8 +ignore-time-conflict 
    15.9 +allow-freeform-uid
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/test_files/427_bad_gpg_conf_6	Fri Jul 27 13:17:34 2018 +0200
    16.3 @@ -0,0 +1,2 @@
    16.4 +allow-freeform-uidallow-freeform-uidallow-freeform-uid
    16.5 +allow-freeform-uid
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/test_files/427_fixed_gpg_conf_0	Fri Jul 27 13:17:34 2018 +0200
    17.3 @@ -0,0 +1,8 @@
    17.4 +personal-cipher-preferences AES 
    17.5 +no-emit-version
    17.6 +keyserver hkp://keys.gnupg.net
    17.7 +cert-digest-algo SHA256
    17.8 +no-comments 
    17.9 +personal-digest-preferences SHA256 SHA512 SHA384 SHA224
   17.10 +ignore-time-conflict 
   17.11 +allow-freeform-uid 
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/test_files/427_fixed_gpg_conf_1	Fri Jul 27 13:17:34 2018 +0200
    18.3 @@ -0,0 +1,10 @@
    18.4 +comment No Comment
    18.5 +keyid-format 0xlong
    18.6 +ignore-time-conflict
    18.7 +personal-cipher-preferences AES
    18.8 +allow-freeform-uid
    18.9 +keyserver hkp://keys.gnupg.net
   18.10 +cert-digest-algo SHA256
   18.11 +no-emit-version
   18.12 +no-comments
   18.13 +personal-digest-preferences SHA256 SHA512 SHA384 SHA224
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/test_files/427_fixed_gpg_conf_2	Fri Jul 27 13:17:34 2018 +0200
    19.3 @@ -0,0 +1,10 @@
    19.4 +comment No Comment
    19.5 +allow-freeform-uid
    19.6 +keyid-format 0xlong
    19.7 +ignore-time-conflict 
    19.8 +personal-cipher-preferences AES
    19.9 +keyserver hkp://keys.gnupg.net
   19.10 +cert-digest-algo SHA256
   19.11 +no-emit-version
   19.12 +no-comments
   19.13 +personal-digest-preferences SHA256 SHA512 SHA384 SHA224
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/test_files/427_fixed_gpg_conf_3	Fri Jul 27 13:17:34 2018 +0200
    20.3 @@ -0,0 +1,11 @@
    20.4 +comment No Comment
    20.5 +allow-freeform-uid
    20.6 +keyid-format 0xlong
    20.7 +ignore-time-conflict 
    20.8 +personal-cipher-preferences AES 
    20.9 +keyserver hkp://keys.gnupg.net
   20.10 +cert-digest-algo SHA256
   20.11 +no-emit-version
   20.12 +no-comments
   20.13 +personal-digest-preferences SHA256 SHA512 SHA384 SHA224
   20.14 +                                           
   20.15 \ No newline at end of file
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/test_files/427_fixed_gpg_conf_4	Fri Jul 27 13:17:34 2018 +0200
    21.3 @@ -0,0 +1,10 @@
    21.4 +comment No Comment
    21.5 +allow-freeform-uid
    21.6 +cert-digest-algo SHA256 ignore-time-conflict-butts
    21.7 +keyid-format 0xlong
    21.8 +ignore-time-conflict 
    21.9 +personal-cipher-preferences AES 
   21.10 +keyserver hkp://keys.gnupg.net
   21.11 +no-emit-version
   21.12 +no-comments
   21.13 +personal-digest-preferences SHA256 SHA512 SHA384 SHA224
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/test_files/427_fixed_gpg_conf_5	Fri Jul 27 13:17:34 2018 +0200
    22.3 @@ -0,0 +1,10 @@
    22.4 +comment No Comment
    22.5 +allow-freeform-uid
    22.6 +keyid-format 0xlong
    22.7 +ignore-time-conflict 
    22.8 +personal-cipher-preferences AES 
    22.9 +keyserver hkp://keys.gnupg.net
   22.10 +cert-digest-algo SHA256
   22.11 +no-emit-version
   22.12 +no-comments
   22.13 +personal-digest-preferences SHA256 SHA512 SHA384 SHA224
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/test_files/427_fixed_gpg_conf_6	Fri Jul 27 13:17:34 2018 +0200
    23.3 @@ -0,0 +1,8 @@
    23.4 +allow-freeform-uid
    23.5 +keyserver hkp://keys.gnupg.net
    23.6 +cert-digest-algo SHA256
    23.7 +no-emit-version
    23.8 +no-comments
    23.9 +personal-cipher-preferences AES AES256 AES192 CAST5
   23.10 +personal-digest-preferences SHA256 SHA512 SHA384 SHA224
   23.11 +ignore-time-conflict