save own keys sync
authorVolker Birk <vb@pep-project.org>
Tue, 02 Apr 2019 15:48:25 +0200
branchsync
changeset 3434458a804f88e4
parent 3433 759e5f5244a7
child 3437 50ec7a39e522
save own keys
src/pEpEngine.c
sync/cond_act_sync.yml2
     1.1 --- a/src/pEpEngine.c	Tue Apr 02 11:34:45 2019 +0200
     1.2 +++ b/src/pEpEngine.c	Tue Apr 02 15:48:25 2019 +0200
     1.3 @@ -3955,6 +3955,8 @@
     1.4      PEP_STATUS status = session->cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify(
     1.5              session, ctext, csize, dsigtext, dsigsize, ptext, psize, keylist,
     1.6              filename_ptr);
     1.7 +
     1.8 +    if (status == PEP_DECRYPT_NO_KEY)
     1.9          signal_Sync_event(session, Sync_PR_keysync, CannotDecrypt);
    1.10  
    1.11      return status;
     2.1 --- a/sync/cond_act_sync.yml2	Tue Apr 02 11:34:45 2019 +0200
     2.2 +++ b/sync/cond_act_sync.yml2	Tue Apr 02 15:48:25 2019 +0200
     2.3 @@ -203,82 +203,19 @@
     2.4      free_identity_list(il);
     2.5  ||
     2.6  
     2.7 -action ownKeysAreGroupKeys {
     2.8 -    call "init_sql" with "sql" {
     2.9 -        ||
    2.10 -        "select fpr, username, comm_type, lang,"
    2.11 -                "   identity.flags | pgp_keypair.flags"
    2.12 -                "   from identity"
    2.13 -                "   join person on id = identity.user_id"
    2.14 -                "   join pgp_keypair on fpr = identity.main_key_id"
    2.15 -                "   join trust on id = trust.user_id"
    2.16 -                "       and pgp_keypair_fpr = identity.main_key_id"
    2.17 -                "   where identity.is_own = true ;"
    2.18 -        ||
    2.19 +action ownKeysAreGroupKeys
    2.20 +||
    2.21 +    PEP_STATUS status = PEP_STATUS_OK;
    2.22 +
    2.23 +    // set flag for current keys
    2.24 +    for (identity_list *il = session->sync_state.common.own_identities; il && il->ident ; il = il->next) {
    2.25 +        if (!(il->ident->flags && PEP_idf_not_for_sync)) {
    2.26 +            status = set_identity_flags(session, il->ident, PEP_idf_devicegroup);
    2.27 +            if (status)
    2.28 +                return status;
    2.29 +        }
    2.30      }
    2.31 -
    2.32 -    ||
    2.33 -        identity_list *il = new_identity_list(NULL);
    2.34 -        if (!il)
    2.35 -            return PEP_OUT_OF_MEMORY;
    2.36 -
    2.37 -        pEp_identity *from = session->sync_state.common.from;
    2.38 -        identity_list *_il = il;
    2.39 -
    2.40 -        int result;
    2.41 -        do {
    2.42 -            result = sqlite3_step(_sql);
    2.43 -            pEp_identity *_identity = NULL;
    2.44 -            switch (result) {
    2.45 -            case SQLITE_ROW:
    2.46 -                _identity = new_identity(
    2.47 -                        from->address,
    2.48 -                        (const char *) sqlite3_column_text(_sql, 0),
    2.49 -                        from->user_id,
    2.50 -                        (const char *) sqlite3_column_text(_sql, 1)
    2.51 -                    );
    2.52 -                assert(_identity);
    2.53 -                if (_identity == NULL)
    2.54 -                    return PEP_OUT_OF_MEMORY;
    2.55 -
    2.56 -                _identity->comm_type = (PEP_comm_type)
    2.57 -                    sqlite3_column_int(_sql, 2);
    2.58 -                const char* const _lang = (const char *)
    2.59 -                    sqlite3_column_text(_sql, 3);
    2.60 -                if (_lang && _lang[0]) {
    2.61 -                    assert(_lang[0] >= 'a' && _lang[0] <= 'z');
    2.62 -                    assert(_lang[1] >= 'a' && _lang[1] <= 'z');
    2.63 -                    assert(_lang[2] == 0);
    2.64 -                    _identity->lang[0] = _lang[0];
    2.65 -                    _identity->lang[1] = _lang[1];
    2.66 -                    _identity->lang[2] = 0;
    2.67 -                }
    2.68 -                _identity->flags = (unsigned int)
    2.69 -                    sqlite3_column_int(_sql, 4);
    2.70 -
    2.71 -                _il = identity_list_add(_il, _identity);
    2.72 -                if (!_il) {
    2.73 -                    free_identity_list(il);
    2.74 -                    free_identity(_identity);
    2.75 -                    return PEP_OUT_OF_MEMORY;
    2.76 -                }
    2.77 -                break;
    2.78 -
    2.79 -            case SQLITE_DONE:
    2.80 -                break;
    2.81 -
    2.82 -            default:
    2.83 -                free_identity_list(il);
    2.84 -                return PEP_UNKNOWN_ERROR;
    2.85 -            }
    2.86 -        } while (result != SQLITE_DONE);
    2.87 -
    2.88 -        IdentityList_t *r = IdentityList_from_identity_list(il, &session->sync_state.keysync.ownIdentities);
    2.89 -        free_identity_list(il);
    2.90 -        if (!r)
    2.91 -            return PEP_OUT_OF_MEMORY;
    2.92 -    ||
    2.93 -}
    2.94 +||
    2.95  
    2.96  action receivedKeysAreGroupKeys;
    2.97