ENGINE-293: Compiles and runs SOME tests. SQL and myself() fixes. ENGINE-293
authorKrista Bennett <krista@pep-project.org>
Tue, 05 Dec 2017 16:35:23 +0100
branchENGINE-293
changeset 2305f617e0acae94
parent 2304 3bd45e2b8f92
child 2306 5744a544ecd2
ENGINE-293: Compiles and runs SOME tests. SQL and myself() fixes.
src/keymanagement.c
src/pEpEngine.c
     1.1 --- a/src/keymanagement.c	Tue Dec 05 10:00:48 2017 +0100
     1.2 +++ b/src/keymanagement.c	Tue Dec 05 16:35:23 2017 +0100
     1.3 @@ -438,11 +438,13 @@
     1.4      status = get_own_userid(session, &own_id);
     1.5  
     1.6      assert(EMPTYSTR(identity->user_id) ||
     1.7 -           (own_id && strcmp(identity->user_id, own_id) == 0));
     1.8 +           (own_id && strcmp(identity->user_id, own_id) == 0) ||
     1.9 +           !own_id);
    1.10  
    1.11      if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.12              (EMPTYSTR(identity->user_id) ||
    1.13 -            (own_id && strcmp(identity->user_id, own_id) == 0))))
    1.14 +            (own_id && strcmp(identity->user_id, own_id) == 0) ||
    1.15 +             !own_id)))
    1.16          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.17  
    1.18      identity->comm_type = PEP_ct_pEp;
     2.1 --- a/src/pEpEngine.c	Tue Dec 05 10:00:48 2017 +0100
     2.2 +++ b/src/pEpEngine.c	Tue Dec 05 16:35:23 2017 +0100
     2.3 @@ -177,14 +177,14 @@
     2.4  // We only care if it's 0 or non-zero
     2.5  static const char *sql_own_key_is_listed = 
     2.6      "select count(*) from ("
     2.7 -    "   select fpr from trust"
     2.8 -    "      join identity on id = identity.user_id"
     2.9 -    "      where fpr = upper(replace(?1,' ',''))"
    2.10 -    "           and identity.is_own = 1;"
    2.11 +    "   select pgp_keypair_fpr from trust"
    2.12 +    "      join identity on trust.user_id = identity.user_id"
    2.13 +    "      where pgp_keypair_fpr = upper(replace(?1,' ',''))"
    2.14 +    "           and identity.is_own = 1"
    2.15      ");";
    2.16  
    2.17  static const char *sql_own_identities_retrieve =  
    2.18 -    "select address, fpr, username, user_id, "
    2.19 +    "select address, fpr, username, identity.user_id, "
    2.20      "   lang, identity.flags | pgp_keypair.flags"
    2.21      "   from identity"
    2.22      "   join person on id = identity.user_id"
    2.23 @@ -194,13 +194,13 @@
    2.24      "   where identity.is_own = 1"
    2.25      "       and (identity.flags & ?1) = 0;";
    2.26  
    2.27 -static const char *sql_own_keys_retrieve =  
    2.28 -    "select fpr from trust"
    2.29 -    "   join identity on id = identity.user_id"
    2.30 +static const char *sql_own_keys_retrieve = 
    2.31 +    "select pgp_keypair_fpr from trust"
    2.32 +    "   join identity on trust.user_id = identity.user_id"
    2.33      "   where identity.is_own = 1";
    2.34  
    2.35  static const char* sql_get_own_userid =
    2.36 -    "select user_id from person"
    2.37 +    "select id from person"
    2.38      "   join identity on id = identity.user_id"
    2.39      "   where identity.is_own = 1";
    2.40  
    2.41 @@ -413,8 +413,8 @@
    2.42                  "       references pgp_keypair (fpr)\n"
    2.43                  "       on delete set null,\n"
    2.44                  "   comment text,\n"
    2.45 -                "   flags integer default 0,"
    2.46 -                "   is_own integer default 0,"
    2.47 +                "   flags integer default 0,\n"
    2.48 +                "   is_own integer default 0,\n"
    2.49                  "   primary key (address, user_id)\n"
    2.50                  ");\n"
    2.51                  "create table if not exists trust (\n"