Merge with ENGINE-581 sequoia_windows
authorThomas
Tue, 25 Jun 2019 14:44:43 +0200
branchsequoia_windows
changeset 3871d1d515455192
parent 3868 157c5339cbb6
parent 3870 018251280dbf
child 3873 d020bf7cf4f8
Merge with ENGINE-581
src/pEp_internal.h
src/pgp_sequoia.c
     1.1 --- a/src/pEp_internal.h	Fri Jun 21 18:41:56 2019 +0200
     1.2 +++ b/src/pEp_internal.h	Tue Jun 25 14:44:43 2019 +0200
     1.3 @@ -17,7 +17,7 @@
     1.4  #define PARMS_MAX 32768
     1.5  
     1.6  // maximum busy wait time in ms
     1.7 -#define BUSY_WAIT_TIME 5000
     1.8 +#define BUSY_WAIT_TIME 10000
     1.9  
    1.10  // maximum line length for reading gpg.conf
    1.11  #define MAX_LINELENGTH 1024
    1.12 @@ -132,6 +132,7 @@
    1.13      sqlite3 *key_db;
    1.14      struct {
    1.15          sqlite3_stmt *begin_transaction;
    1.16 +        sqlite3_stmt *begin_transaction_excl;
    1.17          sqlite3_stmt *commit_transaction;
    1.18          sqlite3_stmt *rollback_transaction;
    1.19          sqlite3_stmt *tpk_find;
    1.20 @@ -487,4 +488,3 @@
    1.21      } while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
    1.22      return rc;
    1.23  }
    1.24 -
     2.1 --- a/src/pgp_sequoia.c	Fri Jun 21 18:41:56 2019 +0200
     2.2 +++ b/src/pgp_sequoia.c	Tue Jun 25 14:44:43 2019 +0200
     2.3 @@ -233,6 +233,8 @@
     2.4          ERROR_OUT(NULL, PEP_INIT_CANNOT_OPEN_DB,
     2.5                    "opening keys DB: %s", sqlite3_errmsg(session->key_db));
     2.6  
     2.7 +    sqlite3_busy_timeout(session->key_db, BUSY_WAIT_TIME);
     2.8 +
     2.9      sqlite_result = sqlite3_exec(session->key_db,
    2.10                                   "PRAGMA secure_delete=true;\n"
    2.11                                   "PRAGMA foreign_keys=true;\n"
    2.12 @@ -310,6 +312,11 @@
    2.13      assert(sqlite_result == SQLITE_OK);
    2.14  
    2.15      sqlite_result
    2.16 +        = sqlite3_prepare_v2(session->key_db, "begin transaction exclusive",
    2.17 +                             -1, &session->sq_sql.begin_transaction_excl, NULL);
    2.18 +    assert(sqlite_result == SQLITE_OK);
    2.19 +
    2.20 +    sqlite_result
    2.21          = sqlite3_prepare_v2(session->key_db, "commit transaction",
    2.22                               -1, &session->sq_sql.commit_transaction, NULL);
    2.23      assert(sqlite_result == SQLITE_OK);
    2.24 @@ -711,7 +718,7 @@
    2.25      char *email = NULL;
    2.26      char *name = NULL;
    2.27  
    2.28 -    sqlite3_stmt *stmt = session->sq_sql.begin_transaction;
    2.29 +    sqlite3_stmt *stmt = session->sq_sql.begin_transaction_excl;
    2.30      int sqlite_result = Sqlite3_step(stmt);
    2.31      sqlite3_reset(stmt);
    2.32      if (sqlite_result != SQLITE_DONE)
    2.33 @@ -866,6 +873,7 @@
    2.34                        sqlite3_errmsg(session->key_db));
    2.35      }
    2.36  
    2.37 +
    2.38      T("(%s) -> %s", fpr, pEp_status_to_string(status));
    2.39  
    2.40      free(email);
     3.1 --- a/test/src/engine_tests/IOS1664Tests.cc	Fri Jun 21 18:41:56 2019 +0200
     3.2 +++ b/test/src/engine_tests/IOS1664Tests.cc	Tue Jun 25 14:44:43 2019 +0200
     3.3 @@ -48,12 +48,23 @@
     3.4      
     3.5      pEp_identity* you = new_identity("superxat@gmail.com", NULL, NULL, NULL);
     3.6      
     3.7 +    // N.B. while obviously it would be better to write the test expecting us to 
     3.8 +    // accept the key, I'm actually testing that we don't get the wrong status
     3.9 +    // based on the presumption of rejection
    3.10 +    
    3.11      message* out_msg = new_message(PEP_dir_outgoing);
    3.12      out_msg->from = me;
    3.13      out_msg->to = new_identity_list(you);
    3.14      out_msg->shortmsg = strdup("Hussidente 2020!");
    3.15      out_msg->longmsg = strdup("A Huss in every office!");
    3.16      
    3.17 +    status = identity_rating(session, out_msg->from, &rating);
    3.18 +    TEST_ASSERT(status == PEP_STATUS_OK);
    3.19 +    TEST_ASSERT_MSG(rating == PEP_rating_trusted_and_anonymized, tl_rating_string(rating));
    3.20 +    status = identity_rating(session, out_msg->to->ident, &rating);
    3.21 +    TEST_ASSERT_MSG(status == PEP_KEY_NOT_FOUND, tl_status_string(status));
    3.22 +    TEST_ASSERT_MSG(rating == PEP_rating_undefined, tl_rating_string(rating));
    3.23 +
    3.24      status = outgoing_message_rating(session, out_msg, &rating);
    3.25      TEST_ASSERT(rating == PEP_rating_unencrypted);
    3.26