Browse Source

fixes for _own_keys_retrieve

pEpMIME_windows
parent
commit
18cdd326d8
5 changed files with 44 additions and 9 deletions
  1. +27
    -3
      src/keymanagement.c
  2. +8
    -4
      src/keymanagement.h
  3. +1
    -1
      sync/cond_act_sync.yml2
  4. +3
    -0
      test/gentestshell.py
  5. +5
    -1
      test/src/SuiteMaker.cc

+ 27
- 3
src/keymanagement.c View File

@ -1737,7 +1737,8 @@ DYNAMIC_API PEP_STATUS own_identities_retrieve(
PEP_STATUS _own_keys_retrieve(
PEP_SESSION session,
stringlist_t **keylist,
identity_flags_t excluded_flags
identity_flags_t excluded_flags,
bool private_only
)
{
PEP_STATUS status = PEP_STATUS_OK;
@ -1785,8 +1786,31 @@ PEP_STATUS _own_keys_retrieve(
} while (result != SQLITE_DONE);
sqlite3_reset(session->own_keys_retrieve);
if (status == PEP_STATUS_OK)
if (status == PEP_STATUS_OK) {
dedup_stringlist(_keylist);
if (private_only) {
stringlist_t* _kl = _keylist;
stringlist_t* _kl_prev = NULL;
while (_kl) {
bool has_private = false;
contains_priv_key(session, _kl->value, &has_private);
if (!has_private) {
stringlist_t* _kl_tmp = _kl;
if (_kl_prev) {
_kl_prev->next = _kl->next;
}
_kl = _kl->next;
_kl_tmp->next = NULL;
free_stringlist(_kl_tmp);
continue;
}
_kl_prev = _kl;
_kl = _kl->next;
}
}
*keylist = _keylist;
}
else
free_stringlist(_keylist);
@ -1802,7 +1826,7 @@ the_end:
DYNAMIC_API PEP_STATUS own_keys_retrieve(PEP_SESSION session, stringlist_t **keylist)
{
return _own_keys_retrieve(session, keylist, 0);
return _own_keys_retrieve(session, keylist, 0, true);
}
DYNAMIC_API PEP_STATUS set_own_key(


+ 8
- 4
src/keymanagement.h View File

@ -330,17 +330,19 @@ PEP_STATUS contains_priv_key(PEP_SESSION session, const char *fpr,
// parameters:
// session (in) session to use
// keylist (out) list of fingerprints
// excluded_flags (int) flags to exclude from results
//
// excluded_flags (in) flags to exclude from results
// private_only (in) if true, return only fprs for
// which we have the secret part
// caveat:
// the ownership of the list goes to the caller
DYNAMIC_API PEP_STATUS _own_keys_retrieve(
PEP_SESSION session,
stringlist_t **keylist,
identity_flags_t excluded_flags
identity_flags_t excluded_flags,
bool private_only
);
// own_keys_retrieve() - retrieve all flagged keypair fingerprints
// own_keys_retrieve() - retrieve all flagged public/private keypair fingerprints
//
// parameters:
// session (in) session to use
@ -348,6 +350,8 @@ DYNAMIC_API PEP_STATUS _own_keys_retrieve(
//
// caveat:
// the ownership of the list goes to the caller
// this function does not return keys without a private key part
//
DYNAMIC_API PEP_STATUS own_keys_retrieve(
PEP_SESSION session,
stringlist_t **keylist


+ 1
- 1
sync/cond_act_sync.yml2 View File

@ -233,7 +233,7 @@ timeout KeySync
action prepareOwnKeys
||
stringlist_t *own_keys;
PEP_STATUS status = _own_keys_retrieve(session, &own_keys, PEP_idf_not_for_sync);
PEP_STATUS status = _own_keys_retrieve(session, &own_keys, PEP_idf_not_for_sync, true);
if (status)
return status;


+ 3
- 0
test/gentestshell.py View File

@ -86,7 +86,10 @@ if not args.no_hdr:
if not args.no_src:
src_inc = ('#include <stdlib.h>\n'
'#include <cstring>\n'
'#include <string>\n\n'
'#include <cpptest.h>\n'
'#include "test_util.h"\n\n'
'#include "pEpEngine.h"\n\n'
'#include "' + superclass +'.h"\n'
'#include "' + test_suite + '.h"\n\n')


+ 5
- 1
test/src/SuiteMaker.cc View File

@ -61,6 +61,7 @@
#include "KeyResetMessageTests.h"
#include "DeleteKeyTests.h"
#include "KeyAttachmentTests.h"
#include "OwnKeysRetrieveTests.h"
#include "TrustManipulationTests.h"
#include "SyncTests.h"
#include "AppleMailTests.h"
@ -116,13 +117,14 @@ const char* SuiteMaker::all_suites[] = {
"KeyResetMessageTests",
"DeleteKeyTests",
"KeyAttachmentTests",
"OwnKeysRetrieveTests",
"TrustManipulationTests",
"SyncTests",
"AppleMailTests",
};
// This file is generated, so magic constants are ok.
int SuiteMaker::num_suites = 52;
int SuiteMaker::num_suites = 53;
void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
if (strcmp(test_class_name, "MimeTests") == 0)
@ -223,6 +225,8 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new DeleteKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "KeyAttachmentTests") == 0)
*test_suite = new KeyAttachmentTests(test_class_name, test_home);
else if (strcmp(test_class_name, "OwnKeysRetrieveTests") == 0)
*test_suite = new OwnKeysRetrieveTests(test_class_name, test_home);
else if (strcmp(test_class_name, "TrustManipulationTests") == 0)
*test_suite = new TrustManipulationTests(test_class_name, test_home);
else if (strcmp(test_class_name, "SyncTests") == 0)


Loading…
Cancel
Save